100 lines
4.3 KiB
Plaintext
100 lines
4.3 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Default On Percieve
|
|
//:: NW_C2_DEFAULT2
|
|
//:: Copyright (c) 2001 Bioware Corp.
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
Checks to see if the perceived target is an
|
|
enemy and if so fires the Determine Combat
|
|
Round function
|
|
*/
|
|
//:://////////////////////////////////////////////
|
|
//:: Created By: Preston Watamaniuk
|
|
//:: Created On: Oct 16, 2001
|
|
//:://////////////////////////////////////////////
|
|
|
|
#include "NW_I0_GENERIC"
|
|
|
|
void main()
|
|
{
|
|
//This is the equivalent of a force conversation bubble, should only be used if you want an NPC
|
|
//to say something while he is already engaged in combat.
|
|
if(GetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION) && GetIsPC(GetLastPerceived()) && GetLastPerceptionSeen())
|
|
{
|
|
SpeakOneLinerConversation();
|
|
}
|
|
//If the last perception event was hearing based or if someone vanished then go to search mode
|
|
if ((GetLastPerceptionVanished()) && GetIsEnemy(GetLastPerceived()))
|
|
{
|
|
object oGone = GetLastPerceived();
|
|
if((GetAttemptedAttackTarget() == GetLastPerceived() ||
|
|
GetAttemptedSpellTarget() == GetLastPerceived() ||
|
|
GetAttackTarget() == GetLastPerceived()) && GetArea(GetLastPerceived()) != GetArea(OBJECT_SELF))
|
|
{
|
|
ClearAllActions();
|
|
DetermineCombatRound();
|
|
}
|
|
}
|
|
//Do not bother checking the last target seen if already fighting
|
|
else if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
|
|
{
|
|
//Check if the last percieved creature was actually seen
|
|
if(GetLastPerceptionSeen())
|
|
{
|
|
int GroupHD = GetHitDice(GetLastPerceived());
|
|
int EnemyHD = GetHitDice(OBJECT_SELF);
|
|
int Nth = 1;
|
|
object Creature = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_FRIEND, OBJECT_SELF, Nth);
|
|
while (GetIsObjectValid(Creature) && GetDistanceToObject(Creature) <= 30.0)
|
|
{
|
|
GroupHD == GroupHD + GetHitDice(Creature);
|
|
Nth++;
|
|
Creature = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_FRIEND, OBJECT_SELF, Nth);
|
|
}
|
|
|
|
Nth = 1;
|
|
Creature = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_FRIEND, GetLastPerceived(), Nth);
|
|
while (GetIsObjectValid(Creature) && GetDistanceBetween(Creature, GetLastPerceived()) <= 30.0)
|
|
{
|
|
EnemyHD == EnemyHD + GetHitDice(Creature);
|
|
Nth++;
|
|
Creature = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_FRIEND, GetLastPerceived(), Nth);
|
|
}
|
|
|
|
|
|
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL))
|
|
{
|
|
DetermineSpecialBehavior();
|
|
}
|
|
else if((GetIsEnemy(GetLastPerceived()) && GroupHD > EnemyHD) ||
|
|
(GetIsEnemy(GetLastPerceived()) && GetDistanceToObject(GetLastPerceived()) < (IntToFloat(GroupHD)/IntToFloat(EnemyHD))*30.0) ||
|
|
(GetIsEnemy(GetLastPerceived()) && GetDistanceToObject(GetLastPerceived()) < 5.0))
|
|
{
|
|
if(!GetHasEffect(EFFECT_TYPE_SLEEP))
|
|
{
|
|
SetFacingPoint(GetPosition(GetLastPerceived()));
|
|
// SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
|
|
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
|
|
DetermineCombatRound();
|
|
}
|
|
}
|
|
else if (GetIsEnemy(GetLastPerceived()) && d100() > FloatToInt((IntToFloat(GroupHD)/IntToFloat(EnemyHD))*100.0))
|
|
{
|
|
ClearAllActions();
|
|
AssignCommand(OBJECT_SELF, ActionMoveAwayFromObject(GetLastPerceived(), TRUE));
|
|
AssignCommand(OBJECT_SELF, ActionRandomWalk());
|
|
}
|
|
//Linked up to the special conversation check to initiate a special one-off conversation
|
|
//to get the PCs attention
|
|
else if(GetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION) && GetIsPC(GetLastPerceived()))
|
|
{
|
|
ActionStartConversation(OBJECT_SELF);
|
|
}
|
|
}
|
|
}
|
|
if(GetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT) && GetLastPerceptionSeen())
|
|
{
|
|
SignalEvent(OBJECT_SELF, EventUserDefined(1002));
|
|
}
|
|
}
|