[Quest API] Export targets to EVENT_CONSIDER and EVENT_CONSIDER_CORPSE (#2908)

# Perl
- Export `$target` to `EVENT_CONSIDER`.
- Export `$corpse` to `EVENT_CONSIDER_CORPSE`.

# Lua
- Export `e.other` to `EVENT_CONSIDER`.
- Export `e.corpse` to `EVENT_CONSIDER_CORPSE`.

 # Notes
- Allows operators to grab the target or corpse a player is considering.
This commit is contained in:
Alex King 2023-02-12 23:32:04 -05:00 committed by GitHub
parent 93f19d3971
commit 2dcff247c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 104 additions and 72 deletions

View File

@ -4922,110 +4922,119 @@ void Client::Handle_OP_ConsentDeny(const EQApplicationPacket *app)
void Client::Handle_OP_Consider(const EQApplicationPacket *app) void Client::Handle_OP_Consider(const EQApplicationPacket *app)
{ {
if (app->size != sizeof(Consider_Struct)) if (app->size != sizeof(Consider_Struct)) {
{
LogDebug("Size mismatch in Consider expected [{}] got [{}]", sizeof(Consider_Struct), app->size); LogDebug("Size mismatch in Consider expected [{}] got [{}]", sizeof(Consider_Struct), app->size);
return; return;
} }
Consider_Struct* conin = (Consider_Struct*)app->pBuffer;
Mob* tmob = entity_list.GetMob(conin->targetid);
if (tmob == 0)
return;
std::string export_string = fmt::format("{}", conin->targetid); auto *conin = (Consider_Struct*) app->pBuffer;
if (parse->EventPlayer(EVENT_CONSIDER, this, export_string, 0) == 1) { auto *t = entity_list.GetMob(conin->targetid);
if (!t) {
return; return;
} }
if (tmob->GetClass() == LDON_TREASURE) if (parse->PlayerHasQuestSub(EVENT_CONSIDER)) {
{ std::vector<std::any> args = { t };
Message(Chat::Yellow, "%s", tmob->GetCleanName());
if (parse->EventPlayer(EVENT_CONSIDER, this, std::to_string(conin->targetid), 0, &args) == 1) {
return;
}
}
if (t->GetClass() == LDON_TREASURE) {
Message(Chat::Yellow, fmt::format("{}", t->GetCleanName()).c_str());
return; return;
} }
auto outapp = new EQApplicationPacket(OP_Consider, sizeof(Consider_Struct)); auto outapp = new EQApplicationPacket(OP_Consider, sizeof(Consider_Struct));
Consider_Struct* con = (Consider_Struct*)outapp->pBuffer; auto* con = (Consider_Struct*) outapp->pBuffer;
con->playerid = GetID(); con->playerid = GetID();
con->targetid = conin->targetid; con->targetid = conin->targetid;
if (tmob->IsNPC()) if (t->IsNPC()) {
con->faction = GetFactionLevel(character_id, tmob->GetNPCTypeID(), GetFactionRace(), class_, deity, (tmob->IsNPC()) ? tmob->CastToNPC()->GetPrimaryFaction() : 0, tmob); // Dec. 20, 2001; TODO: Send the players proper deity con->faction = GetFactionLevel(
else character_id,
t->GetNPCTypeID(),
GetFactionRace(),
class_,
deity,
(t->IsNPC()) ? t->CastToNPC()->GetPrimaryFaction() : 0,
t
);
} else {
con->faction = 1; con->faction = 1;
con->level = GetLevelCon(tmob->GetLevel()); }
con->level = GetLevelCon(t->GetLevel());
if (ClientVersion() <= EQ::versions::ClientVersion::Titanium) { if (ClientVersion() <= EQ::versions::ClientVersion::Titanium) {
if (con->level == CON_GRAY) { if (con->level == CON_GRAY) {
con->level = CON_GREEN; con->level = CON_GREEN;
} } else if (con->level == CON_WHITE) {
if (con->level == CON_WHITE) {
con->level = CON_WHITE_TITANIUM; con->level = CON_WHITE_TITANIUM;
} }
} }
if (zone->IsPVPZone()) { if (zone->IsPVPZone()) {
if (!tmob->IsNPC()) if (!t->IsNPC()) {
con->pvpcon = tmob->CastToClient()->GetPVP(); con->pvpcon = t->CastToClient()->GetPVP();
}
} }
// If we're feigned show NPC as indifferent // If we're feigned show NPC as indifferent
if (tmob->IsNPC()) if (t->IsNPC()) {
{ if (GetFeigned()) {
if (GetFeigned())
con->faction = FACTION_INDIFFERENTLY; con->faction = FACTION_INDIFFERENTLY;
}
} }
if (!(con->faction == FACTION_SCOWLS)) if (!(con->faction == FACTION_SCOWLS)) {
{ if (t->IsNPC()) {
if (tmob->IsNPC()) if (t->CastToNPC()->IsOnHatelist(this)) {
{
if (tmob->CastToNPC()->IsOnHatelist(this))
con->faction = FACTION_THREATENINGLY; con->faction = FACTION_THREATENINGLY;
}
} }
} }
if (con->faction == FACTION_APPREHENSIVELY) { if (con->faction == FACTION_APPREHENSIVELY) {
con->faction = FACTION_SCOWLS; con->faction = FACTION_SCOWLS;
} } else if (con->faction == FACTION_DUBIOUSLY) {
else if (con->faction == FACTION_DUBIOUSLY) {
con->faction = FACTION_THREATENINGLY; con->faction = FACTION_THREATENINGLY;
} } else if (con->faction == FACTION_SCOWLS) {
else if (con->faction == FACTION_SCOWLS) {
con->faction = FACTION_APPREHENSIVELY; con->faction = FACTION_APPREHENSIVELY;
} } else if (con->faction == FACTION_THREATENINGLY) {
else if (con->faction == FACTION_THREATENINGLY) {
con->faction = FACTION_DUBIOUSLY; con->faction = FACTION_DUBIOUSLY;
} }
mod_consider(tmob, con); mod_consider(t, con);
QueuePacket(outapp); QueuePacket(outapp);
// only wanted to check raid target once // only wanted to check raid target once
// and need con to still be around so, do it here! // and need con to still be around so, do it here!
if (tmob->IsRaidTarget()) { if (t->IsRaidTarget()) {
uint32 color = 0; uint32 color = 0;
switch (con->level) { switch (con->level) {
case CON_GREEN: case CON_GREEN:
color = 2; color = 2;
break; break;
case CON_LIGHTBLUE: case CON_LIGHTBLUE:
color = 10; color = 10;
break; break;
case CON_BLUE: case CON_BLUE:
color = 4; color = 4;
break; break;
case CON_WHITE_TITANIUM: case CON_WHITE_TITANIUM:
case CON_WHITE: case CON_WHITE:
color = 10; color = 10;
break; break;
case CON_YELLOW: case CON_YELLOW:
color = 15; color = 15;
break; break;
case CON_RED: case CON_RED:
color = 13; color = 13;
break; break;
case CON_GRAY: case CON_GRAY:
color = 6; color = 6;
break; break;
} }
if (ClientVersion() <= EQ::versions::ClientVersion::Titanium) { if (ClientVersion() <= EQ::versions::ClientVersion::Titanium) {
@ -5039,11 +5048,11 @@ void Client::Handle_OP_Consider(const EQApplicationPacket *app)
// this could be done better, but this is only called when you con so w/e // this could be done better, but this is only called when you con so w/e
// Shroud of Stealth has a special message // Shroud of Stealth has a special message
if (improved_hidden && (!tmob->see_improved_hide && (tmob->SeeInvisible() || tmob->see_hide))) if (improved_hidden && (!t->see_improved_hide && (t->SeeInvisible() || t->see_hide))) {
MessageString(Chat::NPCQuestSay, SOS_KEEPS_HIDDEN); MessageString(Chat::NPCQuestSay, SOS_KEEPS_HIDDEN); // we are trying to hide but they can see us
// we are trying to hide but they can see us } else if ((invisible || invisible_undead || hidden || invisible_animals) && !IsInvisible(t)) {
else if ((invisible || invisible_undead || hidden || invisible_animals) && !IsInvisible(tmob))
MessageString(Chat::NPCQuestSay, SUSPECT_SEES_YOU); MessageString(Chat::NPCQuestSay, SUSPECT_SEES_YOU);
}
safe_delete(outapp); safe_delete(outapp);
@ -5057,18 +5066,21 @@ void Client::Handle_OP_ConsiderCorpse(const EQApplicationPacket *app)
return; return;
} }
Consider_Struct* conin = (Consider_Struct*)app->pBuffer; auto* conin = (Consider_Struct*)app->pBuffer;
Corpse* target = entity_list.GetCorpseByID(conin->targetid); auto* t = entity_list.GetCorpseByID(conin->targetid);
std::string export_string = fmt::format("{}", conin->targetid); if (!t) {
if (!target) {
return; return;
} }
if (parse->EventPlayer(EVENT_CONSIDER_CORPSE, this, export_string, 0)) { if (parse->PlayerHasQuestSub(EVENT_CONSIDER_CORPSE)) {
return; std::vector<std::any> args = { t };
if (parse->EventPlayer(EVENT_CONSIDER_CORPSE, this, std::to_string(conin->targetid), 0, &args)) {
return;
}
} }
uint32 decay_time = target->GetDecayTime(); uint32 decay_time = t->GetDecayTime();
if (decay_time) { if (decay_time) {
auto time_string = Strings::SecondsToTime(decay_time, true); auto time_string = Strings::SecondsToTime(decay_time, true);
Message( Message(
@ -5079,12 +5091,12 @@ void Client::Handle_OP_ConsiderCorpse(const EQApplicationPacket *app)
).c_str() ).c_str()
); );
if (target->IsPlayerCorpse()) { if (t->IsPlayerCorpse()) {
Message( Message(
Chat::NPCQuestSay, Chat::NPCQuestSay,
fmt::format( fmt::format(
"This corpse {} be resurrected.", "This corpse {} be resurrected.",
target->IsRezzed() ? "cannot" : "can" t->IsRezzed() ? "cannot" : "can"
).c_str() ).c_str()
); );
} }

View File

@ -1908,11 +1908,17 @@ void PerlembParser::ExportEventVariables(
case EVENT_CONSIDER: { case EVENT_CONSIDER: {
ExportVar(package_name.c_str(), "entity_id", std::stoi(data)); ExportVar(package_name.c_str(), "entity_id", std::stoi(data));
if (extra_pointers && extra_pointers->size() == 1) {
ExportVar(package_name.c_str(), "target", "Mob", std::any_cast<Mob*>(extra_pointers->at(0)));
}
break; break;
} }
case EVENT_CONSIDER_CORPSE: { case EVENT_CONSIDER_CORPSE: {
ExportVar(package_name.c_str(), "corpse_entity_id", std::stoi(data)); ExportVar(package_name.c_str(), "corpse_entity_id", std::stoi(data));
if (extra_pointers && extra_pointers->size() == 1) {
ExportVar(package_name.c_str(), "corpse", "Corpse", std::any_cast<Corpse*>(extra_pointers->at(0)));
}
break; break;
} }

View File

@ -1105,6 +1105,13 @@ void handle_player_consider(
) { ) {
lua_pushinteger(L, Strings::ToInt(data)); lua_pushinteger(L, Strings::ToInt(data));
lua_setfield(L, -2, "entity_id"); lua_setfield(L, -2, "entity_id");
if (extra_pointers && extra_pointers->size() == 1) {
Lua_NPC l_npc(std::any_cast<NPC*>(extra_pointers->at(0)));
luabind::adl::object l_npc_o = luabind::adl::object(L, l_npc);
l_npc_o.push(L);
lua_setfield(L, -2, "other");
}
} }
void handle_player_consider_corpse( void handle_player_consider_corpse(
@ -1117,6 +1124,13 @@ void handle_player_consider_corpse(
) { ) {
lua_pushinteger(L, Strings::ToInt(data)); lua_pushinteger(L, Strings::ToInt(data));
lua_setfield(L, -2, "corpse_entity_id"); lua_setfield(L, -2, "corpse_entity_id");
if (extra_pointers && extra_pointers->size() == 1) {
Lua_Corpse l_corpse(std::any_cast<Corpse *>(extra_pointers->at(0)));
luabind::adl::object l_corpse_o = luabind::adl::object(L, l_corpse);
l_corpse_o.push(L);
lua_setfield(L, -2, "corpse");
}
} }
void handle_player_inspect( void handle_player_inspect(