×
Меню
Индекс

MSFD Making Actors activate objects

 
AiActivate "Object ID"
AiActivate ObjectID [reset]
 
     Actor->AIActivate "Object"
 
In the words of Bethesda: "This package tells the Actor to activate the specified ObjectID. A powerful and admittedly underutilized and undertested package."
 
In standard Morrowind this function appeared to be mostly broken, except for making an NPC quaff a potion. With Tribunal it seems to have been fixed, at least to some extent. I could successfully use it to get an NPC to pick up a weapon, open a normal door and go through a load door. LoadDoors only work if the door marker it teleports to is in the same interior cell, or within the loaded (PC's current and surrounding) cells in exterior cells – otherwise the game crashes. I also tested it successfully with an activator (switch to open Ghostgate).
The usual precautions with AI functions apply (make sure the Actor is not too far away, have a good AI grid in place, make sure nothing can get in the way, etc.). Although not thoroughly tested, I didn't seem to get an AIPackageDone signal, but other conditions can be constructed (see examples below) to set the NPC to a different AIPackage again.
 
Object Type     Activation
NPC     Activating NPC will approach and circle the target NPC
Container     Opens
Door     Opens
Load door     Opens/teleports (same cell only)
Weapon, armor, misc., etc     Picks up
Book/Scroll     Reads <meaning what to an NPC?>
Activators     Execute as defined by script. If the activator doesn't have an OnActivate block (or doesn't have a script), the Actor will try to activate it anyway, in much the same way as 'activating' NPCs (approach and circle).
 
 
Note:
If you place the object to be activate too high, the NPC will still approach and circle underneath it.
 
Sample Script: these are just a few testing scripts I made. They show how you can set conditions to determine when the NPC has finished his action.
Begin TT_opendoor
 
short doonce
short AIState
 
 
if ( doonce == 0 )
     if ( GetDistance, Player < 400 )
          AIActivate TT_door
          set doonce to 1
     endif
elseif ( doonce == 1 )
     set AIState to GetCurrentAIPackage
     MessageBox "Package = %g", AIState
     if ( TT_door->GetAngle, z != 180 ); As soon as door starts rotating
          MessageBox "Done"
          AIWander 30, 5, 0, 0, 20, 0, 0, 10, 30, 0, 0
          set doonce to 2
     endif
endif
 
 
end
 
 
Begin TT_pickmace
short doonce
short AIState
if ( doonce == 0 )
     if ( GetDistance, Player < 400 )
          AIActivate TT_daedric_mace
          set doonce to 1
     endif
elseif ( doonce == 1 )
     set AIState to GetCurrentAIPackage
     MessageBox "Package = %g", AIState
     if ( GetItemCount, TT_daedric_mace >= 1 ); when NPC has the mace in his inventory
          MessageBox "Done"
          AIWander 512, 5, 0, 0, 20, 0, 0, 10, 30, 0, 0
          set doonce to 2
     endif
endif
 
end
 
Begin TT_openloaddoor
short doonce
short AIState
 
 
if ( doonce == 0 )
     if ( GetDistance, Player < 400 )
          AIActivate TT_door
          set doonce to 1
     endif
elseif ( doonce == 1 )
     set AIState to GetCurrentAIPackage
     MessageBox "Package = %g", AIState
     if ( GetPos, y > 2000 ); position has changed. Loaddor target is in same cell          MessageBox "Done"
          AIWander 30, 5, 0, 0, 20, 0, 0, 10, 30, 0, 0
          set doonce to 2
     endif
endif
 
 
end