Jump to content

[HELP] Adding loot and rewards to HK's.


Guest blainicus
 Share

Recommended Posts

Alright, so I'm working on recompiling and I have it down to the guts of the new stuff in error, no errors in the rest of the code.

The intended effect is to grant 10 silver and 100 exp per level of the killed target, in BG's only, to all players in range for an HK.

The error is "identifier not found" for

getVictim()

GiveXP()

ModifyMoney()

All of the functions i copied from other CPP file snippets, but I don't know how to cause them to be declared, and I'm not 100% sure the syntax is correct for the effect other than that.

This is the only edited section of any code. It is in Battleground.cpp. Unedited HK's and battlegrounds do work.

void BattleGround::HandleKillPlayer( Player *player, Player *killer )
{
   //keep in mind that for arena this will have to be changed a bit

   // add +1 deaths
   UpdatePlayerScore(player, SCORE_DEATHS, 1);

   // add +1 kills to group and +1 killing_blows to killer
   if (killer)
   {
       Unit *pVictim = getVictim();
       uint32 v_level1 = (pVictim->getLevel());
       uint32 loot1 = (1000*v_level1);
       GiveXP(100*v_level1);
       ModifyMoney((int32)loot1);
       UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1);
       UpdatePlayerScore(killer, SCORE_KILLING_BLOWS, 1);

       for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
       {
           Player *plr = objmgr.GetPlayer(itr->first);

           if (!plr || plr == killer)
               continue;

           if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player))
               Unit *pVictim = getVictim();
               uint32 v_level1 = (pVictim->getLevel());
               uint32 loot1 = (1000*v_level1);
               GiveXP(100*v_level1);
               ModifyMoney((int32)loot1);
               UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1);
       }
   }

   // to be able to remove insignia -- ONLY IN BattleGrounds
   if (!isArena())
       player->SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE );
}

Link to comment
Share on other sites

void BattleGround::HandleKillPlayer( Player *player, Player *killer )
{
   //keep in mind that for arena this will have to be changed a bit

   // add +1 deaths
   UpdatePlayerScore(player, SCORE_DEATHS, 1);

   // add +1 kills to group and +1 killing_blows to killer
   if (killer)
   {
Unit *pVictim = killer->getVictim();
       uint32 v_level1 = (pVictim->getLevel());
       uint32 loot1 = (1000*v_level1);
       killer->GiveXP(100*v_level1);
       killer->ModifyMoney((int32)loot1);
       UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1);
       UpdatePlayerScore(killer, SCORE_KILLING_BLOWS, 1);

       for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
       {
           Player *plr = objmgr.GetPlayer(itr->first);

           if (!plr || plr == killer)
               continue;

           if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player))
	Unit *pVictim = killer->getVictim();
               uint32 v_level1 = (pVictim->getLevel());
               uint32 loot1 = (1000*v_level1);
               plr->GiveXP(100*v_level1);
               plr->ModifyMoney((int32)loot1);
               UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1);
       }
   }

   // to be able to remove insignia -- ONLY IN BattleGrounds
   if (!isArena())
       player->SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE );
}

Link to comment
Share on other sites

You are a god ;O thanks very very much.

It's only the following error now:

..\\..\\src\\game\\BattleGround.cpp(1691) : error C2660: 'Player::GiveXP' : function does not take 1 arguments

..\\..\\src\\game\\BattleGround.cpp(1707) : error C2660: 'Player::GiveXP' : function does not take 1 arguments

...Not fixed, working on it

Link to comment
Share on other sites

Correction, I fixed the error messages by adding ( ,plr) and ( ,killer) to the arguments, and that removed the error, but it may or may not work.

Update: tested with experience gain left out of the compilation, server still crashes due to money code.

error log:

Revision: * * SITML-Dev 8541 *
Date 11:10:2009. Time 12:39 
//=====================================================
*** Hardware ***
Processor: Intel(R) Pentium(R) D CPU 3.00GHz
Number Of Processors: 2
Physical Memory: 2095124 KB (Available: 519136 KB)
Commit Charge Limit: 4033388 KB

