View difference between Paste ID: LjF5x7h4 and mBUfpgaE
SHOW: | | - or go back to the newest paste.
1
#include "ScriptPCH.h"
2-
 
2+
// Edited from Parranoia's script:
3-
struct KillstreakData
3+
// http://pastebin.com/mBUfpgaE
4
5-
	int32 killstreak;
5+
struct KillstreakData { uint32 killstreak, high_ks; };
6-
	int32 high_ks;
6+
static UNORDERED_MAP<uint64, KillstreakData> m_killstreak;
7
8
void alertServer(Player * killer, Player * victim, uint32 killstreak, int code)
9-
typedef std::map<uint64 guid, KillstreakData> KillstreakMap;
9+
10-
static KillstreakMap m_killstreak;
10+
    char msg[256];
11
    switch(code)
12-
int32 GetKillstreak(Player * player, bool high)
12+
13
    case 0: sprintf(msg, "|cffff0000[Killstreak] |cffffffff%s's |cff00ffffkillstreak of %u has been ended by |cffffffff%s", victim->GetName(), killstreak, killer->GetName()); break;
14-
    QueryResult ks = CharacterDatabase.PQuery("SELECT ks, high_ks FROM killstreak WHERE guid = '%u'", player->GetGUIDLow());
14+
    case 1: sprintf(msg, "|cffff0000[Killstreak] |cffffffff%s|cff00ffff has a killstreak of %u", killer->GetName(), killstreak); break;
15-
    if (!ks)
15+
    case 2: sprintf(msg, "|cffff0000[Killstreak] |cffffffff%s|cff00ffff has a killstreak of %u. A bounty worth 50 arena points has been placed for their head.", killer->GetName(), killstreak); break;
16-
        return -1;
16+
17-
    Field * killstreak = ks->Fetch();
17+
18-
 
18+
19-
    return high ? killstreak[1].GetUInt32() : killstreak[0].GetUInt32();
19+
20
class Killstreak : public PlayerScript
21-
 
21+
22-
void alertServer(Player * killer, Player * victim, int32 killstreak, int code)
22+
public:
23
    Killstreak() : PlayerScript("Killstreak"){}
24-
	char msg[200];
24+
25-
 
25+
26
    {
27
        uint64 kGUID = killer->GetGUID();
28-
		case 0:
28+
        uint64 vGUID = victim->GetGUID();
29-
	 		sprintf(msg, "|cffff0000[Killstreak] |cffffffff%s's |cff00ffffkillstreak of %d has been ended by |cffffffff%s", victim->GetName(), killstreak, killer->GetName());
29+
        if (kGUID == vGUID)
30-
			break;
30+
31-
    	case 1:
31+
32-
			sprintf(msg, "|cffff0000[Killstreak] |cffffffff%s|cff00ffff has a killstreak of %d", killer->GetName(), killstreak);
32+
33-
			break;
33+
34-
	   case 2:
34+
        m_killstreak[kGUID].killstreak++;
35-
			sprintf(msg, "|cffff0000[Killstreak] |cffffffff%s|cff00ffff has a killstreak of %d. A bounty worth 50 arena points has been placed for their head.", killer->GetName(), killstreak);
35+
        uint32 kKillstreak = m_killstreak[kGUID].killstreak;
36-
			break;
36+
        uint32 vKillstreak = m_killstreak[vGUID].killstreak;
37
38-
 
38+
        m_killstreak[kGUID].high_ks = kKillstreak > m_killstreak[kGUID].high_ks ? kKillstreak : m_killstreak[kGUID].high_ks;
39
40
        if (vKillstreak >= 25)
41-
 
41+
            killer->ModifyArenaPoints(50);
42
        if (vKillstreak >= 5)
43
            alertServer(killer, victim, vKillstreak, 0);
44-
	public:
44+
        m_killstreak[vGUID].killstreak = 0;
45-
        Killstreak() : PlayerScript("Killstreak"){}
45+
46
        if(kKillstreak > 0) // hate large switches
47
        {
48
            if(kKillstreak % 5 == 0)
49-
        if (killer->GetGUIDLow() == victim->GetGUIDLow())
49+
            {
50
                alertServer(killer, victim, kKillstreak, kKillstreak <= 20 ? 1 : 2);
51
                if(kKillstreak == 5)
52
                    killer->AddItem(6657, 5);
53
                else if(kKillstreak == 15)
54-
        int32 kKillstreak = m_killstreak[killer->GetGUID()].killstreak;
54+
                    killer->AddItem(8529, 15);
55-
        int32 vKillstreak = m_killstreak[victim->GetGUID()].killstreak;
55+
                else if(kKillstreak % 10 == 0)
56
                    killer->AddItem(20558, uint32(kKillstreak/10));
57
            }
58-
            killer->SetArenaPoints(killer->GetArenaPoints() + 50);
58+
59
    }
60-
        if (kKillstreak == -1)
60+
61-
            m_killstreak[killer->GetGUID()].killstreak = 1;
61+
    void OnLogin(Player* player)
62-
		  else
62+
63-
			   m_killstreak[killer->GetGUID()].killstreak = kKillstreak++;
63+
        QueryResult ks = CharacterDatabase.PQuery("SELECT ks, high_ks FROM killstreak WHERE guid = %u", player->GetGUIDLow());
64-
        
64+
        if (!ks)
65-
        m_killstreak[killer->GetGUID()].high_ks = kKillstreak > m_killstreak[killer->GetGUID()].high_ks ? kKillstreak : m_killstreak[killer->GetGUID()].high_ks;
65+
66
        Field * killstreak = ks->Fetch();
67-
		  // Only send a server message if their streak is 5 or more
67+
        KillstreakData temp = {killstreak[0].GetUInt32(), killstreak[1].GetUInt32()};
68-
		  if (vKillstreak >= 5)
68+
        m_killstreak[player->GetGUID()] = temp;
69-
		  	   alertServer(killer, victim, vKillstreak, 0);
69+
70-
		  m_killstreak[victim->GetGUID()].killstreak = 0;
70+
71
    void OnLogout(Player* player)
72-
        switch(kKillstreak)
72+
73
        uint64 pGUID = player->GetGUID();
74-
            case 5:
74+
        if(m_killstreak.find(pGUID) != m_killstreak.end())
75-
                alertServer(killer, victim, kKillstreak, 1);
75+
            CharacterDatabase.PExecute("REPLACE INTO killstreak (guid, ks, high_ks) VALUES (%u, %u, %u)", m_killstreak[pGUID].killstreak, m_killstreak[pGUID].high_ks, player->GetGUIDLow());
76-
                killer->AddItem(6657, 5);
76+
77-
                break;
77+
78-
            case 10:
78+
79-
                alertServer(killer, victim, kKillstreak, 1);
79+
80-
                killer->AddItem(20558, 1);
80+
81-
                break;
81+
82-
            case 15:
82+