Added helms and dynamic goblins

Added  helms and dynamic goblins.  Added onEnter spawner scripts to all dungeon areas.  Fixed the Dishonest Patrol to be dynamic & more like PnP.  Full compile.

Co-Authored-By: Draygoth <65428430+Draygoth@users.noreply.github.com>
This commit is contained in:
Jaysyn904
2022-11-30 00:45:38 -05:00
parent 8989a30fc8
commit 909da8ff18
1647 changed files with 896882 additions and 37126 deletions

View File

@@ -0,0 +1,20 @@
//:://////////////////////////////////////////////
//:: cv_10pct_chance.nss
//:: Copyright (c) 2022 NWNDS
//:://////////////////////////////////////////////
/*
10% chance for this conversation choice
*/
//:://////////////////////////////////////////////
//:: Created By: Jaysyn
//:: Created On: 20220625
//:://////////////////////////////////////////////
int StartingConditional()
{
//:: Randomize
if(Random(10) >= 1)
return FALSE;
return TRUE;
}

View File

@@ -0,0 +1,20 @@
//:://////////////////////////////////////////////
//:: cv_20pct_chance.nss
//:: Copyright (c) 2022 NWNDS
//:://////////////////////////////////////////////
/*
20% chance for this conversation choice
*/
//:://////////////////////////////////////////////
//:: Created By: Jaysyn
//:: Created On: 20220625
//:://////////////////////////////////////////////
int StartingConditional()
{
//:: Randomize
if(Random(5) >= 1)
return FALSE;
return TRUE;
}

View File

@@ -0,0 +1,20 @@
//:://////////////////////////////////////////////
//:: cv_50pct_chance.nss
//:: Copyright (c) 2022 NWNDS
//:://////////////////////////////////////////////
/*
50% chance for this conversation choice
*/
//:://////////////////////////////////////////////
//:: Created By: Jaysyn
//:: Created On: 20221128
//:://////////////////////////////////////////////
int StartingConditional()
{
//:: Randomize
if(Random(1) >= 0)
return FALSE;
return TRUE;
}

View File

@@ -0,0 +1,20 @@
//:://////////////////////////////////////////////
//:: cv_5pct_chance.nss
//:: Copyright (c) 2022 NWNDS
//:://////////////////////////////////////////////
/*
5% chance for this conversation choice
*/
//:://////////////////////////////////////////////
//:: Created By: DSO Team
//:: Created On: 10/9/2002 1:53:23 AM
//:://////////////////////////////////////////////
int StartingConditional()
{
//:: Randomize
if(Random(20) >= 1)
return FALSE;
return TRUE;
}

View File

@@ -0,0 +1,23 @@
//:://////////////////////////////////////////////
//:: cv_is_charmed.nss
//:: Copyright (c) 2022 NWNDS
//:://////////////////////////////////////////////
/*
Checks to see if the NPC speaker is Charmed
*/
//:://////////////////////////////////////////////
//:: Created By: Jaysyn
//:: Created On: 20221128
//:://////////////////////////////////////////////
#include "x0_i0_match"
int StartingConditional()
{
int isCharmed = GetHasEffect(EFFECT_TYPE_CHARMED, OBJECT_SELF);
if (isCharmed)
return TRUE;
return FALSE;
}

View File

@@ -0,0 +1,85 @@
/* Generic area onEnter script for streamlined addition of Sparky Spawner variables
Created By: The Amethyst Dragon (www.amethyst-dragon.com/nwn)
Can be used for the onEnter script for all areas of a module. If you already
have your own area enter script, you can add just the includes and the
"Sparky Spawner Section" of code.
This causes the area to check to see if Sparky variables are set on the area.
If not, it searches for the Encounter Variables placeable object in the area
to find out which variables to add to the area, then runs the Sparky spawning
code.
If no such variables or placeable are present in the area, it skips any further
Sparky code from running.
*/
#include "sparky_inc"
#include "sparky_enc"
#include "X0_I0_PARTYWIDE"
#include "spawn_functions"
void main()
{
object oPC = GetEnteringObject();
object oArea = OBJECT_SELF;
//:: Nothing happens if it wasn't a PC entering the area.
if (GetIsPC(oPC) == TRUE)
{
//:: Records that the PC has entered Rappan Athuk at least once.
SetLocalInt(oPC, "bEnteredDungeon", 1);
//:: Fires any NESS spawners
ExecuteScript("spawn_smpl_onen2");
//////////////////////////////////////////////// Sparky Spawner Section
if (GetLocalInt(oArea, "sparkyloaded") != 1)
{
//:: Find encounters-holding placeable
object oEncVars = GetFirstObjectInArea(oArea);
while (oEncVars != OBJECT_INVALID)
{
if (GetTag(oEncVars) == "sparky_variables") { break; }
oEncVars = GetNextObjectInArea(oArea);
}
if (oEncVars != OBJECT_INVALID)
{
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc01"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc02"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc03"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc04"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc05"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc06"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc07"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc08"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc09"));
LoadEncounterVariables(oArea, GetLocalInt(oEncVars, "enc10"));
DestroyObject(oEncVars, 1.0);
}
SetLocalInt(oArea, "sparkyloaded", 1);
}
int iDisabled = GetLocalInt(oArea, "iSparkyDisabled");
int iAlreadySpawned = GetLocalInt(oArea, "iSparkySpawned");
if (GetIsDM(oPC))
{
SendMessageToPC(oPC, "Sparky spawns are " + (iDisabled ? "OFF" : "ON"));
return;
}
if (iAlreadySpawned || iDisabled)
{
return;
}
SpawnEncounters(oArea);
//////////////////////////////////////////////// End Sparky Section
}
}

View File

@@ -0,0 +1,32 @@
//::///////////////////////////////////////////////
//:: Name ondeath_ostland
//:: Copyright (c) 2022 Project RATDOG
//:://////////////////////////////////////////////
/*
Sheriff Ostland's OnDeath script
*/
//:://////////////////////////////////////////////
//:: Created By: Jaysyn
//:: Created On: 20221129
//:://////////////////////////////////////////////
#include "sql_db_partywide"
#include "pqj_inc"
void main()
{
object oNPC = OBJECT_SELF;
object oPC = GetLastKiller();
//:: Track which PC's have seen Ostland dead
SQL_SetLocalIntOnAll(oPC, "bKilledOstland", 1);
//:: Set quest stage & update DB.
AddPersistentJournalQuestEntry("DishonestPatrol", 1, oPC);
//:: Execute Default NPC OnDeath script
ExecuteScript("nw_c2_default7", OBJECT_SELF);
//:: Execute PRC NPC OnDeath script
ExecuteScript("prc_npc_death", OBJECT_SELF);
}

View File

@@ -0,0 +1,99 @@
//::///////////////////////////////////////////////
//:: Name Area Auto-cleaner
//:: FileName areaclean
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Place this script in the OnExit field of an area's event
tab. This will wait a few minutes after the last PC has
left the area then destroy all non-plot items dropped by
a PC or a slain NPC.
It will never perform a cleaning while a PC is in the area.
*/
//:://////////////////////////////////////////////
//:: Created By: Undivine
//:: Created On: November 2002
//:://////////////////////////////////////////////
void DestroyAllItems();
int GetIsAreaOccupied(object oArea);
void main()
{
if ((!GetIsAreaOccupied(OBJECT_SELF)) && (GetIsPC(GetExitingObject())))
{
float Wait = 0.0; // How many seconds to delay after PC has left area
int Rounds = GetLocalInt(OBJECT_SELF, "PrepClean") + 1;
/*
Rounds counts how many times the delayed DestroyAllItems fires.
This accounts for when a PC leaves and comes back and leaves again.
*/
SetLocalInt(OBJECT_SELF, "PrepClean", Rounds);
Rounds = GetLocalInt(OBJECT_SELF, "PrepClean");
DelayCommand(Wait, DestroyAllItems());
}
}
void DestroyAllItems()
{
int Rounds = GetLocalInt(OBJECT_SELF, "PrepClean");
if (!GetIsAreaOccupied(OBJECT_SELF))
{
// If this is in reaction to the most recent instance of a PC leaving the area, clean up.
if (Rounds == 1)
{
object oItem = GetFirstObjectInArea(OBJECT_SELF);
// When an NPC dies, they drop an object, not an item... like a treasure chest.
while (oItem != OBJECT_INVALID)
{
//
//if (GetTag(oItem) == "Body Bag")
// {
object oLookIn = GetFirstItemInInventory(oItem);
// Destroy everything in it except plot items.
while (oLookIn != OBJECT_INVALID)
{
// if (!GetPlotFlag(oLookIn)) uncomment to not destroy plot items
DestroyObject(oLookIn);
oLookIn = GetNextItemInInventory(oItem);
}
// }
// else
if (((GetObjectType(oItem) == OBJECT_TYPE_ITEM)||(GetObjectType(oItem) == OBJECT_TYPE_CREATURE)) && (!GetPlotFlag(oItem))) //modified to clear out creatures smo
DestroyObject(oItem);
oItem = GetNextObjectInArea(OBJECT_SELF);
}
SetLocalInt(OBJECT_SELF, "PrepClean", 0);
SetLocalInt(OBJECT_SELF, "iInUse", 0);//for PW support
}
else
{
// If this is not from the most recent instance of a PC leaving an area, decriment.
Rounds--;
SetLocalInt(OBJECT_SELF, "PrepClean", Rounds);
}
}
else
{
Rounds--;
SetLocalInt(OBJECT_SELF, "PrepClean", Rounds);
}
}
/*
This function returns TRUE if oArea currently
has a PC in it and FALSE if it doesn't.
*Note: Returns FALSE if oArea is not valid.
*/
int GetIsAreaOccupied(object oArea)
{
if (GetIsObjectValid(oArea))
{
object oPlayer = GetFirstPC();
while ((GetArea(oPlayer) != oArea) && (oPlayer != OBJECT_INVALID))
oPlayer = GetNextPC();
if (oPlayer != OBJECT_INVALID)
return TRUE;
else
return FALSE;
}
else
return FALSE;
}

View File

@@ -0,0 +1,39 @@
/*Starting conditional to test to make sure party members are close by in MP
games. Thanks to Warleader_6 for bringing this to my attention, and to Jack
Gorman for some of the scripts that were part of his Legs-of-the-trip script*/
//Also adds in custom tag functionality
#include "otres_inc"
int StartingConditional()
{
object oTrigger=OBJECT_SELF;
OTRESTokens(oTrigger);
object oTalker=GetPCSpeaker();
SetLocalObject(oTalker,"oTrigger",oTrigger);
if(GetLocalInt(oTalker,"bFinalNext"))
return FALSE;
object oFM=GetFirstFactionMember(oTalker);
oFM=GetNextFactionMember(oTalker);
if (oFM==OBJECT_INVALID) //single player
return TRUE;
// Loop to check each party members distance from the PC.
while (GetIsObjectValid(oFM))
{//begin while loop
// Skip dead party members
if (!GetIsDead(oFM))
{//begin not dead if
int iDistanceCheck = FloatToInt(GetDistanceToObject(oFM));
// Check to see if oPartyMember is within 10 meters. If not, send
// the message and exit the conditional as FALSE.
if (iDistanceCheck > 10)
{//begin distance check if
// If all party members are not present do not show travel dialog
return FALSE;
}//end distance check if
}//end not dead if
oFM = GetNextFactionMember(oTalker);
}//end while loop
//if all within 10 m show the travel dialog
return TRUE;
}

View File

@@ -0,0 +1,39 @@
/*Starting conditional to test to make sure party members are close by in MP
games. Thanks to Warleader_6 for bringing this to my attention, and to Jack
Gorman for some of the scripts that were part of his Legs-of-the-trip script*/
//This is the inverse of otres_cond for the "cannot travel" dialog
//Custom tag functionality not needed since tags are not used in the dialog this shows
int StartingConditional()
{
object oTalker=GetPCSpeaker();
int bEncounterDone=GetLocalInt(oTalker,"bEncounterDone");
if (!(bEncounterDone)) //Allows for a flag to keep the PC in the random encounter - set it to false in the OnEnter event for the area or encounter
return FALSE;
object oFM=GetFirstFactionMember(oTalker);
oFM=GetNextFactionMember(oTalker);
if (oFM==OBJECT_INVALID) //single player
return FALSE;
// Loop to check each party members distance from the PC.
while (GetIsObjectValid(oFM))
{//begin while loop
// Skip dead party members
if (!GetIsDead(oFM))
{//begin not dead if
int iDistanceCheck = FloatToInt(GetDistanceToObject(oFM));
// Check to see if oPartyMember is within 10 meters. If not, send
// the message and exit the conditional as TRU.
if (iDistanceCheck > 10)
{//begin distance check if
// If all party members are not present do not show travel dialog
return TRUE;
}//end distance check if
}//end not dead if
oFM = GetNextFactionMember(oTalker);
}//end while loop
//if all within 10 m show the travel dialog
return FALSE;
}

