//An example OnHB script for an invisible placeable to spawn a ground trap #include "prc_alterations" #include "prgt_inc" void main() { //:: Declare major variables int nTotalPCs; int nTotalPCLevel; int nAveragePCLevel; 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. { nTotalPCs++; nTotalPCLevel = nTotalPCLevel + GetHitDice(oPC); } oPC = GetNextObjectInArea(oArea); } if (nTotalPCs > 0) { nAveragePCLevel = nTotalPCLevel / nTotalPCs; } else { nAveragePCLevel = 3; } struct trap tTrap; //add code in here to change things if you want to //for example, to set the detect DC to be 23 use: //tTrap.nDetectDC = 23; //tTrap.nDisarmDC = 27; tTrap.nCR = nAveragePCLevel + 5; tTrap.nRespawnSeconds = 600; //will respawn after 10 minutes tTrap.nRespawnRandomCR = tTrap.nCR ; //will rerandomize the trap each time its respawned tTrap.sDisarmScript = "ema_xp4trap_dis"; //:: This will use tTrap.nCR as the CR for the trap tTrap = CreateRandomTrap(tTrap.nCR); PRGT_CreateTrapAtLocation(GetLocation(OBJECT_SELF), tTrap); DestroyObject(OBJECT_SELF); }