Rune_PRC8/_module/nss/oai_default6.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

115 lines
3.3 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
//
// Olander's AI
// nw_c2_default6
// by Don Anderson
// dandersonru@msn.com
//
// OnDamaged
// Original Script by Bioware
//
////////////////////////////////////////////////////////////////////////////////
#include "oai_inc_ai"
void main()
{
object oDamager = GetLastDamager();
//OAI Critical System
OAI_Crits(oDamager,OBJECT_SELF);
//Trolls
if(GetBattleCondition(OAI_ROLE_TROLL)) TrollDamaged();
//FIGHT_OR_FLIGHT Addition
if(GetLocalInt(OBJECT_SELF,"FIGHT_OR_FLIGHT") == 1 && GetLocalInt(OBJECT_SELF,"RETREATED") == 0)
{
FOF_Execute();
}
if(GetIsObjectValid(oDamager) && !GetIsDM(oDamager))
{
//Blink Ability
if(GetBattleCondition(OAI_BLINK_OTHERS))
{
if(GetDamageDealtByType(DAMAGE_TYPE_SLASHING | DAMAGE_TYPE_PIERCING | DAMAGE_TYPE_BLUDGEONING) > 0
&& Random(100) >= GetLocalInt(OBJECT_SELF, "OAI_BLINK_FAILURE"))
{
BlinkMove();
}
}
//Illusionary Creatures
if(GetLocalInt(OBJECT_SELF, "OAI_ILLUSION_DC") > 0)
{
if(BreakIllusion(oDamager)) {}
}
if(!GetIsFighting(OBJECT_SELF))
{
// If we're not fighting, determine combat round
if(GetBehaviorState(NW_FLAG_BEHAVIOR_OMNIVORE) || GetBehaviorState(NW_FLAG_BEHAVIOR_HERBIVORE))
{
//DetermineSpecialBehavior(oDamager);
OAI_DetermineSpecialBehavior(oDamager);
}
else
{
if(!GetObjectSeen(oDamager) && GetArea(OBJECT_SELF) == GetArea(oDamager))
{
// We don't see our attacker, go find them
ActionMoveToLocation(GetLocation(oDamager), TRUE);
ActionDoCommand(OAI_DetermineCombatRound());
}
else
{
if(OAI_GetIsAlly(oDamager))
{
ClearPersonalReputation(oDamager, OBJECT_SELF);
ClearAllActions(TRUE);
DelayCommand(1.2, ActionDoCommand(OAI_DetermineCombatRound()));
}
else OAI_DetermineCombatRound(oDamager);
}
}
}
else
{
// We are fighting already -- consider switching if we've been
// attacked by a more powerful enemy
object oTarget = GetAttackTarget();
if(!GetIsObjectValid(oTarget)) oTarget = GetAttemptedAttackTarget();
if(!GetIsObjectValid(oTarget)) oTarget = GetAttemptedSpellTarget();
// If our target isn't valid
// or our damager has just dealt us 25% or more
// of our hp in damager
// or our damager is more than 2HD more powerful than our target
// switch to attack the damager.
if(!GetIsObjectValid(oTarget)
|| (oTarget != oDamager
&& (GetTotalDamageDealt() > (GetMaxHitPoints(OBJECT_SELF) / 4)
|| (GetHitDice(oDamager) - 2) > GetHitDice(oTarget))))
{
if(OAI_GetIsAlly(oDamager))
{
ClearAllActions(TRUE);
OAI_DetermineCombatRound();
}
// Switch targets
else OAI_DetermineCombatRound(oDamager);
}
}
}
// Send the user-defined event signal
if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DAMAGED));
}
}