PDA

View Full Version : [C++][TrinityCore] ZwowZ, Remove PVP flags from a player npc



Wise
22-02-11, 11:34 PM
//Created by Chronic
//of http://ZwowZ.com (http://zwowz.com/)
//Enjoy. Feel free to Improve/Include this script on your server.
//I have provided various functions that are capable of this.
//
#define GOSSIP_ITEM_1000 "Remove PVP Flags"
//#define GOSSIP_ITEM_903 ""

//duh
//uint32 m_contestedPvPTimer;
uint32 HasUnitState;
uint32 ClearUnitState;
uint32 RemoveByteFlag;
uint32 uiAction;



class npc_remove_pvp : public CreatureScript
{
public: npc_remove_pvp() : CreatureScript("npc_remove_pvp")
{
}

bool OnGossipHello(Player* pPlayer, Creature* pCreature)
{
if (pPlayer->isInCombat())
{
pCreature->MonsterWhisper("You Are In Combat!", pPlayer->GetGUID());
pPlayer->CLOSE_GOSSIP_MENU();
return true;
}
else
{
pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1000, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1000);
pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());

return true;
}
//Remove me from pvp
if (uiAction == GOSSIP_ACTION_INFO_DEF+1000)
{
//pPlayer->CastSpell(pPlayer, 20762, true),//Soul Stone
pPlayer->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP),
//m_contestedPvPTimer = 0, // another method I think for contested
//pPlayer->SetContestedPvPTimer(3), //another method
pPlayer->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP),
pPlayer->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP),
//pPlayer->RemoveFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP),//another method
pPlayer->HasAuraType(SPELL_AURA_MOD_FACTION),
pPlayer->RemoveAura(SPELL_AURA_MOD_FACTION),
pPlayer->HasUnitState(UNIT_STAT_ATTACK_PLAYER),
pPlayer->ClearUnitState(UNIT_STAT_ATTACK_PLAYER),
pPlayer->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER),
pPlayer->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP),
pPlayer->CLOSE_GOSSIP_MENU();
}

}
};

void AddSC_npc_remove_pvp()
{
new npc_remove_pvp();
}SQL

INSERT INTO `creature_template` VALUES ('9009002', '0', '0', '0', '0', '0', '18802', '0', '0', '0', 'Remove', 'Player vs Player', '', '0', '80', '80', '0', '35', '35', '1', '1', '1.14286', '1', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '', '0', '3', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', 'npc_remove_pvp', '12340');