Initial upload
Initial upload
This commit is contained in:
139
_module/nss/moduleheartbeat.nss
Normal file
139
_module/nss/moduleheartbeat.nss
Normal file
@@ -0,0 +1,139 @@
|
||||
#include "nw_i0_tool"
|
||||
|
||||
// Modified by AW Olorin on 6-11-2004
|
||||
// Added Announcement system. DM's may make announcements via Doby.
|
||||
// These will be announced to players every 60 minutes.
|
||||
|
||||
void TakeOffCrown(object oItem,object oPC);
|
||||
|
||||
void main()
|
||||
{
|
||||
object oPC = GetFirstPC();
|
||||
|
||||
while(GetIsObjectValid(oPC))
|
||||
{
|
||||
if (!GetIsDead(oPC)){
|
||||
SetLocalInt(GetModule(), "died"+GetName(oPC), 99999999999);
|
||||
}
|
||||
if ( GetIsDead(oPC)){
|
||||
int deathtime = GetLocalInt(GetModule(), "died"+GetName(oPC));
|
||||
int currenttime = GetLocalInt(GetModule(), "loadtimer");
|
||||
int timer = currenttime - deathtime;
|
||||
|
||||
if (timer > 54) {
|
||||
SetLocalObject(oPC, "respawn", oPC);
|
||||
AssignCommand(oPC, ExecuteScript("forcerespawn", oPC));
|
||||
}
|
||||
}
|
||||
object detector = GetNearestObjectByTag("nocrown", oPC, 0);
|
||||
if (GetIsObjectValid(detector))
|
||||
{
|
||||
object trap = GetNearestTrapToObject(detector, FALSE);
|
||||
if ( GetTrapCreator(trap) == oPC && !GetIsDM(oPC) && GetIsPC(oPC))
|
||||
if (GetArea(oPC) != GetArea(GetObjectByTag("throneofdeath")))
|
||||
{
|
||||
AssignCommand(oPC, ClearAllActions());
|
||||
AssignCommand(oPC, ActionJumpToLocation(GetLocation(GetWaypointByTag("prison"))));
|
||||
SendMessageToPC(oPC, "You have been sent to jail for setting a trap in a restricted area.");
|
||||
}
|
||||
}
|
||||
object crown = GetObjectByTag("ImmortalCrown2");
|
||||
object helm = GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
|
||||
if (helm != OBJECT_INVALID && helm == crown)
|
||||
{
|
||||
if (GetIsObjectValid(detector))
|
||||
{
|
||||
TakeOffCrown(helm,oPC);
|
||||
return;
|
||||
}
|
||||
object target = (GetNearestObject(OBJECT_TYPE_CREATURE, oPC,1) );
|
||||
object target2 = (GetNearestObject(OBJECT_TYPE_CREATURE, oPC,2) );
|
||||
object target3 = (GetNearestObject(OBJECT_TYPE_CREATURE, oPC,3) );
|
||||
object target4 = (GetNearestObject(OBJECT_TYPE_CREATURE, oPC,4) );
|
||||
effect eBeam = EffectBeam(VFX_BEAM_EVIL,oPC,BODY_NODE_CHEST);
|
||||
effect eDamage = EffectDamage(60+d20(5), DAMAGE_TYPE_NEGATIVE, DAMAGE_POWER_NORMAL);
|
||||
|
||||
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam, target, 2.0f);
|
||||
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam, target2, 2.0f);
|
||||
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam, target3, 2.0f);
|
||||
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam, target4, 2.0f);
|
||||
|
||||
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage , target);
|
||||
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage , target2);
|
||||
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage , target3);
|
||||
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage , target4);
|
||||
|
||||
// The following commented out code was used for debugging.
|
||||
/*SendMessageToPC(oPC,"Death rays to creatures " +
|
||||
GetName(target) + ", " +
|
||||
GetName(target2) + ", " +
|
||||
GetName(target3) + ", " +
|
||||
GetName(target4) + "."); */
|
||||
}
|
||||
|
||||
if(GetCurrentHitPoints(oPC) >= 1)
|
||||
{
|
||||
object oItemToTake;
|
||||
oItemToTake = GetItemPossessedBy(oPC, "death");
|
||||
DestroyObject(oItemToTake);
|
||||
}
|
||||
|
||||
oPC = GetNextPC();
|
||||
}
|
||||
|
||||
// Server reset check
|
||||
int timekeeper = GetLocalInt(GetModule(), "loadtimer");
|
||||
SetLocalInt(GetModule(), "loadtimer", (timekeeper +1));
|
||||
|
||||
if (timekeeper >= 2300)
|
||||
{
|
||||
string time = IntToString(GetLocalInt(GetModule(), "loadtimer"));
|
||||
WriteTimestampedLogEntry("Timekeeper = " + time);
|
||||
ExecuteScript("dieserverdie",OBJECT_SELF);
|
||||
}
|
||||
|
||||
// DM announcement check
|
||||
int iAnnounceTimer = GetLocalInt(GetModule(),"iAnnounceTimer");
|
||||
SetLocalInt(GetModule(), "iAnnounceTimer", (iAnnounceTimer +1) );
|
||||
|
||||
|
||||
if(iAnnounceTimer >= GetLocalInt(GetModule(),"iAnnounce_Period"))
|
||||
{
|
||||
string sAnnouncement = GetLocalString(GetModule(),"Announcement");
|
||||
string sAuthor = GetLocalString(GetModule(),"Announcement_Author");
|
||||
SetLocalInt(GetModule(),"iAnnounceTimer",0);
|
||||
if(sAnnouncement == "") return;
|
||||
oPC = GetFirstPC();
|
||||
while(GetIsObjectValid(oPC))
|
||||
{
|
||||
if(GetIsDM(oPC))
|
||||
SendMessageToPC(oPC,"Module wide announcement being sent, created by DM " + sAuthor + ".");
|
||||
SendMessageToPC(oPC,sAnnouncement);
|
||||
oPC = GetNextPC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TakeOffCrown(object oItem,object oPC)
|
||||
{
|
||||
object oDagger = GetItemPossessedBy(oPC,"immortaldagger1");
|
||||
|
||||
if(GetIsObjectValid(oItem))
|
||||
AssignCommand(oPC,ActionUnequipItem(oItem));
|
||||
|
||||
if(GetIsObjectValid(oDagger))
|
||||
{
|
||||
SetPlotFlag(oDagger,FALSE);
|
||||
AssignCommand(oPC,ActionUnequipItem(oDagger));
|
||||
AssignCommand(oPC,DestroyObject(oDagger));
|
||||
}
|
||||
|
||||
oDagger = GetItemPossessedBy(oPC,"immortaldagger2");
|
||||
|
||||
if(GetIsObjectValid(oDagger))
|
||||
{
|
||||
SetPlotFlag(oDagger,FALSE);
|
||||
AssignCommand(oPC,ActionUnequipItem(oDagger));
|
||||
AssignCommand(oPC,DestroyObject(oDagger));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user