Initial Commit
Initial Commit [v1.32PRC8]
This commit is contained in:
511
_module/nss/rd_spawn.nss
Normal file
511
_module/nss/rd_spawn.nss
Normal file
@@ -0,0 +1,511 @@
|
||||
#include "rd_camptype"
|
||||
#include "rd_spawnmobs"
|
||||
#include "rd_misc"
|
||||
|
||||
void SpawnCamps(string sZone, int iLevel, int iSpecialSpawn = 0);
|
||||
void SpawnCamp(string sZone, int iCamp, int iLevel);
|
||||
void SpawnMobs(string sZone, int iLevel);
|
||||
void SpawnMob(string sEncounter);
|
||||
object SpawnQuestCamp(string sZone, int iCamp, int iLevel, int iLeader=0, string sCType = "");
|
||||
int CampPoints(string sZone, int iCamp);
|
||||
int IsQuestCampUsed(string sZone, int iCamp);
|
||||
//int CheckForHardcore();
|
||||
|
||||
void SpawnCamps(string sZone, int iLevel, int iSpecialSpawn = 0)
|
||||
{
|
||||
string sCampTest;
|
||||
string sTagBase;
|
||||
int iIndex;
|
||||
int iFlag;
|
||||
int iArea;
|
||||
int iBaseLevel;
|
||||
int iSpawned;
|
||||
int iRandom;
|
||||
object oEncounter;
|
||||
object oCreature;
|
||||
object oArea;
|
||||
|
||||
iIndex = 1;
|
||||
iFlag = 1;
|
||||
|
||||
sCampTest = sZone + "_C1_Boss";
|
||||
oEncounter = GetObjectByTag(sCampTest);
|
||||
if (GetIsObjectValid(oEncounter))
|
||||
{
|
||||
oArea = GetArea(oEncounter);
|
||||
iArea=GetIsAreaInterior(oArea);
|
||||
//iBaseLevel=AdjustLevel(iLevel);
|
||||
if (iSpecialSpawn == 0)
|
||||
{
|
||||
if (iArea == FALSE)
|
||||
SetupCampTypes(iLevel,0,0,1);
|
||||
else
|
||||
SetupCampTypes(iLevel,0,1,1);
|
||||
} else {
|
||||
SetupSpecialCamps(iSpecialSpawn);
|
||||
}
|
||||
iSpawned = GetLocalInt(oArea,"Spawned");
|
||||
while (iFlag == 1)
|
||||
{
|
||||
sCampTest = sZone + "_C" + IntToString(iIndex) + "_Boss";
|
||||
oEncounter = GetObjectByTag(sCampTest);
|
||||
if (GetIsObjectValid(oEncounter))
|
||||
if (iSpawned == 0)
|
||||
{
|
||||
DelayCommand(0.1f,SpawnCamp(sZone,iIndex,iLevel));
|
||||
} else {
|
||||
iRandom = Random(4);
|
||||
if (iRandom > 0)
|
||||
DelayCommand(0.1f,SpawnCamp(sZone,iIndex,iLevel));
|
||||
}
|
||||
else
|
||||
iFlag = 0;
|
||||
iIndex++;
|
||||
if (iIndex>99)
|
||||
iFlag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnCamp(string sZone, int iCamp, int iLevel)
|
||||
{
|
||||
int iFlag;
|
||||
int iIndex;
|
||||
int iType;
|
||||
int iBoss;
|
||||
int iBaseLevel;
|
||||
int iBase;
|
||||
int iBaseStart;
|
||||
int iBaseMax;
|
||||
int iCampType;
|
||||
int iCampPoints;
|
||||
int iArea;
|
||||
string sEncounter;
|
||||
string sBossTest;
|
||||
string sCampType;
|
||||
string sTreasure;
|
||||
object oEncounter;
|
||||
object oCreature;
|
||||
object oArea;
|
||||
object oMod;
|
||||
object oEnemyBoss;
|
||||
object oTreasure;
|
||||
location lEncounter;
|
||||
location lHostage;
|
||||
string sHostage;
|
||||
int iHostage;
|
||||
int iAltSpawn;
|
||||
int iSkip;
|
||||
|
||||
oMod = GetModule();
|
||||
|
||||
sEncounter = sZone + "_C" + IntToString(iCamp) + "_Boss";
|
||||
oArea=GetArea(GetObjectByTag(sEncounter));
|
||||
|
||||
iBoss = 0;
|
||||
sBossTest = sZone + "_C" + IntToString(iCamp) + "_Boss_S";
|
||||
oCreature = GetObjectByTag(sBossTest);
|
||||
if (GetIsObjectValid(oCreature))
|
||||
{
|
||||
iBoss=1;
|
||||
sCampType = GetLocalString(oCreature,"CampType");
|
||||
iBaseLevel = GetLocalInt(oCreature,"BaseLevel");
|
||||
iBase = GetLocalInt(oCreature,"iBase");
|
||||
iBaseStart = GetLocalInt(oCreature,"iBaseStart");
|
||||
iBaseMax= GetLocalInt(oCreature,"iBaseMax");
|
||||
iCampType= GetLocalInt(oCreature,"iCampType");
|
||||
iAltSpawn = GetLocalInt(oCreature,"iAltSpawn");
|
||||
} else {
|
||||
sTreasure = sZone + "_C" + IntToString(iCamp) + "_Treasure";
|
||||
oTreasure = GetObjectByTag(sTreasure);
|
||||
if (GetIsObjectValid(oTreasure))
|
||||
SetLocalInt(oTreasure,"NW_DO_ONCE",0);
|
||||
|
||||
iBaseLevel=iLevel;
|
||||
|
||||
//Deal with one camp attacking and killing another camp's boss by populating with the apparent winner
|
||||
oEncounter = GetObjectByTag(sEncounter);
|
||||
if (GetLocalString(oEncounter,"EN4AttackedBy") == "")
|
||||
{
|
||||
sCampType = GetCampType();
|
||||
}
|
||||
else
|
||||
{
|
||||
oEnemyBoss = GetObjectByTag(GetLocalString(oEncounter,"EN4AttackedBy"));
|
||||
if (GetIsObjectValid(oEnemyBoss) && GetLocalString(oEnemyBoss,"CampType") == GetLocalString(oEncounter,"EN4AttackedByCampType"))
|
||||
{
|
||||
sCampType = GetLocalString(oEnemyBoss,"CampType");
|
||||
SetLocalInt(oMod,"iBase",GetLocalInt(oEnemyBoss,"iBase"));
|
||||
SetLocalInt(oMod,"iBaseStart",GetLocalInt(oEnemyBoss,"iBaseStart"));
|
||||
SetLocalInt(oMod,"iBaseMax",GetLocalInt(oEnemyBoss,"iBaseMax"));
|
||||
SetLocalInt(oMod,"iCampType",GetLocalInt(oEnemyBoss,"iCampType"));
|
||||
} else {
|
||||
sCampType = GetCampType();
|
||||
}
|
||||
}
|
||||
|
||||
SetLocalString(oEncounter,"EN4AttackedBy","");
|
||||
SetLocalString(oEncounter,"EN4AttackedByCampType","");
|
||||
|
||||
iBase = GetLocalInt(oMod,"iBase");
|
||||
iBaseStart = GetLocalInt(oMod,"iBaseStart");
|
||||
iBaseMax = GetLocalInt(oMod,"iBaseMax");
|
||||
iCampType = GetLocalInt(oMod,"iCampType");
|
||||
SetLocalInt(oMod,"iBase",0);
|
||||
SetLocalInt(oMod,"iBaseStart",0);
|
||||
SetLocalInt(oMod,"iBaseMax",0);
|
||||
SetLocalInt(oMod,"iCampType",0);
|
||||
sEncounter = sZone + "_C" + IntToString(iCamp) + "_Boss";
|
||||
|
||||
//if less than 5 camp spawn points don't spawn boss mob, spawn type 3 instead.
|
||||
iCampPoints = CampPoints(sZone, iCamp);
|
||||
if (iCampPoints > 4)
|
||||
{
|
||||
oCreature = GetCampMob(99,sEncounter,sCampType,iBaseLevel,iBaseStart,iBase,iBaseMax,iCampType);
|
||||
iHostage = Random(15);
|
||||
if (sCampType == "dwarf" || sCampType == "elf" || sCampType == "human" || sCampType == "halfling" || sCampType == "angelic")
|
||||
iHostage=1;
|
||||
if (iCampType == 1 && iHostage == 0)
|
||||
{
|
||||
lHostage = GetLocation(oCreature);
|
||||
sHostage = "en3_hostage" + IntToString(Random(6)+1);
|
||||
CreateObject(OBJECT_TYPE_CREATURE,sHostage,lHostage);
|
||||
if (Random(6)==0)
|
||||
{
|
||||
sHostage = "en3_hostage" + IntToString(Random(6)+1);
|
||||
CreateObject(OBJECT_TYPE_CREATURE,sHostage,lHostage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oCreature = GetCampMob(3,sEncounter,sCampType,iBaseLevel,iBaseStart,iBase,iBaseMax,iCampType);
|
||||
}
|
||||
|
||||
SetLocalString(oCreature,"CampType",sCampType);
|
||||
SetLocalInt(oCreature,"BaseLevel",iBaseLevel);
|
||||
SetLocalInt(oCreature,"iBase",iBase);
|
||||
SetLocalInt(oCreature,"iBaseStart",iBaseStart);
|
||||
SetLocalInt(oCreature,"iBaseMax",iBaseMax);
|
||||
SetLocalInt(oCreature,"iCampType",iCampType);
|
||||
iAltSpawn = 0;
|
||||
if (CheckHardcore())
|
||||
iAltSpawn = Random(3)+1;
|
||||
SetLocalInt(oCreature,"iAltSpawn",iAltSpawn);
|
||||
}
|
||||
|
||||
iType = 1;
|
||||
while (iType <4)
|
||||
{
|
||||
iFlag = 1;
|
||||
iIndex = 1;
|
||||
while (iFlag == 1)
|
||||
{
|
||||
sEncounter = sZone + "_C" + IntToString(iCamp) +
|
||||
"_T" + IntToString(iType) + "_" + IntToString(iIndex);
|
||||
oEncounter = GetObjectByTag(sEncounter);
|
||||
if (GetIsObjectValid(oEncounter))
|
||||
{
|
||||
if (iAltSpawn == 0)
|
||||
DelayCommand(0.5f,SpawnCampMob(iType,sEncounter,sCampType,iBaseLevel,iBaseStart,iBase,iBaseMax,iCampType));
|
||||
else
|
||||
{
|
||||
iSkip = FALSE;
|
||||
if (iAltSpawn == 1 && iIndex % 2 == 0)
|
||||
iSkip = TRUE;
|
||||
if (iAltSpawn == 2 && iIndex % 2 == 1)
|
||||
iSkip = TRUE;
|
||||
if (iAltSpawn == 3 && iIndex % 3 == 0)
|
||||
iSkip = TRUE;
|
||||
if (iSkip == FALSE)
|
||||
DelayCommand(0.5f,SpawnCampMob(iType,sEncounter,sCampType,iBaseLevel,iBaseStart,iBase,iBaseMax,iCampType));
|
||||
}
|
||||
} else
|
||||
iFlag =0;
|
||||
iIndex++;
|
||||
if (iIndex > 1000)
|
||||
{
|
||||
iFlag = 0;
|
||||
}
|
||||
}
|
||||
iType++;
|
||||
}
|
||||
}
|
||||
|
||||
int CampPoints(string sZone, int iCamp)
|
||||
{
|
||||
int iType;
|
||||
int iFlag;
|
||||
int iIndex;
|
||||
int iCount;
|
||||
string sEncounter;
|
||||
object oEncounter;
|
||||
|
||||
//set iCount to one and skip Boss which is a given
|
||||
iCount = 1;
|
||||
|
||||
iType = 1;
|
||||
while (iType <4)
|
||||
{
|
||||
iFlag = 1;
|
||||
iIndex = 1;
|
||||
while (iFlag == 1)
|
||||
{
|
||||
sEncounter = sZone + "_C" + IntToString(iCamp) +
|
||||
"_T" + IntToString(iType) + "_" + IntToString(iIndex);
|
||||
oEncounter = GetObjectByTag(sEncounter);
|
||||
if (GetIsObjectValid(oEncounter))
|
||||
{
|
||||
iCount++;
|
||||
} else
|
||||
iFlag =0;
|
||||
iIndex++;
|
||||
if (iIndex > 1000)
|
||||
{
|
||||
iFlag = 0;
|
||||
}
|
||||
}
|
||||
iType++;
|
||||
}
|
||||
|
||||
return iCount;
|
||||
}
|
||||
|
||||
void SpawnMobs(string sZone, int iLevel)
|
||||
{
|
||||
string sTagBase;
|
||||
string sEncounter;
|
||||
int iRandom;
|
||||
int iFlag;
|
||||
int iIndex;
|
||||
int iArea;
|
||||
int iSpawned;
|
||||
location lEncounter;
|
||||
object oEncounter;
|
||||
object oCreature;
|
||||
object oArea;
|
||||
|
||||
//SendMessageToPC(GetFirstPC(),"Checking Zone");
|
||||
|
||||
sTagBase = sZone + "_S_";
|
||||
|
||||
iFlag = 1;
|
||||
iIndex = 1;
|
||||
|
||||
sEncounter = sTagBase + IntToString(iIndex);
|
||||
oEncounter = GetObjectByTag(sEncounter);
|
||||
if (GetIsObjectValid(oEncounter))
|
||||
{
|
||||
oArea=GetArea(oEncounter);
|
||||
iArea=GetIsAreaInterior(oArea);
|
||||
if (iArea == FALSE)
|
||||
SetCreatureTags(iLevel,0);
|
||||
else
|
||||
SetCreatureTags(iLevel,1);
|
||||
|
||||
iSpawned = GetLocalInt(oArea,"Spawned");
|
||||
while (iFlag == 1)
|
||||
{
|
||||
sEncounter = sTagBase + IntToString(iIndex);
|
||||
iIndex++;
|
||||
oEncounter = GetObjectByTag(sEncounter);
|
||||
//SendMessageToPC(GetFirstPC(),"Checking " + sEncounter);
|
||||
if (GetIsObjectValid(oEncounter))
|
||||
{
|
||||
if (iSpawned == 0)
|
||||
{
|
||||
SpawnMob(sEncounter);
|
||||
} else {
|
||||
iRandom = Random(4);
|
||||
if (iRandom > 0)
|
||||
SpawnMob(sEncounter);
|
||||
}
|
||||
} else {
|
||||
iFlag = 0;
|
||||
}
|
||||
if (iIndex > 1000)
|
||||
{
|
||||
iFlag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnMob(string sEncounter)
|
||||
{
|
||||
object oCreature;
|
||||
object oCreature2;
|
||||
object oSpawn;
|
||||
location lLoc;
|
||||
string sCreature;
|
||||
int iNewLevel;
|
||||
int iRace;
|
||||
int iFlag;
|
||||
int iRandom;
|
||||
|
||||
int iTest;
|
||||
|
||||
oCreature = GetObjectByTag(sEncounter + "_S");
|
||||
//oCreature2 = GetObjectByTag(sEncounter + "_W");
|
||||
//if (!GetIsObjectValid(oCreature) && !GetIsObjectValid(oCreature2))
|
||||
if (!GetIsObjectValid(oCreature))
|
||||
{
|
||||
sCreature=GetCreatureTag();
|
||||
oSpawn=GetCreature(sEncounter,sCreature);
|
||||
if (Random(5) == 0)
|
||||
SetLocalInt(oCreature,"Wander",Random(10)+1);
|
||||
|
||||
iRace = GetRacialType(oSpawn);
|
||||
iFlag = 0;
|
||||
switch (iRace)
|
||||
{
|
||||
case RACIAL_TYPE_DRAGON: case RACIAL_TYPE_DWARF: case RACIAL_TYPE_ELF:
|
||||
case RACIAL_TYPE_FEY: case RACIAL_TYPE_GIANT: case RACIAL_TYPE_GNOME:
|
||||
case RACIAL_TYPE_HALFELF: case RACIAL_TYPE_HALFLING: case RACIAL_TYPE_HALFORC:
|
||||
case RACIAL_TYPE_HUMAN: case RACIAL_TYPE_HUMANOID_GOBLINOID: case RACIAL_TYPE_HUMANOID_MONSTROUS:
|
||||
case RACIAL_TYPE_HUMANOID_ORC: case RACIAL_TYPE_HUMANOID_REPTILIAN: case RACIAL_TYPE_OUTSIDER:
|
||||
case RACIAL_TYPE_SHAPECHANGER: case RACIAL_TYPE_UNDEAD:
|
||||
iFlag = 1; break;
|
||||
}
|
||||
if (iFlag == 1)
|
||||
{
|
||||
iRandom = Random(100)+1;
|
||||
if (iRandom < (GetHitDice(oSpawn)/6 + 1))
|
||||
{
|
||||
if (Random(2)==0)
|
||||
CreateRandomItem(oSpawn);
|
||||
else
|
||||
GetMagicItem(oSpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int IsQuestCampUsed(string sZone, int iCamp)
|
||||
{
|
||||
string sBossTest;
|
||||
object oCreature;
|
||||
int iReturn;
|
||||
|
||||
sBossTest = sZone + "_Q" + IntToString(iCamp) + "_Boss_S";
|
||||
oCreature = GetObjectByTag(sBossTest);
|
||||
iReturn = FALSE;
|
||||
if (GetIsObjectValid(oCreature))
|
||||
iReturn=TRUE;
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
object SpawnQuestCamp(string sZone, int iCamp, int iLevel, int iLeader=0, string sCType = "")
|
||||
{
|
||||
int iFlag;
|
||||
int iIndex;
|
||||
int iType;
|
||||
int iBaseLevel;
|
||||
int iBase;
|
||||
int iBaseStart;
|
||||
int iBaseMax;
|
||||
int iCampType;
|
||||
int iArea;
|
||||
int iAltSpawn;
|
||||
int iSkip;
|
||||
string sEncounter;
|
||||
string sBossTest;
|
||||
string sCampType;
|
||||
string sCD;
|
||||
object oEncounter;
|
||||
object oCreature;
|
||||
object oBoss;
|
||||
object oMod;
|
||||
object oArea;
|
||||
location lEncounter;
|
||||
|
||||
oMod = GetModule();
|
||||
sEncounter = sZone + "_Q" + IntToString(iCamp) + "_Boss";
|
||||
oEncounter = GetObjectByTag(sEncounter);
|
||||
oArea = GetArea(oEncounter);
|
||||
|
||||
iArea=GetIsAreaInterior(oArea);
|
||||
iBaseLevel=iLevel;
|
||||
|
||||
if (iArea == FALSE)
|
||||
SetupCampTypes(iBaseLevel,1,0,0);
|
||||
else
|
||||
SetupCampTypes(iBaseLevel,1,1,0);
|
||||
|
||||
if (sCType == "")
|
||||
sCampType = GetCampType();
|
||||
else
|
||||
sCampType = GetSpecificCampType(sCType);
|
||||
|
||||
iBase = GetLocalInt(oMod,"iBase");
|
||||
iBaseStart = GetLocalInt(oMod,"iBaseStart");
|
||||
iBaseMax = GetLocalInt(oMod,"iBaseMax");
|
||||
iCampType = GetLocalInt(oMod,"iCampType");
|
||||
sCD = GetLocalString(oMod,"sCD");
|
||||
|
||||
//debug line
|
||||
//SendMessageToPC(GetFirstPC(),"Spawn Specific camptype " + sCampType + " at type " + IntToString(iCampType));
|
||||
|
||||
SetLocalInt(oMod,"iBase",0);
|
||||
SetLocalInt(oMod,"iBaseStart",0);
|
||||
SetLocalInt(oMod,"iBaseMax",0);
|
||||
SetLocalInt(oMod,"iCampType",0);
|
||||
SetLocalString(oMod,"sCD","");
|
||||
|
||||
sEncounter = sZone + "_Q" + IntToString(iCamp) + "_Boss";
|
||||
|
||||
oBoss = GetCampMob(99,sEncounter,sCampType,iBaseLevel,iBaseStart,iBase,iBaseMax,iCampType);
|
||||
|
||||
SetLocalString(oBoss,"CampType",sCampType);
|
||||
SetLocalInt(oBoss,"BaseLevel",iBaseLevel);
|
||||
SetLocalInt(oBoss,"iBase",iBase);
|
||||
SetLocalInt(oBoss,"iBaseStart",iBaseStart);
|
||||
SetLocalInt(oBoss,"iBaseMax",iBaseMax);
|
||||
SetLocalInt(oBoss,"iCampType",iCampType);
|
||||
SetLocalString(oBoss,"Description",sCD);
|
||||
iAltSpawn = 0;
|
||||
if (CheckHardcore())
|
||||
iAltSpawn = Random(3)+1;
|
||||
SetLocalInt(oBoss,"iAltSpawn",iAltSpawn);
|
||||
|
||||
iType = 1;
|
||||
while (iType <4)
|
||||
{
|
||||
iFlag = 1;
|
||||
iIndex = 1;
|
||||
while (iFlag == 1)
|
||||
{
|
||||
sEncounter = sZone + "_Q" + IntToString(iCamp) +
|
||||
"_T" + IntToString(iType) + "_" + IntToString(iIndex);
|
||||
oEncounter = GetObjectByTag(sEncounter);
|
||||
if (GetIsObjectValid(oEncounter))
|
||||
{
|
||||
if (iAltSpawn == 0)
|
||||
DelayCommand(0.5f,SpawnCampMob(iType,sEncounter,sCampType,iBaseLevel,iBaseStart,iBase,iBaseMax,iCampType));
|
||||
else
|
||||
{
|
||||
iSkip = FALSE;
|
||||
if (iAltSpawn == 1 && iIndex % 2 == 0)
|
||||
iSkip = TRUE;
|
||||
if (iAltSpawn == 2 && iIndex % 2 == 1)
|
||||
iSkip = TRUE;
|
||||
if (iAltSpawn == 3 && iIndex % 3 == 0)
|
||||
iSkip = TRUE;
|
||||
if (iSkip == FALSE)
|
||||
DelayCommand(0.5f,SpawnCampMob(iType,sEncounter,sCampType,iBaseLevel,iBaseStart,iBase,iBaseMax,iCampType));
|
||||
}
|
||||
} else
|
||||
iFlag =0;
|
||||
iIndex++;
|
||||
if (iIndex > 1000)
|
||||
{
|
||||
iFlag = 0;
|
||||
}
|
||||
}
|
||||
iType++;
|
||||
}
|
||||
|
||||
return oBoss;
|
||||
}
|
||||
|
Reference in New Issue
Block a user