| Author |
Sticky: Post
Working Scripts Here |
| Layrinn
|
Posted: Monday, 22 July 08:43AM |
I got tired of Linu standing in the middle
of a huge melee battle trying to fire her crossbow and getting whacked
by a dozen attacks of opportunity. I'm sure this has been done before,
but I modified the OnCombatRoundEnd script...
1. Script name: nw_ch_ac3.ncs
2. What it does: Step 1... Checks the distance between the NPC and the
nearest enemy and whether or not that enemy is a valid target. Step 2...
If the NPC has is currently using his/her ranged weapon and there is an
enemy within 4 meters, he/she will temporarily switch to his/her melee
weapon. Step 3... If the NPC is temporarily using his/her melee weapon
and there is no longer a creature within 4 meters, he/she will switch
back to his/her ranged weapon. The end result is that the NPC fires
his/her ranged weapon as long as it's safe to do so. The NPC will switch
to his/her melee weapon if the need arises and switch back when it's
safe to do so. The original NPC state (use ranged weapon) is preserved.
The NPC will announce when changes are being made.
3. Notes: The script works with custom modules as well as with the
default module. In order to modify the standard NPC's behavior, place
the compiled script in the \override directory. You must replace the
nw_ch_ac3.ncs file. I would recommend making a back up of the original
file. This is my first version of this code, after all.
4. The script:
NWScript:
#include "NW_I0_GENERIC"
void main()
{
if(!GetSpawnInCondition(NW_FLAG_SET_WARNINGS))
{
DetermineCombatRound();
}
if(GetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1003));
}
object oNearestEnemy = GetNearestSeenOrHeardEnemy();
if ( (GetIsObjectValid(oNearestEnemy)) && (GetDistanceBetween(OBJECT_SELF, oNearestEnemy) < 4.0))
{
if (!GetLocalInt(OBJECT_SELF, "nTempMelee"))
{
SpeakString("They're getting too close!! I need to use my melee weapon.");
SetAssociateState(NW_ASC_USE_RANGED_WEAPON, FALSE);
SetLocalInt(OBJECT_SELF, "nTempMelee", TRUE);
ClearAllActions();
ActionDoCommand(EquipAppropriateWeapons(GetMaster()));
ActionDoCommand(DetermineCombatRound());
}
}
else
{
if (GetLocalInt(OBJECT_SELF, "nTempMelee"))
{
SpeakString("I'll switch back to my ranged weapon now.");
SetAssociateState(NW_ASC_USE_RANGED_WEAPON, TRUE);
SetLocalInt(OBJECT_SELF, "nTempMelee", FALSE);
ClearAllActions();
EquipAppropriateWeapons(GetMaster());
ActionDoCommand(DetermineCombatRound());
}
}
}
|
|