Open Helianthella opened 7 years ago
Would be nice addition 👍
+1 kinda similar with http://herc.ws/board/topic/11296-onpcuseskillevent/ but this PR are able to bind through npc script. nice ..
it would be nice too if you included unbindskill
script command as well.
able to bind and unbind the skill to trigger different event at certain times to avoid conflict between 2 or more events.
@Emistry we could just make binds overwrite any existing ones, so you can use the command again to change the event
Perhaps this buildin isn't needed after all... do we want bindskill()
to attach an event to existing skills or to register new skills altogether? If pre-defined skills only then we could just add OnCastScript
, OnUseScript
and OnFailScript
in the skill db, kinda like it's done for items in the item db. Also I'm not a fan of having scripts embedded in the databases; maybe we could do On...Event
rather than On...Script
so that it directly calls a npc event
EDIT: sorry for closing... hit the wrong button by mistake
It can be performance issue. Because by default hercules allow some skills use with very small default pauses. This mean some one can flood with skill many times per second and it will run scripts again and again.
Another issue skill casting with scripts may overrun already executed scripts attached to player.
Which is why I would use the event queue, just like addtimer does
Btw, items have scripts and they too can be spammed
This would be nice. More useful for quests.
I don't mind this, if there are concrete use cases that require it. Considering how the client needs to know the skill information in advance, I believe the skill db approach is reasonable, since it wouldn't be possible to dynamically create new skills.
Using the event queue requires some tests with reasonable skill scripts, to see if the current size of the queue is appropriate (MAX_EVENTQUEUE == 2
, MAX_EVENTTIMER == 32
). I'd prefer if those wouldn't get increased unless really necessary though, to avoid affecting resource use and performance for those that aren't interested in this feature.
Here's a proposal: a new command that allows to bind skill invocations to script events. This would allow for dynamic skills that rely on quest state and such, and would allow scripters to make new skills without having to modify the engine or write a plugin.
When the skill is invoked it would call
NPC::Event
with the invoking player attached, and would register the following array:@skill_target
In the past I did something similar for tmwAthena, but it used chat commands (bound with the
registercmd
buildin) instead of skills, although using skills was the plan but it never came to fruition... If you're curious, see the files here: https://github.com/themanaworld/tmwa-server-data/tree/master/world/map/npc/magic