mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
This restores sending items to EVENT_TRADE that are updated by source
controlled delivery tasks which was removed in 7cf96ca2d8.
That patch filtered out items consumed by task updates to fix a few bugs
with items being returned despite incrementing a task:
- If an npc without a quest trade event handler was the target of a
delivery task for a NoDrop/non-Quest item, the npc would auto return
it due to the `ReturnNonQuestNoDropItems` rule.
- If an npc without a quest trade event handler was the target of a
delivery task for a non-NoDrop item, the item would be added to the
npc's loot.
- If an npc with an EVENT_ITEM/EVENT_TRADE quest handler used the Lua
or Perl trade plugins, the plugins would return task items unless
specific checks for the turned in slots existed.
The quest plugin item returns are problematic for this since they just
summon to return items not handled by the script
e.g. For a task to deliver N Large Fruit Bat Wings (item id 19616),
if a player turned in 1 Wing in slot 1 and a stack of 20 Wings in slot
2, the task would be incremented 21 times and the following Lua trade
handler would return the stack of 20 from the 2nd trade slot:
```lua
function event_trade(e)
local item_lib = require("items")
if item_lib.check_turn_in(e.trade, { item1 = 19616 }) then
eq.debug("Lua consumed 1 slot and will return other slots")
end
item_lib.return_items(e.self, e.other, e.trade)
end
```
This also occured with the perl plugin though slightly differently
since that plugin returns all slots unless the exact handin slot count
matches (requiring check_handin conditions for all slots):
```perl
sub EVENT_ITEM {
if (plugin::check_handin(\%itemcount, 19616 => 1)) {
# No issue if only one slot used for trade (item not returned)
}
# Perl fails handin check if multiple slots not checked and returns all
plugin::return_items(\%itemcount);
}
```
While that patch solved the issue, it's inconvenient and wrong to not
receive items in trade events used in a source task update. It breaks
existing trade scripts for tasks that aren't quest controlled and it
forces tasks to be changed to quest controlled and manually updated to
script any extra behavior.
This patch stores the task update count on the item instance before
dispatching it to quests. The burden is now on quests and plugins to
use that value in order to prevent returning items consumed by tasks.
`ItemInstance::RemoveTaskDeliveredItems` has been added to simplify
handling this in plugins which is also used for non-quest item returns.
129 lines
5.8 KiB
C++
129 lines
5.8 KiB
C++
/* EQEMu: Everquest Server Emulator
|
|
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
|
are required to give you total support for your newly bought product;
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#ifndef EQEMU_EMBPARSER_H
|
|
#define EQEMU_EMBPARSER_H
|
|
#ifdef EMBPERL
|
|
|
|
#include "quest_parser_collection.h"
|
|
#include "quest_interface.h"
|
|
#include <string>
|
|
#include <queue>
|
|
#include <map>
|
|
#include "embperl.h"
|
|
|
|
class Mob;
|
|
class Client;
|
|
class NPC;
|
|
|
|
namespace EQ
|
|
{
|
|
class ItemInstance;
|
|
}
|
|
|
|
typedef enum
|
|
{
|
|
questUnloaded,
|
|
questLoaded,
|
|
questFailedToLoad
|
|
} PerlQuestStatus;
|
|
|
|
class PerlembParser : public QuestInterface {
|
|
public:
|
|
PerlembParser();
|
|
~PerlembParser();
|
|
|
|
virtual int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
|
std::vector<std::any> *extra_pointers);
|
|
virtual int EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
|
std::vector<std::any> *extra_pointers);
|
|
virtual int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
|
std::vector<std::any> *extra_pointers);
|
|
virtual int EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
|
std::vector<std::any> *extra_pointers);
|
|
virtual int EventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
|
std::vector<std::any> *extra_pointers);
|
|
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
|
std::vector<std::any> *extra_pointers);
|
|
|
|
virtual bool HasQuestSub(uint32 npcid, QuestEventID evt);
|
|
virtual bool HasGlobalQuestSub(QuestEventID evt);
|
|
virtual bool PlayerHasQuestSub(QuestEventID evt);
|
|
virtual bool GlobalPlayerHasQuestSub(QuestEventID evt);
|
|
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
|
|
virtual bool ItemHasQuestSub(EQ::ItemInstance *itm, QuestEventID evt);
|
|
|
|
virtual void LoadNPCScript(std::string filename, int npc_id);
|
|
virtual void LoadGlobalNPCScript(std::string filename);
|
|
virtual void LoadPlayerScript(std::string filename);
|
|
virtual void LoadGlobalPlayerScript(std::string filename);
|
|
virtual void LoadItemScript(std::string filename, EQ::ItemInstance *item);
|
|
virtual void LoadSpellScript(std::string filename, uint32 spell_id);
|
|
|
|
virtual void AddVar(std::string name, std::string val);
|
|
virtual std::string GetVar(std::string name);
|
|
virtual void ReloadQuests();
|
|
virtual uint32 GetIdentifier() { return 0xf8b05c11; }
|
|
|
|
private:
|
|
Embperl *perl;
|
|
|
|
void ExportHash(const char *pkgprefix, const char *hashname, std::map<std::string, std::string> &vals);
|
|
void ExportVar(const char *pkgprefix, const char *varname, const char *value);
|
|
void ExportVar(const char *pkgprefix, const char *varname, int32 value);
|
|
void ExportVar(const char *pkgprefix, const char *varname, uint32 value);
|
|
void ExportVar(const char *pkgprefix, const char *varname, float value);
|
|
void ExportVar(const char* pkgprefix, const char* varname, const char* classname, void* value);
|
|
void ExportVarComplex(const char *pkgprefix, const char *varname, const char *value);
|
|
|
|
int EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, EQ::ItemInstance* item_inst, const SPDat_Spell_Struct* spell, Mob* mob,
|
|
uint32 extradata, bool global, std::vector<std::any> *extra_pointers);
|
|
int SendCommands(const char *pkgprefix, const char *event, uint32 spell_id, Mob* other, Mob* mob, EQ::ItemInstance *item_inst, const SPDat_Spell_Struct *spell);
|
|
void MapFunctions();
|
|
|
|
void GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
|
|
bool &isSpellQuest, QuestEventID event, NPC* npcmob, EQ::ItemInstance* item_inst, Mob* mob, bool global);
|
|
void GetQuestPackageName(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
|
|
bool &isSpellQuest, std::string &package_name, QuestEventID event, uint32 objid, const char * data,
|
|
NPC* npcmob, EQ::ItemInstance* item_inst, bool global);
|
|
void ExportCharID(const std::string &package_name, int &char_id, NPC *npcmob, Mob *mob);
|
|
void ExportQGlobals(bool isPlayerQuest, bool isGlobalPlayerQuest, bool isGlobalNPC, bool isItemQuest,
|
|
bool isSpellQuest, std::string &package_name, NPC *npcmob, Mob *mob, int char_id);
|
|
void ExportMobVariables(bool isPlayerQuest, bool isGlobalPlayerQuest, bool isGlobalNPC, bool isItemQuest,
|
|
bool isSpellQuest, std::string &package_name, Mob *mob, NPC *npcmob);
|
|
void ExportZoneVariables(std::string &package_name);
|
|
void ExportItemVariables(std::string &package_name, Mob *mob);
|
|
void ExportEventVariables(std::string &package_name, QuestEventID event, uint32 objid, const char * data,
|
|
NPC* npcmob, EQ::ItemInstance* item_inst, Mob* mob, uint32 extradata, std::vector<std::any> *extra_pointers);
|
|
|
|
std::map<uint32, PerlQuestStatus> npc_quest_status_;
|
|
PerlQuestStatus global_npc_quest_status_;
|
|
PerlQuestStatus player_quest_status_;
|
|
PerlQuestStatus global_player_quest_status_;
|
|
std::map<uint32, PerlQuestStatus> item_quest_status_;
|
|
std::map<uint32, PerlQuestStatus> spell_quest_status_;
|
|
|
|
std::map<std::string, std::string> vars_;
|
|
SV *_empty_sv;
|
|
std::map<std::string, int> clear_vars_;
|
|
};
|
|
|
|
#endif
|
|
#endif
|
|
|