Jump to content

Ks System


tim

Recommended Posts

Versuche gerade ein killstreak system zu erstellen wenn jemand lust hat mit zu machen änderungen oder vorschläge hat kann er sie gerne posten..

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index e9d7659..7096ce7 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -103,8 +103,10 @@ bool LoginQueryHolder::Initialize()
    res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGLYPHS,          "SELECT spec, slot, glyph FROM character_glyphs WHERE guid='%u'", m_guid.GetCounter());
    res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILS,           "SELECT id,messageType,sender,receiver,subject,body,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId,has_items FROM mail WHERE receiver = '%u' ORDER BY id DESC", m_guid.GetCounter());
    res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILEDITEMS,     "SELECT data, text, mail_id, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE receiver = '%u'", m_guid.GetCounter());
-
-    return res;
+    //Custom PVP
+    res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADPVP,             "SELECT totalkills, currentkills, totaldeaths, currentdeaths, groupkills, killstreak, lastkillguid, lastkillcount FROM character_pvp WHERE guid = %u", m_guid.GetCounter());
+    //end
+    return res;
}

// don't call WorldSession directly
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index 0f50875..297bcb3 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -825,7 +825,8 @@ ChatCommand * ChatHandler::getCommandTable()
        { "quit",           SEC_CONSOLE,        true,  &ChatHandler::HandleQuitCommand,                "", NULL },
        { "gearscore",      SEC_ADMINISTRATOR,  false, &ChatHandler::HandleShowGearScoreCommand,       "", NULL },
        { "mmap",           SEC_GAMEMASTER,     false, NULL,                                           "", mmapCommandTable },
-
+        //Custom Pvp System
+        { "getdmgheal",     SEC_ADMINISTRATOR,  false, &ChatHandler::HandleGetDmgHealCommand,          "", NULL },
        { NULL,             0,                  false, NULL,                                           "", NULL }
    };

@@ -1021,7 +1022,17 @@ void ChatHandler::PSendSysMessage(const char *format, ...)
    va_end(ap);
    SendSysMessage(str);
}
-
+//Cutom PVP
+void ChatHandler::PSendGlobalSysMessage(const char *format, ...)
+{
+    va_list ap;
+    char str [2048];
+    va_start(ap, format);
+    vsnprintf(str,2048,format, ap );
+    va_end(ap);
+    SendGlobalSysMessage(str);
+}
+//end
void ChatHandler::CheckIntegrity( ChatCommand *table, ChatCommand *parentCommand )
{
    for(uint32 i = 0; table[i].Name != NULL; ++i)
diff --git a/src/game/Chat.h b/src/game/Chat.h
index 7e72cdc..886ed45 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -97,7 +97,9 @@ class MANGOS_DLL_SPEC ChatHandler
        void SendSysMessage(          int32     entry);
        void PSendSysMessage(         const char *format, ...) ATTR_PRINTF(2,3);
        void PSendSysMessage(         int32     entry, ...  );
-
+        //Custom PVP
+        void PSendGlobalSysMessage(   const char *format, ...) ATTR_PRINTF(2,3);
+        //end
        bool ParseCommands(const char* text);
        ChatCommand const* FindCommand(char const* text);

@@ -597,6 +599,8 @@ class MANGOS_DLL_SPEC ChatHandler
        bool HandleWaterwalkCommand(char* args);
        bool HandleQuitCommand(char* args);
        bool HandleShowGearScoreCommand(char* args);
+        //Custom PvP System
+        bool HandleGetDmgHealCommand(char * args);

        bool HandleMmapPathCommand(char* args);
        bool HandleMmapLocCommand(char* args);
diff --git a/src/game/Group.cpp b/src/game/Group.cpp
index 5ca0c87..c146221 100644
--- a/src/game/Group.cpp
+++ b/src/game/Group.cpp
@@ -32,6 +32,8 @@
#include "MapPersistentStateMgr.h"
#include "Util.h"
#include "LootMgr.h"
+//Custom PVP
+#include "Chat.h"

#define LOOT_ROLL_TIMEOUT  (1*MINUTE*IN_MILLISECONDS)

@@ -1923,7 +1925,9 @@ void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap)
    uint32 sum_level = 0;
    Player* member_with_max_level = NULL;
    Player* not_gray_member_with_max_level = NULL;
