* Core/Scripts: fix Nightfall proc chance and reduce it for victims with level above 60
Adding a TrinityCore commit eac9c1f0b9
* Update rev_1597581112860069800.sql
* Update rev_1597581112860069800.sql
Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com>
Co-authored-by: Stefano Borzì <stefanoborzi32@gmail.com>
272 lines
7.7 KiB
C++
272 lines
7.7 KiB
C++
/*
|
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
|
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
*/
|
|
|
|
/* ScriptData
|
|
SDName: Item_Scripts
|
|
SD%Complete: 100
|
|
SDComment: Items for a range of different items. See content below (in script)
|
|
SDCategory: Items
|
|
EndScriptData */
|
|
|
|
/* ContentData
|
|
item_nether_wraith_beacon(i31742) Summons creatures for quest Becoming a Spellfire Tailor (q10832)
|
|
item_flying_machine(i34060, i34061) Engineering crafted flying machines
|
|
item_gor_dreks_ointment(i30175) Protecting Our Own(q10488)
|
|
item_only_for_flight Items which should only useable while flying
|
|
EndContentData */
|
|
|
|
#include "ScriptMgr.h"
|
|
#include "ScriptedCreature.h"
|
|
#include "Spell.h"
|
|
#include "Player.h"
|
|
|
|
/*#####
|
|
# item_only_for_flight
|
|
#####*/
|
|
|
|
enum OnlyForFlight
|
|
{
|
|
SPELL_ARCANE_CHARGES = 45072
|
|
};
|
|
|
|
class item_only_for_flight : public ItemScript
|
|
{
|
|
public:
|
|
item_only_for_flight() : ItemScript("item_only_for_flight") { }
|
|
|
|
bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/)
|
|
{
|
|
uint32 itemId = item->GetEntry();
|
|
bool disabled = false;
|
|
|
|
//for special scripts
|
|
switch (itemId)
|
|
{
|
|
case 24538:
|
|
if (player->GetAreaId() != 3628)
|
|
disabled = true;
|
|
break;
|
|
case 34489:
|
|
if (player->GetZoneId() != 4080)
|
|
disabled = true;
|
|
break;
|
|
case 34475:
|
|
if (const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(SPELL_ARCANE_CHARGES))
|
|
Spell::SendCastResult(player, spellInfo, 1, SPELL_FAILED_NOT_ON_GROUND);
|
|
break;
|
|
}
|
|
|
|
// allow use in flight only
|
|
if (player->IsInFlight() && !disabled)
|
|
return false;
|
|
|
|
// error
|
|
player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, nullptr);
|
|
return true;
|
|
}
|
|
};
|
|
|
|
/*#####
|
|
# item_nether_wraith_beacon
|
|
#####*/
|
|
|
|
class item_nether_wraith_beacon : public ItemScript
|
|
{
|
|
public:
|
|
item_nether_wraith_beacon() : ItemScript("item_nether_wraith_beacon") { }
|
|
|
|
bool OnUse(Player* player, Item* /*item*/, SpellCastTargets const& /*targets*/)
|
|
{
|
|
if (player->GetQuestStatus(10832) == QUEST_STATUS_INCOMPLETE)
|
|
{
|
|
if (Creature* nether = player->SummonCreature(22408, player->GetPositionX(), player->GetPositionY()+20, player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 180000))
|
|
nether->AI()->AttackStart(player);
|
|
|
|
if (Creature* nether = player->SummonCreature(22408, player->GetPositionX(), player->GetPositionY()-20, player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 180000))
|
|
nether->AI()->AttackStart(player);
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
/*#####
|
|
# item_gor_dreks_ointment
|
|
#####*/
|
|
|
|
class item_gor_dreks_ointment : public ItemScript
|
|
{
|
|
public:
|
|
item_gor_dreks_ointment() : ItemScript("item_gor_dreks_ointment") { }
|
|
|
|
bool OnUse(Player* player, Item* item, SpellCastTargets const& targets)
|
|
{
|
|
if (targets.GetUnitTarget() && targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT &&
|
|
targets.GetUnitTarget()->GetEntry() == 20748 && !targets.GetUnitTarget()->HasAura(32578))
|
|
return false;
|
|
|
|
player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, nullptr);
|
|
return true;
|
|
}
|
|
};
|
|
|
|
/*#####
|
|
# item_incendiary_explosives
|
|
#####*/
|
|
|
|
class item_incendiary_explosives : public ItemScript
|
|
{
|
|
public:
|
|
item_incendiary_explosives() : ItemScript("item_incendiary_explosives") { }
|
|
|
|
bool OnUse(Player* player, Item* item, SpellCastTargets const & /*targets*/)
|
|
{
|
|
if (player->FindNearestCreature(26248, 15) || player->FindNearestCreature(26249, 15))
|
|
return false;
|
|
else
|
|
{
|
|
player->SendEquipError(EQUIP_ERR_OUT_OF_RANGE, item, nullptr);
|
|
return true;
|
|
}
|
|
}
|
|
};
|
|
|
|
/*#####
|
|
# item_mysterious_egg
|
|
#####*/
|
|
|
|
class item_mysterious_egg : public ItemScript
|
|
{
|
|
public:
|
|
item_mysterious_egg() : ItemScript("item_mysterious_egg") { }
|
|
|
|
bool OnExpire(Player* player, ItemTemplate const* /*pItemProto*/)
|
|
{
|
|
ItemPosCountVec dest;
|
|
uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 39883, 1); // Cracked Egg
|
|
if (msg == EQUIP_ERR_OK)
|
|
player->StoreNewItem(dest, 39883, true);
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
/*#####
|
|
# item_disgusting_jar
|
|
#####*/
|
|
|
|
class item_disgusting_jar : public ItemScript
|
|
{
|
|
public:
|
|
item_disgusting_jar() : ItemScript("item_disgusting_jar") { }
|
|
|
|
bool OnExpire(Player* player, ItemTemplate const* /*pItemProto*/)
|
|
{
|
|
ItemPosCountVec dest;
|
|
uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 44718, 1); // Ripe Disgusting Jar
|
|
if (msg == EQUIP_ERR_OK)
|
|
player->StoreNewItem(dest, 44718, true);
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
/*#####
|
|
# item_petrov_cluster_bombs
|
|
#####*/
|
|
|
|
enum PetrovClusterBombs
|
|
{
|
|
SPELL_PETROV_BOMB = 42406,
|
|
AREA_ID_SHATTERED_STRAITS = 4064,
|
|
ZONE_ID_HOWLING = 495
|
|
};
|
|
|
|
class item_petrov_cluster_bombs : public ItemScript
|
|
{
|
|
public:
|
|
item_petrov_cluster_bombs() : ItemScript("item_petrov_cluster_bombs") { }
|
|
|
|
bool OnUse(Player* player, Item* item, const SpellCastTargets & /*targets*/)
|
|
{
|
|
if (player->GetZoneId() != ZONE_ID_HOWLING)
|
|
return false;
|
|
|
|
if (!player->GetTransport() || player->GetAreaId() != AREA_ID_SHATTERED_STRAITS)
|
|
{
|
|
player->SendEquipError(EQUIP_ERR_NONE, item, nullptr);
|
|
|
|
if (const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(SPELL_PETROV_BOMB))
|
|
Spell::SendCastResult(player, spellInfo, 1, SPELL_FAILED_NOT_HERE);
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
};
|
|
|
|
enum CapturedFrog
|
|
{
|
|
QUEST_THE_PERFECT_SPIES = 25444,
|
|
NPC_VANIRAS_SENTRY_TOTEM = 40187
|
|
};
|
|
|
|
class item_captured_frog : public ItemScript
|
|
{
|
|
public:
|
|
item_captured_frog() : ItemScript("item_captured_frog") { }
|
|
|
|
bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/)
|
|
{
|
|
if (player->GetQuestStatus(QUEST_THE_PERFECT_SPIES) == QUEST_STATUS_INCOMPLETE)
|
|
{
|
|
if (player->FindNearestCreature(NPC_VANIRAS_SENTRY_TOTEM, 10.0f))
|
|
return false;
|
|
else
|
|
player->SendEquipError(EQUIP_ERR_OUT_OF_RANGE, item, nullptr);
|
|
}
|
|
else
|
|
player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, nullptr);
|
|
return true;
|
|
}
|
|
};
|
|
|
|
// Only used currently for
|
|
// 19169: Nightfall
|
|
class item_generic_limit_chance_above_60 : public ItemScript
|
|
{
|
|
public:
|
|
item_generic_limit_chance_above_60() : ItemScript("item_generic_limit_chance_above_60") { }
|
|
|
|
bool OnCastItemCombatSpell(Player* /*player*/, Unit* victim, SpellInfo const* /*spellInfo*/, Item* /*item*/) override
|
|
{
|
|
// spell proc chance gets severely reduced on victims > 60 (formula unknown)
|
|
if (victim->getLevel() > 60)
|
|
{
|
|
// gives ~0.1% proc chance at lvl 70
|
|
float const lvlPenaltyFactor = 9.93f;
|
|
float const failureChance = (victim->getLevel() - 60) * lvlPenaltyFactor;
|
|
|
|
// base ppm chance was already rolled, only roll success chance
|
|
return !roll_chance_f(failureChance);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
void AddSC_item_scripts()
|
|
{
|
|
new item_only_for_flight();
|
|
new item_nether_wraith_beacon();
|
|
new item_gor_dreks_ointment();
|
|
new item_incendiary_explosives();
|
|
new item_mysterious_egg();
|
|
new item_disgusting_jar();
|
|
new item_petrov_cluster_bombs();
|
|
new item_captured_frog();
|
|
new item_generic_limit_chance_above_60();
|
|
}
|