Files
HeroesStone_PRC8/_module/nss/od_polymorph2.nss
Jaysyn904 1eefc84201 Initial Commit
Initial Commit.
2025-09-14 15:40:46 -04:00

138 lines
5.3 KiB
Plaintext

//:://////////////////////////////////////////////////
//:: NW_C2_DEFAULT6
//:: Default OnDamaged handler
/*
If already fighting then ignore, else determine
combat round
*/
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/22/2002
//:://////////////////////////////////////////////////
#include "nw_i0_generic"
void main()
{
int i=6;
int nUser=Random(i);
//attempt to change each damage
//int nUser = GetUserDefinedEventNumber();
//int nChange = GetLocalInt(OBJECT_SELF,"NW_LYCANTHROPE");
//effect eShape = EffectPolymorph(POLYMORPH_TYPE_WERECAT); //Use one of the polymorph constants here (WERE_RAT, WERE_WOLF or WERE_CAT)
effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
if(nUser == 0)
{
//int nChange = GetLocalInt(OBJECT_SELF,"NW_LYCANTHROPE");
effect eShape = EffectPolymorph(POLYMORPH_TYPE_ELDER_FIRE_ELEMENTAL);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eShape, OBJECT_SELF);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(OBJECT_SELF));
SetLocalInt(OBJECT_SELF, "NW_LYCANTHROPE", 1);
}
if(nUser == 1)
{
//int nChange = GetLocalInt(OBJECT_SELF,"NW_LYCANTHROPE");
effect eShape = EffectPolymorph(POLYMORPH_TYPE_DIRE_PANTHER);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eShape, OBJECT_SELF);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(OBJECT_SELF));
SetLocalInt(OBJECT_SELF, "NW_LYCANTHROPE", 1);
}
if(nUser == 2)
{
//int nChange = GetLocalInt(OBJECT_SELF,"NW_LYCANTHROPE");
effect eShape = EffectPolymorph(POLYMORPH_TYPE_FROST_GIANT_FEMALE);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eShape, OBJECT_SELF);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(OBJECT_SELF));
SetLocalInt(OBJECT_SELF, "NW_LYCANTHROPE", 1);
}
if(nUser == 3)
{
//int nChange = GetLocalInt(OBJECT_SELF,"NW_LYCANTHROPE");
effect eShape = EffectPolymorph(POLYMORPH_TYPE_CELESTIAL_AVENGER);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eShape, OBJECT_SELF);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(OBJECT_SELF));
SetLocalInt(OBJECT_SELF, "NW_LYCANTHROPE", 1);
}
if(nUser == 4)
{
//int nChange = GetLocalInt(OBJECT_SELF,"NW_LYCANTHROPE");
effect eShape = EffectPolymorph(POLYMORPH_TYPE_RED_DRAGON);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eShape, OBJECT_SELF);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(OBJECT_SELF));
SetLocalInt(OBJECT_SELF, "NW_LYCANTHROPE", 1);
}
if(nUser == 5)
{
//int nChange = GetLocalInt(OBJECT_SELF,"NW_LYCANTHROPE");
effect eShape = EffectPolymorph(POLYMORPH_TYPE_DOOM_KNIGHT);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eShape, OBJECT_SELF);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(OBJECT_SELF));
SetLocalInt(OBJECT_SELF, "NW_LYCANTHROPE", 1);
}
if(GetFleeToExit()) {
// We're supposed to run away, do nothing
} else if (GetSpawnInCondition(NW_FLAG_SET_WARNINGS)) {
// don't do anything?
} else {
object oDamager = GetLastDamager();
if (!GetIsObjectValid(oDamager)) {
// don't do anything, we don't have a valid damager
} else if (!GetIsFighting(OBJECT_SELF)) {
// If we're not fighting, determine combat round
if(GetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL)) {
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(DetermineCombatRound());
} else {
DetermineCombatRound();
}
}
} 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)
)
)
)
{
// Switch targets
DetermineCombatRound(oDamager);
}
}
}
// Send the user-defined event signal
if(GetSpawnInCondition(NW_FLAG_DAMAGED_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(EVENT_DAMAGED));
}
}