[Feature] Implement OP_CashReward (#2307)

* Implement OP_CashReward

Tit opcode needs verifying still, I think it's correct.

Added Perl and lua client CashReward functions

* Forgot AddMoneyToPP call somehow

* Switch QuestManager::givecash to CashReward packet

* Fix extra comma
This commit is contained in:
Michael Cook (mackal) 2022-07-14 22:17:44 -04:00 committed by GitHub
parent ce74ac9913
commit 139845f971
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 45 additions and 16 deletions

View File

@ -71,6 +71,7 @@ N(OP_Camp),
N(OP_CancelSneakHide),
N(OP_CancelTask),
N(OP_CancelTrade),
N(OP_CashReward),
N(OP_CastSpell),
N(OP_ChangeSize),
N(OP_ChannelMessage),

View File

@ -2192,6 +2192,14 @@ struct QuestReward_Struct
/*068*/
};
struct CashReward_Struct
{
/*000*/ uint32 copper;
/*004*/ uint32 silver;
/*008*/ uint32 gold;
/*012*/ uint32 platinum;
};
// Size: 8
struct Camera_Struct
{

View File

@ -311,6 +311,7 @@ OP_SendFindableNPCs=0x34c3
OP_FindPersonRequest=0x2f3b
OP_FindPersonReply=0x44f7
OP_Sound=0x3cec
OP_CashReward=0x17a5
OP_PetBuffWindow=0x7197
OP_LevelAppearance=0x7c4d
OP_Translocate=0x6f01

View File

@ -312,6 +312,7 @@ OP_SendFindableNPCs=0x4613
OP_FindPersonRequest=0x5cea
OP_FindPersonReply=0x7e58
OP_Sound=0x1a30
OP_CashReward=0x5f7a
OP_PetBuffWindow=0x5882
OP_LevelAppearance=0x3bc9
OP_Translocate=0x6580

View File

@ -307,6 +307,7 @@ OP_SendFindableNPCs=0x5360
OP_FindPersonRequest=0x3168 # C
OP_FindPersonReply=0x1ac8 # C
OP_Sound=0x303e # C
OP_CashReward=0x3703
OP_PetBuffWindow=0x2dd3 # C
OP_LevelAppearance=0x6dc3 # C
OP_Translocate=0x2042 # C

View File

@ -299,6 +299,7 @@ OP_Stun=0x55BF #Derision 2009
OP_FindPersonRequest=0x07F0 #Derision 2009
OP_FindPersonReply=0x7770 #Derision 2009
OP_Sound=0x2B02 #Derision 2009
OP_CashReward=0x5e80
OP_PetBuffWindow=0x124A #Derision 2009
OP_LevelAppearance=0x3EC8 #Derision 2009
OP_Translocate=0x1F0F #Derision 2009

View File

@ -437,6 +437,7 @@ OP_FindPersonReply=0x5711 # ShowEQ 10/27/05
OP_ForceFindPerson=0x0000
OP_LoginComplete=0x0000
OP_Sound=0x541e
OP_CashReward=0x4c8c #maybe
#OP_Zone_MissingName01=0x0000 #remove on recompile
OP_MobRename=0x0498 # ShowEQ 10/27/05
OP_BankerChange=0x6a5b

View File

@ -316,6 +316,7 @@ OP_SendFindableNPCs=0x6193 # C
OP_FindPersonRequest=0x1e04 # C
OP_FindPersonReply=0x7cae # C
OP_Sound=0x737a # C
OP_CashReward=0x039d
OP_PetBuffWindow=0x7b87 # C
OP_LevelAppearance=0x1bd4 # C
OP_Translocate=0x3d9c # C

View File

@ -8798,6 +8798,20 @@ void Client::QuestReward(Mob* target, const QuestReward_Struct &reward, bool fac
safe_delete(outapp);
}
void Client::CashReward(uint32 copper, uint32 silver, uint32 gold, uint32 platinum)
{
auto outapp = std::make_unique<EQApplicationPacket>(OP_CashReward, sizeof(CashReward_Struct));
auto outbuf = reinterpret_cast<CashReward_Struct *>(outapp->pBuffer);
outbuf->copper = copper;
outbuf->silver = silver;
outbuf->gold = gold;
outbuf->platinum = platinum;
AddMoneyToPP(copper, silver, gold, platinum);
QueuePacket(outapp.get());
}
void Client::SendHPUpdateMarquee(){
if (!this || !IsClient() || !current_hp || !max_hp)
return;

View File

@ -1632,6 +1632,7 @@ public:
void QuestReward(Mob* target, uint32 copper = 0, uint32 silver = 0, uint32 gold = 0, uint32 platinum = 0, uint32 itemid = 0, uint32 exp = 0, bool faction = false);
void QuestReward(Mob* target, const QuestReward_Struct &reward, bool faction); // TODO: Fix faction processing
void CashReward(uint32 copper, uint32 silver, uint32 gold, uint32 platinum);
void ResetHPUpdateTimer() { hpupdate_timer.Start(); }

View File

@ -1765,6 +1765,11 @@ void Lua_Client::QuestReward(Lua_Mob target, luabind::adl::object reward) {
self->QuestReward(target, quest_reward, faction);
}
void Lua_Client::CashReward(uint32 copper, uint32 silver, uint32 gold, uint32 platinum) {
Lua_Safe_Call_Void();
self->CashReward(copper, silver, gold, platinum);
}
bool Lua_Client::IsDead() {
Lua_Safe_Call_Bool();
return self->IsDead();
@ -2568,6 +2573,7 @@ luabind::scope lua_register_client() {
.def("CalcCurrentWeight", &Lua_Client::CalcCurrentWeight)
.def("CalcPriceMod", (float(Lua_Client::*)(Lua_Mob,bool))&Lua_Client::CalcPriceMod)
.def("CanHaveSkill", (bool(Lua_Client::*)(int))&Lua_Client::CanHaveSkill)
.def("CashReward", &Lua_Client::CashReward)
.def("ChangeLastName", (void(Lua_Client::*)(std::string))&Lua_Client::ChangeLastName)
.def("CharacterID", (uint32(Lua_Client::*)(void))&Lua_Client::CharacterID)
.def("CheckIncreaseSkill", (void(Lua_Client::*)(int,Lua_Mob))&Lua_Client::CheckIncreaseSkill)

View File

@ -382,6 +382,7 @@ public:
void QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid, uint32 exp);
void QuestReward(Lua_Mob target, uint32 copper, uint32 silver, uint32 gold, uint32 platinum, uint32 itemid, uint32 exp, bool faction);
void QuestReward(Lua_Mob target, luabind::adl::object reward);
void CashReward(uint32 copper, uint32 silver, uint32 gold, uint32 platinum);
bool IsDead();
int CalcCurrentWeight();
int CalcATK();

View File

@ -1653,6 +1653,11 @@ void Perl_Client_QuestReward(Client* self, Mob* mob, uint32 copper, uint32 silve
self->QuestReward(mob, copper, silver, gold, platinum, item_id, exp, faction);
}
void Perl_Client_CashReward(Client* self, uint32 copper, uint32 silver, uint32 gold, uint32 platinum)
{
self->CashReward(copper, silver, gold, platinum);
}
uint32_t Perl_Client_GetMoney(Client* self, int8 type, int8 subtype)
{
return self->GetMoney(type, subtype);
@ -2416,6 +2421,7 @@ void perl_register_client()
package.add("CalcPriceMod", (float(*)(Client*, Mob*))&Perl_Client_CalcPriceMod);
package.add("CalcPriceMod", (float(*)(Client*, Mob*, bool))&Perl_Client_CalcPriceMod);
package.add("CanHaveSkill", &Perl_Client_CanHaveSkill);
package.add("CashReward", &Perl_Client_CashReward);
package.add("ChangeLastName", &Perl_Client_ChangeLastName);
package.add("CharacterID", &Perl_Client_CharacterID);
package.add("CheckIncreaseSkill", (bool(*)(Client*, int))&Perl_Client_CheckIncreaseSkill);

View File

@ -1183,26 +1183,12 @@ void QuestManager::givecash(uint32 copper, uint32 silver, uint32 gold, uint32 pl
platinum
)
) {
initiator->AddMoneyToPP(
initiator->CashReward(
copper,
silver,
gold,
platinum,
true
platinum
);
if (initiator) {
initiator->MessageString(
Chat::MoneySplit,
YOU_RECEIVE,
Strings::Money(
platinum,
gold,
silver,
copper
).c_str()
);
}
}
}