View File

@@ -0,0 +1,37 @@
/*Starting conditional to test to make sure party members are close by in MP
games. Thanks to Warleader_6 for bringing this to my attention, and to Jack
Gorman for some of the scripts that were part of his Legs-of-the-trip script*/
//Also adds in custom tag functionality
//This one is for when the next destination is the final or hub destination
#include "otres_inc"
int StartingConditional()
{
object oTalker=GetPCSpeaker();
if(!(GetLocalInt(oTalker,"bFinalNext")))
return FALSE;
object oFM=GetFirstFactionMember(oTalker);
oFM=GetNextFactionMember(oTalker);
if (oFM==OBJECT_INVALID) //single player
return TRUE;
// Loop to check each party members distance from the PC.
while (GetIsObjectValid(oFM))
{//begin while loop
// Skip dead party members
if (!GetIsDead(oFM))
{//begin not dead if
int iDistanceCheck = FloatToInt(GetDistanceToObject(oFM));
// Check to see if oPartyMember is within 10 meters. If not, send
// the message and exit the conditional as FALSE.
if (iDistanceCheck > 10)
{//begin distance check if
// If all party members are not present do not show travel dialog
return FALSE;
}//end distance check if
}//end not dead if
oFM = GetNextFactionMember(oTalker);
}//end while loop
//if all within 10 m show the travel dialog
return TRUE;
}

View File

@@ -0,0 +1,7 @@
//Start the OTRES conversation
void main()
{
object oPC=GetEnteringObject();
if (!GetIsPC(oPC)) return;
BeginConversation("otres",oPC);//This is the conversation to set the travel variables
}

View File

