UW2_PRC8/_module/nss/on_pc_equip.nss
Jaysyn904 5197ad9a4d Initial upload
Initial upload
2023-09-25 20:24:01 -04:00

171 lines
7.5 KiB
Plaintext

// Modified by AW Olorin 1-26-2004 - Crown exploit fix
int HasSpellEffect(object oPC, int iSpell);
void TakeOffCrown(object oItem, object oPC);
void PunishExploiter(object oPC, object oItem);
void main()
{
object oItemEquipped = GetPCItemLastEquipped();
object oPC = GetPCItemLastEquippedBy();
if(!GetIsObjectValid(oItemEquipped)) return;
if(GetTag(oItemEquipped) != "ImmortalCrown2") return;
// At this point Item being equipped IS the immortal crown.
// First check to see if character is a monk.
if(GetLevelByClass(CLASS_TYPE_MONK,oPC))
{
SendMessageToPC(oPC,"Your class prevents you from wearing the crown.");
TakeOffCrown(oItemEquipped,oPC);
return;
}
if(GetIsDM(oPC))
{
SendMessageToPC(oPC,"The crown is for mortals, shouldn't you be busting exploiters or running quests?");
AssignCommand(oPC,DestroyObject(oItemEquipped));
return;
}
// Next check to see if player is in town or area that they cannot wear the crown in.
object oNoCrown = GetNearestObjectByTag("nocrown", oPC, 0);
if(GetIsObjectValid(oNoCrown))
{
SendMessageToPC(oPC,"A higher power prevents you from wearing the crown here.");
TakeOffCrown(oItemEquipped,oPC);
return;
}
// At this point player can put crown on,
// so we unequip everything the player wearing to remove immunities.
AssignCommand(oPC,ClearAllActions(TRUE));
object oItem = GetItemInSlot (INVENTORY_SLOT_CHEST, oPC);
AssignCommand(oPC, ActionUnequipItem (oItem));
object oItem2 = GetItemInSlot (INVENTORY_SLOT_ARMS, oPC);
AssignCommand(oPC, ActionUnequipItem (oItem2));
object oItem3 = GetItemInSlot (INVENTORY_SLOT_BELT, oPC);
AssignCommand(oPC, ActionUnequipItem (oItem3));
object oItem4 = GetItemInSlot (INVENTORY_SLOT_BOOTS, oPC);
AssignCommand(oPC, ActionUnequipItem (oItem4));
object oItem5 = GetItemInSlot (INVENTORY_SLOT_LEFTHAND, oPC);
//if (oItem5 != GetItemPossessedBy(oPC, "immortaldagger1"))
AssignCommand(oPC, ActionUnequipItem (oItem5));
object oItem6 = GetItemInSlot (INVENTORY_SLOT_LEFTRING, oPC);
AssignCommand(oPC, ActionUnequipItem (oItem6));
object oItem7 = GetItemInSlot (INVENTORY_SLOT_NECK, oPC);
AssignCommand(oPC, ActionUnequipItem (oItem7));
object oItem8 = GetItemInSlot (INVENTORY_SLOT_RIGHTHAND, oPC);
// if (oItem8 != GetItemPossessedBy(oPC, "immortaldagger2"))
AssignCommand(oPC, ActionUnequipItem (oItem8));
object oItem9 = GetItemInSlot (INVENTORY_SLOT_RIGHTRING, oPC);
AssignCommand(oPC, ActionUnequipItem (oItem9));
object oItem10 = GetItemInSlot (INVENTORY_SLOT_CLOAK, oPC);
AssignCommand(oPC, ActionUnequipItem (oItem10));
if(HasSpellEffect(oPC,SPELL_CLARITY))
{
PunishExploiter(oPC,oItemEquipped);
return;
}
object check2 = GetItemPossessedBy(oPC, "immortaldagger1");
if (check2 == OBJECT_INVALID)
{
CreateItemOnObject("immortaldagger1", oPC, 1);
CreateItemOnObject("immortaldagger2", oPC, 1);
object claw1 = GetItemPossessedBy(oPC, "immortaldagger1");
object claw2 = GetItemPossessedBy(oPC, "immortaldagger2");
AssignCommand(oPC, ActionEquipItem(claw1 , INVENTORY_SLOT_LEFTHAND));
AssignCommand(oPC, ActionEquipItem(claw2, INVENTORY_SLOT_RIGHTHAND));
}
AssignCommand(oPC, RemoveFromParty(oPC));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_TENTACLE), oPC);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_GHOSTLY_PULSE), oPC);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PARALYZED), oPC);
DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectAbilityIncrease(ABILITY_STRENGTH, 10)), oPC));
DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectAbilityIncrease(ABILITY_DEXTERITY, 10)), oPC));
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectAbilityIncrease(ABILITY_CONSTITUTION, 10)), oPC));
DelayCommand(0.7, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectDamageResistance((DAMAGE_TYPE_ACID && DAMAGE_TYPE_BLUDGEONING && DAMAGE_TYPE_COLD && DAMAGE_TYPE_DIVINE && DAMAGE_TYPE_ELECTRICAL && DAMAGE_TYPE_FIRE && DAMAGE_TYPE_MAGICAL && DAMAGE_TYPE_NEGATIVE && DAMAGE_TYPE_PIERCING && DAMAGE_TYPE_POSITIVE && DAMAGE_TYPE_SLASHING && DAMAGE_TYPE_SONIC),30)), oPC));
DelayCommand(0.9, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectAttackIncrease(30, ATTACK_BONUS_ONHAND)), oPC));
DelayCommand(1.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectAttackIncrease(30, ATTACK_BONUS_OFFHAND)), oPC));
DelayCommand(1.5, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectAttackIncrease(30, ATTACK_BONUS_MISC)), oPC));
DelayCommand(1.7, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectDamageIncrease(60+d20(5), DAMAGE_TYPE_MAGICAL)), oPC));
DelayCommand(1.9, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectTrueSeeing()), oPC));
DelayCommand(2.1, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectHaste()), oPC));
DelayCommand(2.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectDamageIncrease(50, DAMAGE_TYPE_MAGICAL)), oPC));
DelayCommand(2.5, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectRegenerate(200, 2.0f)), oPC));
DelayCommand(3.0, ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(EffectConfused()), oPC));
}
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));
}
}
int HasSpellEffect(object oPC, int iSpell)
{
effect eProbe = GetFirstEffect(oPC);
while (GetIsEffectValid(eProbe))
{
if (GetEffectSpellId(eProbe) == iSpell) return TRUE;
eProbe = GetNextEffect(oPC);
}
return FALSE;
}
void PunishExploiter(object oPC, object oItem)
{
TakeOffCrown(oItem,oPC);
if (GetXP(oPC) > 190000) SetXP(oPC,171001);
else
{
int iXPLoss = GetXP(oPC);
iXPLoss -= ( (GetHitDice(oPC) - 1) * 1000);
SetXP(oPC,iXPLoss);
}
SendMessageToPC(oPC,"The Power of the Crown strives against the mind "
+ "immunity you have in effect. It is too much for your mortal mind "
+ " and body to take. You strip naked, start to shout gibberish about a "
+ "demon, and then die a horrible death. The essence of the crown also "
+ "takes some of your life essence.");
FloatingTextStringOnCreature("AHGGGG!!!!, My head!! There is a demon in my head!!!",
oPC,FALSE);
location locPC = GetLocation(oPC);
SetPlotFlag(oItem,FALSE);
AssignCommand(oPC,DestroyObject(oItem));
effect eDeath = EffectDeath();
CreateObject(OBJECT_TYPE_ITEM,"immortalcrown2",locPC);
DelayCommand(1.0,ApplyEffectToObject(DURATION_TYPE_INSTANT,eDeath,oPC));
}