*** Operation System ***
Microsoft Windows XP Home Edition Service Pack 3 (Version 5.1, Build 2600)

//=====================================================
Exception code: C0000005 ACCESS_VIOLATION
Fault address:  00401457 01:00000457 C:\\Documents and Settings\\Owner\\Desktop\\Mangos322a\\mangosd.exe

Registers:
EAX:00000035
EBX:1AC6BD18
ECX:00000000
EDX:00000000
ESI:00000000
EDI:0084D320
CS:EIP:001B:00401457
SS:ESP:0023:053E3104  EBP:053E4118
DS:0023  ES:0023  FS:003B  GS:0000
Flags:00010282

Call stack:
Address   Frame     Function      SourceFile
00401457  00000000  Object::GetUInt32Value+27
00709D0E  00000000  BattleGround::HandleKillPlayer+4E
007DFFDE  00000000  BattleGroundWS::HandleKillPlayer+3E
0045584D  00000000  Unit::DealDamage+116D
00456EB3  00000000  Unit::DealSpellDamage+173
00691B08  00000000  Spell::DoAllEffectOnTarget+438
00697D85  00000000  Spell::handle_delayed+C5
006A404B  00000000  SpellEvent::Execute+15B
00884B2C  00000000  EventProcessor::Update+EC
0045341B  00000000  Unit::Update+3B
004BDA8C  00000000  Player::Update+EC
00497276  00000000  Map::Update+D6
007D8E7E  00000000  MapInstanced::Update+DE
006008F8  00000000  MapManager::Update+128
005E562B  00000000  World::Update+77B
0042F81E  00000000  WorldRunnable::run+8E
0084D339  00000000  ACE_Based::Thread::ThreadTask+19
00A614D4  00000000  __WSAFDIsSet+FFFFFFFFFFFCC45C
78543433  00000000  _endthreadex+44
785434C7  00000000  _endthreadex+D8
7C80B729  00000000  GetModuleFileNameA+1BA

Call stack:
Address   Frame     Function      SourceFile
7C90E514  00000000  KiFastSystemCallRet+0
7C802542  00000000  WaitForSingleObject+12
00A19C64  00000000  __WSAFDIsSet+FFFFFFFFFFF84BEC
00A864DA  00000000  __WSAFDIsSet+FFFFFFFFFFFF1462
00A8269F  00000000  __WSAFDIsSet+FFFFFFFFFFFED627
005FD63A  00000000  WorldSocketMgr::Wait+4A
1AA4EA54  00000000  0000:00000000 
1AA4EA54  00000000  0000:00000000 
6C696146  00000000  

crash log when XP was used but money was not:

Revision: * * SITML-Dev 8541 *
Date 11:10:2009. Time 13:5 
//=====================================================
*** Hardware ***
Processor: Intel(R) Pentium(R) D CPU 3.00GHz
Number Of Processors: 2
Physical Memory: 2095124 KB (Available: 295132 KB)
Commit Charge Limit: 4033388 KB

*** Operation System ***
Microsoft Windows XP Home Edition Service Pack 3 (Version 5.1, Build 2600)

//=====================================================
Exception code: C0000005 ACCESS_VIOLATION
Fault address:  00401457 01:00000457 C:\\Documents and Settings\\Owner\\Desktop\\Mangos322a\\mangosd.exe

Registers:
EAX:00000035
EBX:1AC47F98
ECX:00000000
EDX:00000000
ESI:053FF7E4
EDI:0084D330
CS:EIP:001B:00401457
SS:ESP:0023:053E9E84  EBP:053EAE98
DS:0023  ES:0023  FS:003B  GS:0000
Flags:00010206

