generated from Jaysyn/ModuleTemplate
228 lines
7.3 KiB
Plaintext
228 lines
7.3 KiB
Plaintext
// Gets the death state of the player - MODULE_EVERYONE_ALIVE or MODULE_NOTEVERYONE_ALIVE
|
|
int GetModuleDeathState();
|
|
// Sets the death state of the player - MODULE_EVERYONE_ALIVE or MODULE_NOTEVERYONE_ALIVE
|
|
void SetModuleDeathState(int nState);
|
|
// Gets the death state of the player - PLAYER_ALIVE, PLAYER_BLEEDING or PLAYER_STABLE
|
|
int GetDeathState(object oRespawner);
|
|
// Sets the death state of the player - PLAYER_ALIVE, PLAYER_BLEEDING or PLAYER_STABLE
|
|
void SetDeathState(object oRespawner, int nState);
|
|
// Player unequips items in their hands
|
|
void UnequipPlayer(object oPlayer, int nHandsOnly = TRUE);
|
|
// * removes all negative effects
|
|
void RemoveNegativeEffects(object oDead);
|
|
// Ressurects them and then teleports them if nRessurect ==TRUE. Not needed for
|
|
// Raise dead and res spells
|
|
// Heals them, unequips them, does black screen, sets the correct module death
|
|
// state, and does res sickness
|
|
// but does not decay their items
|
|
void Ressurect(object oRespawner, int nRespawning=TRUE);
|
|
// Applys the XP penalty at nAmount x level
|
|
void ApplyPenalty(object oDead, int nAmount=50);
|
|
// Sets the tag of the PC's new res location
|
|
// This is a waypoint with the tag of the area they are in pluse
|
|
// _res_wp
|
|
void SetPCResLocation(object oPC);
|
|
// Gets the string of the WP the PC should res at
|
|
// The respawn script should check this location is valid and
|
|
// send them to BH if not
|
|
string GetPCResLocation(object oPC);
|
|
|
|
|
|
|
|
const int PLAYER_ALIVE=0;
|
|
const int PLAYER_BLEEDING=1;
|
|
const int PLAYER_STABLE=2;
|
|
const int PLAYER_DEAD=3;
|
|
|
|
const int MODULE_EVERYONE_ALIVE=0;
|
|
const int MODULE_NOTEVERYONE_ALIVE=1;
|
|
|
|
void SetDeathState(object oRespawner, int nState)
|
|
{
|
|
object oModule=GetItemPossessedBy(oRespawner,"jw_crafting_gem");
|
|
SetLocalInt(oModule,"deathstate",nState);
|
|
}
|
|
|
|
int GetDeathState(object oRespawner)
|
|
{
|
|
object oModule=GetItemPossessedBy(oRespawner,"jw_crafting_gem");
|
|
int nState=GetLocalInt(oModule,"deathstate");
|
|
return nState;
|
|
}
|
|
|
|
void SetModuleDeathState(int nState)
|
|
{
|
|
SetLocalInt(GetModule(),"moduledeathstate",nState);
|
|
}
|
|
|
|
int GetModuleDeathState()
|
|
{
|
|
int nState=GetLocalInt(GetModule(),"moduledeathstate");
|
|
return nState;
|
|
}
|
|
|
|
void Ressurect(object oRespawner, int nRespawning=TRUE)
|
|
{
|
|
RemoveNegativeEffects(oRespawner);
|
|
|
|
if (nRespawning==TRUE)
|
|
{
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
|
|
object oResPoint=GetWaypointByTag(GetPCResLocation(oRespawner));
|
|
AssignCommand(oRespawner, ClearAllActions());
|
|
AssignCommand(oRespawner, JumpToObject(oResPoint, FALSE));
|
|
UnequipPlayer (oRespawner, TRUE);
|
|
//BlackScreen(oRespawner);
|
|
//DelayCommand(0.5,BlackScreen(oRespawner));
|
|
SendMessageToPC(oRespawner, "You find yourself in " + GetName(GetArea(oResPoint)));
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner); // moved to fix raise dead spell giving full hitpoints
|
|
//DelayCommand(8.0,FadeFromBlack(oRespawner, FADE_SPEED_SLOW));
|
|
//DelayCommand(1.0,ActionPlayAnimation(ANIMATION_LOOPING_DEAD_FRONT,1.0,10.0));
|
|
|
|
}
|
|
else
|
|
{
|
|
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectKnockdown(),oRespawner,8.0));
|
|
}
|
|
|
|
|
|
SetDeathState(oRespawner,PLAYER_ALIVE);
|
|
// Do res sickness
|
|
effect eSickness=EffectCurse(4,4,0,0,0,0); //con damage will cause the player to die again when raise dead is cast on them (only heals to 1 hp, then they lose 2/level hp from con damage = instantly dead again. INT WIS and CHA cause spell slots to be lost, irritating for player.
|
|
eSickness = EffectLinkEffects(EffectACDecrease(3), eSickness);
|
|
eSickness = EffectLinkEffects(EffectAttackDecrease(-5), eSickness);
|
|
eSickness = EffectLinkEffects(EffectSkillDecrease(SKILL_ALL_SKILLS, 5), eSickness); // adds a few other effects to the (now weakened) respawn curse
|
|
eSickness=ExtraordinaryEffect(eSickness);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eSickness,oRespawner,240.0);
|
|
|
|
|
|
// Stop PC resting for a bit
|
|
int nCurrentHour = (GetCalendarYear()-1)*12*28*24 +
|
|
(GetCalendarMonth()-1)*28*24 +
|
|
(GetCalendarDay()-1)*24 +
|
|
GetTimeHour();
|
|
SetLocalInt( oRespawner, "LastRestHour",nCurrentHour);
|
|
ExportSingleCharacter(oRespawner);
|
|
}
|
|
|
|
|
|
void UnequipPlayer(object oPlayer, int nHandsOnly = TRUE)
|
|
{
|
|
AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_LEFTHAND)));
|
|
AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND)));
|
|
}
|
|
|
|
|
|
// * removes all negative effects
|
|
void RemoveNegativeEffects(object oDead)
|
|
{
|
|
//Declare major variables
|
|
object oTarget = oDead;
|
|
|
|
int bValid;
|
|
|
|
effect eBad = GetFirstEffect(oTarget);
|
|
//Search for negative effects
|
|
while(GetIsEffectValid(eBad))
|
|
{
|
|
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_FRIGHTENED ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_DAZED ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_CONFUSED ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_POISON ||
|
|
GetEffectType(eBad) == EFFECT_TYPE_DISEASE
|
|
)
|
|
{
|
|
//Remove effect if it is negative.
|
|
RemoveEffect(oTarget, eBad);
|
|
}
|
|
eBad = GetNextEffect(oTarget);
|
|
}
|
|
//Fire cast spell at event for the specified target
|
|
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
|
|
|
|
}
|
|
|
|
void ApplyPenalty(object oDead, int nAmount=50)
|
|
{
|
|
int nHD = GetHitDice(oDead);
|
|
if (nHD<=8)
|
|
{
|
|
nAmount=nAmount-20;
|
|
}
|
|
else
|
|
if (nHD==9)
|
|
{
|
|
nAmount=nAmount-10;
|
|
}
|
|
|
|
int nXP = GetXP(oDead);
|
|
int nLevel=GetHitDice(oDead);
|
|
int nPenalty = nAmount * GetHitDice(oDead);
|
|
|
|
int nNewXP = nXP - nPenalty;
|
|
|
|
if (nLevel<20)
|
|
{
|
|
// * You can not lose a level with this respawning
|
|
int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
|
|
|
|
|
|
if (nNewXP < nMin)
|
|
{
|
|
nNewXP = nMin;
|
|
}
|
|
}
|
|
|
|
|
|
if (nHD==1)
|
|
{
|
|
nNewXP = (nXP-10);
|
|
}
|
|
|
|
if (nNewXP < (nXP/10*9))
|
|
{
|
|
nNewXP = (nXP/10*9);
|
|
}
|
|
|
|
|
|
if (nNewXP < 1)
|
|
{
|
|
nNewXP = 1;
|
|
}
|
|
|
|
|
|
SetXP(oDead, nNewXP);
|
|
|
|
DelayCommand(4.0, FloatingTextStringOnCreature("Experience loss", oDead, FALSE));
|
|
}
|
|
|
|
void SetPCResLocation(object oPC)
|
|
{
|
|
object oBox=GetItemPossessedBy(oPC,"jw_crafting_gem");
|
|
string sWPTag=GetTag(GetArea(oPC))+"_res_wp";
|
|
object oResWP=GetWaypointByTag(sWPTag);
|
|
if (GetIsObjectValid(oResWP))
|
|
{
|
|
SetLocalString(oBox,"resloc",sWPTag);
|
|
}
|
|
}
|
|
|
|
string GetPCResLocation(object oPC)
|
|
{
|
|
object oBox=GetItemPossessedBy(oPC,"jw_crafting_gem");
|
|
string sWPTag=GetLocalString(oBox,"resloc");
|
|
return sWPTag;
|
|
}
|