Jump to content

Killstreak reset problem ?


tim

Recommended Posts

Hi Guys i have taken this from Trinity and make it working on mangos. The problem what i have is where and how do i reset the streak for Player if he hit alt F4 or logout button ingame ?

void Player::SendKillStreak(Player* pKiller, Player* pVictim)
{
   if(!sWorld.getConfig(CONFIG_BOOL_KILLSTREAK_ENABLE))
       return;

   uint8 MapRestriction    = sWorld.getConfig(CONFIG_FLOAT_KILLSTREAK_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;

   uint32 goldAmount                = sWorld.getConfig(CONFIG_FLOAT_KILLSTREAK_GOLD);
   uint32 RewardedForKillingSameP  = sWorld.getConfig(CONFIG_FLOAT_KILLSTREAK_SAME_PLAYER); //Name speaks for It self.
   uint32 AmountOfRewardsOnKillStreak[5] = { 2, 3, 4, 5, 6 }; 

   // Killstreak Steps
   const uint32 KillerStreak1 = 1;
   const uint32 KillerStreak2 = 2;
   const uint32 KillerStreak3 = 3; 
   const uint32 KillerStreak4 = 4; 
   const uint32 KillerStreak5 = 5;

   uint32 KillStreaks[5] = 
   {
       KillerStreak1,
       KillerStreak2,
       KillerStreak3,
       KillerStreak4,
       KillerStreak5,
   };

   struct SystemInfo
   {
       uint32              KillStreak;
       uint64              LastGUIDKill;
       uint8               KillCount;
   };

   static std::map<uint32, SystemInfo> KillingStreak;

   uint64 kGUID; 
   uint64 vGUID;
   char msg[500];
   kGUID = pKiller->GetGUID();
   vGUID = pVictim->GetGUID();

   if(kGUID == vGUID)
   {
       return;
   }

   if(KillingStreak[kGUID].LastGUIDKill == vGUID)
   {
       KillingStreak[kGUID].KillCount++;
       KillingStreak[vGUID].KillCount = 1;
   }

   if(KillingStreak[kGUID].LastGUIDKill != vGUID)
   {
       KillingStreak[kGUID].KillCount = 1;
       KillingStreak[vGUID].KillCount = 1;
   }

   // 3 kills same player anouncer to killer
   if(KillingStreak[kGUID].KillCount == 3)
   {   
       std::ostringstream msg;
       std::ostringstream KillerName;
       std::ostringstream KilledName;
       std::string pVictimColor    = "|cFF008000";
       std::string AreaColor        = "|CFFFE8A0E";

       KillerName << pKiller->GetName();
       KilledName << pVictim->GetName();
       std::ostringstream Kills;

       msg << AreaColor << "[PvP-"<< pKiller->GetMap()->GetMapName() << "] " << "|cffffffff == You pwned == " << KilledName.str().c_str();

       ChatHandler(this).SendSysMessage(msg.str().c_str());
   }

   // 3 kills same player anouncer to victim
   if(KillingStreak[kGUID].KillCount == 3)
   {   
       std::ostringstream msg;
       std::ostringstream KillerName;
       std::ostringstream KilledName;
       std::string pVictimColor    = "|cFF008000";
       std::string AreaColor        = "|CFFFE8A0E";

       KillerName << pKiller->GetName();
       KilledName << pVictim->GetName();
       std::ostringstream Kills;

       msg << AreaColor << "[PvP-"<< pKiller->GetMap()->GetMapName() << "] " << "|cffffffff == You get pwned by == " << KillerName.str().c_str();

       ChatHandler(pVictim).SendSysMessage(msg.str().c_str());
   }

   if(KillingStreak[kGUID].KillCount >= RewardedForKillingSameP)
   {
       return;
   }

   KillingStreak[kGUID].KillStreak++;
   KillingStreak[vGUID].KillStreak = 0;
   KillingStreak[kGUID].LastGUIDKill = vGUID;
   KillingStreak[vGUID].LastGUIDKill = 0;

   if(goldAmount > 0)
       {
           int hntmn = goldAmount+(KillingStreak[kGUID].KillStreak)*1000;

           // set the varables for our string
           int buffer, goldAmount = hntmn / 10000, silv = (hntmn % 10000) / 1000, copp = (hntmn % 10000) % 100;
           char const *addgoldstr;
           std::stringstream ss;
           std::string AreaColor        =  "|CFFFE8A0E";

           // build our string
           ss << AreaColor << "[PvP-"<< pKiller->GetMap()->GetMapName() << "] |cffffffff You recieve " << goldAmount << "." << silv << "" << copp << " gold for killing " << pVictim->GetName() << ".";

           // conver string to const chr
           std::string addgoldcstr = ss.str();
           addgoldstr = addgoldcstr.c_str();

           // send the player the gold
           pKiller->ModifyMoney(hntmn);
           SaveGoldToDB();

           // send the player the message
           ChatHandler(this).SendSysMessage(addgoldstr);
       }

   switch(KillingStreak[kGUID].KillStreak)
       {
           case KillerStreak1:
               // geht das hier so???????
               sprintf(msg, "%s has a %u killing-spree. ", pKiller->GetName(), KillerStreak1);
               //sWorld.SendWorldText(LANG_SYSTEMMESSAGE, msg);
               ChatHandler(this).SendSysMessage(msg);
               {
               //we Cast Illusion Test here
               pKiller->CastSpell(pKiller, 37806, false);
               }
               break;

           case KillerStreak2:



           case KillerStreak3:



       }
}

Link to comment
Share on other sites

  • 2 weeks later...
This were the most hacky damn system i have seen xD completley useless imo, rewrite it and add the variables to the player class and your system is solved.

Completley useless is your answer it has nothing to do with my question. I thought this is a learning project and we get some help in this forum. If you have better system post it. For me this system is working the only thing what not working or i dont know how to handel is the reset of streak on logoutrequest.

Link to comment
Share on other sites

This were the most hacky damn system i have seen xD completley useless imo, rewrite it and add the variables to the player class and your system is solved.

Completley useless is your answer it has nothing to do with my question. I thought this is a learning project and we get some help in this forum. If you have better system post it. For me this system is working the only thing what not working or i dont know how to handel is the reset of streak on logoutrequest.

Thing is, the players class gets erased from the memory each time the player logs off, and then you dont have to mess with more then really few variables.... Killstreak is enuf i suppose ;)

