Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

202 lines
9.3 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Default: On Spawn In
//:: NW_C2_DEFAULT9
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Determines the course of action to be taken
after having just been spawned in
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Oct 25, 2001
//:://////////////////////////////////////////////
#include "NW_O2_CONINCLUDE"
#include "NW_I0_GENERIC"
#include "x3_inc_string"
#include "uc_h"
int fnGetRandomFromString(string sIn)
{ // PURPOSE: To return a random value from input value of
// # of values.value 1/value2/value3/../valuen
string sMaster=sIn;
string sMax=StringParse(sMaster,".");
string sParse;
int nMax=StringToInt(sMax);
int nR;
int nN;
if (nMax>0)
{ // continue
sMaster=StringRemoveParsed(sMaster,sMax,".");
nR=Random(nMax)+1;
nN=0;
sParse=StringParse(sMaster,"/");
while(GetStringLength(sMaster)>0)
{ // parse
nN++;
if (nN==nR) return StringToInt(sParse);
sMaster=StringRemoveParsed(sMaster,sParse,"/");
sParse=StringParse(sMaster,"/");
} // parse
} // continue
return -1;
} // fnGetRandomFromString()
////////////////////////////////////////////////////[ MAIN ]////////////////////
void main()
{
ExecuteScript("prc_npc_spawn", OBJECT_SELF);
object oMe=OBJECT_SELF;
object oMod=GetModule();
object oAProxy;
string sID=GetLocalString(oMe,"sTeamID");
string sS=GetLocalString(oMod,"sIsAlliedTo"+sID);
int nTime;
int nN;
string sResRef=GetResRef(OBJECT_SELF);
string sMyTag=GetTag(OBJECT_SELF);
int nBornTime=GetTimeHour()+GetCalendarDay()*24+GetCalendarMonth()*24*30+GetCalendarYear()*24*30*12;
int nUnitNum=GetLocalInt(oMe,"nUnitNum");
if (GetLocalInt(oMe,"bChampion"))
{ // champion
PrintString("Champion was born:"+GetName(oMe));
SetAILevel(oMe,AI_LEVEL_NORMAL);
AssignCommand(oMe,SetIsDestroyable(FALSE,TRUE,TRUE));
} // champion
if (GetStringLength(sS)>0&&GetLocalInt(oMod,"bIsAllianceLeader"+sID)!=TRUE)
{ // make sure allied
oAProxy=GetObjectByTag(sS+"_PROXY");
if(GetIsEnemy(oAProxy,oMe)) ChangeFaction(oMe,oAProxy);
} // make sure allied
if (StringToInt(GetStringRight(sMyTag,2))>0) sMyTag=GetStringLeft(sMyTag,GetStringLength(sMyTag)-2);
else sMyTag=GetStringLeft(sMyTag,GetStringLength(sMyTag)-1);
if (sMyTag=="DWF"||sMyTag=="SPID"||sMyTag=="UND"||sMyTag=="UNC"||sMyTag=="MER")
{ // assign team
SetLocalString(OBJECT_SELF,"sTeamID",sMyTag);
} // assign team
if (sMyTag=="UND25") SetLocalInt(OBJECT_SELF,"nMana",4);
// 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);
//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.)
//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
DelayCommand(0.1,ExecuteScript("rts_unit_count",oMe));
if (nUnitNum>0)
{ // unit num
if (GetLocalInt(oMe,"nTimeToUpgrade")<1)
{ // don't know upgrades yet
nTime=GetUnitTimedUpgradeTime(sID,nUnitNum);
SetLocalInt(oMe,"nBornTime",nBornTime);
if (nTime>0) SetLocalInt(oMe,"nTimeToUpgrade",nBornTime+nTime);
} // don't know upgrades yet
if (nTime>0)
{ // timed upgrade
//SendMessageToPC(GetFirstPC(),"==DelayCommand set==");
DelayCommand(18.0,ExecuteScript("rts_timed_upg",oMe));
SetLocalInt(oMe,"nTimedUpgSet",TRUE);
} // timed upgrade
} // unit num
if (sResRef!="dwfupg1"&&sResRef!="dwfupg2") ExecuteScript("rts_unit_ai",oMe);
object oNear=GetNearestObjectByTag(GetTag(oMe),oMe);
object oNear2=GetNearestObjectByTag(GetTag(oMe),oMe,2);
if (GetIsObjectValid(oNear)&&GetIsObjectValid(oNear2)&&GetDistanceBetween(oMe,oNear2)<10.0) return; // abort randomize with large groups.
sS=GetLocalString(oMe,"sRandomAppearance");
if (GetStringLength(sS)>0)
{ // possible random appearance
nN=fnGetRandomFromString(sS);
if (nN>-1) SetCreatureAppearanceType(oMe,nN);
} // possible random appearance
else if (sResRef=="und2")
{ // random zombie appearance
if (d4()>2) SetCreatureAppearanceType(OBJECT_SELF,APPEARANCE_TYPE_ZOMBIE_ROTTING);
} // random zombie appearance
sS=GetLocalString(oMe,"sRandomHead");
if (GetStringLength(sS)>0)
{ // random head
nN=fnGetRandomFromString(sS);
if (nN>-1) SetCreatureBodyPart(CREATURE_PART_HEAD,nN,oMe);
} // random head
sS=GetLocalString(oMe,"sRandomPhenotype");
if (GetStringLength(sS)>0)
{ // random phenotype
nN=fnGetRandomFromString(sS);
if (nN>-1) SetPhenoType(nN,oMe);
} // random phenotype
sS=GetLocalString(oMe,"sRandomTail");
if (GetStringLength(sS)>0)
{ // random tail
nN=fnGetRandomFromString(sS);
if (nN>-1) SetCreatureTailType(nN,oMe);
} // random tail
sS=GetLocalString(oMe,"sRandomSkinColor");
if (GetStringLength(sS)>0)
{ // random skin color
nN=fnGetRandomFromString(sS);
if (nN>-1) SetColor(oMe,COLOR_CHANNEL_SKIN,nN);
} // random skin color
sS=GetLocalString(oMe,"sRandomHairColor");
if (GetStringLength(sS)>0)
{ // random hair color
nN=fnGetRandomFromString(sS);
if (nN>-1) SetColor(oMe,COLOR_CHANNEL_HAIR,nN);
} // random hair color
}