generated from Jaysyn/ModuleTemplate
287 lines
8.4 KiB
Plaintext
287 lines
8.4 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Werewolf Include
|
|
//:: WW_INC
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
Uses userdefined events instead of heartbeats for
|
|
low over head. Holds all the meat of the lycanthropy
|
|
effects.
|
|
*/
|
|
//:://////////////////////////////////////////////
|
|
//:: Created By: 69_Jeremy_69
|
|
//:: Created On: April 27, 2003
|
|
//:://////////////////////////////////////////////
|
|
//void main(){} // Debug Only
|
|
|
|
////////////////////
|
|
//:: CONSTANTS :://
|
|
///////////////////
|
|
// Setup time, 24 clock, edit these values as you wish
|
|
int DUSK = 18;
|
|
int DAWN = 6;
|
|
// Default sayings
|
|
string NO_CHANGE = "You resisted the lycanthropy effects.";
|
|
string CONTROL = "You succumbed to the lycanthropy effects, but were able to control yourself.";
|
|
string NO_CONTROL = "You succumbed to the lycanthropy effects fully.";
|
|
string ARMOR_GONE = "The force of the change was too great for your Armor to bear.";
|
|
string CURED = "It worked, the lycanthropy effects were cured.";
|
|
string CURE_FAIL = "The attempt to cure your lycanthropy failed.";
|
|
string BELLADONNA = "You have already tried this cure, it can't help you any more.";
|
|
// See ww_actions for werewolf sounds
|
|
|
|
////////////////////////
|
|
//:: FUNCTION LIST :://
|
|
///////////////////////
|
|
|
|
// Change all infected players back to there human form
|
|
void ChangeFromWerewolf();
|
|
// Change all infected players into Werewolves
|
|
void ChangeToWerewolf();
|
|
// Called once by the very first player that is bitten
|
|
void SetUpShapeChange();
|
|
// Check to see if the player breaks there armor when they shape shift
|
|
void WerewolfArmor(object oPC);
|
|
// Make the player act crazy like a wererolf
|
|
void WerewolfConfuse(object oPC);
|
|
// Undue any damage the player has done
|
|
void WerewolfResetFactions(object oPlayer);
|
|
// Try to cure the Lycanthropy effects
|
|
void CureWerewolf(object oPC, int nType, object oCaster=OBJECT_INVALID);
|
|
// Checks for werewolves in the Module
|
|
void CheckForWerewolves();
|
|
// Module
|
|
object oMod = GetModule();
|
|
|
|
///////////////////////
|
|
//:: THE FUNCTIONS :://
|
|
///////////////////////
|
|
void SetUpShapeChange()
|
|
{
|
|
SetLocalInt(oMod, "WEREWOLF",1);
|
|
event eRun = EventUserDefined(6901);
|
|
int nHour = GetTimeHour();
|
|
//int nMin = GetTimeMinute();
|
|
float fTrigger;
|
|
|
|
if(nHour >= DUSK)
|
|
{
|
|
nHour = (24-nHour)+DUSK;
|
|
}else{
|
|
nHour = DUSK-nHour;
|
|
}
|
|
fTrigger = HoursToSeconds(nHour);
|
|
DelayCommand(fTrigger, SignalEvent(oMod, eRun));
|
|
}
|
|
|
|
void ChangeToWerewolf()
|
|
{
|
|
if(!GetLocalInt(oMod, "WEREWOLF")) return;
|
|
|
|
object oPC = GetFirstPC();
|
|
string sID = GetName(oPC)+GetPCPublicCDKey(oPC);
|
|
int nHour = (24-DUSK) + DAWN;
|
|
float fTrigger = HoursToSeconds(nHour);
|
|
SetLocalInt(oMod, "HB_WEREWOLF",1);
|
|
int nCtrl;
|
|
|
|
while(GetIsObjectValid(oPC))
|
|
{
|
|
|
|
if(GetLocalInt(oMod,"AFF_WEREWOLF"+sID)==1)
|
|
{
|
|
// Able to control there shape
|
|
int nControl = WillSave(oPC, 25);
|
|
if(!nControl)
|
|
{
|
|
FloatingTextStringOnCreature(NO_CONTROL, oPC, FALSE);
|
|
}else{
|
|
FloatingTextStringOnCreature(CONTROL, oPC, FALSE);
|
|
SetLocalInt(oMod, "WERE_CONTROL"+sID,1);
|
|
}
|
|
nCtrl = GetLocalInt(oMod, "WERE_CONTROL"+sID);
|
|
WerewolfArmor(oPC);
|
|
PlaySound("c_werewolf_bat2");
|
|
effect eWolf = EffectPolymorph(POLYMORPH_TYPE_WEREWOLF);
|
|
eWolf = EffectLinkEffects(eWolf, EffectSilence());
|
|
eWolf = SupernaturalEffect(eWolf);
|
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eWolf, oPC);
|
|
|
|
// Must fire to check and see they kept their form
|
|
WerewolfConfuse(oPC);
|
|
if(!nCtrl) SetCommandable(FALSE, oPC);
|
|
DelayCommand(fTrigger, SetCommandable(TRUE, oPC));
|
|
}
|
|
oPC = GetNextPC();
|
|
sID = GetName(oPC)+GetPCPublicCDKey(oPC);
|
|
|
|
DelayCommand(fTrigger, SetLocalInt(GetModule(),"HB_WEREWOLF",0));
|
|
}
|
|
event eRun = EventUserDefined(6902);
|
|
DelayCommand(fTrigger, SignalEvent(GetModule(), eRun));
|
|
}
|
|
|
|
void ChangeFromWerewolf()
|
|
{
|
|
if(!GetLocalInt(oMod, "WEREWOLF")) return;
|
|
SetLocalInt(oMod, "HB_WEREWOLF",0);
|
|
|
|
object oPC = GetFirstPC();
|
|
string sID = GetName(oPC)+GetPCPublicCDKey(oPC);
|
|
int nHour = DUSK - DAWN;
|
|
float fTrigger = HoursToSeconds(nHour);
|
|
effect eWolf = GetFirstEffect(oPC);
|
|
while(GetIsObjectValid(oPC))
|
|
{
|
|
if(GetLocalInt(oMod, "AFF_WEREWOLF"+sID)==1)
|
|
{
|
|
while(GetIsEffectValid(eWolf))
|
|
{
|
|
if(GetEffectType(eWolf) == EFFECT_TYPE_POLYMORPH ||
|
|
GetEffectType(eWolf) == EFFECT_TYPE_SILENCE)
|
|
{
|
|
RemoveEffect(oPC, eWolf);
|
|
}
|
|
eWolf = GetNextEffect(oPC);
|
|
}
|
|
DeleteLocalInt(oMod, "WERE_CONTROL"+sID);
|
|
SetCommandable(TRUE, oPC);
|
|
// Fix any problems they caused
|
|
WerewolfResetFactions(oPC);
|
|
}
|
|
oPC = GetNextPC();
|
|
sID = GetName(oPC)+GetPCPublicCDKey(oPC);
|
|
}
|
|
event eRun = EventUserDefined(6901);
|
|
DelayCommand(fTrigger, SignalEvent(GetModule(), eRun));
|
|
}
|
|
|
|
void WerewolfArmor(object oPC)
|
|
{
|
|
object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
|
|
// If the dont have armor quit
|
|
if(!GetIsObjectValid(oArmor)) return;
|
|
int iSave=((d20(1))+2);
|
|
|
|
if(!(iSave>=15))
|
|
{
|
|
DestroyObject(oArmor);
|
|
FloatingTextStringOnCreature(ARMOR_GONE, oPC, FALSE);
|
|
}
|
|
}
|
|
|
|
void WerewolfConfuse(object oPC)
|
|
{
|
|
string sID = GetName(oPC)+GetPCPublicCDKey(oPC);
|
|
if(!GetLocalInt(oMod, "HB_WEREWOLF")) return;
|
|
if(!GetLocalInt(oMod, "AFF_WEREWOLF"+sID))
|
|
{
|
|
SetCommandable(TRUE, oPC);
|
|
return;
|
|
}
|
|
ExecuteScript("ww_actions", oPC);
|
|
DelayCommand(10.0, WerewolfConfuse(oPC));
|
|
}
|
|
|
|
void WerewolfResetFactions(object oPlayer)
|
|
{
|
|
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
|
|
{
|
|
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
|
|
}
|
|
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
|
|
{
|
|
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
|
|
}
|
|
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
|
|
{
|
|
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
|
|
}
|
|
}
|
|
|
|
void CureWerewolf(object oPC, int nType, object oCaster=OBJECT_INVALID)
|
|
{
|
|
string sID = GetName(oPC)+GetPCPublicCDKey(oPC);
|
|
//////////////////////////////////
|
|
//:: Types
|
|
//:: 1. Belladonna
|
|
//:: 2. Remove Disease
|
|
//:: 2. Heal
|
|
//:: 3. Remove Curse
|
|
//////////////////////////////////
|
|
int nCured=0;
|
|
int nUsed = GetLocalInt(oMod,"BELLADONNA"+sID);
|
|
if(nType==1)
|
|
{
|
|
// Belladonna
|
|
if(!nUsed)
|
|
{
|
|
int nHeal = GetSkillRank(SKILL_HEAL, oCaster) + d20();
|
|
if(nHeal > 20) nCured = 1;
|
|
|
|
if(!FortitudeSave(oPC,20,SAVING_THROW_TYPE_POISON))
|
|
{
|
|
effect ePoison = EffectPoison(POISON_NIGHTSHADE);
|
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoison, oPC);
|
|
}else{
|
|
nCured = 1;
|
|
}
|
|
// Belladonna must be successfull on first try
|
|
SetLocalInt(oMod, "BELLADONNA"+sID,1);
|
|
}else{
|
|
SendMessageToPC(oPC, BELLADONNA);
|
|
}
|
|
}else if(nType==2){
|
|
// Remove Disease or Heal
|
|
int nLevel = GetLevelByClass(CLASS_TYPE_CLERIC, oCaster);
|
|
if(nLevel >= 12) nCured = 1;
|
|
}else if(nType==3){
|
|
// Remove Curse
|
|
if(WillSave(oPC,20)) nCured = 1;
|
|
}
|
|
|
|
if(nCured)
|
|
{
|
|
effect eWolf = GetFirstEffect(oPC);
|
|
// Reset Belladonna cure
|
|
DeleteLocalInt(oMod, "BELLADONNA"+sID);
|
|
DeleteLocalInt(oMod, "WERE_CONTROL"+sID);
|
|
while(GetIsEffectValid(eWolf))
|
|
{
|
|
if(GetEffectType(eWolf) == EFFECT_TYPE_POLYMORPH ||
|
|
GetEffectType(eWolf) == EFFECT_TYPE_SILENCE)
|
|
{
|
|
RemoveEffect(oPC, eWolf);
|
|
}
|
|
eWolf = GetNextEffect(oPC);
|
|
}
|
|
SetCommandable(TRUE, oPC);
|
|
// Fix any problems they caused as a werewolf
|
|
WerewolfResetFactions(oPC);
|
|
DeleteLocalInt(oMod, "AFF_WEREWOLF"+sID);
|
|
SendMessageToPC(oPC, CURED);
|
|
CheckForWerewolves();
|
|
}else{
|
|
SendMessageToPC(oPC, CURE_FAIL);
|
|
}
|
|
}
|
|
|
|
void CheckForWerewolves()
|
|
{
|
|
object oPC = GetFirstPC();
|
|
string sID = GetName(oPC)+GetPCPublicCDKey(oPC);
|
|
int nWolf = 0;
|
|
|
|
while(GetIsObjectValid(oPC))
|
|
{
|
|
if(GetLocalInt(oMod, "AFF_WEREWOLF"+sID)) nWolf++;
|
|
oPC = GetNextPC();
|
|
sID = GetName(oPC)+GetPCPublicCDKey(oPC);
|
|
}
|
|
|
|
if(!nWolf)
|
|
{
|
|
SetLocalInt(oMod, "HB_WEREWOLF",0);
|
|
SetLocalInt(oMod,"WEREWOLF",0);
|
|
}
|
|
}
|