Call stack:
Address   Frame     Function      SourceFile
00401457  00000000  Object::GetUInt32Value+27
00709D0E  00000000  BattleGround::HandleKillPlayer+4E
007DFFEE  00000000  BattleGroundWS::HandleKillPlayer+3E
0045584D  00000000  Unit::DealDamage+116D
00786613  00000000  ChatHandler::HandleDieCommand+103
0053A2D4  00000000  ChatHandler::ExecuteCommandInTable+284
0053AAEF  00000000  ChatHandler::ParseCommands+19F
00827E0F  00000000  WorldSession::HandleMessagechatOpcode+56F
005C5082  00000000  WorldSession::Update+192
005E697E  00000000  World::UpdateSessions+CE
005E5215  00000000  World::Update+365
0042F81E  00000000  WorldRunnable::run+8E
0084D349  00000000  ACE_Based::Thread::ThreadTask+19
00A614D4  00000000  __WSAFDIsSet+FFFFFFFFFFFCC45C
78543433  00000000  _endthreadex+44
785434C7  00000000  _endthreadex+D8
7C80B729  00000000  GetModuleFileNameA+1BA

Call stack:
Address   Frame     Function      SourceFile
7C90E514  00000000  KiFastSystemCallRet+0
7C802542  00000000  WaitForSingleObject+12
00A19C64  00000000  __WSAFDIsSet+FFFFFFFFFFF84BEC
00A864DA  00000000  __WSAFDIsSet+FFFFFFFFFFFF1462
00A8269F  00000000  __WSAFDIsSet+FFFFFFFFFFFED627
005FD63A  00000000  WorldSocketMgr::Wait+4A
1AA5102C  00000000  0000:00000000 
1AA5102C  00000000  0000:00000000 
6C696146  00000000  

Code used for exp only:

void BattleGround::HandleKillPlayer( Player *player, Player *killer )
{
   //keep in mind that for arena this will have to be changed a bit

   // add +1 deaths
   UpdatePlayerScore(player, SCORE_DEATHS, 1);

   // add +1 kills to group and +1 killing_blows to killer
   if (killer)
   {
       Unit *pVictim = killer->getVictim();
       uint32 v_level1 = (pVictim->getLevel());
       uint32 loot1 = (1000*v_level1);
       uint32 loot3 = (100*v_level1);
       killer->GiveXP((int32)loot3, killer);
       UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1);
       UpdatePlayerScore(killer, SCORE_KILLING_BLOWS, 1);

       for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
       {
           Player *plr = objmgr.GetPlayer(itr->first);

           if (!plr || plr == killer)
               continue;

           if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player))
               Unit *pVictim = killer->getVictim();
               uint32 v_level2 = (pVictim->getLevel());
               uint32 loot2 = (1000*v_level2);
               uint32 loot4 = (100*v_level2);
               plr->GiveXP((int32)loot4, plr);
               UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1);
       } 

Link to comment
Share on other sites

void BattleGround::HandleKillPlayer( Player *player, Player *killer )
{
   // add +1 deaths
   UpdatePlayerScore(player, SCORE_DEATHS, 1);

   // add +1 kills to group and +1 killing_blows to killer
   if (killer)
   {
       uint32 v_level1 = (player->getLevel());
       uint32 loot = (1000*v_level1);
       uint32 exp = (100*v_level1);
       killer->SetUInt32Value(PLAYER_XP, killer->GetUInt32Value(PLAYER_XP) + exp);
       killer->ModifyMoney(loot);
       UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1);
       UpdatePlayerScore(killer, SCORE_KILLING_BLOWS, 1);

       for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
       {
           Player *plr = objmgr.GetPlayer(itr->first);

           if (!plr || plr == killer)
               continue;

           if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player))
           {
               plr->SetUInt32Value(PLAYER_XP, plr->GetUInt32Value(PLAYER_XP) + exp);
               plr->ModifyMoney(loot);
               UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1);
           }

       }
   }

   // to be able to remove insignia -- ONLY IN BattleGrounds
   if (!isArena())
       player->SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE );
}

Link to comment
Share on other sites

 Share

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