-
+    //Custom PVP
+    Player* victim = NULL;
+    //end
    GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level,player_tap);

    if(member_with_max_level)
@@ -1935,7 +1939,11 @@ void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap)
        bool is_raid = PvP ? false : sMapStore.LookupEntry(pVictim->GetMapId())->IsRaid() && isRaidGroup();
        bool is_dungeon = PvP ? false : sMapStore.LookupEntry(pVictim->GetMapId())->IsDungeon();
        float group_rate = MaNGOS::XP::xp_in_group_rate(count,is_raid);
+        //Custom PVP
+        if(pVictim->GetTypeId() == TYPEID_PLAYER && PvP)

+            victim = (Player*)pVictim;
+        //end
        for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
        {
            Player* pGroupGuy = itr->getSource();
@@ -1950,13 +1958,44 @@ void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap)
                continue;                               // member (alive or dead) or his corpse at req. distance

            RewardGroupAtKill_helper(pGroupGuy, pVictim, count, PvP, group_rate, sum_level, is_dungeon, not_gray_member_with_max_level, member_with_max_level, xp);
-        }
-
+            //Custom PVP
+            // Reward group members
+
+            if(sWorld.getConfig(CONFIG_BOOL_PVP_SYSTEM_GROUP_FARMING_ENABLE))
+            {
+                //if(victim && (player_tap->GetSession()->GetRemoteAddress() != victim->GetSession()->GetRemoteAddress()))
+                    {        //only for alive group member or dead but with not released body or is in world
+                        if(pGroupGuy->isAlive()||!pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) || pGroupGuy->IsInWorld() )
+                            {
+                                ChatHandler(pGroupGuy).PSendSysMessage(PVP_CHAT_COLOR"Group member %s killed %s, you have been awarded a Badge of Justice", player_tap->GetName(), victim->GetName());
+                                pGroupGuy->StoreNewItemInBestSlots(29434, 1);
+                            }else
+                            ChatHandler(pGroupGuy).PSendSysMessage(PVP_CHAT_COLOR"Group member is not in world or dead and has  release his body so no reward");
+                    }
+            }
+        }
+        //end
        if(player_tap)
        {
            // member (alive or dead) or his corpse at req. distance
            if(player_tap->IsAtGroupRewardDistance(pVictim))
                RewardGroupAtKill_helper(player_tap, pVictim, count, PvP, group_rate, sum_level, is_dungeon, not_gray_member_with_max_level, member_with_max_level, xp);
-        }
-    }
+            //Custom PVP
+            // Handle victims death for PvP mod
+            if(sWorld.getConfig(CONFIG_BOOL_PVP_SYSTEM_GROUP_FARMING_ENABLE))
+                {
+                    //if(victim && (player_tap->GetSession()->GetRemoteAddress() != victim->GetSession()->GetRemoteAddress()))
+                        {
+                            victim->HandlePvPDeath(player_tap);
+                            ChatHandler(player_tap).PSendSysMessage(PVP_CHAT_COLOR"Group member %s killed %s, you have been awarded a Badge of Justice", player_tap->GetName(), victim->GetName());
+                
+                            player_tap->StoreNewItemInBestSlots(29434, 1);
+                            player_tap->PvP_CurrentDeaths = 0;
+                            player_tap->PvP_GroupKills +=1 ;
+
+                            
+                        }
+                }    
+        }
+}
}
diff --git a/src/game/Level0.cpp b/src/game/Level0.cpp
index 77b38a9..4248e83 100644
--- a/src/game/Level0.cpp
+++ b/src/game/Level0.cpp
@@ -89,7 +89,7 @@ bool ChatHandler::HandleStartCommand(char* /*args*/)

bool ChatHandler::HandleServerInfoCommand(char* /*args*/)
{
-    uint32 activeClientsNum = sWorld.GetActiveSessionCount();
+   /* uint32 activeClientsNum = sWorld.GetActiveSessionCount();
    uint32 queuedClientsNum = sWorld.GetQueuedSessionCount();
    uint32 maxActiveClientsNum = sWorld.GetMaxActiveSessionCount();
    uint32 maxQueuedClientsNum = sWorld.GetMaxQueuedSessionCount();
@@ -117,7 +117,7 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/)
    PSendSysMessage(LANG_USING_EVENT_AI,sWorld.GetCreatureEventAIVersion());
    PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
    PSendSysMessage(LANG_UPTIME, str.c_str());
-
+    */
    return true;
}

diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 211709a..a305fd3 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -7155,3 +7155,24 @@ bool ChatHandler::HandleMmapTestArea(char* args)

    return true;
}
+//custom PvP system
+bool ChatHandler::HandleGetDmgHealCommand(char* args)
+{
+    Player* pl = m_session->GetPlayer();
+    PSendSysMessage("Your guid is %u",pl->GetObjectGuid());
+    Player* plTarget = getSelectedPlayer();
+    if(!plTarget)
+    {
+        PSendSysMessage("You got no target, selected yourself instead");
+        plTarget = pl;
+    }
+    for (std::map<ObjectGuid, DamageHealData*>::iterator itr = plTarget->m_DamagersAndHealers.begin(); itr != plTarget->m_DamagersAndHealers.end(); ++itr)
+    {
+        PSendSysMessage("%u",itr->second->guid);
+        if (itr->second->damage > itr->second->healing)
+            PSendSysMessage("did %u damage",itr->second->damage);
+        else
+            PSendSysMessage("did %u healing",itr->second->healing);
+    }
+    return true;
+}
\\ No newline at end of file
diff --git a/src/game/Object.h b/src/game/Object.h
index 9e3ac08..b93c4a3 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -354,7 +354,8 @@ class MANGOS_DLL_SPEC Object
        uint16 GetValuesCount() const { return m_valuesCount; }

        void InitValues() { _InitValues(); }
-
+        //custom pvp system
+        Player* ToPlayer(){ if (GetTypeId() == TYPEID_PLAYER)  return reinterpret_cast<Player*>(this); else return NULL;  }
        virtual bool HasQuest(uint32 /* quest_id */) const { return false; }
        virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; }

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 2c378d8..bc412f7 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -509,6 +509,17 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m

    m_stableSlots = 0;

+    //Custom PVP
+  /////////////////// PvP System /////////////////////
+    PvP_TotalKills = 0;
+    PvP_CurrentKills = 0;
+    PvP_TotalDeaths = 0;
+    PvP_CurrentDeaths = 0;
+    PvP_KillStreak = 0;
+    PvP_GroupKills = 0;
+    PvP_LastKillGuid = 0;
+    PvP_LastKillCount = 0;
+    //end
    /////////////////// Instance System /////////////////////

    m_HomebindTimer = 0;
@@ -1332,7 +1343,7 @@ void Player::Update( uint32 update_diff, uint32 p_time )
        else
            m_nextSave -= update_diff;
    }
-
+    
    //Handle Water/drowning
    HandleDrowning(update_diff);

@@ -3580,7 +3591,33 @@ void Player::RemoveAllSpellCooldown()
        m_spellCooldowns.clear();
    }
}
+//Custom PVP
+void Player::_LoadPvPData(QueryResult* result)
+{
+    ////    we load this on right place so no need to activate^^            0           1             2            3              4           5           6             7
+    //QueryResult *result = CharacterDatabase.PQuery("SELECT totalkills, currentkills, totaldeaths, currentdeaths, groupkills, killstreak, lastkillguid, lastkillcount FROM character_pvp WHERE guid %u", GetGUIDLow());
+
+    if(result)
+    {
+        do
+        {
+            Field *fields = result->Fetch();
+
+            PvP_TotalKills    = fields[0].GetUInt32();
+            PvP_CurrentKills  = fields[1].GetUInt32();
+            PvP_TotalDeaths   = fields[2].GetUInt32();
+            PvP_CurrentDeaths = fields[3].GetUInt32();
+            PvP_GroupKills    = fields[4].GetUInt32();
+            PvP_KillStreak    = fields[5].GetUInt32();
+            PvP_LastKillGuid  = fields[6].GetUInt32();
+            PvP_LastKillCount = fields[7].GetUInt32();

+        } while( result->NextRow() );
+    }
+
+    delete result;
+}
+//end
void Player::_LoadSpellCooldowns(QueryResult *result)
{
    // some cooldowns can be already set at aura loading...
@@ -4273,6 +4310,9 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
            CharacterDatabase.PExecute("DELETE FROM character_equipmentsets WHERE guid = '%u'", lowguid);
            CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE PlayerGuid1 = '%u' OR PlayerGuid2 = '%u'", lowguid, lowguid);
            CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE PlayerGuid = '%u'", lowguid);
+            //Cutom PVP
+            CharacterDatabase.PExecute("DELETE FROM character_pvp WHERE guid = '%u'", lowguid);
+            //end
            CharacterDatabase.CommitTransaction();
            break;
        }
