HerculesWS / Hercules

Hercules is a collaborative software development project revolving around the creation of a robust massively multiplayer online role playing game (MMORPG) server package. Written in C, the program is very versatile and provides NPCs, warps and modifications. The project is jointly managed by a group of volunteers located around the world as well as a tremendous community providing QA and support. Hercules is a continuation of the original Athena project.
http://herc.ws
GNU General Public License v3.0
886 stars 756 forks source link

Scriptable skills #1795

Open Helianthella opened 7 years ago

Helianthella commented 7 years ago

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.

bindskill(<id>, "<name>", "<NPC::Event>");


When the skill is invoked it would call NPC::Event with the invoking player attached, and would register the following array:


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

dastgirp commented 7 years ago

Would be nice addition 👍

Emistry commented 7 years ago

+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.

Helianthella commented 7 years ago

@Emistry we could just make binds overwrite any existing ones, so you can use the command again to change the event

Helianthella commented 7 years ago

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

4144 commented 7 years ago

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.

Helianthella commented 7 years ago

Which is why I would use the event queue, just like addtimer does

Btw, items have scripts and they too can be spammed

VMGlab commented 7 years ago

This would be nice. More useful for quests.

MishimaHaruna commented 7 years ago

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.