/////////////////////////////////////////////////////////////////////////////////// // 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