Jaysyn904 e2f4ba74d5 Merged redundant hak files
Merged redundant hak files.  Moved hak scripts into module.  Updated gitignore.  Full Compile.  Added release folder & archive.
2024-12-12 15:02:17 -05:00

298 lines
12 KiB
Plaintext

///////////////////////////////////////////////////////////////////////////////////
// REAL TIME STRATEGY ADVENTURE - Kit
// FILE: rtsa_wrap9
// NAME: OnSpawn Dynamic Script wrapper
// SCRIPTED BY: Deva Bryson Winblood
// DATE: 3/27/2003
///////////////////////////////////////////////////////////////////////////////////
// Modified from the Bioware script nw_c2_default9
#include "NW_O2_CONINCLUDE"
#include "NW_I0_GENERIC"
#include "rtsa_headerf" // factions
/// ProtoTypes
void fnPFX(int nNum); // Persistent Visual effect
void fnTimedUpgrade();// start timed upgrade
void fnRegainMana(); // regain 1 personal mana per hour
void fnLightSensitivity(int nI); // Light Sensitivity
void fnLightFatality(int nI); // Light Fatality
void fnProximityHeal(int nR,string sU); // heal when near placeable
void fnHealsInSunlight();
void fnRunAI();
void main()
{
object oMod=GetModule();
string sRes=GetResRef(OBJECT_SELF);
string sID=GetLocalString(oMod,"s"+sRes+"TID");
int nC=GetLocalInt(oMod,"n"+sID+"UC");
int nV;
object oWP;
nC++;
SetLocalInt(oMod,"n"+sID+"UC",nC); // add to unit count
SetLocalString(OBJECT_SELF,"sTeamID",sID);
nC=GetLocalInt(oMod,"n"+sRes+"Team");
SetLocalInt(OBJECT_SELF,"nTeamN",nC);
if (GetLocalInt(oMod,"n"+sRes+"PF")>0)
fnPFX(GetLocalInt(oMod,"n"+sRes+"PF"));
nV=GetLocalInt(oMod,"n"+sRes+"TUP");
if (nV>0)
DelayCommand(HoursToSeconds(nV),fnTimedUpgrade());
nV=GetLocalInt(oMod,"n"+sRes+"MM");
if (nV>0)
{
SetLocalInt(OBJECT_SELF,"nMana",nV);
fnRegainMana();
}
nV=GetLocalInt(oMod,"n"+sRes+"LS");
if (nV>0)
fnLightSensitivity(nV);
nV=GetLocalInt(oMod,"n"+sRes+"LF");
if (nV>0)
fnLightFatality(nV);
nV=GetLocalInt(oMod,"n"+sRes+"A12");
if (nV>0)
fnProximityHeal(nV,sRes);
nV=GetLocalInt(oMod,"n"+sRes+"A10");
if (nV>0)
fnHealsInSunlight();
// OPTIONAL BEHAVIORS (Comment In or Out to Activate ) ****************************************************************************
//SetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION);
//SetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION);
// This causes the creature to say a special greeting in their conversation file
// upon Perceiving the player. Attach the [NW_D2_GenCheck.nss] script to the desired
// greeting in order to designate it. As the creature is actually saying this to
// himself, don't attach any player responses to the greeting.
SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);
// This will set the listening pattern on the NPC to attack when allies call
//SetSpawnInCondition(NW_FLAG_STEALTH);
// If the NPC has stealth and they are a rogue go into stealth mode
//SetSpawnInCondition(NW_FLAG_SEARCH);
// If the NPC has Search go into Search Mode
SetSpawnInCondition(NW_FLAG_SET_WARNINGS);
// This will set the NPC to give a warning to non-enemies before attacking
//SetSpawnInCondition(NW_FLAG_SLEEP);
//Creatures that spawn in during the night will be asleep.
//SetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING);
if (GetLocalInt(oMod,"n"+GetResRef(OBJECT_SELF)+"A18")==TRUE) SetSpawnInCondition(NW_FLAG_APPEAR_SPAWN_IN_ANIMATION);
//SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);
//SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
//This will play Ambient Animations until the NPC sees an enemy or is cleared.
//NOTE that these animations will play automatically for Encounter Creatures.
// NOTE: ONLY ONE OF THE FOLOOWING ESCAPE COMMANDS SHOULD EVER BE ACTIVATED AT ANY ONE TIME.
//SetSpawnInCondition(NW_FLAG_ESCAPE_RETURN); // OPTIONAL BEHAVIOR (Flee to a way point and return a short time later.)
//SetSpawnInCondition(NW_FLAG_ESCAPE_LEAVE); // OPTIONAL BEHAVIOR (Flee to a way point and do not return.)
//SetSpawnInCondition(NW_FLAG_TELEPORT_LEAVE); // OPTIONAL BEHAVIOR (Teleport to safety and do not return.)
if (GetLocalInt(oMod,"n"+GetResRef(OBJECT_SELF)+"A4")==TRUE)SetSpawnInCondition(NW_FLAG_TELEPORT_RETURN); // OPTIONAL BEHAVIOR (Teleport to safety and return a short time later.)
// CUSTOM USER DEFINED EVENTS
/*
The following settings will allow the user to fire one of the blank user defined events in the NW_D2_DefaultD. Like the
On Spawn In script this script is meant to be customized by the end user to allow for unique behaviors. The user defined
events user 1000 - 1010
*/
//SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1001
//SetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1002
//SetSpawnInCondition(NW_FLAG_ATTACK_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1005
//SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1006
//SetSpawnInCondition(NW_FLAG_DISTURBED_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1008
//SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1003
//SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1004
SetSpawnInCondition(NW_FLAG_DEATH_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1007
// DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) *****************************************************************************************
SetListeningPatterns(); // Goes through and sets up which shouts the NPC will listen to.
//WalkWayPoints(); // Optional Parameter: void WalkWayPoints(int nRun = FALSE, float fPause = 1.0)
// 1. Looks to see if any Way Points in the module have the tag "WP_" + NPC TAG + "_0X", if so walk them
// 2. If the tag of the Way Point is "POST_" + NPC TAG the creature will return this way point after
// combat.
// GenerateNPCTreasure(); //* Use this to create a small amount of treasure on the creature
fnRunAI();
SetLocalInt(OBJECT_SELF,"nBaseWeight",GetWeight(OBJECT_SELF));
//------------------------ CRSP
oWP=GetWaypointByTag(GetResRef(OBJECT_SELF)+"CRSP9");
if (oWP!=OBJECT_INVALID)
{ // run additional script
ExecuteScript(GetName(oWP),OBJECT_SELF);
} // run additional script
SetListening(OBJECT_SELF,TRUE);
SetListenPattern(OBJECT_SELF,"Troops, **",112670);
SetListenPattern(OBJECT_SELF,"Traders, **",91474);
DelayCommand(10.0,fnMatchFaction(OBJECT_SELF)); // set proper faction rep
}
//--- Run AI routines
void fnRunAI()
{ // Run AI routines
object oMod=GetModule();
object oMe=OBJECT_SELF;
int nSpeed=GetLocalInt(oMod,"nRTSAISpeed");
int nState=GetLocalInt(oMe,"nMState");
int nSState=GetLocalInt(oMe,"nSState");
float fDelay;
SetLocalInt(oMe,"nRTSALastAI",GetTimeSecond());
if (nSpeed<1) nSpeed=2;
if (nState==3||nState==5||nState==6||nState==16||nState==7||nState==17) nSpeed=nSpeed+4;
else if (nSState==10) nSpeed=nSpeed+20;
else if (nState==9||nState==21||nState==11||nState==27) nSpeed=nSpeed+5;
else if (nState==12||nSState==0||nState==24) nSpeed=nSpeed+8;
else if (nState==28||nState==23||nState==8||nState==19) nSpeed=nSpeed+28;
ExecuteScript("rtsa_unit_ai",oMe);
fDelay=IntToFloat(nSpeed);
DelayCommand(fDelay,fnRunAI());
} // fnRunAI()
//--- Persistent Effect
void fnPFX(int nNum)
{ // play persistent effect
effect eVFX=EffectVisualEffect(nNum);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,OBJECT_SELF,3.0);
DelayCommand(2.0,fnPFX(nNum));
} // fnPFX
//--- Timed Upgrade
void fnTimedUpgrade()
{ // upgrade to new unit
object oMe=OBJECT_SELF;
object oNew;
object oMod=GetModule();
string sMe=GetResRef(oMe);
string sRR=GetLocalString(oMod,"s"+sMe+"TUP");
oNew=CreateObject(OBJECT_TYPE_CREATURE,sRR,GetLocation(oMe),FALSE);
DelayCommand(1.5,SetLocalInt(oNew,"nKills",GetLocalInt(oMe,"nKills")));
DelayCommand(1.5,SetLocalInt(oNew,"nMState",GetLocalInt(oMe,"nMState")));
DelayCommand(1.5,SetLocalInt(oNew,"nSState",GetLocalInt(oMe,"nSState")));
DelayCommand(1.5,SetLocalInt(oNew,"nTeamN",GetLocalInt(oMe,"nTeamN")));
DelayCommand(1.5,SetLocalInt(oNew,"nMana",GetLocalInt(oMe,"nMana")));
DelayCommand(1.5,SetLocalInt(oNew,"nRun",GetLocalInt(oMe,"nRun")));
DelayCommand(1.5,SetLocalObject(oNew,"oDest",GetLocalObject(oMe,"oDest")));
DelayCommand(1.5,SetLocalString(oNew,"sTeamID",GetLocalString(oMe,"sTeamID")));
DelayCommand(2.0,DestroyObject(oMe));
} // fnTimedUpgrade()
//---- Regain Mana
void fnRegainMana()
{ // mana regain
object oMe=OBJECT_SELF;
int nM=GetLocalInt(oMe,"nMana");
if (nM<GetLocalInt(GetModule(),"n"+GetResRef(oMe)+"MM"))
{ // regain mana
nM=nM+1;
SetLocalInt(oMe,"nMana",nM);
} // regain mana
DelayCommand(HoursToSeconds(1),fnRegainMana());
} // fnRegainMana()
//-- Light sensitivity
void fnLightSensitivity(int nI)
{ // process light sensitivity
object oMe=OBJECT_SELF;
object oOb=GetFirstObjectInArea(GetArea(oMe));
effect eF;
effect eV=EffectVisualEffect(VFX_IMP_DAZED_S);
int nS=FALSE;
if (GetIsDay())
{
if (GetTag(oOb)=="RTSA_SUN") nS=TRUE;
else
{
oOb=GetNearestObjectByTag("RTSA_SUN",oOb);
if (oOb!=OBJECT_INVALID) nS=TRUE;
}
if (nS)
{ // light sensitive area
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eF,oMe,10.0);
eF=EffectAbilityDecrease(ABILITY_DEXTERITY,nI);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eF,oMe,10.0);
eF=EffectMovementSpeedDecrease(nI*10);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eF,oMe,10.0);
} // light sensitive area
DelayCommand(10.0,fnLightSensitivity(nI));
} // is day
else
DelayCommand(30.0,fnLightSensitivity(nI));
} // fnLightSensitivity()
//-- Light Fatality
void fnLightFatality(int nI)
{ // Light is harmful
object oMe=OBJECT_SELF;
object oOb=GetFirstObjectInArea(GetArea(oMe));
effect eFire=EffectVisualEffect(VFX_IMP_FLAME_M);
int nD=0;
int nL=1;
effect eDmg;
while(nL<=nI)
{
nD=nD+d4();
nL++;
}
eDmg=EffectDamage(nD,DAMAGE_TYPE_FIRE,DAMAGE_POWER_PLUS_FIVE);
int nS=FALSE;
if (GetIsDay())
{
if (GetTag(oOb)=="RTSA_SUN") nS=TRUE;
else
{
oOb=GetNearestObjectByTag("RTSA_SUN",oOb);
if (oOb!=OBJECT_INVALID) nS=TRUE;
}
if (nS)
{ // light sensitive area
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eFire,oMe,3.0);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eDmg,oMe,1.0);
} // light sensitive area
DelayCommand(2.0,fnLightFatality(nI));
} // is day
else
DelayCommand(12.0,fnLightFatality(nI));
} // fnLightFatality()
//-- fnProximityHeal()
void fnProximityHeal(int nR,string sU)
{ // heal near placeable
object oMod=GetModule();
object oMe=OBJECT_SELF;
effect eHeal=EffectHeal(1);
float fDist;
object oType;
string sTag=GetLocalString(oMod,"s"+sU+"A12");
oType=GetNearestObjectByTag(sTag);
if (oType!=OBJECT_INVALID)
{ // !OI
fDist=GetDistanceToObject(oType);
if (fDist!=-1.0&&fDist<=IntToFloat(nR))
ApplyEffectToObject(DURATION_TYPE_INSTANT,eHeal,oMe,1.0);
} // !OI
DelayCommand(10.0,fnProximityHeal(nR,sU));
} // fnProximityHeal()
void fnHealsInSunlight()
{ // heals in sunlight
object oMe=OBJECT_SELF;
object oOb=GetFirstObjectInArea(GetArea(oMe));
effect eF;
int nH=1+GetAbilityModifier(ABILITY_CONSTITUTION,oMe);
int nS=FALSE;
if (nH<1) nH=1;
if (GetIsDay())
{
if (GetTag(oOb)=="RTSA_SUN") nS=TRUE;
else
{
oOb=GetNearestObjectByTag("RTSA_SUN",oOb);
if (oOb!=OBJECT_INVALID) nS=TRUE;
}
if (nS)
{ // light sensitive area
eF=EffectHeal(nH);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eF,oMe,1.0);
} // light sensitive area
} // is day
DelayCommand(HoursToSeconds(1),fnHealsInSunlight());
} // fnHealsInSunlight()