The first is COMMAND_USE_EQUIPPED_ITEM (275). It is implemented almost exactly like COMMAND_USE_ITEM except the slot_id is passed in instead of the item_index. I also check if the item is useable before calling the item script. I verified this works by hooking up one of the mount whistles to a lua script I created (see horsemount.lua below) and tied the item to that script in the database. The script just calls the beta mount spell. It worked like a charm from the inventory and also when equipped in the charm slot.
horsemount.lua
Code: Select all
function used(Item, ItemUser)
CastSpell(ItemUser, 3101, 1, ItemUser)
end
Also, obviously the handlers have to be updated in the database as well. As always, let me know if I overlooked something. I'm not sure how much time I can devote to this project so don't call me official yet but I am having a blast so far.
Commands.h
Code: Select all
--- Commands.h (revision 437)
+++ Commands.h (working copy)
@@ -477,4 +477,6 @@
#define COMMAND_LOCATION_REMOVE 272
#define COMMAND_LOCATION_DELETE 273
#define COMMAND_LOCATION_LIST 274
+#define COMMAND_USE_EQUIPPED_ITEM 275
+#define COMMAND_CANCEL_MAINTAINED 276
#endif
Code: Select all
--- Commands.cpp (Revision 437)
+++ Commands.cpp (working copy)
@@ -960,6 +960,16 @@
client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /info {inventory|equipment|spell} {id}");
break;
}
+
+ case COMMAND_USE_EQUIPPED_ITEM:
+ if (sep && sep->arg[0] && sep->IsNumber(0)) {
+ int32 slot_id = atoul(sep->arg[0]);
+ Item* item = player->GetEquipmentList()->GetItem(slot_id);
+ if (item && item->generic_info.usable && item->GetItemScript())
+ lua_interface->RunItemScript(item->GetItemScript(), "used", item, player);
+ }
+ break;
+
case COMMAND_USE_ITEM: {
if (sep && sep->arg[0] && sep->IsNumber(0)) {
int32 item_index = atoul(sep->arg[0]);
@@ -3978,6 +3988,21 @@
client->Message(CHANNEL_COLOR_YELLOW,"You are %s invisible to who queries.", client->GetPlayer()->get_character_flag(CF_GM_HIDDEN)?"now":"no longer");
break;
}
+ case COMMAND_CANCEL_MAINTAINED:{
+ if (sep && sep->arg[0] && sep->IsNumber(0)) {
+ int32 spell_index = atoul(sep->arg[0]);
+ MaintainedEffects mEffects = client->GetPlayer()->GetInfoStruct()->maintained_effects[spell_index];
+
+ Spell* spell = master_spell_list.GetSpell(mEffects.spell_id, mEffects.tier);
+ if(spell && spell->GetSpellData()->friendly_spell){
+ if(!client->GetPlayer()->GetZone()->GetSpellProcess()->DeleteCasterSpell(client->GetPlayer(), spell))
+ client->Message(CHANNEL_COLOR_RED, "The maintained spell could not be cancelled.");
+ }
+ else
+ client->Message(CHANNEL_COLOR_RED, "You can only cancel friendly spells!");
+ }
+ break;
+ }
default:{
LogFile->write(EQEMuLog::Status, "Unhandled command: %s", command->command.data.c_str());
}