MSFD Making Actors switch between weapons
Since the equip function does not work, the only way to do this is to take items away from the Actor, or to modify his skills at runtime.
Here is an example I used to make a guard switch between bow and sword:
Begin HBCaravanGuardAI
; this script makes the AI guard more dangerous by making him switch from bow to sword when the player closes in
short currentarrows
short storearrows
short doonce
set currentarrows to GetItemCount "arrow of wasting flame"
if ( doonce == 0 )
set storearrows to currentarrows
endif
if ( GetDistance, Player < 120 )
set currentarrows to GetItemCount "arrow of wasting flame"
if ( currentarrows > 0 )
RemoveItem "arrow of wasting flame", 1
set doonce to 1
endif
elseif ( GetDistance, Player >= 120 )
if ( currentarrows < storearrows )
AddItem "arrow of wasting flame", 1
else
set doonce to 0
endif
endif
End
The next example is one by Bethesda, which does the same thing, using the skill change method (admittedly more elegant than mine ):
begin marksmanToggle
short counter
short myMarksman
if ( MenuMode == 1 )
return
endif
if ( counter < 20 )
Set counter to counter + 1
Return
endif
if ( myMarksman == 0 )
set myMarksman to GetMarksman
endif
if ( GetMarksman > 0 )
if ( GetDistance Player < 400 )
SetMarksman 0
endif
else
if ( GetDistance Player > 600 )
SetMarksman myMarksman
endif
endif
;for level designers... forces AI to do what it ought to do
;when they are near, they use melee weapons
;when they are far, they use missile weapons
;checks every 20 frames for speed
;Note: does not affect spellcasting AI
End