Alter Aeon Community Forum
January 22, 2018, 12:40:01 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Registration is enabled!  Please register using the name of your primary character in-game.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Iacts on mobs - a simple example  (Read 5641 times)
Dentin
Administrator
Full Member
*****
Posts: 249



View Profile WWW
« on: November 25, 2009, 04:38:26 pm »

An 'iact' is a type of interactive procedure that is used to make mobs perform actions.  You can do some pretty complicated stuff with them, including interactive (hence the name) discussions, intelligent quest triggering, and the like.  As examples, Thantos responds to Dentin's name, and the fire giants in the fire plane will give up quite a bit of history of the area if you just sit down and talk to them about it.

As common as these are, there's a lot of confusion about how iacts work.  Most of this seems to stem from the fact that iacts are a form of finite state machine, and most people aren't used to thinking in state machine terms.

As an example, let's consider a mob that would unpack and wield weapons when fighting, then stop using and put them away when not fighting.  This seems like an ideal example to demonstrate a simple state machine iact, as well as give an introduction to how iacts work.

The general idea is that the mob in question, let's call him Bob, has a weapon and a backpack.  When Bob is in combat, the weapon should be out of the backpack and wielded, so Bob can defend himself.  When Bob is not fighting, the weapon should be stored in the backpack, which Bob should be wearing.

The easiest way to do this is via four states in a state machine:

1) Not fighting.  In this state, you wait for fighting to begin.
2) Start fighting.  In this state, Bob is fighting, and should unpack his weapon and wield it.
3) Fighting.  Bob is fighting for his life, and may need to retrieve his weapon if disarmed.
4) Stop fighting.  Bob is no longer fighting, and should disarm and repack his weapon.

Here's a diagram of the four states, with the arrows being transitions between the states.  Each block contains the name of an iact procedure, and in smaller text the iact code for that procedure:



Click on the image for a larger version.

As various things happen to Bob, he moves from one state to another.  Most of his time will be spent waiting for fighting to start.  When fighting does start, he'll quickly get out and wield his weapon in the 'start_fighting' procedure, then he'll transition to the 'fighting' procedure.  While 'fighting', he'll continuously try to rewield his weapon if he's disarmed.  When fighting stops, he'll transition to 'stop_fighting', which will unwield the weapon and put it away.  Then he'll go back to 'not_fighting' and wait for another battle to begin.
Logged
Draak
Jr. Member
**
Posts: 85


god of ice


View Profile
« Reply #1 on: November 29, 2009, 06:28:43 am »

Dentin made a nice simple example that would work better for a player than a mob.  If Bob the Mob were disarmed, his weapon would end up on the ground, not in his inventory, so the line 'get weapon' needs to be added before 'wield weapon'.
Logged

Nothing special there.
Dentin
Administrator
Full Member
*****
Posts: 249



View Profile WWW
« Reply #2 on: November 30, 2009, 03:33:41 am »

Doh.  I didn't realize that.  I should probably update the image.
Logged
Dentin
Administrator
Full Member
*****
Posts: 249



View Profile WWW
« Reply #3 on: November 30, 2009, 03:08:40 pm »

Image updated!  Text is slightly bigger and easier to read, and the mob now picks up the disarmed weapon before trying to wield it.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.058 seconds with 17 queries.