1051 lines
28 KiB
Plaintext
1051 lines
28 KiB
Plaintext
|
#include "rd_spawnzones"
|
||
|
#include "prc_inc_racial"
|
||
|
#include "utl_i_sqluuid"
|
||
|
#include "utl_i_sqlocals"
|
||
|
|
||
|
void CheckQuest();
|
||
|
void CheckRandomEncounter();
|
||
|
void SummonRace(object oPC,location lLoc,int iLevel);
|
||
|
void CheckPCAttackers();
|
||
|
void RemoveLoot();
|
||
|
void RemoveAreaLoot(object oArea);
|
||
|
void RemoveLootFromRemains(object oContainer);
|
||
|
void ForceCameraMode();
|
||
|
void SummonGood(object oPC);
|
||
|
void SummonRndCreature(int iLevel,location lLoc);
|
||
|
void GetCurse(object oPC);
|
||
|
void PCCursed();
|
||
|
void PCHunted();
|
||
|
void GetEnemy(object oPC);
|
||
|
void CampRandom();
|
||
|
void CampRandomAction(object oBoss,object oPC,string sCampType,string sZone);
|
||
|
void WorldEvent();
|
||
|
string GetRandomRaceType();
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
int iHeartbeat;
|
||
|
int iHeartbeatCheck;
|
||
|
|
||
|
iHeartbeat = SQLocals_GetInt(GetModule(),"Heartbeat");
|
||
|
iHeartbeat++;
|
||
|
SQLocals_SetInt(GetModule(),"Heartbeat",iHeartbeat);
|
||
|
|
||
|
iHeartbeatCheck = iHeartbeat % 150;
|
||
|
|
||
|
if (iHeartbeatCheck == 149)
|
||
|
{
|
||
|
RespawnCamps();
|
||
|
}
|
||
|
|
||
|
|
||
|
iHeartbeatCheck = iHeartbeat % 60;
|
||
|
if (iHeartbeatCheck == 59)
|
||
|
{
|
||
|
DelayCommand(0.0f, RemoveLoot());
|
||
|
}
|
||
|
|
||
|
iHeartbeatCheck = iHeartbeat % 20;
|
||
|
if (iHeartbeatCheck == 19)
|
||
|
{
|
||
|
ZoneRandom();
|
||
|
}
|
||
|
|
||
|
iHeartbeatCheck = iHeartbeat % 60;
|
||
|
if (iHeartbeatCheck == 59)
|
||
|
{
|
||
|
DelayCommand(0.0f, PCCursed());
|
||
|
}
|
||
|
|
||
|
iHeartbeatCheck = iHeartbeat % 30;
|
||
|
if (iHeartbeatCheck == 29)
|
||
|
{
|
||
|
DelayCommand(0.0f, PCHunted() );
|
||
|
}
|
||
|
|
||
|
iHeartbeatCheck = iHeartbeat % 25;
|
||
|
if (iHeartbeatCheck == 12)
|
||
|
{
|
||
|
DelayCommand(0.0f, CampRandom() );
|
||
|
}
|
||
|
|
||
|
iHeartbeatCheck = iHeartbeat % 50;
|
||
|
if (iHeartbeatCheck == 49)
|
||
|
{
|
||
|
DelayCommand(0.0f, WorldEvent());
|
||
|
}
|
||
|
|
||
|
|
||
|
DelayCommand(0.0f, CheckRandomEncounter());
|
||
|
DelayCommand(0.0f, CheckPCAttackers());
|
||
|
DelayCommand(0.0f, CheckQuest());
|
||
|
//ForceCameraMode();
|
||
|
}
|
||
|
|
||
|
void CheckQuest()
|
||
|
{
|
||
|
int iQuestType;
|
||
|
int iFlag;
|
||
|
string sQuestTargetMob;
|
||
|
object oPC;
|
||
|
object oLastPC;
|
||
|
object oTarget;
|
||
|
|
||
|
oPC=GetFirstPC();
|
||
|
iFlag = 0;
|
||
|
|
||
|
while (iFlag == 0)
|
||
|
{
|
||
|
iQuestType = SQLocalsUUID_GetInt(oPC,"QuestType");
|
||
|
if (iQuestType == 1 && SQLocalsUUID_GetInt(oPC,"QuestTargetMobDead") == 0)
|
||
|
{
|
||
|
sQuestTargetMob = GetLocalString(oPC,"QuestTargetMob");
|
||
|
oTarget = GetObjectByTag(sQuestTargetMob);
|
||
|
if (!GetIsObjectValid(oTarget))
|
||
|
{
|
||
|
SetCustomToken(105,GetLocalString(oPC,"Token105"));
|
||
|
SetCustomToken(101,GetLocalString(oPC,"Token101"));
|
||
|
SetCustomToken(104,GetLocalString(oPC,"Token104"));
|
||
|
SetCustomToken(106,GetLocalString(oPC,"Token106"));
|
||
|
if (GetLocalString(oPC,"QuestItemTag") == "")
|
||
|
{
|
||
|
AddJournalQuestEntry("jCamp",10,oPC);
|
||
|
} else {
|
||
|
if (SQLocalsUUID_GetInt(oPC,"OverallQuest") == 100)
|
||
|
{
|
||
|
AddJournalQuestEntry("jOverall",2,oPC);
|
||
|
}
|
||
|
else if (SQLocalsUUID_GetInt(oPC,"OverallQuest") == 110)
|
||
|
{
|
||
|
AddJournalQuestEntry("jOverall",5,oPC);
|
||
|
}
|
||
|
else if (SQLocalsUUID_GetInt(oPC,"OverallQuest") == 120)
|
||
|
{
|
||
|
AddJournalQuestEntry("jOverall",8,oPC);
|
||
|
}
|
||
|
else if (SQLocalsUUID_GetInt(oPC,"OverallQuest") == 130)
|
||
|
{
|
||
|
AddJournalQuestEntry("jOverall",11,oPC);
|
||
|
}
|
||
|
else if (SQLocalsUUID_GetInt(oPC,"OverallQuest") == 131)
|
||
|
{
|
||
|
AddJournalQuestEntry("jOverall",13,oPC);
|
||
|
}
|
||
|
else if (SQLocalsUUID_GetInt(oPC,"QuestItemUnknown") == 0)
|
||
|
{
|
||
|
AddJournalQuestEntry("jCamp",11,oPC);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SetCustomToken(104,"item");
|
||
|
AddJournalQuestEntry("jCamp",11,oPC);
|
||
|
}
|
||
|
}
|
||
|
SetLocalInt(oPC,"QuestTargetMobDead",1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Make sure no one is kos to the dark agents
|
||
|
if (GetIsEnemy(GetObjectByTag("rp1_evilquest")))
|
||
|
AdjustReputation(oPC,GetObjectByTag("rp1_evilquest"),50);
|
||
|
|
||
|
oLastPC = oPC;
|
||
|
oPC = GetNextPC();
|
||
|
if (GetName(oLastPC) == GetName(oPC))
|
||
|
iFlag = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CheckRandomEncounter()
|
||
|
{
|
||
|
object oPC;
|
||
|
object oArea;
|
||
|
vector vPC;
|
||
|
vector vNew;
|
||
|
location lLoc;
|
||
|
string sCreature;
|
||
|
int iArea;
|
||
|
int iEncounter;
|
||
|
int iPCEncounter;
|
||
|
int iRandom;
|
||
|
int iRandom2;
|
||
|
int iRndX;
|
||
|
int iRndY;
|
||
|
int iLevel;
|
||
|
int iSpot;
|
||
|
int iPCCount;
|
||
|
int iDeathAllowed;
|
||
|
int iDeathAdjust;
|
||
|
int iAdjustedLevel;
|
||
|
int iChance;
|
||
|
|
||
|
oPC = GetRandomPC();
|
||
|
oArea = GetArea(oPC);
|
||
|
iEncounter = GetLocalInt(oArea,"RandomEncounter");
|
||
|
iPCEncounter = SQLocalsUUID_GetInt(oPC,"NoRandomEncounter");
|
||
|
|
||
|
if (iEncounter == 1 && iPCEncounter == 0)
|
||
|
{
|
||
|
iChance = 50;
|
||
|
if (SQLocalsUUID_GetInt(oPC,"Unlucky")==1 || SQLocalsUUID_GetInt(oPC,"Cursed")==1)
|
||
|
iChance = 30;
|
||
|
if (GetLocalInt(GetModule(),"MonsterStorm") == 1)
|
||
|
iChance = 20;
|
||
|
iRandom = Random(iChance);
|
||
|
|
||
|
//iRandom = 0;
|
||
|
|
||
|
if (iRandom == 0)
|
||
|
{
|
||
|
iSpot=Random(25)+1;
|
||
|
if (iSpot<=GetAbilityScore(oPC,ABILITY_WISDOM))
|
||
|
{
|
||
|
SendMessageToPC(oPC,"You hear a strange rustling nearby...");
|
||
|
}
|
||
|
vPC = GetPosition(oPC);
|
||
|
iRndX = Random(8) + 4;
|
||
|
iRndY = Random(8) + 4;
|
||
|
if (Random(2) == 1) iRndX=iRndX * -1;
|
||
|
if (Random(2) == 1) iRndY=iRndY * -1;
|
||
|
vNew = vPC + Vector( iRndX/1.0, iRndY/1.0, 0.0 );
|
||
|
lLoc = Location(GetArea(oPC), vNew, VectorToAngle( -1.0 * vNew ) );
|
||
|
|
||
|
iLevel = GetHitDice(oPC);
|
||
|
iAdjustedLevel = AdjustLevel(iLevel);
|
||
|
iAdjustedLevel = ZoneLevel(GetArea(oPC),iAdjustedLevel);
|
||
|
|
||
|
iRandom = Random(10)+1;
|
||
|
switch (iRandom)
|
||
|
{
|
||
|
case 1: case 2: SummonAnimal(lLoc,iAdjustedLevel); break;
|
||
|
case 3: case 4: SummonAnything(oPC,lLoc,iAdjustedLevel); break;
|
||
|
case 5: case 9: DelayCommand(0.0f, SummonRace(oPC,lLoc,iAdjustedLevel)); break;
|
||
|
case 6: if (iAdjustedLevel < 15)
|
||
|
{
|
||
|
GetRaceCreatures("bandit",lLoc,iAdjustedLevel);
|
||
|
} else {
|
||
|
GetRaceCreatures("merc",lLoc,iAdjustedLevel);
|
||
|
}
|
||
|
break;
|
||
|
case 7: if (GetIsNight())
|
||
|
{
|
||
|
if (iLevel < 10)
|
||
|
{
|
||
|
iRandom2 = Random(2) + 1;
|
||
|
switch (iRandom2)
|
||
|
{
|
||
|
case 1: GetRaceCreatures("duergar",lLoc,iAdjustedLevel); break;
|
||
|
case 2: GetRaceCreatures("skeleton",lLoc,iAdjustedLevel); break;
|
||
|
}
|
||
|
} else {
|
||
|
iRandom2 = Random(3) + 1;
|
||
|
switch (iRandom2)
|
||
|
{
|
||
|
case 1: GetRaceCreatures("drow",lLoc,iAdjustedLevel); break;
|
||
|
case 2: GetRaceCreatures("vampire",lLoc,iAdjustedLevel); break;
|
||
|
case 3: GetRaceCreatures("duergar",lLoc,iAdjustedLevel); break;
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
SummonInsect(lLoc,iAdjustedLevel); break;
|
||
|
}
|
||
|
break;
|
||
|
case 8: DelayCommand(0.0f, SummonGood(oPC)); break;
|
||
|
case 10: DelayCommand(0.0f, SummonRndCreature(iAdjustedLevel,lLoc)); break;
|
||
|
/*case 3: case 4: SummonAnimal(oLoc,iLevel); break;
|
||
|
case 5: case 6: SummonCreature(oLoc,iLevel); break;
|
||
|
case 7: case 8: SummonBandits(oLoc,iLevel); break;
|
||
|
case 9: case 10: SummonInsect(oLoc,iLevel); break;*/
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void SummonRace(object oPC,location lLoc,int iLevel)
|
||
|
{
|
||
|
object oArea;
|
||
|
int iArea;
|
||
|
int iRandom;
|
||
|
int iIndex;
|
||
|
string sCampType;
|
||
|
|
||
|
if ((SQLocalsUUID_GetInt(oPC,"EvilPath") > 0 || SQLocalsUUID_GetInt(oPC,"Monstrous") == 1) && Random(3) == 0)
|
||
|
{
|
||
|
iRandom=Random(3)+1;
|
||
|
switch (iRandom)
|
||
|
{
|
||
|
case 1: sCampType="elf"; break;
|
||
|
case 2: sCampType="dwarf"; break;
|
||
|
case 3: sCampType="halfling"; break;
|
||
|
}
|
||
|
} else {
|
||
|
oArea=GetArea(oPC);
|
||
|
iArea=GetIsAreaInterior(oArea);
|
||
|
if (iArea == FALSE)
|
||
|
SetupCampTypes(iLevel, 1, 0, 1, 1);
|
||
|
else
|
||
|
SetupCampTypes(iLevel, 1, 1, 1, 1);
|
||
|
|
||
|
sCampType = GetCampType();
|
||
|
}
|
||
|
|
||
|
iIndex = 0;
|
||
|
iRandom = Random(4)+1;
|
||
|
if (iRandom > 2 && iLevel < 3)
|
||
|
iRandom = 2;
|
||
|
if (iRandom == 4 && iLevel < 7)
|
||
|
iRandom = 3;
|
||
|
|
||
|
while (iIndex < iRandom)
|
||
|
{
|
||
|
GetRaceCreature(sCampType,lLoc,iLevel);
|
||
|
iIndex++;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void CheckPCAttackers()
|
||
|
{
|
||
|
int iFlag;
|
||
|
object oPC;
|
||
|
object oLastPC;
|
||
|
string sCampType;
|
||
|
vector vPC;
|
||
|
vector vNew;
|
||
|
location lLoc;
|
||
|
int iSpot;
|
||
|
int iRndX;
|
||
|
int iRndY;
|
||
|
int iLevel;
|
||
|
int iChance;
|
||
|
object oArea;
|
||
|
int iEncounter;
|
||
|
int iPCEncounter;
|
||
|
int iAttacked;
|
||
|
int iPCCount;
|
||
|
|
||
|
oPC=GetFirstPC();
|
||
|
iFlag = 0;
|
||
|
//object GetRaceCreature(string sCampType,location lLoc, int iLevel)
|
||
|
|
||
|
while (iFlag == 0)
|
||
|
{
|
||
|
sCampType=GetLocalString(oPC,"QuestAttackers");
|
||
|
if (!(sCampType == ""))
|
||
|
{
|
||
|
oArea = GetArea(oPC);
|
||
|
iEncounter = GetLocalInt(oArea,"RandomEncounter");
|
||
|
iPCEncounter = SQLocalsUUID_GetInt(oPC,"NoRandomEncounter");
|
||
|
|
||
|
if (iEncounter == 1 && iPCEncounter == 0)
|
||
|
{
|
||
|
iAttacked = SQLocalsUUID_GetInt(oPC,"QuestAttacked");
|
||
|
iPCCount = GetPCCount(oPC);
|
||
|
iChance = 10 + iAttacked * 2 + ((iPCCount-1 + iAttacked) * 2);
|
||
|
if (Random(iChance) == 0)
|
||
|
{
|
||
|
iAttacked++;
|
||
|
SetLocalInt(oPC,"QuestAttacked",iAttacked);
|
||
|
iSpot=Random(25)+1;
|
||
|
if (iSpot<=GetAbilityScore(oPC,ABILITY_WISDOM))
|
||
|
{
|
||
|
SendMessageToPC(oPC,"You hear something nearby...");
|
||
|
}
|
||
|
vPC = GetPosition(oPC);
|
||
|
iRndX = Random(8) + 4;
|
||
|
iRndY = Random(8) + 4;
|
||
|
if (Random(2) == 1) iRndX=iRndX * -1;
|
||
|
if (Random(2) == 1) iRndY=iRndY * -1;
|
||
|
vNew = vPC + Vector( iRndX/1.0, iRndY/1.0, 0.0 );
|
||
|
lLoc = Location(GetArea(oPC), vNew, VectorToAngle( -1.0 * vNew ) );
|
||
|
|
||
|
iLevel = GetHitDice(oPC);
|
||
|
iLevel = ZoneLevel(GetArea(oPC),iLevel);
|
||
|
|
||
|
GetRaceCreature(sCampType,lLoc,iLevel);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
oLastPC = oPC;
|
||
|
oPC = GetNextPC();
|
||
|
if (GetName(oLastPC) == GetName(oPC))
|
||
|
iFlag = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void RemoveLoot()
|
||
|
{
|
||
|
object oPC;
|
||
|
object oLastPC;
|
||
|
object oArea;
|
||
|
string sLastArea;
|
||
|
int iFlag;
|
||
|
int iLevel;
|
||
|
|
||
|
|
||
|
oPC=GetFirstPC();
|
||
|
iFlag = 0;
|
||
|
|
||
|
while (iFlag == 0)
|
||
|
{
|
||
|
|
||
|
oArea = GetArea(oPC);
|
||
|
if (!(GetTag(oArea) == sLastArea))
|
||
|
DelayCommand(0.0f, RemoveAreaLoot(oArea));
|
||
|
|
||
|
oLastPC = oPC;
|
||
|
sLastArea = GetTag(oArea);
|
||
|
oPC = GetNextPC();
|
||
|
|
||
|
if (GetName(oLastPC) == GetName(oPC))
|
||
|
{
|
||
|
iFlag = 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void RemoveAreaLoot(object oArea)
|
||
|
{
|
||
|
object oItem;
|
||
|
object oLastItem;
|
||
|
int iFlag;
|
||
|
int iDeleteFlag;
|
||
|
|
||
|
iFlag = 0;
|
||
|
|
||
|
oItem = GetFirstObjectInArea(oArea);
|
||
|
|
||
|
while (iFlag == 0)
|
||
|
{
|
||
|
if (GetName(oItem) == "Remains")
|
||
|
{
|
||
|
iDeleteFlag = GetLocalInt(oItem,"DeleteRemains");
|
||
|
if (iDeleteFlag == 1)
|
||
|
{
|
||
|
DelayCommand(0.0f, RemoveLootFromRemains(oItem));
|
||
|
DestroyObject(oItem);
|
||
|
} else {
|
||
|
SetLocalInt(oItem,"DeleteRemains",1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
oLastItem = oItem;
|
||
|
oItem = GetNextObjectInArea(oArea);
|
||
|
if (oLastItem == oItem)
|
||
|
iFlag = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void RemoveLootFromRemains(object oContainer)
|
||
|
{
|
||
|
object oItem;
|
||
|
object oLastItem;
|
||
|
int iFlag;
|
||
|
int iDeleteFlag;
|
||
|
|
||
|
iFlag = 0;
|
||
|
|
||
|
oItem = GetFirstItemInInventory(oContainer);
|
||
|
|
||
|
while (iFlag == 0)
|
||
|
{
|
||
|
DestroyObject(oItem);
|
||
|
|
||
|
oLastItem = oItem;
|
||
|
oItem = GetNextItemInInventory(oContainer);
|
||
|
|
||
|
if (oLastItem == oItem)
|
||
|
iFlag = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void ForceCameraMode()
|
||
|
{
|
||
|
int iFlag;
|
||
|
int iRacialType;
|
||
|
object oPC;
|
||
|
object oLastPC;
|
||
|
int iFP;
|
||
|
|
||
|
iFP = GetCampaignInt("EndlessNightsIII","E3FirstPerson");
|
||
|
oPC=GetFirstPC();
|
||
|
iFlag = 0;
|
||
|
|
||
|
while (iFlag == 0)
|
||
|
{
|
||
|
if (SQLocalsUUID_GetInt(oPC,"FirstPerson") == 1 || iFP == 1)
|
||
|
{
|
||
|
iRacialType = MyPRCGetRacialType(oPC);
|
||
|
SetCameraMode(oPC,CAMERA_MODE_STIFF_CHASE_CAMERA);
|
||
|
if (iRacialType == RACIAL_TYPE_HALFLING || iRacialType == RACIAL_TYPE_GNOME || iRacialType == RACIAL_TYPE_DWARF)
|
||
|
SetCameraHeight(oPC,2.0);
|
||
|
else
|
||
|
SetCameraHeight(oPC,2.5);
|
||
|
AssignCommand(oPC,SetCameraFacing(-1.0,4.0,80.0));
|
||
|
AssignCommand(oPC,SetCameraFacing(GetFacing(oPC),4.0,80.0));
|
||
|
}
|
||
|
|
||
|
oLastPC = oPC;
|
||
|
oPC = GetNextPC();
|
||
|
|
||
|
if (GetName(oLastPC) == GetName(oPC))
|
||
|
{
|
||
|
iFlag = 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void SummonGood(object oPC)
|
||
|
{
|
||
|
vector vPC;
|
||
|
vector vNew;
|
||
|
location lLoc;
|
||
|
int iRndX;
|
||
|
int iRndY;
|
||
|
int iLevel;
|
||
|
int iRandom;
|
||
|
string sArea;
|
||
|
string sRace;
|
||
|
string sEvilRace;
|
||
|
|
||
|
vPC = GetPosition(oPC);
|
||
|
iRndX = Random(4) + 8;
|
||
|
iRndY = Random(4) + 8;
|
||
|
if (Random(2) == 1) iRndX=iRndX * -1;
|
||
|
if (Random(2) == 1) iRndY=iRndY * -1;
|
||
|
vNew = vPC + Vector( iRndX/1.0, iRndY/1.0, 0.0 );
|
||
|
lLoc = Location(GetArea(oPC), vNew, VectorToAngle( -1.0 * vNew ) );
|
||
|
iLevel = GetHitDice(oPC);
|
||
|
sArea = GetZone(oPC);
|
||
|
iLevel = ZoneLevel(GetArea(oPC),iLevel);
|
||
|
|
||
|
sRace = "human";
|
||
|
iRandom = Random(3)+1;
|
||
|
switch (iRandom)
|
||
|
{
|
||
|
case 1: sRace == "elf"; break;
|
||
|
case 2: sRace == "dwarf"; break;
|
||
|
case 3: sRace == "human"; break;
|
||
|
}
|
||
|
|
||
|
if (iLevel < 5)
|
||
|
if (Random(3)==0)
|
||
|
sRace = "halfling";
|
||
|
|
||
|
if (iLevel>24)
|
||
|
if (Random(4)==0)
|
||
|
sRace = "angelic";
|
||
|
|
||
|
GetRaceCreatures(sRace,lLoc,iLevel);
|
||
|
|
||
|
iRandom=Random(2)+1;
|
||
|
|
||
|
if (iRandom == 1)
|
||
|
{
|
||
|
if (Random(2) == 0)
|
||
|
{
|
||
|
SummonAnything(oPC,lLoc,iLevel);
|
||
|
} else {
|
||
|
sEvilRace = "bandit";
|
||
|
if (iLevel > 9 && iLevel < 20)
|
||
|
sEvilRace = "mercenary";
|
||
|
if (iLevel>19)
|
||
|
sEvilRace = "shade";
|
||
|
if (sRace == "elf")
|
||
|
sEvilRace = "drow";
|
||
|
if (sRace == "dwarf")
|
||
|
sEvilRace = "duergar";
|
||
|
if (sRace == "angelic")
|
||
|
sEvilRace = "fiend";
|
||
|
GetRaceCreatures(sEvilRace,lLoc,iLevel);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void SummonRndCreature(int iLevel,location lLoc)
|
||
|
{
|
||
|
int iIndex;
|
||
|
int iRandom;
|
||
|
string sTag;
|
||
|
|
||
|
sTag = GetRndCreature(iLevel);
|
||
|
iIndex = 0;
|
||
|
iRandom = Random(3)+2;
|
||
|
|
||
|
if (iRandom > 2 && iLevel < 3)
|
||
|
iRandom = 2;
|
||
|
if (iRandom == 4 && iLevel < 7)
|
||
|
iRandom = 3;
|
||
|
while (iIndex < iRandom)
|
||
|
{
|
||
|
CreateObject(OBJECT_TYPE_CREATURE,sTag,lLoc);
|
||
|
iIndex++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void PCCursed()
|
||
|
{
|
||
|
object oPC = GetFirstPC();
|
||
|
object oLastPC;
|
||
|
int iFlag = 0;
|
||
|
|
||
|
while (iFlag == 0)
|
||
|
{
|
||
|
if (SQLocalsUUID_GetInt(oPC,"Cursed")==1)
|
||
|
DelayCommand(0.0f, GetCurse(oPC));
|
||
|
oLastPC = oPC;
|
||
|
oPC = GetNextPC();
|
||
|
if (GetIsObjectValid(oPC) == FALSE)
|
||
|
iFlag = 1;
|
||
|
if (GetName(oPC) == GetName(oLastPC))
|
||
|
iFlag = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void GetCurse(object oPC)
|
||
|
{
|
||
|
int iRandom;
|
||
|
int iRandom2;
|
||
|
int iRandom3;
|
||
|
int iX;
|
||
|
string sMessage;
|
||
|
string sType;
|
||
|
effect eEffect;
|
||
|
|
||
|
iRandom = Random(3);
|
||
|
if (iRandom == 0 )
|
||
|
{
|
||
|
iRandom2 = Random(7)+1;
|
||
|
switch (iRandom2)
|
||
|
{
|
||
|
case 1: eEffect = EffectDamage(1,DAMAGE_TYPE_BLUDGEONING);
|
||
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPC);
|
||
|
sMessage = "You stump your toe.";
|
||
|
break;
|
||
|
case 2: iRandom3 = Random(6)+1;
|
||
|
switch (iRandom3)
|
||
|
{
|
||
|
case 1: iX = DISEASE_BLINDING_SICKNESS; sType = "Blinding Sickness"; break;
|
||
|
case 2: iX = DISEASE_BURROW_MAGGOTS; sType = "Burrow Maggots"; break;
|
||
|
case 3: iX = DISEASE_DEMON_FEVER; sType = "Demon Fever"; break;
|
||
|
case 4: iX = DISEASE_DREAD_BLISTERS; sType = "Dread Blisters"; break;
|
||
|
case 5: iX = DISEASE_RED_ACHE; sType = "the Red Ache"; break;
|
||
|
case 6: iX = DISEASE_SHAKES; sType = "the Shakes"; break;
|
||
|
}
|
||
|
eEffect = EffectDisease(iX);
|
||
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPC);
|
||
|
sMessage = "You develop " + sType + ".";
|
||
|
break;
|
||
|
case 3: eEffect = EffectCurse(Random(3),Random(3),Random(3),Random(3),Random(3),Random(3));
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eEffect,oPC,120.0f);
|
||
|
sMessage = "You feel the curse coming over you.";
|
||
|
break;
|
||
|
case 4: eEffect = EffectConfused();
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eEffect,oPC,10.0f);
|
||
|
sMessage = "You feel confused.";
|
||
|
break;
|
||
|
case 5: eEffect = EffectBlindness();
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eEffect,oPC,30.0f);
|
||
|
sMessage = "You lose your vision.";
|
||
|
break;
|
||
|
case 6: eEffect = EffectFrightened();
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eEffect,oPC,30.0f);
|
||
|
sMessage = "You are suddenly very scared.";
|
||
|
break;
|
||
|
case 7: eEffect = EffectKnockdown();
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eEffect,oPC,3.0f);
|
||
|
sMessage = "You trip.";
|
||
|
break;
|
||
|
}
|
||
|
SendMessageToPC(oPC,sMessage);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void PCHunted()
|
||
|
{
|
||
|
object oPC = GetFirstPC();
|
||
|
object oLastPC;
|
||
|
int iFlag = 0;
|
||
|
|
||
|
while (iFlag == 0)
|
||
|
{
|
||
|
if (SQLocalsUUID_GetInt(oPC,"Enemy")>0)
|
||
|
DelayCommand(0.0f, GetEnemy(oPC) );
|
||
|
oLastPC = oPC;
|
||
|
oPC = GetNextPC();
|
||
|
if (GetIsObjectValid(oPC) == FALSE)
|
||
|
iFlag = 1;
|
||
|
if (GetName(oPC) == GetName(oLastPC))
|
||
|
iFlag = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void GetEnemy(object oPC)
|
||
|
{
|
||
|
int iRandom;
|
||
|
int iEnemy;
|
||
|
int iEncounter;
|
||
|
string sTag;
|
||
|
vector vPC;
|
||
|
vector vNew;
|
||
|
location lLoc;
|
||
|
int iRndX;
|
||
|
int iRndY;
|
||
|
int iLevel;
|
||
|
int iLevels;
|
||
|
object oCreature;
|
||
|
|
||
|
iEncounter = GetLocalInt(GetArea(oPC),"RandomEncounter");
|
||
|
|
||
|
iRandom = Random(4);
|
||
|
|
||
|
if (iRandom == 0 && iEncounter == 1)
|
||
|
{
|
||
|
iEnemy = SQLocalsUUID_GetInt(oPC,"Enemy");
|
||
|
switch (iEnemy)
|
||
|
{
|
||
|
case 1: sTag = "en3_redwizard"; break;
|
||
|
case 2: sTag = "en3_theives"; break;
|
||
|
case 3: sTag = "en3_merchant"; break;
|
||
|
case 4: sTag = "en4_adventurer" + IntToString(Random(4)+1); break;
|
||
|
}
|
||
|
sTag = sTag + IntToString(Random(3)+1);
|
||
|
|
||
|
vPC = GetPosition(oPC);
|
||
|
iRndX = Random(4) + 8;
|
||
|
iRndY = Random(4) + 8;
|
||
|
if (Random(2) == 1) iRndX=iRndX * -1;
|
||
|
if (Random(2) == 1) iRndY=iRndY * -1;
|
||
|
vNew = vPC + Vector( iRndX/1.0, iRndY/1.0, 0.0 );
|
||
|
lLoc = Location(GetArea(oPC), vNew, VectorToAngle( -1.0 * vNew ) );
|
||
|
|
||
|
if (sTag == "en3_redwizard")
|
||
|
{
|
||
|
effect eVFX = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
|
||
|
AssignCommand(OBJECT_SELF, DelayCommand(0.1f, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLoc)));
|
||
|
}
|
||
|
|
||
|
oCreature=CreateObject(OBJECT_TYPE_CREATURE,sTag,lLoc);
|
||
|
|
||
|
iLevel = GetHitDice(oPC);
|
||
|
iLevel = ZoneLevel(GetArea(oPC),iLevel);
|
||
|
iLevels = iLevel - 2 + Random(3);
|
||
|
if (iLevels>0)
|
||
|
iLevel = LevelMob(oCreature,iLevels);
|
||
|
|
||
|
AssignCommand(oCreature,ActionRest());
|
||
|
|
||
|
if (iLevel > 1)
|
||
|
EquipMob(oCreature);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CampRandom()
|
||
|
{
|
||
|
object oPC;
|
||
|
object oBoss;
|
||
|
string sZone;
|
||
|
string sTag;
|
||
|
string sCampType;
|
||
|
int iCount;
|
||
|
int iCamps;
|
||
|
int iCampType;
|
||
|
int iChance;
|
||
|
|
||
|
oPC = GetRandomPC();
|
||
|
|
||
|
sZone = GetZone(oPC);
|
||
|
iCamps = GetMaxCampSpots(sZone);
|
||
|
iCount = 0;
|
||
|
|
||
|
while (iCount < iCamps)
|
||
|
{
|
||
|
iCount++;
|
||
|
sTag = sZone + "_C" + IntToString(iCount) + "_Boss_S";
|
||
|
oBoss = GetObjectByTag(sTag);
|
||
|
iChance = 20 - CampPoints(sZone, iCount);
|
||
|
if (iChance < 5)
|
||
|
iChance == 5;
|
||
|
if (GetIsObjectValid(oBoss))
|
||
|
{
|
||
|
iCampType= GetLocalInt(oBoss,"iCampType");
|
||
|
if (Random(iChance) < 1 && iCampType == 1)
|
||
|
{
|
||
|
sCampType = GetLocalString(oBoss,"CampType");
|
||
|
WriteTimestampedLogEntry("Camp " + sZone + "_C" + IntToString(iCount) + " led by a " + GetName(oBoss) + " doing random action.");
|
||
|
DelayCommand(0.0f, CampRandomAction(oBoss,oPC,sCampType,sZone));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void CampRandomAction(object oBoss,object oPC,string sCampType,string sZone)
|
||
|
{
|
||
|
int iRandom;
|
||
|
int iLevel;
|
||
|
int iMobLevel;
|
||
|
int iNumber;
|
||
|
int iCount;
|
||
|
int iSpot;
|
||
|
int iX;
|
||
|
int iCamps;
|
||
|
int iFlag;
|
||
|
location lLoc;
|
||
|
location lLoc2;
|
||
|
object oCreature;
|
||
|
object oWP;
|
||
|
string sTag;
|
||
|
|
||
|
iRandom = Random(3)+1;
|
||
|
|
||
|
//If last attacked a camp then keep at it
|
||
|
if (GetLocalInt(oBoss,"EN4CampAttack") == 1)
|
||
|
iRandom = 3;
|
||
|
|
||
|
//If last camp attack check led to no camps then attack pc or move to x-spot
|
||
|
if (GetLocalInt(oBoss,"EN4CampAttack") == 2)
|
||
|
{
|
||
|
iRandom = Random(2)+1;
|
||
|
SetLocalInt(oBoss,"EN4CampAttack",0);
|
||
|
}
|
||
|
//iRandom=1;
|
||
|
//SetLocalInt(oBoss,"EN4CampAttack",2);
|
||
|
iLevel = GetHitDice(oPC);
|
||
|
iLevel = ZoneLevel(GetArea(oPC),iLevel);
|
||
|
|
||
|
if (iLevel<5)
|
||
|
iNumber = Random(2)+1;
|
||
|
else if (iLevel < 10)
|
||
|
iNumber = Random(3)+1;
|
||
|
else
|
||
|
iNumber = Random(4)+1;
|
||
|
|
||
|
if (iRandom == 1) //Assassinate PC
|
||
|
{
|
||
|
if (GetIsEnemy(oPC,oBoss))
|
||
|
{
|
||
|
lLoc = GetLocation(oBoss);
|
||
|
iCount = 0;
|
||
|
while (iCount < iNumber)
|
||
|
{
|
||
|
iCount++;
|
||
|
sTag = "en3_" + sCampType + "_" + "r_1";
|
||
|
oCreature = CreateObject(OBJECT_TYPE_CREATURE,sTag,lLoc);
|
||
|
if (!GetIsObjectValid(oCreature))
|
||
|
WriteTimestampedLogEntry("ERROR: Failed to Create " + sTag + " in CampRandom code.");
|
||
|
iMobLevel = Random(5) - 2 + iLevel;
|
||
|
if (iMobLevel>1)
|
||
|
{
|
||
|
LevelMob(oCreature,iMobLevel-1);
|
||
|
EquipMob(oCreature);
|
||
|
}
|
||
|
DelayCommand(1.0f,AssignCommand(oCreature,ActionMoveToObject(oPC,TRUE)));
|
||
|
DelayCommand(10.0f,AssignCommand(oCreature,ActionMoveToObject(oPC,TRUE)));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (iRandom == 2) //Populate X Spot
|
||
|
{
|
||
|
lLoc = GetLocation(oBoss);
|
||
|
iX = GetXSpot(sZone);
|
||
|
iSpot = Random(iX)+1;
|
||
|
sTag = sZone + "_X_" + IntToString(iSpot);
|
||
|
lLoc2 = GetLocation(GetObjectByTag(sTag));
|
||
|
iCount = 0;
|
||
|
while (iCount < iNumber)
|
||
|
{
|
||
|
iCount++;
|
||
|
sTag = "en3_" + sCampType + "_" + GetRandomRaceType() + "_1";
|
||
|
oCreature = CreateObject(OBJECT_TYPE_CREATURE,sTag,lLoc);
|
||
|
if (!GetIsObjectValid(oCreature))
|
||
|
WriteTimestampedLogEntry("ERROR: Failed to Create " + sTag + " in CampRandom code.");
|
||
|
iMobLevel = Random(5) - 2 + iLevel;
|
||
|
if (iMobLevel>1)
|
||
|
{
|
||
|
LevelMob(oCreature,iMobLevel-1);
|
||
|
EquipMob(oCreature);
|
||
|
}
|
||
|
DelayCommand(1.0f,AssignCommand(oCreature,ActionMoveToLocation(lLoc2,TRUE)));
|
||
|
DelayCommand(10.0f,AssignCommand(oCreature,ActionMoveToLocation(lLoc2,TRUE)));
|
||
|
}
|
||
|
}
|
||
|
else if (iRandom == 3) //Raid other Camp or Town
|
||
|
{
|
||
|
lLoc = GetLocation(oBoss);
|
||
|
iCamps = GetMaxCampSpots(sZone);
|
||
|
iCount = 0;
|
||
|
iFlag=0;
|
||
|
while (iCount < iCamps && iFlag == 0)
|
||
|
{
|
||
|
iCount++;
|
||
|
sTag = sZone + "_C" + IntToString(iCount) + "_Boss_S";
|
||
|
oCreature = GetObjectByTag(sTag);
|
||
|
if (GetIsEnemy(oBoss,oCreature))
|
||
|
iFlag=1;
|
||
|
}
|
||
|
if (iFlag == 0)
|
||
|
{
|
||
|
sTag = sZone + "_Town";
|
||
|
SetLocalInt(oBoss,"EN4CampAttack",2);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sTag = sZone + "_C" + IntToString(iCount) + "_Boss";
|
||
|
SetLocalInt(oBoss,"EN4CampAttack",1);
|
||
|
}
|
||
|
|
||
|
if (GetIsObjectValid(GetObjectByTag(sTag)))
|
||
|
{
|
||
|
if (sTag == sZone + "_C" + IntToString(iCount) + "_Boss")
|
||
|
{
|
||
|
oWP = GetObjectByTag(sTag);
|
||
|
SetLocalString(oWP,"EN4AttackedBy",GetTag(oBoss));
|
||
|
SetLocalString(oWP,"EN4AttackedByCampType",sCampType);
|
||
|
}
|
||
|
lLoc2 = GetLocation(GetObjectByTag(sTag));
|
||
|
iCount = 0;
|
||
|
while (iCount < iNumber)
|
||
|
{
|
||
|
iCount++;
|
||
|
sTag = "en3_" + sCampType + "_" + GetRandomRaceType() + "_1";
|
||
|
oCreature = CreateObject(OBJECT_TYPE_CREATURE,sTag,lLoc);
|
||
|
iMobLevel = Random(5) - 2 + iLevel;
|
||
|
if (iMobLevel>1)
|
||
|
{
|
||
|
LevelMob(oCreature,iMobLevel-1);
|
||
|
EquipMob(oCreature);
|
||
|
}
|
||
|
DelayCommand(1.0f,AssignCommand(oCreature,ActionMoveToLocation(lLoc2,TRUE)));
|
||
|
DelayCommand(10.0f,AssignCommand(oCreature,ActionMoveToLocation(lLoc2,TRUE)));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
string GetRandomRaceType()
|
||
|
{
|
||
|
int iRandom;
|
||
|
string sType;
|
||
|
|
||
|
iRandom = Random(10) + 1;
|
||
|
sType = "f";
|
||
|
switch (iRandom)
|
||
|
{
|
||
|
case 1: case 2: case 3: sType = "f"; break; //fighter
|
||
|
case 4: case 5: sType = "r"; break; //rogue
|
||
|
case 6: sType = "m"; break; //mage
|
||
|
case 7: case 8: sType = "c"; break; //cleric
|
||
|
case 9: sType = "s"; break; //special class
|
||
|
case 10: sType = "x"; break; //special creature
|
||
|
}
|
||
|
|
||
|
return sType;
|
||
|
}
|
||
|
|
||
|
void WorldEvent()
|
||
|
{
|
||
|
object oPC;
|
||
|
object oItem;
|
||
|
int iRandom;
|
||
|
string sMessage;
|
||
|
effect eDur;
|
||
|
effect eAttack;
|
||
|
effect eSave;
|
||
|
effect eLink;
|
||
|
effect eShake;
|
||
|
itemproperty ip;
|
||
|
|
||
|
|
||
|
if (GetLocalInt(GetModule(),"MonsterStorm") > 0)
|
||
|
{
|
||
|
oPC = GetFirstPC();
|
||
|
while (GetIsObjectValid(oPC))
|
||
|
{
|
||
|
SendMessageToPC(oPC,"The chaos in the land subsides and the chill leaves your bones.");
|
||
|
oPC = GetNextPC();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (GetLocalInt(GetModule(),"BonusXP") > 0)
|
||
|
{
|
||
|
oPC = GetFirstPC();
|
||
|
while (GetIsObjectValid(oPC))
|
||
|
{
|
||
|
SendMessageToPC(oPC,"Your head clears and you can no longer think as clearly.");
|
||
|
oPC = GetNextPC();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (GetLocalInt(GetModule(),"WildMagic") > 0)
|
||
|
{
|
||
|
oPC = GetFirstPC();
|
||
|
while (GetIsObjectValid(oPC))
|
||
|
{
|
||
|
SendMessageToPC(oPC,"The current of magic shifts again and becomes calm.");
|
||
|
oPC = GetNextPC();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
SQLocals_SetInt(GetModule(),"MonsterStorm",0);
|
||
|
SQLocals_SetInt(GetModule(),"BonusXP",0);
|
||
|
SQLocals_SetInt(GetModule(),"WildMagic",0);
|
||
|
|
||
|
if (Random(50)==0)
|
||
|
{
|
||
|
iRandom = Random(5)+1;
|
||
|
switch (iRandom)
|
||
|
{
|
||
|
case 1: SQLocals_SetInt(GetModule(),"MonsterStorm",1);
|
||
|
sMessage = "The earth beneath you tremors momentarily and a chill passes through you.";
|
||
|
oPC = GetFirstPC();
|
||
|
while (GetIsObjectValid(oPC))
|
||
|
{
|
||
|
eShake = EffectVisualEffect(356);
|
||
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eShake, oPC, RoundsToSeconds(6));
|
||
|
oPC = GetNextPC();
|
||
|
}
|
||
|
break;
|
||
|
case 2: SQLocals_SetInt(GetModule(),"BonusXP",(Random(4)+1) * 25);
|
||
|
sMessage = "A strange wind brushes past you and as you breath in your feel a tingling in your head.";
|
||
|
break;
|
||
|
case 3: oPC = GetFirstPC();
|
||
|
while (GetIsObjectValid(oPC))
|
||
|
{
|
||
|
eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
|
||
|
eAttack = EffectAttackIncrease(2);
|
||
|
eSave = EffectSavingThrowIncrease(SAVING_THROW_ALL, 1, SAVING_THROW_TYPE_FEAR);
|
||
|
eLink = EffectLinkEffects(eAttack, eSave);
|
||
|
eLink = EffectLinkEffects(eLink, eDur);
|
||
|
DelayCommand(1.0f, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oPC, 300.0f));
|
||
|
oPC = GetNextPC();
|
||
|
}
|
||
|
sMessage = "A blessing from the heavens fills your being.";
|
||
|
break;
|
||
|
case 4: oPC = GetFirstPC();
|
||
|
while (GetIsObjectValid(oPC))
|
||
|
{
|
||
|
ip=ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE,IP_CONST_DAMAGEBONUS_1d6);
|
||
|
oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
|
||
|
IPSafeAddItemProperty(oItem,ip,300.0f);
|
||
|
oPC = GetNextPC();
|
||
|
}
|
||
|
sMessage = "The fires of heaven come alive in your hands.";
|
||
|
break;
|
||
|
case 5: SQLocals_SetInt(GetModule(),"WildMagic",1);
|
||
|
sMessage = "The current of magic shifts and becomes chaotic.";
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
|
||
|
oPC = GetFirstPC();
|
||
|
while (GetIsObjectValid(oPC))
|
||
|
{
|
||
|
SendMessageToPC(oPC,sMessage);
|
||
|
oPC = GetNextPC();
|
||
|
}
|
||
|
}
|
||
|
}
|