Code:
#include "StdAfx.h"
#include "Setup.h"
//This struct will help us store the info we need for each player.
struct kill_info
{
kill_info()
{
streak = 0;
lguid = 0;
}
~kill_info() {}
uint16 streak; //Stores how many kills we have in a row
uint32 lguid; //Stores the last player killed guid to prevent abuse
};
static map<uint32, kill_info> kills;
void onPVP(Player * pPlayer, Player * pVictim)
{
//We don't want this script to affect GMs.
if(pPlayer->GetSession()->HasGMPermissions() || pVictim->GetSession()->HasGMPermissions())
return;
//We're storing the guids for easy access later
//They're our indexes of the 'kills' map.
uint32 p = pPlayer->GetGUIDLow();
uint32 v = pVictim->GetGUIDLow();
char msg[256] = ""; //This will store our message to the world
if(p == v) //If the player's guid is the same as the victim guid
{
sprintf(msg, "%s just commited suicide! Pathetic!", pPlayer->GetName());
sWorld.SendWorldWideScreenText(msg);
kills[v].streak = 0;
return;
}
//if we have a restricted no-pvp zone, define it here:
if(pPlayer->GetMapId() == 169 && pVictim->GetMapId() == 169) //In this case it's Emerald Forest
{
//Time to do nasty stuff
pPlayer->Reset_Spells();
pPlayer->Reset_Talents();
pPlayer->Reset_ToLevel1();
pPlayer->EventTeleport(1, 16226.2, 16403.3, -63);
pPlayer->BroadcastMessage("You were sent to jail for killing in the mall.");
char msg[1024];
snprintf(msg, 1024, "|cffff0000 %s the noob got kicked for fighting in the mall.", pPlayer->GetName());
sWorld.SendWorldText(msg);
pPlayer->Kick(60000);
return;
}
//Now let's check if the player killed the same guy twice. If so, give him nothing
if(kills[p].lguid == v)
return;
kills[p].streak++;
//Now it's time to run checks like, if the victim had X kills in a row, do this and that.
//I'm not including this, think up your own stuff ;)
//In the end we set the player's lguid to the current victim, and reset the victim's streak. Don't put this before the checks, for obvious reasons.
kills[p].lguid = v;
kills[v].streak = 0;
//This snippet changes the scale of the player. More kills = bigger scale. On my
//servers the more kills you have in a row, the more marks you're worth
//So this is a good way to see pinatas ;)
if(pPlayer->getRace == RACE_TAUREN) //Taurens start at 1.3 scale
pPlayer->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.3+((kills[p].streak-1)*0.2)); //Tricky line! We take the streak - 1 (so only double kills and up would count), and multiply by 0.2. So 5 kills are 1.3 + 0.8
else
pPlayer->SetFloatValue(OBJECT_FIELD_SCALE_X, 1+((kills[p].streak-1)*0.2)); //Same here, just the base scale is 1
} //Don't forget me!
//And of course we need to set it up now
void SetupPVP(ScriptMgr * mgr)
{
//We register the onPVP function to the ON_KILL hook, so every time a player kills another player, the function gets called.
mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, &onPVP);
}
Now all you need to do is add the appropriate lines in setup.h and setup.cpp and compile