@@ -15992,7 +16032,9 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
    m_achievementMgr.CheckAllAchievementCriteria();

    _LoadEquipmentSets(holder->GetResult(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS));
-
+    //Custom PVP
+    _LoadPvPData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADPVP));
+    //end
    return true;
}

@@ -17388,7 +17430,9 @@ void Player::SaveToDB()
    GetSession()->SaveTutorialsData();                      // changed only while character in game
    _SaveGlyphs();
    _SaveTalents();
-
+    //Cutom PVP
+     _SavePvPData();
+     //end
    CharacterDatabase.CommitTransaction();

    // check if stats should only be saved on logout
@@ -17991,6 +18035,14 @@ void Player::_SaveTalents()
        }
    }
}
+//Custom PVP
+void Player::_SavePvPData()
+{
+    CharacterDatabase.PExecute("DELETE FROM character_pvp WHERE guid='%u'", GetGUIDLow());
+    CharacterDatabase.PExecute("INSERT INTO character_pvp (guid, totalkills, currentkills, totaldeaths, currentdeaths, groupkills, killstreak, lastkillguid, lastkillcount) VALUES
(%u, %u, 0, %u, 0, %u, %u, 0, 0)",
+        GetGUIDLow(), PvP_TotalKills, PvP_CurrentKills, PvP_TotalDeaths, PvP_CurrentDeaths, PvP_GroupKills, PvP_KillStreak, PvP_LastKillGuid, PvP_LastKillCount);
+}
+//end

// save player stats -- only for external usage
// real stats will be recalculated on player login
@@ -20980,7 +21032,158 @@ void Player::RewardSinglePlayerAtKill(Unit* pVictim)
            if(CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(pVictim->GetEntry()))
                KilledMonster(normalInfo, pVictim->GetObjectGuid());
    }
