Aschbourne_PRC8/_module/nss/pcwerewolfdeath.nss
GetOffMyYarn 69879d6957 Areas and Fixes
Added CCOH and missing areas
Changed some areas to be craftable,
Fixed some on death issues,
Fixed the Gaurd
2024-08-30 11:38:44 -04:00

178 lines
6.2 KiB
Plaintext

#include "NW_I0_GENERIC"
void main()
{
object oPlayer = GetFirstPC();
object oDeadNPC = OBJECT_SELF;
object oKiller = GetLastKiller();
//Make sure the PC we're looking at is valid, and keep cycling until the last PC
while (GetIsObjectValid(oPlayer))
{
if(GetLocalInt(oPlayer,"HAS_WEREWOLF_EFFECT") == 1)
{
int iCurHP = GetCurrentHitPoints(oPlayer);
int blarg = iCurHP-1;
object oWerewolf = GetLocalObject(oPlayer,"MY_WOLF");
location lCorpseLoc = GetLocation(oWerewolf);
effect eWolfDead = EffectDamage(blarg,DAMAGE_TYPE_MAGICAL,DAMAGE_POWER_NORMAL);
//Remove effects from the PC
effect eLoop=GetFirstEffect(oPlayer);
while (GetIsEffectValid(eLoop))
{
if (GetEffectType(eLoop)==EFFECT_TYPE_CUTSCENE_PARALYZE)
RemoveEffect(oPlayer, eLoop);
if (GetEffectType(eLoop)==EFFECT_TYPE_DAMAGE_REDUCTION)
RemoveEffect(oPlayer, eLoop);
if (GetEffectType(eLoop)==EFFECT_TYPE_IMMUNITY)
RemoveEffect(oPlayer, eLoop);
if (GetEffectType(eLoop)==EFFECT_TYPE_VISUALEFFECT)
RemoveEffect(oPlayer, eLoop);
if (GetEffectType(eLoop)==EFFECT_TYPE_ETHEREAL)
RemoveEffect(oPlayer, eLoop);
eLoop=GetNextEffect(oPlayer);
}
AssignCommand(oPlayer,JumpToLocation(lCorpseLoc));
DestroyObject(oWerewolf);
effect ePolymorphVFX = EffectVisualEffect(VFX_IMP_POLYMORPH);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePolymorphVFX, oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eWolfDead,oPlayer);
PlayVoiceChat(VOICE_CHAT_NEARDEATH,oPlayer);
object oFirstNPC = GetFirstObjectInShape(SHAPE_SPHERE,10.0,lCorpseLoc,FALSE,OBJECT_TYPE_CREATURE);
while(oFirstNPC != OBJECT_INVALID)
{
int iSeen = GetObjectSeen(oPlayer,oFirstNPC);
if (iSeen)
{
SetLocalInt(oPlayer,"WasSeen",1);
}
//Get next object.
oFirstNPC = GetNextObjectInShape(SHAPE_SPHERE,10.0,lCorpseLoc,FALSE,OBJECT_TYPE_CREATURE);
}
//End of the fun for making them watch themselves
SetCampaignInt("WWData","wolfdead", 1,oPlayer);
SetLocalInt(oPlayer,"wolfdead", 1);
}
oPlayer = GetNextPC();
}
//end werewolf stuff
int noleech = 0;
int nClass = GetLevelByClass(CLASS_TYPE_COMMONER);
int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
if(nClass > 0 && (nAlign == ALIGNMENT_GOOD || nAlign == ALIGNMENT_NEUTRAL))
{
AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
}
SpeakString("NW_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
//Shout Attack my target, only works with the On Spawn In setup
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1007));
}
float BaseEXP = ((GetChallengeRating(OBJECT_SELF)*3.0)+5);
float BonusEXP = GetChallengeRating(OBJECT_SELF)+5;
float BaseMonEXP = BaseEXP;
int NumOfParty = 0;
float PartyLevelSum = 0.0;
object oPartyMember = GetFirstFactionMember(oKiller, TRUE);
while(GetIsObjectValid(oPartyMember)) {
if (GetArea(OBJECT_SELF) == GetArea(oPartyMember))
{
int leech = GetHitDice(oPartyMember);
if (leech >= noleech){
noleech = leech;
}
NumOfParty++;
PartyLevelSum += GetCharacterLevel(oPartyMember);
}
oPartyMember = GetNextFactionMember(oKiller, TRUE);
}
if (PartyLevelSum <= 1.0)
{
PartyLevelSum = 1.0;
}
if (NumOfParty <= 1)
{
NumOfParty = 1;
}
float PartyAvgLvl = PartyLevelSum / NumOfParty;
//Calculate Adjustment Value
if (PartyAvgLvl <= 1.0)
{
PartyAvgLvl = 1.0;
}
float x = GetChallengeRating(OBJECT_SELF);
if (x <= 1.0)
{
x = 1.0;
}
float z = (x / PartyAvgLvl);
float AdjustValue = ((z+2)/3);
float FinalMonValue;
//Determine Final Experience Value
if (AdjustValue == 0.0) {
FinalMonValue = BaseMonEXP;
} else {
if (AdjustValue < 1.0) {
FinalMonValue = BaseMonEXP * AdjustValue;
} else {
FinalMonValue = BaseMonEXP + (BonusEXP * (AdjustValue * (1.10)));
}
}
//Determine the value of the Split EXP
if (NumOfParty >= 6)
{
NumOfParty = 5;
}
if (NumOfParty <= 1)
{
NumOfParty = 1;
}
if (FinalMonValue <= 1.0)
{
FinalMonValue = 1.0;
}
float SplitFinalEXP = FinalMonValue / NumOfParty;
if (SplitFinalEXP <= 1.0)
{
SplitFinalEXP = 1.0;
}
float y = (FinalMonValue - SplitFinalEXP);
if (y <= 1.0)
{
y = 1.0;
}
if (PartyAvgLvl >= 15.0)
{
FinalMonValue = FinalMonValue - ( PartyAvgLvl);
}
float PartyBonus = ((y +1)/ 1.75) + (FinalMonValue + ((21-PartyAvgLvl)/3));
int SFEint = FloatToInt(PartyBonus);
//Distribute EXP to all PCs in the Party
oPartyMember = GetFirstFactionMember(oKiller, TRUE);
while (GetIsObjectValid(oPartyMember)) {
if (GetArea(OBJECT_SELF) == GetArea(oPartyMember)) {
int nHD = GetHitDice(oPartyMember) + 1;
int nMax = (((nHD * (nHD - 1)) / 2) * 1000)+1;
if (nMax <= GetXP(oPartyMember) && nHD <= 40) {
SendMessageToPC(oPartyMember, "You cannot gain experience until you have leveled.");
} else if (GetIsDead(oPartyMember)) {
SendMessageToPC(oPartyMember, "You cannot gain experience while dead. Your XP has been reset.");
} else if ((GetHitDice(oPartyMember)) <= (noleech - 7) || (GetHitDice(oPartyMember)) >= FloatToInt(PartyAvgLvl) + 7) {
SendMessageToPC(oPartyMember, "All party members must be within 6 levels of each other.");
} else {
GiveXPToCreature(oPartyMember, SFEint);
}
}
oPartyMember = GetNextFactionMember(oKiller, TRUE);
}
}