2022-10-10 08:16:23 -04:00
|
|
|
//:://////////////////////////////////////////////////
|
|
|
|
//:: prc_pwonspawn
|
|
|
|
/*
|
|
|
|
PRC's OnSpawn event handler for NPCs.
|
|
|
|
|
|
|
|
*/
|
|
|
|
//:://////////////////////////////////////////////////
|
|
|
|
|
2023-10-26 22:05:43 -04:00
|
|
|
#include "NW_I0_GENERIC"
|
|
|
|
#include "nw_i0_plot"
|
|
|
|
#include "rd_level"
|
|
|
|
#include "inc_sqlite_time"
|
|
|
|
|
|
|
|
void ReallyEquipItemInSlot(object oNPC, object oItem, int nSlot);
|
|
|
|
|
2022-10-10 08:16:23 -04:00
|
|
|
void main()
|
|
|
|
{
|
2023-10-26 22:05:43 -04:00
|
|
|
//:: Initialize Major Variables
|
|
|
|
effect eVFX;
|
|
|
|
|
|
|
|
int nTotalPCs;
|
|
|
|
int nTotalPCLevel;
|
|
|
|
int nAveragePCLevel;
|
2023-10-29 13:45:22 -04:00
|
|
|
int nCommoner = GetLevelByClass(CLASS_TYPE_COMMONER, OBJECT_SELF);
|
2023-10-26 22:05:43 -04:00
|
|
|
|
|
|
|
string sCurrentDate = SQLite_GetSystemDate();
|
|
|
|
string sMonthDay = GetSubString(sCurrentDate, 0, 5);
|
|
|
|
|
|
|
|
object oArea = GetArea(OBJECT_SELF);
|
|
|
|
object oSkelly;
|
|
|
|
object oPC = GetFirstObjectInArea(oArea);
|
|
|
|
|
|
|
|
ExecuteScript("prc_npc_spawn", OBJECT_SELF);
|
|
|
|
|
2023-10-29 13:45:22 -04:00
|
|
|
//: Don't spawn skeletons from skeletons or commoners
|
2023-10-29 20:19:50 -04:00
|
|
|
if (GetResRef(OBJECT_SELF) == "pa_skeleton" || nCommoner > 0)
|
2023-10-26 22:05:43 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
//:: Get average PC level for area
|
|
|
|
//:: Cycle through PCs in Area
|
|
|
|
|
|
|
|
while (oPC != OBJECT_INVALID)
|
|
|
|
{
|
|
|
|
if (GetIsPC(oPC) == TRUE)
|
|
|
|
{
|
|
|
|
nTotalPCs++;
|
|
|
|
nTotalPCLevel = nTotalPCLevel + GetHitDice(oPC);
|
|
|
|
}
|
|
|
|
|
|
|
|
oPC = GetNextObjectInArea(oArea);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nTotalPCs > 0)
|
|
|
|
{
|
2023-10-29 13:45:22 -04:00
|
|
|
nAveragePCLevel = (nTotalPCLevel / nTotalPCs) - 1;
|
2023-10-26 22:05:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
2023-10-29 13:45:22 -04:00
|
|
|
nAveragePCLevel = 2;
|
2023-10-26 22:05:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//:: Only active during Halloween week.
|
|
|
|
if ((sMonthDay == "10/24") ||
|
|
|
|
(sMonthDay == "10/25") ||
|
|
|
|
(sMonthDay == "10/26") ||
|
|
|
|
(sMonthDay == "10/27") ||
|
|
|
|
(sMonthDay == "10/28") ||
|
|
|
|
(sMonthDay == "10/29") ||
|
|
|
|
(sMonthDay == "10/30") ||
|
|
|
|
(sMonthDay == "10/31") ||
|
|
|
|
(sMonthDay == "11/01"))
|
|
|
|
{
|
2023-10-29 18:21:02 -04:00
|
|
|
//:: 33% chance to spawn
|
|
|
|
if ( Random(100) < 33 )
|
2023-10-26 22:05:43 -04:00
|
|
|
{
|
|
|
|
//:: Spawn Skeleton.
|
|
|
|
eVFX = EffectVisualEffect(VFX_IMP_EVIL_HELP);
|
|
|
|
oSkelly = CreateObject(OBJECT_TYPE_CREATURE, "nw_skeleton", GetLocation(OBJECT_SELF));
|
|
|
|
LevelMob(oSkelly, nAveragePCLevel);
|
|
|
|
|
|
|
|
//:: Assign Weapon
|
|
|
|
int nResult = d6(1);
|
|
|
|
int nStackSize = 1; // Create 1 items;
|
|
|
|
string sItem;
|
|
|
|
|
|
|
|
if (nResult == 1)
|
|
|
|
{
|
|
|
|
sItem = "nw_wplhb001"; //:: Halberd
|
|
|
|
}
|
|
|
|
else if(nResult == 2)
|
|
|
|
{
|
|
|
|
sItem = "nw_wplsc001"; //:: Scythe
|
|
|
|
}
|
|
|
|
else if(nResult == 3)
|
|
|
|
{
|
|
|
|
sItem = "nw_wplss001"; //:: Spear
|
|
|
|
}
|
|
|
|
else if(nResult ==4)
|
|
|
|
{
|
|
|
|
sItem = "nw_wblfh001"; //:: Heavy Flail
|
|
|
|
}
|
|
|
|
else if(nResult == 5)
|
|
|
|
{
|
|
|
|
sItem = "nw_wswgs001"; //:: Greatsword
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
sItem = "nw_waxgr001"; //:: Greataxe
|
|
|
|
|
|
|
|
object oWeapon = CreateItemOnObject(sItem, oSkelly, nStackSize);
|
|
|
|
ReallyEquipItemInSlot(oSkelly, oWeapon, INVENTORY_SLOT_RIGHTHAND);
|
|
|
|
|
|
|
|
//:: Apply VFX & Attack
|
|
|
|
AssignCommand(oSkelly, DetermineCombatRound(OBJECT_SELF));
|
|
|
|
DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSkelly));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReallyEquipItemInSlot(object oNPC, object oItem, int nSlot)
|
|
|
|
{
|
|
|
|
if (GetItemInSlot(nSlot) != oItem)
|
|
|
|
{
|
|
|
|
ClearAllActions();
|
|
|
|
ActionEquipItem(oItem, nSlot);
|
|
|
|
DelayCommand(1.0, ReallyEquipItemInSlot(oNPC, oItem, nSlot));
|
|
|
|
}
|
|
|
|
}
|