-}
+ 
+    //Custom PVP
+    /*********************************************************/
+    /***                  CUSTOM PVP SYSTEM                ***/
+    /*********************************************************/
+    // Stop here if:
+    // - The system is not active
+    if(!sWorld.getConfig(CONFIG_BOOL_PVP_SYSTEM_ENABLE))
+        return;
+    
+    uint8 MapRestriction = sWorld.getConfig(CONFIG_FLOAT_PVP_SYSTEM_RESTRICTION);
+
+    // Stop here if:
+    // - The player dont hit the Map Restriction
+    if( MapRestriction == 1 && !InBattleGround() && !HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP) ||
+        MapRestriction == 2 && !HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP) ||
+        MapRestriction == 3 && !InBattleGround())
+        return;
+
+    // Stop here if:
+    // - The victim isn't a player
+    // - The player killed himself
+    // - The player and the victim aren't in the same zone
+    // - The victim is 10 levels lower than the player
+    /*if( pVictim->GetTypeId() != TYPEID_PLAYER
+        || GetGUIDLow() == pVictim->GetGUIDLow ()
+        || GetZoneId() != pVictim->GetZoneId()
+        || getLevel() > pVictim->getLevel() + 10 )
+        return;*/
+    
+    Player* victim = (Player*)pVictim;
+
+    // Stop here if:
+    // - The player killed someone on the same IP address
+    // - The player is in a raid group
+   /* if ( GetSession()->GetRemoteAddress() == victim->GetSession()->GetRemoteAddress() )
+        return;*/
+    //|| ( GetGroup() && GetGroup()->isRaidGroup() )
+    ChatHandler pChat = ChatHandler(this);
+    ChatHandler vChat = ChatHandler(victim);
+    uint32 victimOldSpree = 0;
+    uint32 rewardCount = 0;
+
+    // If player has more than 10 kills assign to old spree variable
+    if(victim->PvP_CurrentKills >= 10)
+        victimOldSpree = victim->PvP_CurrentKills;
+
+    victim->HandlePvPDeath(this);
+/*
+   // Stop if the victim has been killed more than 2 times in a row
+    if (victim->GetGUIDLow() == PvP_LastKillGuid && PvP_LastKillCount > 2)
+    {
+        pChat.PSendSysMessage(PVP_CHAT_COLOR"You already killed this person twice in a row, so you will not be rewarded this time.");
+        return;
+    }
+    */
+    /* KILLER STATS */
+    ++PvP_CurrentKills;
+    ++PvP_TotalKills;
+    PvP_CurrentDeaths = 0;
+
+    // if some have higher Currentkills than his higest killstreak we renew his Killstreak data in Database for later use
+    if (PvP_CurrentKills > PvP_KillStreak)
+        PvP_KillStreak = PvP_CurrentKills;
+
+    if(PvP_LastKillGuid == victim->GetGUIDLow())
+    {
+        ++PvP_LastKillCount;
+    }
+    else
+    {
+        PvP_LastKillGuid = victim->GetGUIDLow();
+        PvP_LastKillCount = 1;
+    }
+
+    //Custom PVP
+    if(sWorld.getConfig(CONFIG_BOOL_PVP_SYSTEM_MORPH_ENABLE))
+        {    
+            if (GetDisplayId() != GetNativeDisplayId())
+                {
+                    DeMorph();
+                }
+                //todo more and right morph ids adding
+                if(PvP_CurrentKills >= 80)
+                    SetDisplayId(17526);
+                else if(PvP_CurrentKills  >= 60)
+                    SetDisplayId(25087);//titan
+                else if(PvP_CurrentKills  >= 40)
+                    SetDisplayId(25113);//donkey kong
+                else if(PvP_CurrentKills  >= 20)
+                    SetDisplayId(25113);
+                else if(PvP_CurrentKills  >= 10)
+                    SetDisplayId(25113);
+        }
+
+    //reward after each killstreak under 20 kills he get 1 Embleme under 20 to 39 he got 2 Emblems...
+    if(PvP_CurrentKills < 20)
+        rewardCount = 1;
+    else if(PvP_CurrentKills < 40)
+        rewardCount = 2;
+    else if(PvP_CurrentKills < 60)
+        rewardCount = 3;
+    else if(PvP_CurrentKills < 80)
+        rewardCount = 4;
+    else
+        rewardCount = 5;
+   
+    //Bonus for hitting Killstreak 20,40,60...
+   if(PvP_CurrentKills % 20 == 0)
+   {
+        rewardCount += 5;
+        pChat.PSendGlobalSysMessage(PVP_CHAT_GLOBAL_COLOR"%s is on a %u kill, killing spree! ", GetName(), PvP_CurrentKills);
+   }
+
+   //This is the reward for ending a killstreak of someone
+   if(victimOldSpree >= 80)
+        rewardCount += 12;
+   else if(victimOldSpree >= 60)
+        rewardCount += 10; 
+   else if(victimOldSpree >= 40)
+        rewardCount += 8;
+   else if(victimOldSpree >= 20)
+        rewardCount += 6;
+   else if(victimOldSpree >= 10)
+        rewardCount += 3;
+
+   // Give reward to killer for his own Killstreak + ending reward for killing someone on a streak
+       StoreNewItemInBestSlots(29434, rewardCount);
+    if(!this->HasAura(47883))
+    {
+    CastSpell(this, 47883, true);
+    }
+}
+
+void Player::HandlePvPDeath(Player* pKiller)
+{    
+    DeMorph();
+    ++PvP_CurrentDeaths;
+    ++PvP_TotalDeaths;
+
+    // We need this check to verify that our victim was on a Streak
+    if(PvP_CurrentKills >= 10)
+        ChatHandler(this).PSendGlobalSysMessage(PVP_CHAT_GLOBAL_COLOR"%s lost a %u kill, killing spree to %s!", GetName(), PvP_CurrentKills, pKiller->GetName());
+        //ChatHandler(this).PSendSysMessage(PVP_CHAT_COLOR"You were killed by %s. Your Consecutive Deaths: %u, Total Deaths: %u.", pKiller->GetName(), PvP_CurrentDeaths, PvP_TotalDeaths);
+    
+        //we return if victim has a soulstone (he dont loose his Currentkills)
+        if(HasAura(47883))
+        return;
+   // Reset players kills after death
+    PvP_CurrentKills = 0;
+}
+//end

