Howdy all,
A vital component of my swimming system is the trigger drawn around riverbank/shore/water tiles that have been altered to make them walkable. While the OnEnter script of this trigger (given below) works perfectly for PCs, it does not fire when a henchperson enters it.
I thought (wrongly) that the GetIsPC function included all types of associates, but it seems that is not so.
Nor is there a GetIsHenchman function to help me out as far as I can see!
If anyone can suggest a way of including henchmen in this script, I would be very grateful indeed.
////////////////////////////////////////////////////////////////////////////////
//
// swim_trig.nss
//
// This is the OnEnter script for the trigger allowing PCs to swim in areas of
// River or Walkable Water terrain.
//
// It changes the PC's phenotype to the Crawl/Swim phenotype, removes a torch
// or shield (if carried) and applies a 65% speed decrease to movement.
//
// If the PC is wearing armour of AC3 or above, it is unequipped automatically
// and an Undroppable item with the Tag "pc_clothing" is equipped in its stead.
// N.B: These items created in the PC's inventory at generation!!
//
// Also, a message is sent to the entering PC informing him he is in swim mode.
//
// Note that this script fires whenever a PC enters the trigger, which is fine
// when entering the water conventionally, but NOT when transitioning BACK from
// another area such as a ship's cabin or hold to the deck of the ship....
//
// As soon as the transition completes, the PC re-enters the swimming trigger
// and adopts the crawl animation and the associated movement penalty!!
//
// As a workaround, a SECOND trigger is used, drawn outside the doorway leading
// to the other area. The OnEnter script of this second trigger resets the PC's
// phenotype to normal and does away with the movement penalty.
//
// The "Area Trigger - Swimming" and the Transition Triggers are all found in:
// Triggers -> Custom -> Special -> Custom 2.
//
////////////////////////////////////////////////////////////////////////////////
void main()
{
object oPC = GetEnteringObject();
// Object must be a PC/Associate/Henchman/DM-Possessed creature to swim.
if (!GetIsPC (oPC)) {return;}
// Object must only have the "Normal" Phenotype to swim.
if (GetPhenoType (oPC) >0) {return;}
// Unequips Torches or Shields.
object oTorch = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
int iIsTorch = GetBaseItemType(oTorch);
if(iIsTorch = BASE_ITEM_TORCH || (iIsTorch = BASE_ITEM_SMALLSHIELD || (iIsTorch = BASE_ITEM_LARGESHIELD || (iIsTorch = BASE_ITEM_TOWERSHIELD))))
{
AssignCommand(oPC, ActionUnequipItem(oTorch));
}
// Unequips Armour of AC 3/4/5.
object oItem = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
int nAC = GetItemACValue(oItem);
if(nAC >= 3)
{
AssignCommand(oPC, ActionUnequipItem(oItem));
// Define the replacement clothing.
object oArmor = GetItemPossessedBy(oPC, "pc_clothing");
// Now equip the replacement clothing.
DelayCommand(0.5, AssignCommand(oPC, ActionEquipItem(oArmor, INVENTORY_SLOT_CHEST)));
}
// Set the object's phenotype to "Crawl/Swim"
SetPhenoType(20,oPC);
// Define the Movement Speed effect.
effect eSlow=ExtraordinaryEffect(EffectMovementSpeedDecrease(65));
// Apply the Movement Speed effect.
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eSlow,oPC);
// Routine for sending the swim-mode message only one time.
int doOnce = GetLocalInt(oPC,"swimming");
if (0 == doOnce)
{
SetLocalInt(oPC,"swimming",1);
// Send warning message to PCs entering the trigger.
FloatingTextStringOnCreature("You are now in Swim Mode. Please do not use any Emotes or Movement Feats while swimming.",oPC);
}
}
Many thanks,
PT