mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +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.
94 lines
2.5 KiB
C++
94 lines
2.5 KiB
C++
#ifndef EQEMU_LUA_ITEMINST_H
|
|
#define EQEMU_LUA_ITEMINST_H
|
|
#ifdef LUA_EQEMU
|
|
|
|
#include "lua_ptr.h"
|
|
|
|
class Lua_Item;
|
|
|
|
namespace EQ
|
|
{
|
|
class ItemInstance;
|
|
}
|
|
|
|
namespace luabind {
|
|
struct scope;
|
|
}
|
|
|
|
luabind::scope lua_register_iteminst();
|
|
|
|
class Lua_ItemInst : public Lua_Ptr<EQ::ItemInstance>
|
|
{
|
|
typedef EQ::ItemInstance NativeType;
|
|
public:
|
|
Lua_ItemInst(int item_id);
|
|
Lua_ItemInst(int item_id, int charges);
|
|
Lua_ItemInst() : Lua_Ptr(nullptr), cloned_(false) { }
|
|
Lua_ItemInst(EQ::ItemInstance *d) : Lua_Ptr(d), cloned_(false) { }
|
|
Lua_ItemInst(EQ::ItemInstance *d, bool cloned) : Lua_Ptr(d), cloned_(cloned) { }
|
|
Lua_ItemInst& operator=(const Lua_ItemInst& o);
|
|
Lua_ItemInst(const Lua_ItemInst& o);
|
|
virtual ~Lua_ItemInst() { if(cloned_) { EQ::ItemInstance *ptr = GetLuaPtrData(); if(ptr) { delete ptr; } } }
|
|
|
|
operator EQ::ItemInstance*() {
|
|
return reinterpret_cast<EQ::ItemInstance*>(GetLuaPtrData());
|
|
}
|
|
|
|
bool IsType(int item_class);
|
|
bool IsStackable();
|
|
bool IsEquipable(int race, int class_);
|
|
bool IsEquipable(int slot_id);
|
|
bool IsAugmentable();
|
|
int GetAugmentType();
|
|
bool IsExpendable();
|
|
Lua_ItemInst GetItem(int slot);
|
|
Lua_Item GetItem();
|
|
void SetItem(Lua_Item item);
|
|
Lua_Item GetUnscaledItem(int slot);
|
|
uint32 GetItemID(int slot);
|
|
int GetTotalItemCount();
|
|
Lua_ItemInst GetAugment(int slot);
|
|
uint32 GetAugmentItemID(int slot);
|
|
bool IsAugmented();
|
|
bool IsWeapon();
|
|
bool IsAmmo();
|
|
uint32 GetID();
|
|
uint32 GetItemScriptID();
|
|
int GetCharges();
|
|
void SetCharges(int charges);
|
|
uint32 GetPrice();
|
|
void SetPrice(uint32 price);
|
|
void SetColor(uint32 color);
|
|
uint32 GetColor();
|
|
bool IsInstNoDrop();
|
|
void SetInstNoDrop(bool flag);
|
|
std::string GetCustomDataString();
|
|
void SetCustomData(std::string identifier, std::string value);
|
|
void SetCustomData(std::string identifier, int value);
|
|
void SetCustomData(std::string identifier, float value);
|
|
void SetCustomData(std::string identifier, bool value);
|
|
std::string GetCustomData(std::string identifier);
|
|
void DeleteCustomData(std::string identifier);
|
|
void SetScaling(bool v);
|
|
void SetScale(double scale_factor);
|
|
uint32 GetExp();
|
|
void SetExp(uint32 exp);
|
|
void AddExp(uint32 exp);
|
|
int GetMaxEvolveLvl();
|
|
uint32 GetKillsNeeded(int current_level);
|
|
Lua_ItemInst Clone();
|
|
void SetTimer(std::string name, uint32 time);
|
|
void StopTimer(std::string name);
|
|
void ClearTimers();
|
|
bool ContainsAugmentByID(uint32 item_id);
|
|
int CountAugmentByID(uint32 item_id);
|
|
int GetTaskDeliveredCount();
|
|
int RemoveTaskDeliveredItems();
|
|
|
|
private:
|
|
bool cloned_;
|
|
};
|
|
|
|
#endif
|
|
#endif
|