HoS_PRC8/_mod/_module/nss/dr_tx_randomin.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

560 lines
22 KiB
Plaintext

////////////////////////////////////////////////////////////////////////////////
// dr_tx_randomin - Transition to Random House Interior
// By Deva B. Winblood. October 27th, 2008
////////////////////////////////////////////////////////////////////////////////
#include "lib_inc_randoms"
/////////////////////////////////
// FUNCTIONS
/////////////////////////////////
void fnRespawnRandoms(object oDoor,int nStorageID)
{ // PURPOSE: Respawn items previously stored
object oOb;
int nN;
int nCount;
string sRR;
string sName;
location lLoc;
nCount=RND_GetStoredInt(nStorageID,"nPlaceables");
if (nCount>0)
{ // Respawn Placeables
nN=1;
while(nN<=nCount)
{ // spawn
sRR=RND_GetStoredString(nStorageID,"sPRR_"+IntToString(nN));
sName=RND_GetStoredString(nStorageID,"sPN_"+IntToString(nN));
lLoc=RND_GetStoredLocation(nStorageID,"lPL_"+IntToString(nN));
oOb=CreateObject(OBJECT_TYPE_PLACEABLE,sRR,lLoc);
SetName(oOb,sName);
nN++;
} // spawn
} // Respawn Placeables
nCount=RND_GetStoredInt(nStorageID,"nItems");
if (nCount>0)
{ // Respawn Items
nN=1;
while(nN<=nCount)
{ // spawn
sRR=RND_GetStoredString(nStorageID,"sIRR_"+IntToString(nN));
sName=RND_GetStoredString(nStorageID,"sIN_"+IntToString(nN));
lLoc=RND_GetStoredLocation(nStorageID,"lIL_"+IntToString(nN));
oOb=CreateObject(OBJECT_TYPE_ITEM,sRR,lLoc);
SetName(oOb,sName);
nN++;
} // spawn
} // Respawn Items
nCount=RND_GetStoredInt(nStorageID,"nCreatures");
if (nCount>0)
{ // Respawn Creatures
nN=1;
while(nN<=nCount)
{ // spawn
sRR=RND_GetStoredString(nStorageID,"sCRR_"+IntToString(nN));
sName=RND_GetStoredString(nStorageID,"sCN_"+IntToString(nN));
lLoc=RND_GetStoredLocation(nStorageID,"lCL_"+IntToString(nN));
oOb=CreateObject(OBJECT_TYPE_CREATURE,sRR,lLoc);
SetName(oOb,sName);
nN++;
} // spawn
} // Respawn Creatures
} // fnRespawnRandoms()
void fnMurdererStoop()
{ // PURPOSE: As long as bStoop is true on this NPC keep stooping
object oMe=OBJECT_SELF;
if (GetLocalInt(oMe,"bStoop"))
{ // keep stooping
AssignCommand(oMe,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,2.5));
DelayCommand(2.0,fnMurdererStoop());
} // keep stooping
} // fnMurdererStoop()
void fnCreateRandoms(object oDoor,int nStorageID,int nStyle)
{ // PURPOSE: This will create the interior if it has not been created. Otherwise,
// it will respawn what was there previously.
int nR;
int nP;
object oOb;
string sS;
object oWP;
string sL;
if (RND_GetStoredInt(nStorageID,"bStored")>0)
{ // respawn
fnRespawnRandoms(oDoor,nStorageID);
} // respawn
else
{ // create
RND_SetStoredInt(nStorageID,"bStored",TRUE);
if (!GetIsDay()) oWP=GetNearestObjectByTag("NPC_SPAWN1_NIGHT",oDoor);
else {oWP=GetNearestObjectByTag("NPC_SPAWN1_DAY",oDoor); }
if (nStyle==1)
{ // single male
nR=d100();
if (nR<61)
{ // commoner
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhman1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // commoner
else if (nR<91)
{ // middle class
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhman2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // middle class
else
{ // dwarf
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhman3",GetLocation(oWP));
sS=RandomName(NAME_FIRST_DWARF_MALE);
SetName(oOb,sS);
} // dwarf
} // single male
else if (nStyle==2)
{ // single female
nR=d100();
if (nR<61)
{ // commoner
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhwoman1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // commoner
else if (nR<91)
{ // middle class
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhwoman2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // middle class
else
{ // courtesan
oWP=GetNearestObjectByTag("NPC_SPAWN1_DAY",oDoor);
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhwoman3",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // courtesan
} // single female
else if (nStyle==3)
{ // married couple
nR=d100();
sL=RandomName(NAME_LAST_HUMAN);
if (nR<76)
{ // male 1
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupm1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE)+" "+sL;
SetName(oOb,sS);
} // male 1
else
{ // male 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupm2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE)+" "+sL;
SetName(oOb,sS);
} // male 2
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN2_NIGHT",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN2_DAY",oDoor); }
nR=d100();
if (nR<76)
{ // female 1
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupf1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE)+" "+sL;
SetName(oOb,sS);
} // female 1
else
{ // female 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupf2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE)+" "+sL;
SetName(oOb,sS);
} // female 2
} // married couple
else if (nStyle==4)
{ // married couple with child
nR=d100();
sL=RandomName(NAME_LAST_HUMAN);
if (nR<76)
{ // male 1
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupm1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE)+" "+sL;
SetName(oOb,sS);
} // male 1
else
{ // male 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupm2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE)+" "+sL;
SetName(oOb,sS);
} // male 2
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN2_NIGHT",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN2_DAY",oDoor); }
nR=d100();
if (nR<76)
{ // female 1
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupf1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE)+" "+sL;
SetName(oOb,sS);
} // female 1
else
{ // female 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupf2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE)+" "+sL;
SetName(oOb,sS);
} // female 2
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN3_NIGHT",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN3_DAY",oDoor); }
nR=d100();
if (nR<51)
{ // female child
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupfc",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE)+" "+sL;
SetName(oOb,sS);
} // female child
else
{ // male child
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcoupmc",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE)+" "+sL;
SetName(oOb,sS);
} // male child
} // married couple with child
else if (nStyle==5)
{ // Bandit - Single Male
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN1_DAY",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN1_NIGHT",oDoor); }
nR=d100();
if (nR<76)
{ // bandit 1
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandm1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // bandit 1
else
{ // bandit 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandm2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HALFLING_MALE);
SetName(oOb,sS);
} // bandit 2
} // Bandit - Single Male
else if (nStyle==6)
{ // Bandit - Single Female
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN1_DAY",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN1_NIGHT",oDoor); }
nR=d100();
if (nR<51)
{ // bandit 1
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HALFLING_FEMALE);
SetName(oOb,sS);
} // bandit 1
else if (nR<81)
{ // bandit 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // bandit 2
else
{ // bandit 3
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf3",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // bandit 3
} // Bandit - Single Female
else if (nStyle==7)
{ // Bandits - 2
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN1_DAY",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN1_NIGHT",oDoor); }
nR=d100();
if (nR<76)
{ // bandit male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandm2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HALFLING_MALE);
SetName(oOb,sS);
} // bandit male
else
{ // bandit female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf3",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // bandit female
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN2_DAY",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN2_NIGHT",oDoor); }
nR=d100();
if (nR<51)
{ // bandit male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandm1",GetLocation(oWP),FALSE,"SEC");
sS=RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // bandit male
else if (nR<76)
{ // bandit female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf1",GetLocation(oWP),FALSE,"SEC");
sS=RandomName(NAME_FIRST_HALFLING_FEMALE);
SetName(oOb,sS);
} // bandit female
else
{ // bandit female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf2",GetLocation(oWP),FALSE,"SEC");
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // bandit female
} // Bandits - 2
else if (nStyle==8)
{ // Bandits - 3
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN1_DAY",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN1_NIGHT",oDoor); }
nR=d100();
if (nR<76)
{ // bandit male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandm2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HALFLING_MALE);
SetName(oOb,sS);
} // bandit male
else
{ // bandit female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf3",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // bandit female
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN2_DAY",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN2_NIGHT",oDoor); }
nR=d100();
if (nR<51)
{ // bandit male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandm1",GetLocation(oWP),FALSE,"SEC");
sS=RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // bandit male
else if (nR<76)
{ // bandit female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf1",GetLocation(oWP),FALSE,"SEC");
sS=RandomName(NAME_FIRST_HALFLING_FEMALE);
SetName(oOb,sS);
} // bandit female
else
{ // bandit female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf2",GetLocation(oWP),FALSE,"SEC");
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // bandit female
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN2_DAY",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN2_NIGHT",oDoor); }
nR=d100();
if (nR<76)
{ // male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandm3",GetLocation(oWP),FALSE,"THIRD");
sS=RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // male
else
{ // female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbandf4",GetLocation(oWP),FALSE,"THIRD");
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // female
} // Bandits - 3
else if (nStyle==9)
{ // Mage - Low Level
nR=d100();
if (nR<76)
{ // male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhmagellm",GetLocation(oWP));
sS="Mage "+RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // male
else
{ // female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhmagellf",GetLocation(oWP));
sS="Mage "+RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // female
} // Mage - Low Level
else if (nStyle==10)
{ // Mage - Mid Level
nR=d100();
if (nR<76)
{ // male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhmagemlm",GetLocation(oWP));
sS="Mage "+RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // male
else
{ // female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhmagemlf",GetLocation(oWP));
sS="Mage "+RandomName(NAME_FIRST_ELF_FEMALE);
SetName(oOb,sS);
} // female
} // Mage - Mid Level
else if (nStyle==11)
{ // retired adventurer
nR=d100();
if (nR<51)
{ // male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhretirem1",GetLocation(oWP));
sS="Adventurer "+RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // male
else if (nR<81)
{ // male 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhretirem2",GetLocation(oWP));
sS="Adventurer "+RandomName(NAME_FIRST_HUMAN_MALE);
SetName(oOb,sS);
} // male 2
else
{ // female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhretiref",GetLocation(oWP));
sS="Adventurer "+RandomName(NAME_FIRST_HUMAN_FEMALE);
SetName(oOb,sS);
} // female
} // retired adventurer
else if (nStyle==12)
{ // Haunted - 1 Ghost
nR=d100();
if (nR<51)
{ // male
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhghost1",GetLocation(oWP));
sS="Ghostly Man";
SetName(oOb,sS);
AssignCommand(oOb,ActionRandomWalk());
} // male
else
{ // female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhghost2",GetLocation(oWP));
sS="Ghostly Woman";
SetName(oOb,sS);
AssignCommand(oOb,ActionRandomWalk());
} // female
} // Haunted - 1 Ghost
else if (nStyle==13)
{ // Haunted - 2 Ghosts
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhghost1",GetLocation(oWP));
sS="Ghostly Man";
SetName(oOb,sS);
AssignCommand(oOb,ActionRandomWalk());
if (GetIsNight()) oWP=GetNearestObjectByTag("NPC_SPAWN2_DAY",oDoor);
else { oWP=GetNearestObjectByTag("NPC_SPAWN2_NIGHT",oDoor); }
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhghost2",GetLocation(oWP));
sS="Ghostly Woman";
SetName(oOb,sS);
AssignCommand(oOb,ActionRandomWalk());
} // Haunted - 2 Ghosts
else if (nStyle==14)
{ // Empty - Nice
} // Empty - Nice
else if (nStyle==15)
{ // Empty - Run Down
} // Empty - Run Down
else if (nStyle==16)
{ // Craftsman
nR=d100();
if (nR<41)
{ // male 1
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcrafter1",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE);
} // male 1
else if (nR<81)
{ // male 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcrafter2",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_MALE);
} // male 2
else
{ // female
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhcrafter3",GetLocation(oWP));
sS=RandomName(NAME_FIRST_HUMAN_FEMALE);
} // female
nR=d100();
if (nR<16)
{ // Cobbler
SetName(oOb,"Cobbler "+sS);
SetLocalInt(oOb,"nCrafter",1);
} // Cobbler
else if (nR<31)
{ // Glass Blower
SetName(oOb,"Glass Blower "+sS);
SetLocalInt(oOb,"nCrafter",2);
} // Glass Blower
else if (nR<46)
{ // Sculpter
SetName(oOb,"Sculpter "+sS);
SetLocalInt(oOb,"nCrafter",3);
} // Sculpter
else if (nR<61)
{ // Artist
SetName(oOb,"Artist "+sS);
SetLocalInt(oOb,"nCrafter",4);
} // Artist
else if (nR<81)
{ // Brewer
SetName(oOb,"Brewer "+sS);
SetLocalInt(oOb,"nCrafter",5);
} // Brewer
else
{ // Sage
SetName(oOb,"Sage "+sS);
SetLocalInt(oOb,"nCrafter",6);
} // Sage
} // Craftsman
else if (nStyle==17)
{ // Beggars
nR=d100();
if (nR<51)
{ // beggar 1
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbeg1",GetLocation(oWP));
} // beggar 1
else
{ // beggar 2
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhbeg2",GetLocation(oWP));
} // beggar 2
} // Beggars
else if (nStyle==18)
{ // Crime Scene 1 - Murder
oWP=GetNearestObjectByTag("NPC_SPAWN1_DAY",oDoor);
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhvictim",GetLocation(oWP));
ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectCutsceneGhost(),oOb);
object oProxy=GetObjectByTag("ABS_PROXY");
oOb=CreateObject(OBJECT_TYPE_CREATURE,"rhmurderer",GetLocation(oWP));
if (!GetIsObjectValid(oOb)) SendMessageToPC(GetFirstPC(),"Error: dr_tx_randomin - failed to create 'rhmurderer'");
DelayCommand(0.05,ChangeFaction(oOb,oProxy));
SetLocalInt(oOb,"bStoop",TRUE);
float fFacing=GetFacing(oWP);
fFacing=fFacing+180.0;
if (fFacing>360.0) fFacing=fFacing-360.0;
DelayCommand(0.11,AssignCommand(oOb,ClearAllActions(TRUE)));
DelayCommand(0.12,AssignCommand(oOb,SetFacing(fFacing)));
DelayCommand(0.15,AssignCommand(oOb,fnMurdererStoop()));
} // Crime Scene 1 - Murder
else if (nStyle==19)
{ // Crime Scene 2 - Necromancy
} // Crime Scene 2 - Necromancy
else if (nStyle==20)
{ // Crime Scene 3 - Arson
} // Crime Scene 3 - Arson
} // create
} // fnCreateRandoms()
///////////////////////////////////////////////////////////////[ MAIN ]/////////
void main()
{
object oDoor=OBJECT_SELF;
object oPC=GetClickingObject();
object oDest=GetLocalObject(oDoor,"oDest");
int nStyle=GetLocalInt(oDoor,"nStyle");
object oExit=GetNearestObject(OBJECT_TYPE_DOOR,oDest,1);
int nStorageID=RND_GetStorageID(oDoor);
if (!GetIsOpen(oExit)) AssignCommand(oExit,ActionOpenDoor(oExit));
if (GetLocalInt(oDest,"nStyle")!=nStyle)
{ // setup before transition
SetLocalObject(oDest,"oExit",oDoor);
SetLocalInt(oDest,"nStyle",nStyle);
fnCreateRandoms(oDest,nStorageID,nStyle);
DelayCommand(1.0,AssignCommand(oPC,ClearAllActions(TRUE)));
DelayCommand(1.01,AssignCommand(oPC,JumpToObject(oDest)));
} // setup before transition
else
{ // transition
AssignCommand(oPC,ClearAllActions(TRUE));
AssignCommand(oPC,JumpToObject(oDest));
} // transition
}
///////////////////////////////////////////////////////////////[ MAIN ]/////////