void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource)
{
@@ -23081,6 +23284,24 @@ uint32 Player::GetEquipGearScore(bool withBags, bool withBank)
    else
        return 0;
}
+//custom pvp system
+void Player::DamagedOrHealed(ObjectGuid guid, uint32 damage, uint32 heal)
+{
+    ChatHandler(GetSession()).PSendSysMessage("%u",guid);
+    ChatHandler(GetSession()).PSendSysMessage("did %u damage",damage);
+    ChatHandler(GetSession()).PSendSysMessage("did %u healing",heal);
+    DamageHealData *data = NULL;
+
+    data = m_DamagersAndHealers[guid];
+    if(!data)
+    {
+        data = new DamageHealData();
+        m_DamagersAndHealers[guid] = data;
+    }
+    data->guid = guid;
+    data->damage += damage;
+    data->healing += heal;
+}

void Player::_fillGearScoreData(Item* item, GearScoreVec* gearScore, uint32& twoHandScore)
{
diff --git a/src/game/Player.h b/src/game/Player.h
index 5b2e8ec..6ca2cf7 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -56,10 +56,22 @@ class Spell;
class Item;

typedef std::deque<Mail*> PlayerMails;
+//Custom pvp system
+struct DamageHealData
+{
+    DamageHealData() : guid(), damage(0), healing(0) { }
+    ObjectGuid guid;
+    uint32 damage;
+    uint32 healing;
+};

#define PLAYER_MAX_SKILLS           127
#define PLAYER_MAX_DAILY_QUESTS     25
#define PLAYER_EXPLORED_ZONES_SIZE  128
+//Custom PVP
+#define PVP_CHAT_COLOR "|c000000ff[PvP]|r|cFFDAA520" //(Blue)[PvP](Goldenrod)Message
+#define PVP_CHAT_GLOBAL_COLOR "|c00ff0000[PvP]|r|cFF32CD32" //(Red)[PvP](Lime Green)Message
+//end

// Note: SPELLMOD_* values is aura types in fact
enum SpellModType
@@ -835,7 +847,9 @@ enum PlayerLoginQueryIndex
    PLAYER_LOGIN_QUERY_LOADTALENTS,
    PLAYER_LOGIN_QUERY_LOADWEEKLYQUESTSTATUS,
    PLAYER_LOGIN_QUERY_LOADMONTHLYQUESTSTATUS,
-
+    //Custom PVP
+    PLAYER_LOGIN_QUERY_LOADPVP,
+    //end
    MAX_PLAYER_LOGIN_QUERY
};

@@ -1014,6 +1028,10 @@ class MANGOS_DLL_SPEC Player : public Unit
        explicit Player (WorldSession *session);
        ~Player ( );

+        //custom pvp system
+        std::map<ObjectGuid, DamageHealData*> m_DamagersAndHealers;
+        void DamagedOrHealed(ObjectGuid guid, uint32 damage, uint32 heal);
+
        void CleanupsBeforeDelete();

        static UpdateMask updateVisualBits;
@@ -1090,6 +1108,9 @@ class MANGOS_DLL_SPEC Player : public Unit
        bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
        void SetGMVisible(bool on);
        void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
+        //Cutom PVP
+        void HandlePvPDeath(Player* pKiller);
+        //end

        // 0 = own auction, -1 = enemy auction, 1 = goblin auction
        int GetAuctionAccessMode() const { return m_ExtraFlags & PLAYER_EXTRA_AUCTION_ENEMY ? -1 : (m_ExtraFlags & PLAYER_EXTRA_AUCTION_NEUTRAL ? 1 : 0); }
@@ -1918,7 +1939,7 @@ class MANGOS_DLL_SPEC Player : public Unit
        void InitDisplayIds();

        bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const;
-        void RewardSinglePlayerAtKill(Unit* pVictim);
+        virtual void RewardSinglePlayerAtKill(Unit* pVictim);
        void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource);
        void RewardPlayerAndGroupAtCast(WorldObject* pRewardSource, uint32 spellid = 0);
        bool isHonorOrXPTarget(Unit* pVictim) const;
@@ -1951,6 +1972,20 @@ class MANGOS_DLL_SPEC Player : public Unit

        //End of PvP System

