mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-05 20:22:28 +00:00
Final
This commit is contained in:
parent
42eee010c8
commit
57ee6423eb
@ -1680,7 +1680,7 @@ void PerlembParser::ExportEventVariables(
|
||||
}
|
||||
|
||||
if (extra_pointers && extra_pointers->size() == 2) {
|
||||
ExportVar(package_name.c_str(), "client", "Client", std::any_cast<Client*>(extra_pointers->at(1)));
|
||||
ExportVar(package_name.c_str(), "player", "Client", std::any_cast<Client*>(extra_pointers->at(1)));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1708,7 +1708,7 @@ void PerlembParser::ExportEventVariables(
|
||||
}
|
||||
|
||||
if (extra_pointers && extra_pointers->size() == 3) {
|
||||
ExportVar(package_name.c_str(), "client", "Client", std::any_cast<Client*>(extra_pointers->at(2)));
|
||||
ExportVar(package_name.c_str(), "player", "Client", std::any_cast<Client*>(extra_pointers->at(2)));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1787,7 +1787,7 @@ void PerlembParser::ExportEventVariables(
|
||||
}
|
||||
|
||||
if (extra_pointers && extra_pointers->size() == 2) {
|
||||
ExportVar(package_name.c_str(), "client", "Client", std::any_cast<Client*>(extra_pointers->at(1)));
|
||||
ExportVar(package_name.c_str(), "player", "Client", std::any_cast<Client*>(extra_pointers->at(1)));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1804,7 +1804,7 @@ void PerlembParser::ExportEventVariables(
|
||||
ExportVar(package_name.c_str(), "popupid", data);
|
||||
|
||||
if (extra_pointers && extra_pointers->size() == 1) {
|
||||
ExportVar(package_name.c_str(), "client", "Client", std::any_cast<Client*>(extra_pointers->at(0)));
|
||||
ExportVar(package_name.c_str(), "player", "Client", std::any_cast<Client*>(extra_pointers->at(0)));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1975,7 +1975,7 @@ void PerlembParser::ExportEventVariables(
|
||||
}
|
||||
|
||||
if (extra_pointers && extra_pointers->size() == 2) {
|
||||
ExportVar(package_name.c_str(), "client", "Client", std::any_cast<Client*>(extra_pointers->at(1)));
|
||||
ExportVar(package_name.c_str(), "player", "Client", std::any_cast<Client*>(extra_pointers->at(1)));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -2088,18 +2088,18 @@ void PerlembParser::ExportEventVariables(
|
||||
|
||||
case EVENT_SPAWN_ZONE: {
|
||||
if (mob) {
|
||||
ExportVar(package_name.c_str(), "spawned_entity_id", mob->GetID());
|
||||
ExportVar(package_name.c_str(), "spawned_bot_id", mob->IsBot() ? mob->CastToBot()->GetBotID() : 0);
|
||||
ExportVar(package_name.c_str(), "spawned_npc_id", mob->IsNPC() ? mob->GetNPCTypeID() : 0);
|
||||
ExportVar(package_name.c_str(), "spawned", "Mob", mob);
|
||||
ExportVar(package_name.c_str(), "spawned_bot_id", mob->IsBot() ? mob->CastToBot()->GetBotID() : 0);
|
||||
ExportVar(package_name.c_str(), "spawned_entity_id", mob->GetID());
|
||||
ExportVar(package_name.c_str(), "spawned_npc_id", mob->IsNPC() ? mob->GetNPCTypeID() : 0);
|
||||
}
|
||||
|
||||
if (extra_pointers && extra_pointers->size() == 1) {
|
||||
Mob* spawn_mob = std::any_cast<Mob*>(extra_pointers->at(0));
|
||||
ExportVar(package_name.c_str(), "spawned_entity_id", spawn_mob->GetID());
|
||||
ExportVar(package_name.c_str(), "spawned_bot_id", spawn_mob->IsBot() ? spawn_mob->CastToBot()->GetBotID() : 0);
|
||||
ExportVar(package_name.c_str(), "spawned_npc_id", spawn_mob->IsNPC() ? spawn_mob->GetNPCTypeID() : 0);
|
||||
ExportVar(package_name.c_str(), "spawned", "Mob", spawn_mob);
|
||||
NPC* spawn_npc = std::any_cast<NPC*>(extra_pointers->at(0));
|
||||
ExportVar(package_name.c_str(), "spawned", "NPC", spawn_npc);
|
||||
ExportVar(package_name.c_str(), "spawned_bot_id", spawn_npc->IsBot() ? spawn_npc->CastToBot()->GetBotID() : 0);
|
||||
ExportVar(package_name.c_str(), "spawned_entity_id", spawn_npc->GetID());
|
||||
ExportVar(package_name.c_str(), "spawned_npc_id", spawn_npc->IsNPC() ? spawn_npc->GetNPCTypeID() : 0);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -2342,6 +2342,7 @@ void PerlembParser::ExportEventVariables(
|
||||
}
|
||||
|
||||
case EVENT_DESPAWN: {
|
||||
ExportVar(package_name.c_str(), "despawned", "Mob", npc_mob);
|
||||
ExportVar(package_name.c_str(), "despawned_entity_id", npc_mob->GetID());
|
||||
ExportVar(package_name.c_str(), "despawned_bot_id", npc_mob->IsBot() ? npc_mob->CastToBot()->GetBotID() : 0);
|
||||
ExportVar(package_name.c_str(), "despawned_merc_id", npc_mob->IsMerc() ? npc_mob->CastToMerc()->GetMercenaryID() : 0);
|
||||
@ -2350,12 +2351,19 @@ void PerlembParser::ExportEventVariables(
|
||||
}
|
||||
|
||||
case EVENT_DESPAWN_ZONE: {
|
||||
ExportVar(package_name.c_str(), "despawned_entity_id", mob->GetID());
|
||||
ExportVar(package_name.c_str(), "despawned_bot_id", mob->IsBot() ? mob->CastToBot()->GetBotID() : 0);
|
||||
ExportVar(package_name.c_str(), "despawned_npc_id", mob->IsNPC() ? mob->GetNPCTypeID() : 0);
|
||||
if (mob) {
|
||||
ExportVar(package_name.c_str(), "despawned", "Mob", mob);
|
||||
ExportVar(package_name.c_str(), "despawned_bot_id", mob->IsBot() ? mob->CastToBot()->GetBotID() : 0);
|
||||
ExportVar(package_name.c_str(), "despawned_entity_id", mob->GetID());
|
||||
ExportVar(package_name.c_str(), "despawned_npc_id", mob->IsNPC() ? mob->GetNPCTypeID() : 0);
|
||||
}
|
||||
|
||||
if (extra_pointers && extra_pointers->size() == 1) {
|
||||
ExportVar(package_name.c_str(), "npc", "NPC", std::any_cast<NPC*>(extra_pointers->at(0)));
|
||||
NPC* spawn_npc = std::any_cast<NPC*>(extra_pointers->at(0));
|
||||
ExportVar(package_name.c_str(), "despawned", "NPC", spawn_npc);
|
||||
ExportVar(package_name.c_str(), "despawned_bot_id", spawn_npc->IsBot() ? spawn_npc->CastToBot()->GetBotID() : 0);
|
||||
ExportVar(package_name.c_str(), "despawned_entity_id", spawn_npc->GetID());
|
||||
ExportVar(package_name.c_str(), "despawned_npc_id", spawn_npc->IsNPC() ? spawn_npc->GetNPCTypeID() : 0);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -2514,7 +2522,7 @@ void PerlembParser::ExportEventVariables(
|
||||
|
||||
case EVENT_ENTER_ZONE: {
|
||||
if (extra_pointers && extra_pointers->size() == 1) {
|
||||
ExportVar(package_name.c_str(), "client", "Client", std::any_cast<Client*>(extra_pointers->at(0)));
|
||||
ExportVar(package_name.c_str(), "player", "Client", std::any_cast<Client*>(extra_pointers->at(0)));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@ -2998,9 +2998,9 @@ void handle_zone_despawn(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Lua_Mob l_mob(std::any_cast<Mob*>(extra_pointers->at(0)));
|
||||
luabind::adl::object l_mob_o = luabind::adl::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
110
zone/zone.cpp
110
zone/zone.cpp
@ -3392,33 +3392,62 @@ bool Zone::IsPausedTimer(std::string name)
|
||||
|
||||
void Zone::PauseTimer(std::string name)
|
||||
{
|
||||
if (!IsLoaded() || zone_timers.empty()) {
|
||||
if (
|
||||
!IsLoaded() ||
|
||||
zone_timers.empty() ||
|
||||
!HasTimer(name) ||
|
||||
IsPausedTimer(name)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 remaining_time = 0;
|
||||
|
||||
const bool has_pause_event = parse->ZoneHasQuestSub(EVENT_TIMER_PAUSE);
|
||||
|
||||
if (!zone_timers.empty()) {
|
||||
for (auto e = zone_timers.begin(); e != zone_timers.end(); e++) {
|
||||
if (e->name == name) {
|
||||
remaining_time = e->timer_.GetRemainingTime();
|
||||
|
||||
zone_timers.erase(e);
|
||||
|
||||
const std::string& export_string = fmt::format(
|
||||
"{} {}",
|
||||
name,
|
||||
remaining_time
|
||||
);
|
||||
|
||||
LogQuests(
|
||||
"Pausing timer [{}] with [{}] ms remaining",
|
||||
name,
|
||||
remaining_time
|
||||
);
|
||||
|
||||
paused_zone_timers.emplace_back(
|
||||
PausedZoneTimer{
|
||||
.name = name,
|
||||
.remaining_time = remaining_time
|
||||
}
|
||||
);
|
||||
|
||||
if (has_pause_event) {
|
||||
parse->EventZone(EVENT_TIMER_PAUSE, this, export_string);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
paused_zone_timers.emplace_back(
|
||||
PausedZoneTimer{
|
||||
.name = name,
|
||||
.remaining_time = remaining_time
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void Zone::ResumeTimer(std::string name)
|
||||
{
|
||||
if (!IsLoaded() || paused_zone_timers.empty()) {
|
||||
if (
|
||||
!IsLoaded() ||
|
||||
paused_zone_timers.empty() ||
|
||||
!IsPausedTimer(name)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3428,59 +3457,41 @@ void Zone::ResumeTimer(std::string name)
|
||||
for (auto e = paused_zone_timers.begin(); e != paused_zone_timers.end(); e++) {
|
||||
if (e->name == name) {
|
||||
remaining_time = e->remaining_time;
|
||||
|
||||
paused_zone_timers.erase(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!remaining_time) {
|
||||
LogQuests("Paused timer [{}] not found or has expired.", name);
|
||||
return;
|
||||
}
|
||||
if (!remaining_time) {
|
||||
LogQuests("Paused timer [{}] not found or has expired.", name);
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string& export_string = fmt::format(
|
||||
"{} {}",
|
||||
name,
|
||||
remaining_time
|
||||
);
|
||||
|
||||
const bool has_resume_event = parse->ZoneHasQuestSub(EVENT_TIMER_RESUME);
|
||||
|
||||
if (!zone_timers.empty()) {
|
||||
for (auto e : zone_timers) {
|
||||
if (e.name == name) {
|
||||
e.timer_.Enable();
|
||||
e.timer_.Start(remaining_time, false);
|
||||
LogQuests(
|
||||
"Resuming timer [{}] with [{}] ms remaining",
|
||||
const std::string& export_string = fmt::format(
|
||||
"{} {}",
|
||||
name,
|
||||
remaining_time
|
||||
);
|
||||
|
||||
if (has_resume_event) {
|
||||
LogQuests(
|
||||
"Creating a new timer and resuming [{}] with [{}] ms remaining",
|
||||
name,
|
||||
remaining_time
|
||||
);
|
||||
|
||||
zone_timers.emplace_back(ZoneTimer(name, remaining_time));
|
||||
|
||||
if (parse->ZoneHasQuestSub(EVENT_TIMER_RESUME)) {
|
||||
parse->EventZone(EVENT_TIMER_RESUME, this, export_string);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zone_timers.emplace_back(ZoneTimer(name, remaining_time));
|
||||
|
||||
if (has_resume_event) {
|
||||
parse->EventZone(EVENT_TIMER_RESUME, this, export_string);
|
||||
}
|
||||
|
||||
LogQuests(
|
||||
"Creating a new timer and resuming [{}] with [{}] ms remaining",
|
||||
name,
|
||||
remaining_time
|
||||
);
|
||||
}
|
||||
|
||||
void Zone::SetTimer(std::string name, uint32 duration)
|
||||
{
|
||||
if (!IsLoaded()) {
|
||||
if (!IsLoaded() || HasTimer(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3494,7 +3505,12 @@ void Zone::SetTimer(std::string name, uint32 duration)
|
||||
|
||||
void Zone::StopTimer(std::string name)
|
||||
{
|
||||
if (!IsLoaded() || zone_timers.empty()) {
|
||||
if (
|
||||
!IsLoaded() ||
|
||||
zone_timers.empty() ||
|
||||
!HasTimer(name) ||
|
||||
IsPausedTimer(name)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user