Link to comment
Share on other sites

  • 3 weeks later...

Very Simpel and very Basic...

Orginal designd by lillcarl (mangos one repro) modified by me...

Have fun guys...

v1.2

[== c++ ==]
diff --git a/dep/tbb/src/tbb/tbb_version.h b/dep/tbb/src/tbb/tbb_version.h index 07a91d6..3bb2f5c 100644 --- a/dep/tbb/src/tbb/tbb_version.h +++ b/dep/tbb/src/tbb/tbb_version.h @@ -33,7 +33,7 @@  #ifndef ENDL  #define ENDL "\\n"  #endif -#include "../../build/vsproject/version_string.tmp" +//#include "../../build/vsproject/version_string.tmp"    #ifndef __TBB_VERSION_STRINGS  #pragma message("Warning: version_string.tmp isn't generated properly by version_info.sh script!") diff --git a/src/game/Chat.h b/src/game/Chat.h index dacfd21..ba7d6ae 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -24,6 +24,21 @@  #include "SharedDefines.h"  #include "ObjectGuid.h"   +//Custom Killstreak system +#define MSG_COLOR_LIGHTRED     "|cffff6060" +#define MSG_COLOR_LIGHTBLUE    "|cff00ccff" +#define MSG_COLOR_BLUE         "|cff0000ff" +#define MSG_COLOR_GREEN        "|cff00ff00" +#define MSG_COLOR_ANN_GREEN    "|c1f40af20" +#define MSG_COLOR_RED          "|cffff0000" +#define MSG_COLOR_GOLD         "|cffffcc00" +#define MSG_COLOR_GREY         "|cff888888" +#define MSG_COLOR_WHITE        "|cffffffff" +#define MSG_COLOR_SUBWHITE     "|cffbbbbbb" +#define MSG_COLOR_MAGENTA      "|cffff00ff" +#define MSG_COLOR_YELLOW       "|cffffff00" +#define MSG_COLOR_CYAN         "|cff00ffff" +  struct AchievementEntry;  struct AchievementCriteriaEntry;  struct AreaTrigger; diff --git a/src/game/Object.h b/src/game/Object.h index 89927ee..c89556d 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -366,6 +366,9 @@ class MANGOS_DLL_SPEC Object            virtual bool HasQuest(uint32 /* quest_id */) const { return false; }          virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; } + +        //custom Killstreak system +        Player* ToPlayer(){ if (GetTypeId() == TYPEID_PLAYER)  return reinterpret_cast<Player*>(this); else return NULL;  }      protected:            Object ( ); diff --git a/src/game/Player.h b/src/game/Player.h index 7e3e96a..c41b230 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1085,6 +1085,17 @@ class MANGOS_DLL_SPEC Player : public Unit          explicit Player (WorldSession *session);          ~Player ( );   +        //Custom Killstreak PvP System Begin  +        uint32 KillStreak; +        uint32 TotalKills; +        uint32 TotalDeaths; +        uint32 ALastGuid; +        uint32 ALastGuidCount; +        uint32 VLastGuid; +        uint32 VLastGuidCount; +                      +        /* PvP System End */ +          void CleanupsBeforeDelete();            static UpdateMask updateVisualBits; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0111de9..16b3ee7 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -880,6 +880,238 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa      {          DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamage: victim just died");   +        //Custom Killstreak system/ +        if (pVictim->GetTypeId() == TYPEID_PLAYER && this->GetTypeId() == TYPEID_PLAYER) +        { +            Player *attacker = ToPlayer(); +            Player *victim = pVictim->ToPlayer(); +            bool GiveGold                = true; +            bool KillStreak                = true; +                                     +            if (attacker->isGameMaster() == true || victim->isGameMaster() == true) +            { +                if(victim->KillStreak > 4) +                { +                    ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You ended %s´s KillStreak of %u!",MSG_COLOR_RED,MSG_COLOR_WHITE, victim->GetName(), victim->KillStreak); +                    ChatHandler(victim).PSendSysMessage("%s[PvP System]%s Your KillStreak was ended by %s.",MSG_COLOR_RED,MSG_COLOR_WHITE,  attacker->GetName()); +                    victim->KillStreak = 0; +                    victim->TotalDeaths++; +                } +                else +                { +                    victim->KillStreak = 0; +                    victim->TotalDeaths++; +                } +            } +            else +            { +                if(victim->KillStreak > 4) +                { +                    ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You ended %s´s KillStreak of %u!",MSG_COLOR_RED,MSG_COLOR_WHITE, victim->GetName(), victim->KillStreak); +                    ChatHandler(victim).PSendSysMessage("%s[PvP System]%s Your KillStreak was ended by %s.",MSG_COLOR_RED,MSG_COLOR_WHITE, attacker->GetName()); +                    victim->KillStreak = 0; +                    victim->TotalDeaths++; +                } +                else +                { +                victim->KillStreak = 0; +                victim->TotalDeaths++; +                } + +                if (attacker == victim) +                { +                    //ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s Suicide or try to cheat the system!",MSG_COLOR_RED,MSG_COLOR_WHITE); +                    attacker->TotalDeaths++; +                    GiveGold = false; +                    KillStreak = false; +                } +                else if (victim->HasAura(2479)) +                { +                    ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You cant farm money or kills from a Player with [Honorless Target] Aura!",MSG_COLOR_RED,MSG_COLOR_WHITE); +                    GiveGold = false; +                    KillStreak = false; +                } +                else if (attacker->GetSession()->GetRemoteAddress() == victim->GetSession()->GetRemoteAddress()) +                { +                    ChatHandler(attacker).PSendSysMessage("%s[Anti Farming System]%s You have same ip as your victim", MSG_COLOR_RED, MSG_COLOR_WHITE); +                    ChatHandler(attacker).PSendSysMessage("%s this means you are on same network and could farm money together.", MSG_COLOR_WHITE); +                    GiveGold = false; +                    KillStreak = false; +                } +                //if not in Battelground no count +                else if (!attacker->GetMap()->IsBattleGround()) +                { +                    ChatHandler(attacker).PSendSysMessage("%s[Anti Farming System]%s Only in Battelgrounds we count kills for Streak system", MSG_COLOR_RED, MSG_COLOR_WHITE); +                    GiveGold = false; +                    KillStreak = false; +                } +                /*//if not in a FFA areas (both instanced and world arenas) no count +                else if (!attacker->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP)) +                { +                    ChatHandler(attacker).PSendSysMessage("%s[Anti Farming System]%s kills only count for FFA areas (both instanced and world arenas)", MSG_COLOR_RED, MSG_COLOR_WHITE); +                    GiveGold = false; +                    KillStreak = false; +                } +                //battlegrounds and FFA areas only both together from above +                else if (!attacker->InBattleGround() && !HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP)) +                { +                    ChatHandler(attacker).PSendSysMessage("%s[Anti Farming System]%s kills count in battlegrounds and FFA areas only both together", MSG_COLOR_RED, MSG_COLOR_WHITE); +                    GiveGold = false; +                    KillStreak = false; +                } +                //custom BG Zone +                else if (!attacker->GetMap() == 876) +                { +                    ChatHandler(attacker).PSendSysMessage("%s[Anti Farming System]%s kills count in in our custom Zone 876 GM Island", MSG_COLOR_RED, MSG_COLOR_WHITE); +                    GiveGold = false; +                    KillStreak = false; +                }*/ +                else if (victim->GetGUID() == attacker->ALastGuid || attacker->GetGUID() == victim->VLastGuid) +                { +                    attacker->ALastGuidCount++; +                    victim->VLastGuidCount++; +                    if (attacker->ALastGuidCount >= 3 && attacker->ALastGuidCount <= 5 || victim->VLastGuidCount >= 3 && victim->VLastGuidCount <= 5) +                    { +                        ChatHandler(attacker).PSendSysMessage("%s[Anti Farming System]%s You don't get awarded for killing a player more than 3 times in a row!.", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        GiveGold = false; +                        KillStreak = false; +                    } +                    else if (attacker->ALastGuidCount > 5 && attacker->ALastGuidCount < 10 || victim->VLastGuidCount > 5 && victim->VLastGuidCount < 10) +                    { +                        ChatHandler(attacker).PSendSysMessage("%s[Anti Farming System]%s You have killed this guy %u times in a row now whats your problem? Stop it or we Kick you out !!", MSG_COLOR_RED, MSG_COLOR_WHITE, attacker->ALastGuidCount); +                        GiveGold = false; +                        KillStreak = false; +                    } +                    else if (attacker->ALastGuidCount >= 10 || victim->VLastGuidCount >= 10) +                    { +                        ChatHandler(attacker).PSendSysMessage("%s[Anti Farming System]%s We don't like gankers GTFO!", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->GetSession()->KickPlayer(); +                        GiveGold = false; +                        KillStreak = false; +                    } +                } +                else +                { +                    attacker->ALastGuidCount = 0; +                } +            } + +            if (GiveGold == true) +            { +                uint32 InRangeCount = 1; +                const uint32 baserewardgold = 10000; +                uint32 rewardgold = 0; + +                if (attacker->GetGroup()) +                { +                    Group* grp = attacker->GetGroup(); +                    Player *pGroup; +                    for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) +                    { +                        pGroup = itr->getSource(); +                        if (pGroup && (pGroup->GetDistance(attacker->GetPositionX(),attacker->GetPositionY(),attacker->GetPositionZ()) < 20.0f || pGroup == attacker)) +                        { +                            InRangeCount++; +                        } +                    } +                    rewardgold = rewardgold+((baserewardgold*2)/InRangeCount); +                    for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) +                    { +                        pGroup = itr->getSource(); +                        if (pGroup && (pGroup->GetDistance(attacker->GetPositionX(),attacker->GetPositionY(),attacker->GetPositionZ()) < 20.0f || pGroup == attacker)) +                        { +                            ChatHandler(pGroup).PSendSysMessage("%s[PvP System]%s You get %u Gold for Assisting %s!",MSG_COLOR_RED, MSG_COLOR_WHITE, (rewardgold/10000), attacker->GetName()); +                            pGroup->ModifyMoney(+rewardgold); +                        } +                    } +                } +                else +                { +                    ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You get %u Gold for killing %s!",MSG_COLOR_RED,MSG_COLOR_WHITE,(baserewardgold/10000),victim->GetName()); +                       attacker->ModifyMoney(+baserewardgold); +                } +            } + +            if (KillStreak == true) +            { +                attacker->KillStreak++; +                attacker->TotalKills++; +                attacker->ALastGuid = victim->GetGUID(); +                victim->VLastGuid = attacker->GetGUID(); +                 +                const uint32 KillStreak1 = 10; +                const uint32 KillStreak2 = 20;  +                const uint32 KillStreak3 = 30;  +                const uint32 KillStreak4 = 40;  +                const uint32 KillStreak5 = 50; +                const uint32 KillStreak6 = 60; +                const uint32 KillStreak7 = 70;  +                const uint32 KillStreak8 = 80;  +                const uint32 KillStreak9 = 90;  +                const uint32 KillStreak10 = 100; + +                switch(attacker->KillStreak) +                    { +                        case KillStreak1: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 10 nothing special for you ...", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(10000)); +                        attacker->SetDisplayId(45); +                        break; + +                        case KillStreak2: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 20 watch your back.", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(20000)); +                        break; + +                        case KillStreak3: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 30 be carefull they are focus you! ", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(30000)); +                        break; + +                        case KillStreak4: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 40 woooohaaa looks like you have a run  !!!! ", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(40000)); +                        break; + +                        case KillStreak5: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 50 amazing is there anybody out there who can stop you? ", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(50000)); +                        break; + +                        case KillStreak6: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 60 you must be cheating...", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(60000)); +                        break; + +                        case KillStreak7: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 70 hell whats going on with you...", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(70000)); +                        break; + +                        case KillStreak8: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 80 this is unbelieveable.... ", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(80000)); +                        break; + +                        case KillStreak9: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 90 Now you are WANTED be carfule 10 more kills and you get the KS_SYSTEM REWARD ", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(90000)); +                        break; + +                        case KillStreak10: +                        ChatHandler(attacker).PSendSysMessage("%s[PvP System]%s You are on a KillStreak of 100 all good things have a [End my friend!!!!] ", MSG_COLOR_RED, MSG_COLOR_WHITE); +                        attacker->ModifyMoney(uint32(100000)); +                        attacker->KillStreak = 0; //End of Streak^^ +                        break; +                         +                    } +            } + + +        } +        /***********************************PVP SYSTEM END***********************************/ + +          // find player: owner of controlled `this` or `this` itself maybe          // for loot will be sued only if group_tap==NULL          Player *player_tap = GetCharmerOrOwnerPlayerOrPlayerItself(); diff --git a/src/game/Unit.h b/src/game/Unit.h index 2cb4d1f..3e3446b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -39,6 +39,9 @@  #include "Timer.h"  #include <list>   +//custom Killstreak +#include "Chat.h" +  enum SpellInterruptFlags  {      SPELL_INTERRUPT_FLAG_MOVEMENT     = 0x01, diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 51b6bfb..0ab906b 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -374,8 +374,8 @@ void WorldSession::LogoutPlayer(bool Save)      // finish pending transfers before starting the logout      while(_player && _player->IsBeingTeleportedFar())          HandleMoveWorldportAckOpcode(); - -    m_playerLogout = true; +     +    m_playerLogout = true;      m_playerSave = Save;        if (_player) @@ -532,7 +532,7 @@ void WorldSession::LogoutPlayer(bool Save)            // Playerbot - remember player GUID for update SQL below          uint32 guid = GetPlayer()->GetGUIDLow(); - +                  ///- Remove the player from the world          // the player may not be in the world when logging out          // e.g if he got disconnected during a transfer to another map @@ -540,11 +540,15 @@ void WorldSession::LogoutPlayer(bool Save)          if (_player->IsInWorld())          {              Map* _map = _player->GetMap(); +            //Custom Killstreak clear on logout +            _player->KillStreak = 0; //working?              _map->Remove(_player, true); -        } +        }          else          {              _player->CleanupsBeforeDelete(); +            //Custom Killstreak clear on logout +            _player->KillStreak = 0; //working?              Map::DeleteFromWorld(_player);          }  

Link to comment
Share on other sites

×
×
  • 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