+        //Cutom PVP
+        /*********************************************************/
+        /***               CUSTOM PVP SYSTEM START             ***/
+        /*********************************************************/
+        uint32 PvP_TotalKills;
+        uint32 PvP_CurrentKills;
+        uint32 PvP_TotalDeaths;
+        uint32 PvP_CurrentDeaths;
+        uint32 PvP_KillStreak;
+        uint32 PvP_GroupKills;
+        uint32 PvP_LastKillGuid;
+        uint32 PvP_LastKillCount;
+        // End of custom PvP System
+    
        void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0);
        uint16 GetDrunkValue() const { return m_drunk; }
        static DrunkenState GetDrunkenstateByValue(uint16 value);
@@ -2387,6 +2422,9 @@ class MANGOS_DLL_SPEC Player : public Unit
        void _LoadBGData(QueryResult* result);
        void _LoadGlyphs(QueryResult *result);
        void _LoadIntoDataField(const char* data, uint32 startOffset, uint32 count);
+        //Custom PVP
+        void _LoadPvPData(QueryResult* result);
+        //end

        /*********************************************************/
        /***                   SAVE SYSTEM                     ***/
@@ -2407,8 +2445,10 @@ class MANGOS_DLL_SPEC Player : public Unit
        void _SaveGlyphs();
        void _SaveTalents();
        void _SaveStats();
-
-        void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
+        //Custom PVP
+        void _SavePvPData();
+        //end
+        void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
        void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;

        /*********************************************************/
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 27f398c..30c7f19 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -530,7 +530,13 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb)
}

uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss)
-{
+{    
+    //custom pvp system
+    if (pVictim->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER)
+    {
+        pVictim->ToPlayer()->DamagedOrHealed(GetObjectGuid(), damage, 0);
+    }
+
    // remove affects from attacker at any non-DoT damage (including 0 damage)
    if( damagetype != DOT)
    {
@@ -6067,7 +6073,13 @@ void Unit::UnsummonAllTotems()
}

int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellProto, bool critical, uint32 absorb)
-{
+{ 
+    //st pvp system
+    if (pVictim->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER)
+    {
+        pVictim->ToPlayer()->DamagedOrHealed(GetObjectGuid(), 0, addhealth);
+    }
+
    int32 gain = pVictim->ModifyHealth(int32(addhealth));

    Unit* unit = this;
@@ -7822,6 +7834,15 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)

void Unit::ClearInCombat()
{
+    //custom pvp system
+    if (GetTypeId() == TYPEID_PLAYER)
+    {
+        Player *p = ((Player*)this);
+
+        for (std::map<ObjectGuid, DamageHealData*>::iterator itr = p->m_DamagersAndHealers.begin(); itr != p->m_DamagersAndHealers.end(); ++itr)
+            delete itr->second; p->m_DamagersAndHealers.clear();
+    }
+
    m_CombatTimer = 0;
    RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);

diff --git a/src/game/World.cpp b/src/game/World.cpp
index b59ba84..c778cc1 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -65,6 +65,7 @@
#include "AuctionHouseBot/AuctionHouseBot.h"
#include "CharacterDatabaseCleaner.h"
#include "CreatureLinkingMgr.h"
+#include "ProgressBar.h"

INSTANTIATE_SINGLETON_1( World );

@@ -894,7 +895,13 @@ void World::LoadConfigSettings(bool reload)
    std::string ignoreMapIds = sConfig.GetStringDefault("mmap.ignoreMapIds", "");
    MMAP::MMapFactory::preventPathfindingOnMaps(ignoreMapIds.c_str());
    sLog.outString("WORLD: mmap pathfinding %sabled", getConfig(CONFIG_BOOL_MMAP_ENABLED) ? "en" : "dis");
-}
+
+     /*Custom PVP Killstreak System */
+    setConfig(CONFIG_BOOL_PVP_SYSTEM_ENABLE,"PvPSystem.Enable", true);
+    setConfig(CONFIG_BOOL_PVP_SYSTEM_MORPH_ENABLE,"PvPSystem.Morph.Enable", true);
+    setConfig(CONFIG_BOOL_PVP_SYSTEM_GROUP_FARMING_ENABLE,"PvPSystem.Group.Farming.Enable", true);
+    setConfig(CONFIG_FLOAT_PVP_SYSTEM_RESTRICTION,"PvPSystem.MapRestriction", 4);
+    }