@@ -0,0 +1,291 @@
/* This script is put in the OnEnter of a random forest encounter map.
The map will have all the encounters below already in place where
the PCs will arrive, but they will be inactive. This script will
randomly choose which encounter to activate. For undead, the script
checks to see if it is day with a GetIsDay() function, and if it is,
will re-run the function to try to get a non-undead encounter.
Theoretically, this could be an infinite loop, but with the number
of encounters here, it won't happen.
*/
//------------RandomEncounter Function------------------------------------------
//Follows is the list of possible encounters or encounter types
//See the end on how to add an enounter
void RandomEncounter()
{//begin RandomEncounter function
object oEncounter;
object oPC=GetPCSpeaker();
object oWay=OBJECT_SELF;//added to fix "No enemies" issue
int iDieRoll2;
int iDieRoll;
//Randomizer
int iSeed=FloatToInt(100*log(IntToFloat(GetTimeMillisecond()+GetCalendarDay()+GetTimeHour())));
int i;
for (i=0;i!=iSeed;i++)
{
iDieRoll=Random(67);
} //This number should match iDieRoll below
//Roll random encounter or encounter type
iDieRoll=Random(67)+1; //change this to match the max if you add encounters
if (iDieRoll==1)
{oEncounter=GetNearestObjectByTag("Badger",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>1)&&iDieRoll<7)
{oEncounter=GetNearestObjectByTag("Bandit",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>6)&&iDieRoll<10) //Encounter type beetle
{iDieRoll2=d4();
switch (iDieRoll2)
{
case 1:
oEncounter=GetNearestObjectByTag("BombBeetle",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
case 2:
oEncounter=GetNearestObjectByTag("FireBeetle",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
case 3:
oEncounter=GetNearestObjectByTag("StagBeetle",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
case 4:
oEncounter=GetNearestObjectByTag("StinkBeetle",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
default:
oEncounter=GetNearestObjectByTag("BombBeetle",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
}
return;
}
else if (iDieRoll==10)
{oEncounter=GetNearestObjectByTag("Boar",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>10)&&(iDieRoll<13))
{oEncounter=GetNearestObjectByTag("BrownBear",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==13)
{oEncounter=GetNearestObjectByTag("Bugbear",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>13)&&(iDieRoll<19))
{oEncounter=GetNearestObjectByTag("Character",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==19)
{oEncounter=GetNearestObjectByTag("Cougar",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>19)&&(iDieRoll<22))
{oEncounter=GetNearestObjectByTag("DireTiger",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>21)&&(iDieRoll<25))
{oEncounter=GetNearestObjectByTag("DireWolf",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==25)
{oEncounter=GetNearestObjectByTag("Dog",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==26) //Encounter type giant
{iDieRoll2=Random(90)+1;
if ((iDieRoll2>0)&&(iDieRoll2<8))
{oEncounter=GetNearestObjectByTag("Ettin",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>7)&&(iDieRoll2<86))
{oEncounter=GetNearestObjectByTag("HillGiant",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>85)&&(iDieRoll2<91))
{oEncounter=GetNearestObjectByTag("StoneGiant",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if (iDieRoll==27) //Encounter type dragon
{iDieRoll2=Random(59)+1;
if ((iDieRoll2>0)&&(iDieRoll2<17))
{oEncounter=GetNearestObjectByTag("BlackDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll2==17)
{oEncounter=GetNearestObjectByTag("BlueDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>17)&&(iDieRoll2<58))
{oEncounter=GetNearestObjectByTag("GreenDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll2==58)
{oEncounter=GetNearestObjectByTag("RedDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll2==59)
{oEncounter=GetNearestObjectByTag("WhiteDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if (iDieRoll==28)
{oEncounter=GetNearestObjectByTag("GreyRender",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>28)&&(iDieRoll<33)) //Encounter type humanoid
{iDieRoll2=Random(80)+1;
if ((iDieRoll2>0)&&(iDieRoll2<11))
{oEncounter=GetNearestObjectByTag("Goblin",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>10)&&(iDieRoll2<61))
{oEncounter=GetNearestObjectByTag("Kobold",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>60)&&(iDieRoll2<81))
{oEncounter=GetNearestObjectByTag("Orc",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if (iDieRoll==33)
{oEncounter=GetNearestObjectByTag("Krenshar",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==34)
{oEncounter=GetNearestObjectByTag("Lion",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>34)&&(iDieRoll<37)) //Encounter type lycanthrope
{iDieRoll2=d20();
if ((iDieRoll2>0)&&(iDieRoll2<6))
{oEncounter=GetNearestObjectByTag("Aranea",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>5)&&(iDieRoll2<11))
{oEncounter=GetNearestObjectByTag("Wererat",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>10)&&(iDieRoll2<21))
{oEncounter=GetNearestObjectByTag("Werewolf",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if (iDieRoll==37)
{oEncounter=GetNearestObjectByTag("Malar",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>37)&&(iDieRoll<42))
{oEncounter=GetNearestObjectByTag("Ogre",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>41)&&(iDieRoll<45))
{oEncounter=GetNearestObjectByTag("Spider",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==45)
{oEncounter=GetNearestObjectByTag("Stirge",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==46)
{oEncounter=GetNearestObjectByTag("Troll",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>46)&&(iDieRoll<49)) //Encounter type undead
{//Check to see if it is night and retry script if it is
if (GetIsDay())
{RandomEncounter();
return;}
iDieRoll2=Random(125+1);
if ((iDieRoll2>0)&&(iDieRoll2<6))
{oEncounter=GetNearestObjectByTag("Allip",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>5)&&(iDieRoll2<10))
{oEncounter=GetNearestObjectByTag("Bodak",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>9)&&(iDieRoll2<20))
{oEncounter=GetNearestObjectByTag("Curst",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>19)&&(iDieRoll2<30))
{oEncounter=GetNearestObjectByTag("Ghast",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>29)&&(iDieRoll2<73))
{oEncounter=GetNearestObjectByTag("Ghoul",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll2==73)
{oEncounter=GetNearestObjectByTag("Lich",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>73)&&(iDieRoll2<81))
{oEncounter=GetNearestObjectByTag("Mohrg",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>80)&&(iDieRoll2<95))
{oEncounter=GetNearestObjectByTag("Shadow",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>94)&&(iDieRoll2<105))
{oEncounter=GetNearestObjectByTag("Spectre",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>104)&&(iDieRoll2<115))
{oEncounter=GetNearestObjectByTag("Vampire",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>114)&&(iDieRoll2<122))
{oEncounter=GetNearestObjectByTag("Wight",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>121)&&(iDieRoll2<126))
{oEncounter=GetNearestObjectByTag("Wraith",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if (iDieRoll==49)
{oEncounter=GetNearestObjectByTag("WilloWisp",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>49)&&(iDieRoll<57))
{oEncounter=GetNearestObjectByTag("Wolf",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>56)&&(iDieRoll<60))
{oEncounter=GetNearestObjectByTag("Worg",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==60) //Skeleton Re-animator
{oEncounter=GetNearestObjectByTag("Skeleton",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==61) //Zombie Re-animator
{oEncounter=GetNearestObjectByTag("Zombie",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>61)&&(iDieRoll<67)) //Ettercap
{oEncounter=GetNearestObjectByTag("Ettercap",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==67) //Rat
{oEncounter=GetNearestObjectByTag("Rat",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
//add new encounters here by copying the "else if" above that matches what you
//want to do (i.e. ==, range, or sub-table) then change the iRoll statement
//and Randomizer back at the beginning
else FloatingTextStringOnCreature(IntToString(iDieRoll),oPC);//catch all debug - if it fires, you are missing that number in the else ifs above
}//end RandomEncounter function
void main()
{
RandomEncounter(); //choose and activate the random encounter
}

385
_module/nss/otres_inc.nss Normal file
View File

@@ -0,0 +1,385 @@
//OTRES include file
//2.6 added variable for PW support
//OTRES trigger tag format:
//StartingDestination_FinalDestination_HoursToGoToFinal_NextWaypoint_HoursToGoToNextWaypoint_Terrain_Facing
//i.e. 7_3_24_1_8_Forest_s or 7_3_24_1_8_Forest_45
//(direction can be n, s, e, w, ne, nw, se, sw, or a number 0 through 360
//with east 0, north 90, etc.)
//Which might translate to, "I am starting off at Point A and I want to go
//to the Forest Tomb. It is 24 hours of travel to get there. To get there,
//I will first be going to Waypoint 1, which is 8 hours of travel through a
//forest, and I will be going generally south."
//OTRESOnModuleLoad stores the jump descriptions and tags
//on the module as an "array"
void OTRESOnModuleLoad()
{//OTRESOnModuleLoad start
object oMod=GetModule();
/*
Enter the destination description for DD1, DD2, etc.
Enter the tag of the waypoint for the area for t1, t2, etc.
Example
SetLocalString(oMod,"DD1","The first forest Wayhouse");
SetLocalString(oMod,"t1","ForestWaypoint1");
*/
SetLocalString(oMod,"DD1","The first forest Wayhouse"); //Description for players for location 1 used in OTRES dialog
SetLocalString(oMod,"t1","ForestWaypoint1"); //Tag of OTRES arrival point for location 1
SetLocalString(oMod,"DD2","The second forest Wayhouse");
SetLocalString(oMod,"t2","ForestWaypoint2");
SetLocalString(oMod,"DD3","The Forest Tomb");
SetLocalString(oMod,"t3","ForestTomb");
SetLocalString(oMod,"DD4","The first plains Wayhouse");
SetLocalString(oMod,"t4","PlainsWaypoint1");
SetLocalString(oMod,"DD5","The second plains Wayhouse");
SetLocalString(oMod,"t5","PlainsWaypoint2");
SetLocalString(oMod,"DD6","The House on the Plains");
SetLocalString(oMod,"t6","PlainsHouse");
SetLocalString(oMod,"DD7","Point A");
SetLocalString(oMod,"t7","PointASouth");
SetLocalString(oMod,"DD8","Point A");
SetLocalString(oMod,"t8","PointAWest");
SetLocalString(oMod,"DD9","The first plains Wayhouse");
SetLocalString(oMod,"t9","PlainsWay1West");
SetLocalString(oMod,"DD10","The second plains Wayhouse");
SetLocalString(oMod,"t10","PlainsWay2West");
//add new area descriptions and tags here, increasing the number each time as above
SetLocalInt(oMod,"iOTRESMax",10); //Highest number of OTRES locations, should match the highest DD and t above - used for error trapping
SetLocalInt(oMod,"bPW",FALSE); //Set this to true for persistant worlds
}//OTRESOnModuleLoad finish
// * Prototype Array Functions (from Noel in nw_o0_itemmaker)
void SetLocalArrayString(object oidObject, string sVarName, int nVarNum, string nValue);
string GetLocalArrayString(object oidObject, string sVarName, int nVarNum);
void SetLocalArrayInt(object oidObject, string sVarName, int nVarNum, int nValue);
int GetLocalArrayInt(object oidObject, string sVarName, int nVarNum);
//The following is a function for returning the travel time coefficient
float TravelTimeCoeff()
{
float fTravelTimeCoeff=1.; //Changing this number would change travel times for all of OTRES which doesn't make sense
/*Instead, say you want to simulate riding a horse. You might add a statement
like this one to decrease the travel time by about 30% (rounding rules are used):
*/
int iBoughtAHorse=GetLocalInt(GetPCSpeaker(),"iBoughtAHorse");
if (iBoughtAHorse==TRUE)
fTravelTimeCoeff=0.7;
//*/
return fTravelTimeCoeff;
}
//The following function returns the encounter probability coefficient
float EncounterCoeff()
{
float fEncounterCoeff=1.;//Changing this number would change the probability for all of OTRES which doesn't make sense
/*Instead, say you want to simulate hiring a local guide who knows how to
avoid the local dangers. You might add a statement like this one to
decrease the encounter probability by about 20%:
*/
int iHiredAGuide=GetLocalInt(GetPCSpeaker(),"iHiredAGuide");
if (iHiredAGuide==TRUE)
fEncounterCoeff=0.8;
//*/
return fEncounterCoeff;
}
/*The following function reads off the OTRES variables and stores them
as local variables on the OTRES trigger. Used only the first time a trigger
is used.*/
void StoreOTRESVar(object oTrigger)
{//begin StoreOTRESVar
object oMod=GetModule(); //the module (used in accessing the array)
int iOTRESMax=GetLocalInt(oMod,"iOTRESMax"); //max number of OTRES areas
int iCount; //where am I in the tag's string
string sChar; //one letter from the tag
string sStartDestinationNum; //Where I am starting from
string sFinalDestinationNum; //What is my final (or hub) destination
string sFinalHoursToGo; //How many hours to the next area of interest
string sNextDestinationNum; //What is my next waypoint destination
string sHoursToGo; //How many hours to the next waypoint? Must be <=12
string sTerrain; //What terrain am I traveling in
string sFacing; //What direction should I face when I arrive
string sTriggerTag=GetTag(oTrigger);
int iStringLength=GetStringLength(sTriggerTag);
int iDim; //Array dimension
//Starting Destination number loop
for (iCount=0;iCount<=iStringLength;iCount++)
{
sChar=GetSubString(sTriggerTag,iCount,1);
if (sChar=="_")
break;
sStartDestinationNum+=sChar;
}
//Change sStartDestinationNum into the tag and description.
iDim=StringToInt(sStartDestinationNum);
if (iDim>iOTRESMax) //error trap
{//begin error trap
SendMessageToAllDMs("Error in OTRES - OTRES start destination tag has a number higher than the max - check OTRESOnModuleLoad");
object oPC=GetPCSpeaker(); //debug - possible source of multi-party problems?
object oMember=GetFirstFactionMember(oPC);
while (oMember!=OBJECT_INVALID)
{
SendMessageToPC(oMember,"OTRES Error - your DM has been notified");
oMember=GetNextFactionMember(oPC);
}
}//end error trap
string sStartDestinationTag=GetLocalArrayString(oMod,"t",iDim);
string sStartDestinationDesc=GetLocalArrayString(oMod,"DD",iDim);
//Final Destination number loop
for (iCount=iCount+1;iCount<=iStringLength;iCount++)
{
sChar=GetSubString(sTriggerTag,iCount,1);
if (sChar=="_")
break;
sFinalDestinationNum+=sChar;
}
//Change sFinalDestinationNum into the tag and description.
iDim=StringToInt(sFinalDestinationNum);
if (iDim>iOTRESMax) //error trap
{//begin error trap
SendMessageToAllDMs("Error in OTRES - OTRES final destinaiton tag has a number higher than the max - check OTRESOnModuleLoad");
object oPC=GetPCSpeaker(); //debug - possible source of multi-party problems?
object oMember=GetFirstFactionMember(oPC);
while (oMember!=OBJECT_INVALID)
{
SendMessageToPC(oMember,"OTRES Error - your DM has been notified");
oMember=GetNextFactionMember(oPC);
}
}//end error trap
string sFinalDestinationTag=GetLocalArrayString(oMod,"t",iDim);
string sFinalDestinationDesc=GetLocalArrayString(oMod,"DD",iDim);
//Hours to go to final loop.
for (iCount=iCount+1;iCount<=iStringLength;iCount++)
{
sChar=GetSubString(sTriggerTag,iCount,1);
if (sChar=="_")
break;
sFinalHoursToGo+=sChar;
}
//Next Waypoint number loop
for (iCount=iCount+1;iCount<=iStringLength;iCount++)
{
sChar=GetSubString(sTriggerTag,iCount,1);
if (sChar=="_")
break;
sNextDestinationNum+=sChar;
}
//Change sDestinationNum into the tag and description.
iDim=StringToInt(sNextDestinationNum);
if (iDim>iOTRESMax) //error trap
{//begin error trap
SendMessageToAllDMs("Error in OTRES - OTRES next destination tag has a number higher than the max - check OTRESOnModuleLoad");
object oPC=GetPCSpeaker(); //debug - possible source of multi-party problems?
object oMember=GetFirstFactionMember(oPC);
while (oMember!=OBJECT_INVALID)
{
SendMessageToPC(oMember,"OTRES Error - your DM has been notified");
oMember=GetNextFactionMember(oPC);
}
}//end error trap
string sNextDestinationTag=GetLocalArrayString(oMod,"t",iDim);
string sNextDestinationDesc=GetLocalArrayString(oMod,"DD",iDim);
//Hours to go to next waypoint loop
for (iCount=iCount+1;iCount<=iStringLength;iCount++)
{
sChar=GetSubString(sTriggerTag,iCount,1);
if (sChar=="_")
break;
sHoursToGo+=sChar;
}
int iHoursToGo=StringToInt(sHoursToGo);
//Terrain loop
for (iCount=iCount+1;iCount<=iStringLength;iCount++)
{
sChar=GetSubString(sTriggerTag,iCount,1);
if (sChar=="_")
break;
sTerrain+=sChar;
}
//Facing loop
for (iCount=iCount+1;iCount<=iStringLength;iCount++)
{
sChar=GetSubString(sTriggerTag,iCount,1);
if (sChar=="")
break;
sFacing+=sChar;
}
//Change sFacing into float
float fFacing;
if (sFacing=="s")
fFacing=DIRECTION_SOUTH;
else if (sFacing=="n")
fFacing=DIRECTION_NORTH;
else if (sFacing=="e")
fFacing=DIRECTION_EAST;
else if (sFacing=="w")
fFacing=DIRECTION_WEST;
else if (sFacing=="se")
fFacing=DIRECTION_SOUTH+45.;
else if (sFacing=="sw")
fFacing=DIRECTION_SOUTH-45.;
else if (sFacing=="ne")
fFacing=DIRECTION_NORTH-45.;
else if (sFacing=="nw")
fFacing=DIRECTION_NORTH+45.;
else if (StringToFloat(sFacing)>=0.)
fFacing=StringToFloat(sFacing);
else fFacing=0.;
//Finally, store local vars on trigger
SetLocalFloat(oTrigger,"fFacing", fFacing);
SetLocalInt(oTrigger,"iHoursToGo", iHoursToGo);
SetLocalString(oTrigger,"sTerrain", sTerrain);
SetLocalString(oTrigger,"sFinalHoursToGo", sFinalHoursToGo); //leave as string
SetLocalString(oTrigger,"sStartDestinationTag", sStartDestinationTag);
SetLocalString(oTrigger,"sStartDestinationDesc",sStartDestinationDesc);
SetLocalString(oTrigger,"sFinalDestinationTag", sFinalDestinationTag);
SetLocalString(oTrigger,"sFinalDestinationDesc",sFinalDestinationDesc);
SetLocalString(oTrigger,"sNextDestinationTag", sNextDestinationTag);
SetLocalString(oTrigger,"sNextDestinationDesc", sNextDestinationDesc);
SetLocalInt(oTrigger,"iDoOnce", 1); //flag to do only once
}//end StoreOTRESVar*/
void SetOTRESVar(object oTrigger,int bRandReturn)
{//begin SetOTRESVar function
//When called, it sets the travel variables on the party in preparation
//for travel. Pass PC as oTrigger when leaving from random encounter.
float fFacing=GetLocalFloat(oTrigger,"fFacing");
int iHoursToGo=GetLocalInt(oTrigger,"iHoursToGo");
string sTerrain=GetLocalString(oTrigger,"sTerrain");
string sFinalHoursToGo=GetLocalString(oTrigger,"sFinalHoursToGo"); //leave as string
string sStartDestinationTag=GetLocalString(oTrigger,"sStartDestinationTag");
string sStartDestinationDesc=GetLocalString(oTrigger,"sStartDestinationDesc");
string sFinalDestinationTag=GetLocalString(oTrigger,"sFinalDestinationTag");
string sFinalDestinationDesc=GetLocalString(oTrigger,"sFinalDestinationDesc");
string sNextDestinationTag=GetLocalString(oTrigger,"sNextDestinationTag");
string sNextDestinationDesc=GetLocalString(oTrigger,"sNextDestinationDesc");
//If returning from a random encounter, change the next destination to
//start destination and the traveltime to iTravelledHours and the facing
if (bRandReturn==TRUE)
{//Begin RandReturn
string sTemp;
sNextDestinationTag=sStartDestinationTag;
sNextDestinationDesc=sStartDestinationDesc;
//Travel Time
iHoursToGo=GetLocalInt(GetPCSpeaker(),"iTravelledHours");
if (TravelTimeCoeff()!=1.0) //add back for travel time coefficient
{//begin travel time correction
float fHoursToGo=IntToFloat(iHoursToGo)/TravelTimeCoeff(); //Hours left in this segment modified by a travel time coefficient in otres_inc
float fRoundTest=fHoursToGo-IntToFloat(FloatToInt(fHoursToGo));
if (fRoundTest>=0.5) //Correct for FloatToInt not rounding but truncating
iHoursToGo=1+FloatToInt(fHoursToGo);
else iHoursToGo=FloatToInt(fHoursToGo);
}//end travel time correction*/
//Set the facing
fFacing+=180;
}//End RandReturn
////////////////////////////////////////////////////////////////////////////////
//Set the variables on the party
//Modified to fix multi-party bugs
////////////////////////////////////////////////////////////////////////////////
object oPC=GetPCSpeaker();
object oMember=GetFirstFactionMember(oPC);
SetLocalInt(oPC,"bTravel",TRUE);
while (oMember!=OBJECT_INVALID) //Loop through the party
{
// Set the variables for the party
SetLocalFloat(oMember,"fFacing", fFacing);
SetLocalInt(oMember,"iHoursToGo", iHoursToGo);
SetLocalString(oMember,"sTerrain", sTerrain);
SetLocalString(oMember,"sFinalHoursToGo", sFinalHoursToGo); //leave as string
SetLocalString(oMember,"sStartDestinationTag", sStartDestinationTag);
SetLocalString(oMember,"sStartDestinationDesc",sStartDestinationDesc);
SetLocalString(oMember,"sFinalDestinationTag", sFinalDestinationTag);
SetLocalString(oMember,"sFinalDestinationDesc",sFinalDestinationDesc);
SetLocalString(oMember,"sNextDestinationTag", sNextDestinationTag);
SetLocalString(oMember,"sNextDestinationDesc", sNextDestinationDesc);
oMember=GetNextFactionMember(oPC);
}
}//end SetOTRESVar function
//This function reads and sets custom tokens for use in the travel conversation
//It also stores the OTRES variables on the trigger if this hasn't been done yet
void OTRESTokens(object oTrigger)
{//Start OTRESTokens
//Calls StoreOTRESVar
if(!GetIsPC(oTrigger))
if(GetLocalInt(oTrigger,"iDoOnce")!=1)
StoreOTRESVar(oTrigger);
//Read all variables needed for tokens from trigger
float fFacing=GetLocalFloat(oTrigger,"fFacing");
int iHoursToGo=GetLocalInt(oTrigger,"iHoursToGo");
string sTerrain=GetLocalString(oTrigger,"sTerrain");
string sFinalHoursToGo=GetLocalString(oTrigger,"sFinalHoursToGo"); //leave as string
string sStartDestinationTag=GetLocalString(oTrigger,"sStartDestinationTag");
string sStartDestinationDesc=GetLocalString(oTrigger,"sStartDestinationDesc");
string sFinalDestinationTag=GetLocalString(oTrigger,"sFinalDestinationTag");
string sFinalDestinationDesc=GetLocalString(oTrigger,"sFinalDestinationDesc");
string sNextDestinationTag=GetLocalString(oTrigger,"sNextDestinationTag");
string sNextDestinationDesc=GetLocalString(oTrigger,"sNextDestinationDesc");
//Starting Destination set token
SetCustomToken(124,sStartDestinationDesc);
//Final Destination set token
SetCustomToken(125,sFinalDestinationDesc);
//Set token for Hours To Go To Final
SetCustomToken(126,sFinalHoursToGo);
//Next Waypoint set token
SetCustomToken(127,sNextDestinationDesc);
//Set token for Hours To Go To Next Waypoint
string sHoursToGo=IntToString(iHoursToGo);
SetCustomToken(128,sHoursToGo);
//Set a flag for the conditional in case the next waypoint and the final are the same
if (sFinalDestinationTag==sNextDestinationTag)
SetLocalInt(GetPCSpeaker(),"bFinalNext",TRUE);
else SetLocalInt(GetPCSpeaker(),"bFinalNext",FALSE);
}//End OTRESTokens
//OTRES Arrays (from Noel in nw_o0_itemmaker)
string GetLocalArrayString(object oidObject, string sVarName, int nVarNum)
{
string sFullVarName = sVarName + IntToString(nVarNum) ;
return GetLocalString(oidObject, sFullVarName);
}
void SetLocalArrayString(object oidObject, string sVarName, int nVarNum, string nValue)
{
string sFullVarName = sVarName + IntToString(nVarNum) ;
SetLocalString(oidObject, sFullVarName, nValue);
}
int GetLocalArrayInt(object oidObject, string sVarName, int nVarNum)
{
string sFullVarName = sVarName + IntToString(nVarNum) ;
return GetLocalInt(oidObject, sFullVarName);
}
void SetLocalArrayInt(object oidObject, string sVarName, int nVarNum, int nValue)
{
string sFullVarName = sVarName + IntToString(nVarNum) ;
SetLocalInt(oidObject, sFullVarName, nValue);
}
//void main(){}

View File

@@ -0,0 +1,6 @@
#include "otres_inc"
void main()
{
//Sets place names and tags in an array on the module
OTRESOnModuleLoad();
}

View File

@@ -0,0 +1,255 @@
/*This function simulates overland travel with random encounters
and making camp. Encounters are scaled.
Encounters based on AD&D DMG tables.
On entering the trigger, they will be told how far the nearest destination and
waypoint are in hours. This script will check at the appropriate times to see
if a random encounter happens.
If an encounter occurs, it will drop the players in a random area near an object
tagged sTerrain+"Random"+int (for example, ForestRandom1) and adjust the time
for the amount "travelled". Make sure that your area tag is not the same as
the JumToObject tag (this took me a looong time to figure out!)The random area
has a large number of inactive encounters, one of which will be activated by
the OnEnter script for the area. Every 12 hours of travelling will put them
at a rest stop to camp.
If you make any changes in this script, recompile the otres_travelcall script too
smo 2002/11/29 to 2002/12/28
03/20/2003 - Added local variable to prevent two parties from arriving in
same map. Note that if there are more parties going to random maps than
there are random maps, a debug message is displayed to the activating PC
and sent to the DM. <edit 6/02/2004>
04/28/2003 - Added coefficients to travel and encounter frequency
07/07/2003 - Changed GetFirstPC() to GetPCSpeaker and then loop through
PCSpeaker's faction to jump everybody. This should be
better for PWs
9/01/2003 - Added PW local integer
10/05/2003 - Fixed intermittent "no enemies" problem by activating encounter
in otres_overland rather than in the OnEnter trigger of the
area. Code added between the end of the PW support and the
beginning of the Send PCs to random map code.
*/
#include "nw_i0_plot"
#include "otres_inc"
//------------------------------------------------------------------------------
//This subroutine sends them to a random map if there is an encounter
//------------------------------------------------------------------------------
void EncounterResult(object oPC, int iHoursToGo, int iTravelledHours, string sDestination, string sTerrain, float fFacing)
{//begin EncounterResult function
int iTime; //Time (hours)
int iMapNumber; //The random map number
int iNumberRandomForestMaps=4; //Total number of random forest maps for encounters
int iNumberRandomPlainsMaps=4; //Total number of random plains maps for encounters
string sRandomArea; //Tag of invisible object in random area where PCs will be dropped ex: Forest Random 1
object oRandomAreaJumpPoint; //Invisible object in random area where PCs will be dropped ex: Forest Random 1
object oMember; //Party members
location locRandomAreaJumpPoint;
object oMod=GetModule();
int bPW=FALSE;
if (GetLocalInt(oMod,"bPW"))
bPW=TRUE;
//Store local overland travel variables back on party
oMember=GetFirstFactionMember(oPC);
//Changed following loop to use oMember instead of oPC to fix multi-party bug
while (oMember!=OBJECT_INVALID) //Loop through for string and float vars
{
SetLocalInt(oMember,"iHoursToGo",iHoursToGo-iTravelledHours);
SetLocalInt(oMember,"iTravelledHours",iTravelledHours);
SetLocalString(oMember,"sDestination",sDestination);
SetLocalString(oMember,"sTerrain",sTerrain);
SetLocalFloat(oMember,"fFacing",fFacing);
SetLocalInt(oMember,"bEncounterDone",TRUE);//FALSE to prevent escape by running away for ALL encounters - if you do this you will have to set it to TRUE after your encounter is done
oMember=GetNextFactionMember(oPC);
} //end while loop
//debug not needed? oPC=GetPCSpeaker(); //Reset oPC
//Set time - should wrap around correctly
iTime=GetTimeHour()+iTravelledHours;
if(!bPW)
SetTime(iTime,0,0,0);
//Send to random map
if (sTerrain=="Forest")
iMapNumber=Random(iNumberRandomForestMaps)+1;
else if (sTerrain=="Plains")
iMapNumber=Random(iNumberRandomPlainsMaps)+1;
//Add additional terrain types here by copying and pasting the else if above
sRandomArea=sTerrain+"Random"+IntToString(iMapNumber);
oRandomAreaJumpPoint=GetObjectByTag(sRandomArea);
if (GetArea(oPC)==GetArea(oRandomAreaJumpPoint))//this will choose a different map than the one they are already on
{
EncounterResult(oPC,iHoursToGo,iTravelledHours,sDestination,sTerrain,fFacing);
return;
}
//This block is for persistant world support - it prevents two parties from occupying the same random map
if (bPW)
{
int i;
int iMapNum;
if (sTerrain=="Forest")
iMapNum=iNumberRandomForestMaps;
else if (sTerrain=="Plains")
iMapNum=iNumberRandomPlainsMaps;
//Add additional terrain types here by copying the else if above and changing the string
//Loop through to check if there are *any* open maps in the PW
for (i=1;i<=iMapNum;i++)
{
if (GetLocalInt(GetArea(oRandomAreaJumpPoint), "iInUse")==0)
break;//OK, the one chosen is open - go there
else //if it is not, we will take the first open one we find
{
sRandomArea=sTerrain+"Random"+IntToString(iMapNum);
oRandomAreaJumpPoint=GetObjectByTag(sRandomArea);
}
if (i==iMapNum) //We got through all the random maps and didn't find any open, but have the last one to check
{
if (GetLocalInt(GetArea(oRandomAreaJumpPoint), "iInUse")==0)
break;//OK, the last map is open - go there
FloatingTextStringOnCreature("There are no overland encounter maps available in this world,",oPC,TRUE);
FloatingTextStringOnCreature("please wait for a bit and try again.",oPC,TRUE);
FloatingTextStringOnCreature("Please notify your world builder to add more.",oPC,TRUE);
SendMessageToAllDMs("Need more OTRES random encounter maps - we just ran out!!");
return; //exit function
}
}//end for loop
}// end of block for PW support*/
//Choose encounter and activate trigger before PCs arrive
if (sTerrain=="Forest")
ExecuteScript("otres_forestrand",oRandomAreaJumpPoint);
else if (sTerrain=="Plains")
ExecuteScript("otres_plainsrand",oRandomAreaJumpPoint);
//Add new terrains here
//Set Local Int for PW support
if (bPW)
SetLocalInt(GetArea(oRandomAreaJumpPoint), "iInUse", 1);
//Send PCs to random map with message
//debug not needed? oPC=GetPCSpeaker();
oMember=GetFirstFactionMember(oPC,FALSE);
while (oMember!=OBJECT_INVALID)
{
AssignCommand(oMember,JumpToObject(oRandomAreaJumpPoint));
DelayCommand(0.5,AssignCommand(oMember,SetFacing(fFacing)));//can use switches to face the right way for a particular map, but this will lose flexibility to have any number of random maps
DelayCommand(1.,FloatingTextStringOnCreature("You were waylaid "
+IntToString(iTravelledHours)+" hours into your journey!",oMember));
oMember=GetNextFactionMember(oPC,FALSE);
}//end while to jump to random map
return;
}//end EncounterResult function
//------------------------------------------------------------------------------
//This is the start of the OverlandTravel function itself
//------------------------------------------------------------------------------
void OverlandTravel(int iHoursToGo,string sDestination,string sTerrain,float fFacing)
{//Begin Overland Travel Function
//iHoursToGo is how much time to travel to either the Wayhouse or Final Destination max of 12 hours
//sDestination is the final target destination set in the intiating dialog
//sTerrain is the type of terrain travelled through
//fFacing is the direction to face the party
object oMod=GetModule();
int bPW=FALSE;
if (GetLocalInt(oMod,"bPW"))
bPW=TRUE;
float fDieRoll; //Where virtual dice rolls go
string sRandomMapTag; //Tag of the map that group will be sent to
object oPC=GetPCSpeaker(); //The PC starting the OTRES convo//debug maybe source of multi-party weirdness? How does GetPCSpeaker work with multiple PCs speaking?
object oMember; //Members of PC's party
object oDestinationJumpPoint; //Waypoint in destination area where PCs will be dropped ex: Wayhouse 1
int iTravelledHours; //Number of hours they have been travelling
float fHoursToGo=IntToFloat(iHoursToGo)*TravelTimeCoeff(); //Hours left in this segment modified by a travel time coefficient in otres_inc
float fRoundTest=fHoursToGo-IntToFloat(FloatToInt(fHoursToGo));
if (fRoundTest>=0.5) //Correct for FloatToInt not rounding but truncating
iHoursToGo=1+FloatToInt(fHoursToGo);
else iHoursToGo=FloatToInt(fHoursToGo);
int iTime; //Time (hours)
//Forest check 3 times every 12 hours chance 1 in 10 for each; 20 miles/day
//Plains check 2 times every 12 hours, 1 in 12 for each;20 miles/day
for (iTravelledHours=1;iTravelledHours!=iHoursToGo;iTravelledHours++)
{//begin for loop to check each hour
if (sTerrain=="Forest")
{//begin forest encounter checks
switch (iTravelledHours) //Check for encounters at appropriate hours of travel
{
case 2: //First check 2 hours into journey
fDieRoll=d10()*EncounterCoeff(); //Check for encounter
if (fDieRoll>=9.5) //start if for "yes, encounter", 9.5 = 10% chance, 8=20% chance, etc (float is used for EncounterCoeff modifications)
{
EncounterResult(oPC,iHoursToGo,iTravelledHours,sDestination,sTerrain,fFacing);
return; //drop out of script and let PC's fight!
}//end if for "yes,encounter" on hour 2
break;
case 6: //Second check 6 hours into journey
fDieRoll=d10()*EncounterCoeff(); //Check for encounter
if (fDieRoll>=9.5) //start if for "yes, encounter"
{
EncounterResult(oPC,iHoursToGo,iTravelledHours,sDestination,sTerrain,fFacing);
return; //drop out of script and let PC's fight!
}//end if for "yes,encounter" on hour 6
break;
case 10: //Third check 10 hours into journey
fDieRoll=d10()*EncounterCoeff(); //Check for encounter
if (fDieRoll>=9.5) //start if for "yes, encounter"
{
EncounterResult(oPC,iHoursToGo,iTravelledHours,sDestination,sTerrain,fFacing);
return; //drop out of script and let PC's fight!
}//end if for "yes,encounter" on hour 10
break;
default: //If it is not time for an encounter check, loop through again
break;
}//end forest encounter switch, let's go to the next hour
}//end forest encounter if
if (sTerrain=="Plains")
{//begin plains encounter checks
switch (iTravelledHours) //Check for encounters at appropriate hours of travel
{
case 2: //First check 2 hours into journey
fDieRoll=d12()*EncounterCoeff(); //Check for encounter
if (fDieRoll>=11.5) //start if for "yes, encounter"
{
EncounterResult(oPC,iHoursToGo,iTravelledHours,sDestination,sTerrain,fFacing);
return; //drop out of script and let PC's fight!
}//end if for "yes,encounter" on hour 2
break;
case 10: //Second check 10 hours into journey
fDieRoll=d12()*EncounterCoeff(); //Check for encounter
if (fDieRoll>=11.5) //start if for "yes, encounter"
{
EncounterResult(oPC,iHoursToGo,iTravelledHours,sDestination,sTerrain,fFacing);
return; //drop out of script and let PC's fight!
}//end if for "yes,encounter" on hour 10
break;
default: //If it is not time for an encounter check, loop through again
break;
}//end forest encounter switch, let's go to the next hour
}//end plains encounter checks
//Add new terrains here
}//end for looping through travel hours - we are now at either a Wayhouse or destination
//Arrive code - send them to sDestination
oDestinationJumpPoint=GetObjectByTag(sDestination);
//Set time - should wrap around correctly
iTime=GetTimeHour()+iTravelledHours;
if (!bPW)
SetTime(iTime,0,0,0);
//debug - not needed? oPC=GetPCSpeaker();
oMember=GetFirstFactionMember(oPC,FALSE);
while (oMember!=OBJECT_INVALID) //Send 'em all to sDestination
{
AssignCommand(oMember,JumpToObject(oDestinationJumpPoint,TRUE));
DelayCommand(0.5,AssignCommand(oMember,SetFacing(fFacing)));//Make sure jump location makes sense for fFacing
oMember=GetNextFactionMember(oPC,FALSE);
}//end while to jump to destination map
}//end void OverlandTravel
//void main(){} //used for recompiling to check for errors, comment out when saving for the last time or you will get a "Duplicate Function" error

View File

@@ -0,0 +1,214 @@
/* This script is put in the OnEnter of a random encounter map. The map will
have all the encounters below already in place where the PCs will arrive,
but they will be inactive. This script will randomly choose which encounter
to activate. For undead, the script checks to see if it is day with a
GetIsDay() function, and if it is, will re-run the function to try to get
a non-undead encounter. Theoretically, this could be an infinite loop,
but with the number of encounters here, it won't happen.
--------------------------------------------------------------------------------
Plains - no undead possible, and thus no RandomEncounter function as in
the forestencount script
--------------------------------------------------------------------------------
*/
void main()
{
int iDieRoll;
int iDieRoll2;
object oEncounter;
object oPC=GetPCSpeaker();
object oWay=OBJECT_SELF;//added to fix "no enemies" issue
//Randomizer
int iSeed=FloatToInt(100*log(IntToFloat(GetTimeMillisecond()+GetCalendarDay()+GetTimeHour())));
int i;
for (i=0;i!=iSeed;i++)
{
iDieRoll=d100();
} //This number should match iDieRoll below
//Roll random encounter or encounter type
iDieRoll=d100(); //change this to match the max if you add encounters i.e. =Random(69)+1
//Follows is the list of possible encounters or encounter types
//See the end on how to add an enounter
if (iDieRoll==1)
{oEncounter=GetNearestObjectByTag("BrownBear",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==2)
{oEncounter=GetNearestObjectByTag("Boar",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==3)
{oEncounter=GetNearestObjectByTag("Bugbear",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>3)&&(iDieRoll<8))
{oEncounter=GetNearestObjectByTag("WildOx",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>7)&&(iDieRoll<10))
{oEncounter=GetNearestObjectByTag("Dog",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>9)&&(iDieRoll<11)) //Encounter type dragon
{iDieRoll2=Random(5)+1;
switch (iDieRoll2)
{
case 1:
oEncounter=GetNearestObjectByTag("BlackDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
case 2:
oEncounter=GetNearestObjectByTag("BlueDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
case 3:
oEncounter=GetNearestObjectByTag("GreenDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
case 4:
oEncounter=GetNearestObjectByTag("RedDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
case 5:
oEncounter=GetNearestObjectByTag("WhiteDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
default:
oEncounter=GetNearestObjectByTag("GreenDragon",oWay);
SetEncounterActive(TRUE,oEncounter);
break;
}
return;
}
else if ((iDieRoll>10)&&(iDieRoll<14)) //Encounter type giant
{iDieRoll2=d100();
if ((iDieRoll2>0)&&(iDieRoll2<4))
{oEncounter=GetNearestObjectByTag("Ettin",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>3)&&(iDieRoll2<7))
{oEncounter=GetNearestObjectByTag("FireGiant",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>6)&&(iDieRoll2<10))
{oEncounter=GetNearestObjectByTag("FrostGiant",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>9)&&(iDieRoll2<97))
{oEncounter=GetNearestObjectByTag("HillGiant",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>96)&&(iDieRoll2<101))
{oEncounter=GetNearestObjectByTag("StoneGiant",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if ((iDieRoll>13)&&(iDieRoll<17)) //Encounter type humanoid
{iDieRoll2=d100();
if ((iDieRoll2>0)&&(iDieRoll2<6))
{oEncounter=GetNearestObjectByTag("Goblin",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>5)&&(iDieRoll2<101))
{oEncounter=GetNearestObjectByTag("Orc",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if ((iDieRoll>16)&&(iDieRoll<37))
{oEncounter=GetNearestObjectByTag("Lion",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>28)&&(iDieRoll<33)) //Encounter type lycanthrope
{iDieRoll2=Random(75)+1;
if ((iDieRoll2>0)&&(iDieRoll2<6))
{oEncounter=GetNearestObjectByTag("Wererat",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>5)&&(iDieRoll2<16))
{oEncounter=GetNearestObjectByTag("Weretiger",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>15)&&(iDieRoll2<76))
{oEncounter=GetNearestObjectByTag("Werewolf",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if ((iDieRoll>36)&&(iDieRoll<59)) //Encounter type men
{iDieRoll2=d20();
if ((iDieRoll2>0)&&(iDieRoll2<11))
{oEncounter=GetNearestObjectByTag("Bandit",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll2>10)&&(iDieRoll2<21))
{oEncounter=GetNearestObjectByTag("Character",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
}
else if ((iDieRoll>58)&&(iDieRoll<63))
{oEncounter=GetNearestObjectByTag("Ogre",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>62)&&(iDieRoll<65))
{oEncounter=GetNearestObjectByTag("Spider",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>64)&&(iDieRoll<67))
{oEncounter=GetNearestObjectByTag("Troll",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>66)&&(iDieRoll<78))
{oEncounter=GetNearestObjectByTag("Wolf",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>77)&&(iDieRoll<81))
{oEncounter=GetNearestObjectByTag("Worg",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>80)&&(iDieRoll<83))
{oEncounter=GetNearestObjectByTag("DireTiger",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>82)&&(iDieRoll<88))
{oEncounter=GetNearestObjectByTag("Cougar",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>87)&&(iDieRoll<93))
{oEncounter=GetNearestObjectByTag("DireWolf",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==93) //Skeleton Re-animator
{oEncounter=GetNearestObjectByTag("Skeleton",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==94) //Zombie Re-animator
{oEncounter=GetNearestObjectByTag("Zombie",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==95)
{oEncounter=GetNearestObjectByTag("Malar",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==96)
{oEncounter=GetNearestObjectByTag("Badger",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==97)
{oEncounter=GetNearestObjectByTag("Rat",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if (iDieRoll==98)
{oEncounter=GetNearestObjectByTag("GreyRender",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
else if ((iDieRoll>98)&&(iDieRoll<101))
{oEncounter=GetNearestObjectByTag("Krenshar",oWay);
SetEncounterActive(TRUE,oEncounter);
return;}
//add new encounters here by copying the "else if" above that matches what you
//want to do (i.e. ==, range, or sub-table) then change the iRoll statement
//and Randomizer back at the beginning
else FloatingTextStringOnCreature(IntToString(iDieRoll),oPC);//catch all debug - if it fires, you are missing that number in the else ifs above
}

View File

@@ -0,0 +1,55 @@
//::///////////////////////////////////////////////
//:: FileName otres_rand_sc
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: smo
//::
//Set up the travel time remaining as a custom tag so we can use them
//in conversation
//Also returns FALSE if the optional encounter flag is FALSE
//:://////////////////////////////////////////////
//include needed for the Set Party Variable function
#include "nw_i0_plot"
int StartingConditional()
{
object oPC=GetPCSpeaker();
int bEncounterDone=GetLocalInt(oPC,"bEncounterDone");
if (!(bEncounterDone)) //Allows for a flag to keep the PC in the random encounter - set it to false in the OnEnter event for the area or encounter
return FALSE;
int iHoursToGo=GetPLocalInt(oPC, "iHoursToGo"); //Hours to go until next point on journey
string sHoursToGo=IntToString(iHoursToGo);
int iTravelledHours=GetPLocalInt(oPC, "iTravelledHours"); //Hours travelled
string sTravelledHours=IntToString(iTravelledHours);
string sStartDestinationDesc=GetLocalString(oPC,"sStartDestinationDesc");
string sNextDestinationDesc=GetLocalString(oPC,"sNextDestinationDesc");
SetCustomToken(129,sTravelledHours);
SetCustomToken(123,sHoursToGo);
SetCustomToken(124,sStartDestinationDesc);
SetCustomToken(127,sNextDestinationDesc);
object oTalker=GetPCSpeaker();
object oFM=GetFirstFactionMember(oTalker);
if (oFM==OBJECT_INVALID) //single player
return TRUE;
// Loop to check each party members distance from the PC.
while (GetIsObjectValid(oFM))
{//begin while loop
// Skip dead party members
if (!GetIsDead(oFM))
{//begin not dead if
int iDistanceCheck = FloatToInt(GetDistanceToObject(oFM));
// Check to see if oPartyMember is within 10 meters. If not, send
// the message and exit the conditional as FALSE.
if (iDistanceCheck > 10)
{//begin distance check if
// If all party members are not present do not show travel dialog
return FALSE;
}//end distance check if
}//end not dead if
oFM = GetNextFactionMember(oTalker);
}//end while loop
//if all within 10 m show the travel dialog
return TRUE;
}

View File

@@ -0,0 +1,17 @@
//::///////////////////////////////////////////////
//:: FileName otres_randleavd2
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: smo
//::
//:: Sets bTravel variable to true for the party
//:://////////////////////////////////////////////
#include "nw_i0_plot"
void main()
{
object oPC=GetPCSpeaker();
SetPLocalInt(GetPCSpeaker(),"bTravel",TRUE);
}

View File

@@ -0,0 +1,18 @@
//::///////////////////////////////////////////////
//:: FileName otresre_flag2
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: Script Wizard
//:: Created On: 4/30/2003 9:31:32 AM
//Sets up the dialog function for the optional encounter flag
//:://////////////////////////////////////////////
int StartingConditional()
{
// Inspect local variables
if(GetLocalInt(GetPCSpeaker(), "bEncounterDone") == TRUE)
//Allows for a flag to keep the PC in the random encounter - set it to false in the OnEnter event for the area or encounter
return FALSE;
return TRUE;
}

View File

@@ -0,0 +1,9 @@
//Starts the conversation to leave a random encounter area
void main()
{
object oPC=GetEnteringObject();
location locPC=GetLocation(oPC);
if (!GetIsPC(oPC)) return;
SetLocalLocation(oPC,"locArea",locPC);
BeginConversation("otres_rand_leave",oPC);//This is the conversation to set the travel variables
}

View File

@@ -0,0 +1,9 @@
//Calls a function to set the travel variables that are stored
//in the trigger tag
#include "otres_inc"
void main()
{
object oTrigger=GetLocalObject(GetPCSpeaker(),"oTrigger");
SetOTRESVar(oTrigger,FALSE);
}

View File

@@ -0,0 +1,12 @@
//Sets the travel variables to return to the starting area
#include "otres_inc"
#include "nw_i0_plot"
void main()
{
object oPC=GetPCSpeaker();
string sTriggerTag=GetLocalString(oPC,"sTriggerTag");
SetOTRESVar(oPC,TRUE);
SetPLocalInt(GetPCSpeaker(),"bTravel",TRUE);
}

View File

@@ -0,0 +1,16 @@
//This calls the overland travel function
#include "otres_overland"
void main()
{
int bTravel=GetLocalInt(GetPCSpeaker(),"bTravel");
int iHoursToGo=GetLocalInt(GetPCSpeaker(),"iHoursToGo");
string sDestination=GetLocalString(GetPCSpeaker(),"sNextDestinationTag");
string sTerrain=GetLocalString(GetPCSpeaker(),"sTerrain");
float fFacing=GetLocalFloat(GetPCSpeaker(),"fFacing");
if (bTravel)
{
OverlandTravel(iHoursToGo,sDestination,sTerrain,fFacing);
}
else return;
}

View File

@@ -0,0 +1,13 @@
//::///////////////////////////////////////////////
//:: FileName otres_travelinit
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: smo
//::
//:://////////////////////////////////////////////
void main()
{
// Set the variable
SetLocalInt(GetPCSpeaker(), "bTravel", FALSE);
}

View File

@@ -0,0 +1,17 @@
// ra_mod_onleave.nss
/////////////////////////////////////////////////////////////////////
//
// This script has been auto-generated by HakInstaller to call
// multiple handlers for the onmoduleload event.
//
/////////////////////////////////////////////////////////////////////
void main()
{
ExecuteScript("prc_onleave", OBJECT_SELF);
//:: Rappan Athuk time tracking
}

View File

@@ -0,0 +1,487 @@
//::///////////////////////////////////////////////
//:: Name ra_rnd_ftman_spw
//:: Copyright (c) 2001 Bioware Corp.
//:: Copyright (c) NWN Dark Sun
//:://////////////////////////////////////////////
/*
Default On Spawn script
2003-07-28: Georg Zoeller:
If you set a ninteger on the creature named
"X2_USERDEFINED_ONSPAWN_EVENTS"
The creature will fire a pre and a post-spawn
event on itself, depending on the value of that
variable
1 - Fire Userdefined Event 1510 (pre spawn)
2 - Fire Userdefined Event 1511 (post spawn)
3 - Fire both events
2007-12-31: Deva Winblood
Modified to look for X3_HORSE_OWNER_TAG and if
it is defined look for an NPC with that tag
nearby or in the module (checks near first).
It will make that NPC this horse's master.
*/
//:://////////////////////////////////////////////
//:: Created By: Keith Warner, Georg Zoeller
//:: Created On: June 11/03
//:://////////////////////////////////////////////
const int EVENT_USER_DEFINED_PRESPAWN = 1510;
const int EVENT_USER_DEFINED_POSTSPAWN = 1511;
#include "NW_I0_GENERIC"
#include "ms_name_inc"
#include "x2_inc_switches"
#include "rnd_commoner_inc"
#include "ra_rnd_armor_inc"
void ShrinkEm(object oPC)
{
SetObjectVisualTransform(oPC, OBJECT_VISUAL_TRANSFORM_SCALE, 0.5f);
}
void GrowEm(object oPC)
{
SetObjectVisualTransform(oPC, OBJECT_VISUAL_TRANSFORM_SCALE, 1.5f);
}
void main()
{
string sTag;
object oNPC;
// User defined OnSpawn event requested?
int nSpecEvent = GetLocalInt(OBJECT_SELF,"X2_USERDEFINED_ONSPAWN_EVENTS");
// Pre Spawn Event requested
if (nSpecEvent == 1 || nSpecEvent == 3 )
{
SignalEvent(OBJECT_SELF,EventUserDefined(EVENT_USER_DEFINED_PRESPAWN ));
}
//:: Initialize Mount System
sTag=GetLocalString(OBJECT_SELF,"X3_HORSE_OWNER_TAG");
if (GetStringLength(sTag)>0)
{ // look for master
oNPC=GetNearestObjectByTag(sTag);
if (GetIsObjectValid(oNPC)&&GetObjectType(oNPC)==OBJECT_TYPE_CREATURE)
{ // master found
AddHenchman(oNPC);
} // master found
else
{ // look in module
oNPC=GetObjectByTag(sTag);
if (GetIsObjectValid(oNPC)&&GetObjectType(oNPC)==OBJECT_TYPE_CREATURE)
{ // master found
AddHenchman(oNPC);
} // master found
else
{ // master does not exist - remove X3_HORSE_OWNER_TAG
DeleteLocalString(OBJECT_SELF,"X3_HORSE_OWNER_TAG");
} // master does not exist - remove X3_HORSE_OWNER_TAG
} // look in module
} // look for master
//:: Sets a random integer on the creature to use with other spell functions
string sImmune = GetName(OBJECT_SELF)+"_AURA_IMMUNE";
int nRandomSeed = Random(999);
SetLocalInt(OBJECT_SELF, sImmune, nRandomSeed);
//:: Creature will quickly & automatically buff itself up with any defensive
//:: spells it has memorized.
int nAutobuff = GetLocalInt(OBJECT_SELF,"AUTOBUFF");
if (nAutobuff > 0 )
{
SetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY);
}
//:: Creature will flee those that close within 7m if they are not friends,
//:: Rangers or Druids.
int nHerbivore = GetLocalInt(OBJECT_SELF,"CREATURE_VAR_HERBIVORE");
if (nHerbivore > 0 )
{
SetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL);
SetBehaviorState(NW_FLAG_BEHAVIOR_HERBIVORE);
}
//:: Creature will only attack those that close within 5m and are not friends,
//:: Rangers or Druids.
int nOmnivore = GetLocalInt(OBJECT_SELF,"CREATURE_VAR_OMNIVORE");
if (nOmnivore > 0 )
{
SetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL);
SetBehaviorState(NW_FLAG_BEHAVIOR_OMNIVORE);
}
int nOLM = GetLocalInt(OBJECT_SELF,"OLM");
if (nOLM > 0)
{
DelayCommand(0.0f, ShrinkEm(OBJECT_SELF));
effect eSlow = EffectMovementSpeedDecrease(50);
eSlow = SupernaturalEffect(eSlow);
eSlow = ExtraordinaryEffect(eSlow);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eSlow,OBJECT_SELF));
}
int nHuge = GetLocalInt(OBJECT_SELF,"HUGE");
if (nHuge > 0)
{
DelayCommand(0.0f, GrowEm(OBJECT_SELF));
}
int nNoStun = GetLocalInt(OBJECT_SELF,"NOSTUN");
if (nNoStun > 0)
{
effect eNoStun = EffectImmunity(IMMUNITY_TYPE_STUN);
eNoStun = SupernaturalEffect(eNoStun);
eNoStun = ExtraordinaryEffect(eNoStun);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eNoStun,OBJECT_SELF));
}
int nNatInvis = GetLocalInt(OBJECT_SELF,"NATURAL_INVIS");
if (nNatInvis > 0)
{
effect eNatInvis = EffectInvisibility(4);
eNatInvis = SupernaturalEffect(eNatInvis);
eNatInvis = ExtraordinaryEffect(eNatInvis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eNatInvis,OBJECT_SELF));
}
int nNoSleep = GetLocalInt(OBJECT_SELF,"NOSLEEP");
if (nNoSleep > 0)
{
effect eNoSleep = EffectImmunity(IMMUNITY_TYPE_SLEEP);
eNoSleep = SupernaturalEffect(eNoSleep);
eNoSleep = ExtraordinaryEffect(eNoSleep);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eNoSleep,OBJECT_SELF));
}
int nNoDaze = GetLocalInt(OBJECT_SELF,"NODAZE");
if (nNoDaze > 0)
{
effect eNoDaze = EffectImmunity(IMMUNITY_TYPE_DAZED);
eNoDaze = SupernaturalEffect(eNoDaze);
eNoDaze = ExtraordinaryEffect(eNoDaze);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eNoDaze,OBJECT_SELF));
}
int nNoBlind = GetLocalInt(OBJECT_SELF,"NOBLIND");
if (nNoBlind > 0)
{
effect eNoBlind = EffectImmunity(IMMUNITY_TYPE_BLINDNESS);
eNoBlind = SupernaturalEffect(eNoBlind);
eNoBlind = ExtraordinaryEffect(eNoBlind);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eNoBlind,OBJECT_SELF));
}
int nNoDeaf = GetLocalInt(OBJECT_SELF,"NODEAF");
if (nNoDeaf > 0)
{
effect eNoDeaf = EffectImmunity(IMMUNITY_TYPE_DEAFNESS);
eNoDeaf = SupernaturalEffect(eNoDeaf);
eNoDeaf = ExtraordinaryEffect(eNoDeaf);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eNoDeaf,OBJECT_SELF));
}
int nDeaf = GetLocalInt(OBJECT_SELF,"IS_DEAF");
if (nDeaf > 0)
{
effect eDeaf = EffectDeaf();
eDeaf = SupernaturalEffect(eDeaf);
eDeaf = ExtraordinaryEffect(eDeaf);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eDeaf,OBJECT_SELF));
}
/* Fix for the new golems to reduce their number of attacks */
int nNumber = GetLocalInt(OBJECT_SELF,CREATURE_VAR_NUMBER_OF_ATTACKS);
if (nNumber >0 )
{
SetBaseAttackBonus(nNumber);
}
int nVFX = GetLocalInt(OBJECT_SELF,"SpawnVFX");
if(nVFX)
{
ApplyEffectToObject(DURATION_TYPE_PERMANENT,SupernaturalEffect(EffectVisualEffect(nVFX)),OBJECT_SELF);
}
int nRegen = GetLocalInt(OBJECT_SELF,"FAST_HEALING");
if(nRegen)
{
effect eRegen = EffectRegenerate(nRegen, 6.0f);
eRegen = SupernaturalEffect(eRegen);
eRegen = ExtraordinaryEffect(eRegen);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eRegen, OBJECT_SELF));
}
int nShadowy = GetLocalInt(OBJECT_SELF,"SHADOWY");
if (nShadowy)
{
effect eVis = EffectVisualEffect(VFX_DUR_PROT_SHADOW_ARMOR);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
int nStony = GetLocalInt(OBJECT_SELF,"STONY");
if (nStony)
{
effect eVis = EffectVisualEffect(VFX_DUR_PROT_STONESKIN);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
int nFirey = GetLocalInt(OBJECT_SELF,"FIREY");
if (nFirey)
{
effect eVis = EffectVisualEffect(VFX_DUR_INFERNO_NO_SOUND);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
int nWoody = GetLocalInt(OBJECT_SELF,"WOODY");
if (nWoody)
{
effect eVis = EffectVisualEffect(VFX_DUR_PROT_BARKSKIN);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
int nConcealed20 = GetLocalInt(OBJECT_SELF,"CONCEALED20");
if (nConcealed20)
{
effect eVis = EffectVisualEffect(VFX_DUR_BLUR );
effect eConceal = EffectConcealment(20, 0);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
int nConcealed50 = GetLocalInt(OBJECT_SELF,"CONCEALED50");
if (nConcealed50)
{
effect eVis = EffectVisualEffect(VFX_DUR_BLUR );
effect eConceal = EffectConcealment(50, 0);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
int nIcy = GetLocalInt(OBJECT_SELF,"ICY");
if (nIcy)
{
effect eVis = EffectVisualEffect(VFX_DUR_ICESKIN);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
int nSR = GetLocalInt(OBJECT_SELF,"SPELL_RESISTANCE");
if ( nSR )
{
effect eSR = EffectSpellResistanceIncrease(nSR);
eSR = SupernaturalEffect(eSR);
eSR = ExtraordinaryEffect(eSR);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eSR,OBJECT_SELF);
}
int nAttackBonus = GetLocalInt(OBJECT_SELF,"ATTACK_BONUS");
if ( nAttackBonus )
{
effect eAttack = EffectAttackIncrease(nAttackBonus);
eAttack = SupernaturalEffect(eAttack);
eAttack = ExtraordinaryEffect(eAttack);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eAttack,OBJECT_SELF);
}
int nAcidShield = GetLocalInt(OBJECT_SELF,"ACID_SHIELD");
if ( nAcidShield )
{
effect eShield = EffectDamageShield(0,DAMAGE_BONUS_1d8,DAMAGE_TYPE_ACID);
eShield = SupernaturalEffect(eShield);
eShield = ExtraordinaryEffect(eShield);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eShield,OBJECT_SELF);
}
int nSerratedEdge = GetLocalInt(OBJECT_SELF,"SERRATED_EDGE");
if ( nSerratedEdge )
{
effect eShield = EffectDamageShield(0,DAMAGE_BONUS_1d6,DAMAGE_TYPE_SLASHING);
eShield = SupernaturalEffect(eShield);
eShield = ExtraordinaryEffect(eShield);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eShield,OBJECT_SELF);
}
int nSpikedArmor = GetLocalInt(OBJECT_SELF,"SPIKED_ARMOR");
if ( nSpikedArmor )
{
effect eShield = EffectDamageShield(0,DAMAGE_BONUS_1d4,DAMAGE_TYPE_PIERCING);
eShield = SupernaturalEffect(eShield);
eShield = ExtraordinaryEffect(eShield);
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eShield,OBJECT_SELF);
}
int nGlow = GetLocalInt (OBJECT_SELF,"GLOW_COLOR");
if (nGlow == 1)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_BLUE);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 2)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_BROWN);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 3)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_GREEN);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 4)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_GREY);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 5)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_BLUE);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 6)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_BROWN);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 7)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_GREEN);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 8)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_ORANGE);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 9)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_PURPLE);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 10)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_RED);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 11)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_YELLOW);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 12)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_ORANGE);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 13)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_PURPLE);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 14)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_RED);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 15)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_WHITE);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
else if (nGlow == 16)
{
effect eVis = EffectVisualEffect(VFX_DUR_GLOW_YELLOW);
eVis = SupernaturalEffect(eVis);
eVis = ExtraordinaryEffect(eVis);
DelayCommand(0.0f, ApplyEffectToObject(DURATION_TYPE_PERMANENT,eVis,OBJECT_SELF));
}
// Check for randomizations.
ms_Nomenclature(OBJECT_SELF);
int nKeepskin = GetLocalInt(OBJECT_SELF,"RA_KEEPSKIN");
if (nKeepskin != 1)
{
rnd_skin(OBJECT_SELF);
}
rnd_skin(OBJECT_SELF);
int nKeephead = GetLocalInt(OBJECT_SELF,"RA_KEEPHEAD");
if (nKeephead != 1)
{
rnd_head(OBJECT_SELF);
}
int nKeeptats = GetLocalInt(OBJECT_SELF,"RA_KEEPTATS");
if (nKeeptats != 1)
{
rnd_tattoo(OBJECT_SELF);
}
// Execute default OnSpawn script.
ExecuteScript("nw_c2_default9", OBJECT_SELF);
// Execute PRC OnSpawn script.
ExecuteScript("prc_npc_spawn", OBJECT_SELF);
//Post Spawn event requeste
if (nSpecEvent == 2 || nSpecEvent == 3)
{
SignalEvent(OBJECT_SELF,EventUserDefined(EVENT_USER_DEFINED_POSTSPAWN));
}
}

285
_module/nss/ra_st_magic.nss Normal file
View File

@@ -0,0 +1,285 @@
//::////////////////////////////////////////////////////////////////////////////
//:: Store Open Script
//:: ar_st_magic
//:: For slightly slower store restocking
//:: -DM Heatstroke
//::////////////////////////////////////////////////////////////////////////////
/*
This script will allow stores to partially reset
themselves to their original state after some
time has passed.
Intended for persistent worlds.
*/
//::////////////////////////////////////////////////////////////////////////////
//:: Created By: The Krit
//:: Created On: 3/2/07
//:: Replaces the "do-nothing" BioWare script.
//::////////////////////////////////////////////////////////////////////////////
//::////////////////////////////////////////////////////////////////////////////
//
// This script will cause a store's finite inventory
// and limited gold to be (partially) replenished
// after a certain amount of time passes. It will also
// clean out new items and excess gold. I call this
// restocking.
//
// The timer starts when the store is first opened
// after server rest or the last restock. The time
// is random, but will be at least RESTOCK_TIME_FIXED
// real-time hours. The random component of the time
// is added to this minimum, and will range from 0
// to RESTOCK_TIME_VARIABLE minutes.
//
// Items are only replaced if all of that type have
// been sold (and not bought back). The chance for an
// item to be replaced is RESTOCK_CHANCE.
//
// Items not in the store's original inventory have a
// chance to be removed (sold to unspecified NPC's, if
// you will) when the store restocks. This chance is
// UNSTOCK_CHANCE.
//
// After the store restocks, the store's gold supply -- if
// limited -- will be no more than GOLD_MAX_FRACTION times
// its starting value.
//
// After the store restocks, the store's gold supply -- if
// limited -- will be no less than GOLD_MIN_FRACTION times
// its starting value.
//
// If you try to mess with things and make GOLD_MAX_FRACTION
// less than GOLD_MIN_FRACTION, you deserve whatever happens.
// You may also smack yourself for making trouble. :)
//
//::////////////////////////////////////////////////////////////////////////////
//
// The variables mentioned above are set globally below.
// In addition, you can change the value for a particular
// store by setting a local variable of the same name
// (and type) on the store.
// NOTE: These variables must be set on the *store*, not
// the merchant.
//
//::////////////////////////////////////////////////////////////////////////////
//
// This script will (likely) break if you switch a
// store from unlimited gold to limited gold through
// scripting. Don't do that. There would be no
// original gold level to refer to when restocking.
//
//::////////////////////////////////////////////////////////////////////////////
// The following is the minimum number of real-time (not
// game-time) hours that elapse before a store gets
// restocked.
const int RESTOCK_TIME_FIXED = 2;
// The following is the maximum number of minutes (not
// hours) that a restock might be delayed beyond the
// above minimum number of hours.
const int RESTOCK_TIME_VARIABLE = 30;
// The following is the chance (percentage) that a depleted
// item will be replaced when the restocking occurs. Each
// item rolls this percentage individually.
const int RESTOCK_CHANCE = 25;
// The following is the chance (percentage) that an item
// not in the store's original inventory will be removed
// when a restocking occurs.
const int UNSTOCK_CHANCE = 10;
// The following is the fraction (floating point) of the
// stores original gold that is the most a store can have
// after restocking.
// (No effect on stores with unlimited gold.)
const float GOLD_MAX_FRACTION = 2.20;
// The following is the fraction (floating point) of the
// stores original gold that is the least a store can have
// after restocking.
// (No effect on stores with unlimited gold.)
const float GOLD_MIN_FRACTION = 0.80;
// The following are names of local variables used by
// this script.
const string STORE_GOLD = "TK_STORE_STARTING_GOLD";
const string ORIG_INVENTORY = "TK_STORE_STARTING_INVENTORY_";
const string CUR_INVENTORY = "TK_STORE_CURRENT_INVENTORY_";
const string INVENTORY_STACK = "TK_STORE_INVENTORY_STACK_LIST_";
const string INVENTORY_LIST = "TK_STORE_INVENTORY_LIST_";
const string INVENTORY_SIZE = "TK_STORE_INVENTORY_SIZE";
const string INVENTORIED = "TK_STORE_DID_INVENTORY";
const string RESTOCK_ORDERED = "TK_STORE_DID_DELAY";
// Records the store's current (starting) inventory.
void DoInventory();
// Restocks the store.
void Restock();
//////////////////////////////////////////////////
// main()
//
// Intended for a store's OnOpenStore event, replacing the BioWare default.
//
void main()
{
// See if the store's original inventory has been recorded.
if ( !GetLocalInt(OBJECT_SELF, INVENTORIED) )
{
// Record the current inventory.
DoInventory();
SetLocalInt(OBJECT_SELF, INVENTORIED, TRUE);
}
// See if a restock is currently on delay.
if ( !GetLocalInt(OBJECT_SELF, RESTOCK_ORDERED) )
{
// Determine the restock times (possibly stored locally).
int nRestockHours = GetLocalInt(OBJECT_SELF, "RESTOCK_TIME_FIXED");
if ( nRestockHours == 0 )
nRestockHours = RESTOCK_TIME_FIXED;
int nRestockMinutes = GetLocalInt(OBJECT_SELF, "RESTOCK_TIME_VARIABLE");
if ( nRestockMinutes == 0 )
nRestockMinutes = RESTOCK_TIME_VARIABLE;
// Order (delay) a restock.
DelayCommand( TurnsToSeconds(60*nRestockHours + Random(nRestockMinutes+1)),
Restock());
SetLocalInt(OBJECT_SELF, RESTOCK_ORDERED, TRUE);
}
}
//////////////////////////////////////////////////
// DoInventory()
//
// Records the store's current (starting) inventory.
//
void DoInventory()
{
// Record the store's current gold.
SetLocalInt(OBJECT_SELF, STORE_GOLD, GetStoreGold(OBJECT_SELF));
// Record the store's current inventory.
int nCount = 0;
object oItem = GetFirstItemInInventory();
while ( oItem != OBJECT_INVALID )
{
// We are only concerned with items in finite supply.
if ( !GetInfiniteFlag(oItem) )
{
string sResRef = GetResRef(oItem);
// Set a boolean flag based on the blueprint name.
SetLocalInt(OBJECT_SELF, ORIG_INVENTORY + sResRef, TRUE);
// Add sResRef to the list of blueprints.
SetLocalString(OBJECT_SELF, INVENTORY_LIST + IntToString(nCount), sResRef);
// Record the stack size.
SetLocalInt(OBJECT_SELF, INVENTORY_STACK + IntToString(nCount), GetItemStackSize(oItem));
// Update the count.
nCount++;
}
// Next item.
oItem = GetNextItemInInventory();
}
// Record the length of the list of blueprints.
SetLocalInt(OBJECT_SELF, INVENTORY_SIZE, nCount);
}
//////////////////////////////////////////////////
// Restock()
//
// Restocks the store.
//
void Restock()
{
// Check the store's gold.
int nCurGold = GetStoreGold(OBJECT_SELF);
// We are only concerned if the store has limited gold.
if ( nCurGold > -1 )
{
// Determine the min and max gold fractions (possibly stored locally).
float fGoldMin = GetLocalFloat(OBJECT_SELF, "GOLD_MIN_FRACTION");
if ( fGoldMin == 0.0 )
fGoldMin = GOLD_MIN_FRACTION;
float fGoldMax = GetLocalFloat(OBJECT_SELF, "GOLD_MAX_FRACTION");
if ( fGoldMax == 0.0 )
fGoldMax = GOLD_MAX_FRACTION;
// Calculate the minimum and maximum gold levels.
int nOrigGold = GetLocalInt(OBJECT_SELF, STORE_GOLD);
int nMinGold = FloatToInt(IntToFloat(nOrigGold) * fGoldMin);
int nMaxGold = FloatToInt(IntToFloat(nOrigGold) * fGoldMax);
// Check for too little gold.
if ( nCurGold < nMinGold )
SetStoreGold(OBJECT_SELF, nMinGold);
// Check for too much gold.
else if ( nCurGold > nMaxGold )
SetStoreGold(OBJECT_SELF, nMaxGold);
}
// Determine the unstock chance (possibly stored locally).
int nUnstockChance = GetLocalInt(OBJECT_SELF, "UNSTOCK_CHANCE");
if ( nUnstockChance == 0 )
nUnstockChance = UNSTOCK_CHANCE;
// Scan the store's current inventory.
// Record which original items are still around.
// Possibly remove non-original items.
object oItem = GetFirstItemInInventory();
while ( oItem != OBJECT_INVALID )
{
// We are only concerned with items in finite supply.
if ( !GetInfiniteFlag(oItem) )
{
string sResRef = GetResRef(oItem);
// See if this item is an original item.
if ( GetLocalInt(OBJECT_SELF, ORIG_INVENTORY + sResRef) )
{
// Set a boolean flag (temporarily) based on the blueprint name.
SetLocalInt(OBJECT_SELF, CUR_INVENTORY + sResRef, TRUE);
DelayCommand(0.0, DeleteLocalInt(OBJECT_SELF, CUR_INVENTORY + sResRef));
}
// See if this (not original) item should be removed.
else if ( d100() <= nUnstockChance )
// Delete this item.
DestroyObject(oItem);
}
// Next item.
oItem = GetNextItemInInventory();
}
// Determine the restock chance (possibly stored locally).
int nRestockChance = GetLocalInt(OBJECT_SELF, "RESTOCK_CHANCE");
if ( nRestockChance == 0 )
nRestockChance = RESTOCK_CHANCE;
// Loop through the list of items that might be restored.
int nCount = GetLocalInt(OBJECT_SELF, INVENTORY_SIZE);
while ( nCount-- > 0 )
{
string sResRef = GetLocalString(OBJECT_SELF, INVENTORY_LIST + IntToString(nCount));
// Make sure no items of this type are in the store's inventory (before this loop).
if ( !GetLocalInt(OBJECT_SELF, CUR_INVENTORY + sResRef) )
// See if this item should be restocked.
if ( d100() <= nRestockChance )
// Add this item to the store.
CreateItemOnObject(sResRef, OBJECT_SELF,
GetLocalInt(OBJECT_SELF, INVENTORY_STACK + IntToString(nCount)));
}
// Restocking is no longer in progress.
SetLocalInt(OBJECT_SELF, RESTOCK_ORDERED, FALSE);
}

File diff suppressed because it is too large Load Diff

View File

@@ -99,6 +99,57 @@ int SpawnCheckCustom(object oSpawn)
}
}
//
//:: Spawns The Dishonest Patrol if the party's average level is over 10,
//:: they have been inside the dungeon & Sheriff Ostland is still alive.
if (nSpawnCheckCustom == 11)
{
// Initialize Variables
int nTotalPCs;
int nTotalPCLevel;
int nAveragePCLevel;
int bDungeon;
int bOstlandDead;
object oArea = GetArea(OBJECT_SELF);
// Cycle through PCs in Area
object oPC = GetFirstObjectInArea(oArea);
while (oPC != OBJECT_INVALID)
{
if (GetIsPC(oPC) == TRUE || GetIsPC(GetMaster(oPC)) == TRUE) //:: Summons & henchmen should count towards this.
{
//:: Check if the PC has entered the Dungeon yet
bDungeon++;
bDungeon = GetLocalInt(oPC, "bEnteredDungeon");
//:: Check to see if Ostland has been killed.
bOstlandDead++;
bOstlandDead = RetrieveQuestState("DishonestPatrol", oPC);
nTotalPCs++;
nTotalPCLevel = nTotalPCLevel + GetHitDice(oPC);
}
oPC = GetNextObjectInArea(oArea);
}
if (nTotalPCs > 0)
{
nAveragePCLevel = nTotalPCLevel / nTotalPCs;
}
else
{
nAveragePCLevel = 3;
}
if ((nAveragePCLevel > 10) && (bOstlandDead < 1) && (bDungeon > 0))
{
nProcessSpawn = TRUE;
}
}
//:: Spawns The Dishonest Patrol if the party's average level is over 10,
//:: they have been inside the dungeon & Sheriff Ostland is still alive.
//:: Checks for stage 1 or lower for the "Spider's Captive quest"
if (nSpawnCheckCustom == 50)

View File

@@ -0,0 +1,123 @@
//:://////////////////////////////////////////////////
//:: SQL_DB_PARTYWIDE
/*
Modified x0_i0_partywide include library for
persistent party-wide database functions.
*/
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/08/2002
//:: Modified By: Jaysyn
//:: Modified On: 11/16/2022
//:://////////////////////////////////////////////////
#include "utl_i_sqluuid"
/**********************************************************************
* CONSTANTS
**********************************************************************/
/**********************************************************************
* FUNCTION PROTOTYPES
**********************************************************************/
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party.
// For strings.
void SQL_SetLocalStringOnAll(object oPC, string sVarname, string value);
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party.
// For ints.
void SQL_SetLocalIntOnAll(object oPC, string sVarname, int value);
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party.
// For floats.
void SQL_SetLocalFloatOnAll(object oPC, string sVarname, float value);
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party.
// For locations.
void SQL_SetLocalLocationOnAll(object oPC, string sVarname, location value);
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party.
// For objects.
void SQL_SetLocalObjectOnAll(object oPC, string sVarname, object value);
/**********************************************************************
* FUNCTION DEFINITIONS
**********************************************************************/
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party, including associates.
// For strings.
void SQL_SetLocalStringOnAll(object oPC, string sVarname, string value)
{
object oPartyMem = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oPartyMem)) {
SQLocalsUUID_SetString(oPartyMem, sVarname, value);
oPartyMem = GetNextFactionMember(oPC, FALSE);
}
}
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party, including associates.
// For ints.
void SQL_SetLocalIntOnAll(object oPC, string sVarname, int value)
{
object oPartyMem = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oPartyMem)) {
SQLocalsUUID_SetInt(oPartyMem, sVarname, value);
oPartyMem = GetNextFactionMember(oPC, FALSE);
}
}
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party.
// For floats.
void SQL_SetLocalFloatOnAll(object oPC, string sVarname, float value)
{
object oPartyMem = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oPartyMem)) {
SQLocalsUUID_SetFloat(oPartyMem, sVarname, value);
oPartyMem = GetNextFactionMember(oPC, FALSE);
}
}
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party.
// For locations.
void SQL_SetLocalLocationOnAll(object oPC, string sVarname, location value)
{
object oPartyMem = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oPartyMem)) {
SQLocalsUUID_SetLocation(oPartyMem, sVarname, value);
oPartyMem = GetNextFactionMember(oPC, FALSE);
}
}
// Given a varname, value, and PC, sets the variable on
// all members of the PC's party.
// For objects.
void SQL_SetLocalObjectOnAll(object oPC, string sVarname, object value)
{
object oPartyMem = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oPartyMem)) {
SQLocalsUUID_SetObject(oPartyMem, sVarname, value);
oPartyMem = GetNextFactionMember(oPC, FALSE);
}
}
// void main (){}

View File

@@ -0,0 +1,121 @@
//::///////////////////////////////////////////////
//:: Example XP2 OnLoad Script
//:: x2_mod_def_load
//:: (c) 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*
Put into: OnModuleLoad Event
This example script demonstrates how to tweak the
behavior of several subsystems in your module.
For more information, please check x2_inc_switches
which holds definitions for several variables that
can be set on modules, creatures, doors or waypoints
to change the default behavior of Bioware scripts.
Warning:
Using some of these switches may change your games
balancing and may introduce bugs or instabilities. We
recommend that you only use these switches if you
know what you are doing. Consider these features
unsupported!
Please do NOT report any bugs you experience while
these switches have been changed from their default
positions.
Make sure you visit the forums at nwn.bioware.com
to find out more about these scripts.
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-07-16
//:://////////////////////////////////////////////
#include "x2_inc_switches"
#include "x2_inc_restsys"
void main()
{
if (GetGameDifficulty() == GAME_DIFFICULTY_CORE_RULES || GetGameDifficulty() == GAME_DIFFICULTY_DIFFICULT)
{
// * Setting the switch below will enable a seperate Use Magic Device Skillcheck for
// * rogues when playing on Hardcore+ difficulty. This only applies to scrolls
SetModuleSwitch (MODULE_SWITCH_ENABLE_UMD_SCROLLS, TRUE);
// * Activating the switch below will make AOE spells hurt neutral NPCS by default
// SetModuleSwitch (MODULE_SWITCH_AOE_HURT_NEUTRAL_NPCS, TRUE);
}
// * AI: Activating the switch below will make the creaures using the WalkWaypoint function
// * able to walk across areas
// SetModuleSwitch (MODULE_SWITCH_ENABLE_CROSSAREA_WALKWAYPOINTS, TRUE);
// * Spells: Activating the switch below will make the Glyph of Warding spell behave differently:
// * The visual glyph will disappear after 6 seconds, making them impossible to spot
// SetModuleSwitch (MODULE_SWITCH_ENABLE_INVISIBLE_GLYPH_OF_WARDING, TRUE);
// * Craft Feats: Want 50 charges on a newly created wand? We found this unbalancing,
// * but since it is described this way in the book, here is the switch to get it back...
// SetModuleSwitch (MODULE_SWITCH_ENABLE_CRAFT_WAND_50_CHARGES, TRUE);
// * Craft Feats: Use this to disable Item Creation Feats if you do not want
// * them in your module
// SetModuleSwitch (MODULE_SWITCH_DISABLE_ITEM_CREATION_FEATS, TRUE);
// * Palemaster: Deathless master touch in PnP only affects creatures up to a certain size.
// * We do not support this check for balancing reasons, but you can still activate it...
// SetModuleSwitch (MODULE_SWITCH_SPELL_CORERULES_DMASTERTOUCH, TRUE);
// * Epic Spellcasting: Some Epic spells feed on the liveforce of the caster. However this
// * did not fit into NWNs spell system and was confusing, so we took it out...
// SetModuleSwitch (MODULE_SWITCH_EPIC_SPELLS_HURT_CASTER, TRUE);
// * Epic Spellcasting: Some Epic spells feed on the liveforce of the caster. However this
// * did not fit into NWNs spell system and was confusing, so we took it out...
// SetModuleSwitch (MODULE_SWITCH_RESTRICT_USE_POISON_TO_FEAT, TRUE);
// * Spellcasting: Some people don't like caster's abusing expertise to raise their AC
// * Uncommenting this line will drop expertise mode whenever a spell is cast by a player
// SetModuleSwitch (MODULE_VAR_AI_STOP_EXPERTISE_ABUSE, TRUE);
// * Item Event Scripts: The game's default event scripts allow routing of all item related events
// * into a single file, based on the tag of that item. If an item's tag is "test", it will fire a
// * script called "test" when an item based event (equip, unequip, acquire, unacquire, activate,...)
// * is triggered. Check "x2_it_example.nss" for an example.
// * This feature is disabled by default.
SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);
if (GetModuleSwitchValue (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
// * If Tagbased scripts are enabled, and you are running a Local Vault Server
// * you should use the line below to add a layer of security to your server, preventing
// * people to execute script you don't want them to. If you use the feature below,
// * all called item scrips will be the prefix + the Tag of the item you want to execute, up to a
// * maximum of 16 chars, instead of the pure tag of the object.
// * i.e. without the line below a user activating an item with the tag "test",
// * will result in the execution of a script called "test". If you uncomment the line below
// * the script called will be "1_test.nss"
// SetUserDefinedItemEventPrefix("1_");
}
// * This initializes Bioware's wandering monster system as used in Hordes of the Underdark
// * You can deactivate it, making your module load faster if you do not use it.
// * If you want to use it, make sure you set "x2_mod_def_rest" as your module's OnRest Script
// SetModuleSwitch (MODULE_SWITCH_USE_XP2_RESTSYSTEM, TRUE);
if (GetModuleSwitchValue(MODULE_SWITCH_USE_XP2_RESTSYSTEM) == TRUE)
{
// * This allows you to specify a different 2da for the wandering monster system.
// SetWanderingMonster2DAFile("des_restsystem");
//* Do not change this line.
WMBuild2DACache();
}
//SetLocalString(GetModule(), "X0_CAMPAIGN_DB", "RATDOG_DB");
}

View File

@@ -0,0 +1,79 @@
//::///////////////////////////////////////////////
//:: 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 "ms_name_inc"
void main()
{
// 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
ms_Nomenclature(OBJECT_SELF);
}