/// Initialize the World
void World::SetInitialWorldSettings()
@@ -1386,6 +1393,9 @@ void World::SetInitialWorldSettings()

    sLog.outString("Initialize AuctionHouseBot...");
    sAuctionBot.Initialize();
+        
+    sLog.outString("Loading Killstreak System..."); 
+    //end

    sLog.outString( "WORLD: World initialized" );

diff --git a/src/game/World.h b/src/game/World.h
index 6e0cc08..21af8ee 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -274,7 +274,8 @@ enum eConfigFloatValues
    CONFIG_FLOAT_THREAT_RADIUS,
    CONFIG_FLOAT_GHOST_RUN_SPEED_WORLD,
    CONFIG_FLOAT_GHOST_RUN_SPEED_BG,
-    CONFIG_FLOAT_VALUE_COUNT
+    CONFIG_FLOAT_PVP_SYSTEM_RESTRICTION,
+    CONFIG_FLOAT_VALUE_COUNT
};

/// Configuration elements
@@ -333,7 +334,10 @@ enum eConfigBoolValues
    CONFIG_BOOL_VMAP_INDOOR_CHECK,
    CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT,
    CONFIG_BOOL_MMAP_ENABLED,
-    CONFIG_BOOL_VALUE_COUNT
+    CONFIG_BOOL_PVP_SYSTEM_ENABLE,
+    CONFIG_BOOL_PVP_SYSTEM_MORPH_ENABLE,
+    CONFIG_BOOL_PVP_SYSTEM_GROUP_FARMING_ENABLE,
+    CONFIG_BOOL_VALUE_COUNT
};

/// Can be used in SMSG_AUTH_RESPONSE packet
@@ -455,7 +459,7 @@ class World
        Weather* FindWeather(uint32 id) const;
        Weather* AddWeather(uint32 zone_id);
        void RemoveWeather(uint32 zone_id);
-
+                
        /// Get the active session server limit (or security level limitations)
        uint32 GetPlayerAmountLimit() const { return m_playerLimit >= 0 ? m_playerLimit : 0; }
        AccountTypes GetPlayerSecurityLimit() const { return m_playerLimit <= 0 ? AccountTypes(-m_playerLimit) : SEC_PLAYER; }
@@ -480,6 +484,9 @@ class World
        /// Get the current Message of the Day
        const char* GetMotd() const { return m_motd.c_str(); }

+        //Custom PvP System
+        void LoadPvPSystemData(); 
+
        LocaleConstant GetDefaultDbcLocale() const { return m_defaultDbcLocale; }

        /// Get the path where data (dbc, maps) are stored on disk
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index 2175180..7a70857 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1653,3 +1653,30 @@ SOAP.Port = 7878
CharDelete.Method = 0
CharDelete.MinLevel = 0
CharDelete.KeepDays = 30
+
+###################################################################################################################
+# PvP System (custom patch)
+#
+#    PvPSystem.Enable
+#         Enable/disable PvP System.
+#         Default: 1 (enabled)
+#                  0 (disabled)
+#
+#    PvPSystemk.MapRestriction
+#         The type of maps where players can have Killstreak
+#         Default: 4 - all maps
+#                  3 - battlegrounds only
+#                  2 - FFA areas only (both instanced and world arenas)
+#                  1 - battlegrounds and FFA areas only
+#
+#    PVPSystem.Morph
+#          Enable/disable PVP System Transforms
+#
+#
+#
+###################################################################################################################
+
+PvPSystem.Enable.Enable = 1
+PvPSystem.MapRestriction = 4
+PvPSystem.Morph.Enable = 1
+PvPSystem.Group.Farming.Enable = 1
\\ No newline at end of file

Inspired by this https://github.com/Lillecarl/one/commit/c5ff316854fbbd3f8d3857b4c5e39b23badaee93

Link to comment
Share on other sites

I would suggest you to please add credits to your post. Me and Kerhong are 2 of the people who have been working on your base code.

Shame on you! And this is far more then a killstreak system!

Google Translate:

Ich würde vorschlagen, Sie fügen Sie bitte Credits zu Ihrem Beitrag. Me and Kerhong sind 2 von den Menschen, die an Ihrer Basis-Code gearbeitet haben.

Shame on you! Und das ist weit mehr als ein Killstreak System!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use