Triggering a script by using an item?

Discussions on various DOL development features

Moderator: Support Team

Triggering a script by using an item?

Postby tegstewart » Fri Mar 03, 2017 8:13 pm

Is there any way to tie a script to an item being used in the DB?

For instance, if somebody used their bind stone, could it fire a script that gives a list of places to teleport to and casts a spell to move them there?

That's not what I was going to use for, but now that I've come up with an easy example I kinda want to do that as well.

Thanks!
tegstewart
Developer
 
Posts: 102
Joined: Sun Dec 13, 2009 11:46 pm

Re: Triggering a script by using an item?

Postby ontheDOL » Fri Mar 03, 2017 9:54 pm

there definitely is a way :D Storm d2 has many items that trigger scripts

i'm also interested in possibly seeing an example script to work from, but havent got around to looking.

Neon pvp scripts in user files might have something of use for you, though the code might be outdated.

sorry i cant help more
- Unty -
Model Showroom and DOL guides
http://losojos-001-site1.btempurl.com
User avatar
ontheDOL
Developer
 
Posts: 311
Joined: Fri May 20, 2016 4:21 am
Location: Australian abroad

Re: Triggering a script by using an item?

Postby tegstewart » Sat Mar 04, 2017 12:21 am

Hmm. Now I'm curious. I can think of all kinds of useful stuff I could stick in a custom base skill tree available to everybody. It would be a lot more elegant than hauling around a bunch of items.
tegstewart
Developer
 
Posts: 102
Joined: Sun Dec 13, 2009 11:46 pm

Re: Triggering a script by using an item?

Postby PlanarChaosRvrtwo » Sat Mar 04, 2017 1:47 am

its not that nice but you could work around the script and create generetic inventory item or such that have an spell like spiritmaster pet bit modified and is loading teleport npctemplate or something.
DOL dint only gaved me the data to start my server,
it also gaved me 16 amazing years with nice peeps,
and now its on me to return the favor.
User avatar
PlanarChaosRvrtwo
Database Team
 
Posts: 517
Joined: Thu Jul 07, 2016 6:21 am

Re: Triggering a script by using an item?

Postby Leodagan » Sat Mar 04, 2017 7:25 am

Whenever a player try to activate any inventory Item we have an event fired :

In GamePlayer.cs (UseSlot() around line 8900)
Code: Select all
// notify event handlers about used slot Notify(GamePlayerEvent.UseSlot, this, new UseSlotEventArgs(slot, type));
If you listen to these events, and add a specific script in gameserverscript, you can then filter events to your own flavor (Get Player inventory item from used slot, then check if inventory item is the Name or Id_Nb you want to target, then do anything you want !)

Be careful this event could be silenced if the item has any "real use event" (when it triggers a spell or a switch the method exits before notify...)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Triggering a script by using an item?

Postby Dinberg » Sat Mar 04, 2017 11:31 am

Be careful this event could be silenced if the item has any "real use event" (when it triggers a spell or a switch the method exits before notify...)
This behaviour sounds unintended and possibly a bug. Can you think of any scenarios where a player would /use an item where we don't want the notify to be called?
The Marvelous Contraption begins to stir...
User avatar
Dinberg
Inactive Staff Member
 
Posts: 4695
Joined: Sat Mar 10, 2007 9:47 am
Yahoo Messenger: dinberg_darktouch
Location: Jordheim

Re: Triggering a script by using an item?

Postby Leodagan » Sat Mar 04, 2017 12:17 pm

Yeah probably when it's already handled by "hardcoded" methods, Weapon Switch, Quiver Use, Mount Call...

It may have been a choice to not fire the slot use event if the gameserver handle this specific case himself and don't want other method to interfere...

Typically this kind of events should have multiple "state event", the UseSlot() Method is huge and there is no distinction to fire "inventory switch event" or "item spell fired event", there should also be some specific "Before Use Slot Event" to allow some scripts to act before the game server code and maybe even stop him completely...

It's not only this behavior that sounds unintended it's more GamePlayer class being completely bloated, further customization should rely on subclassing GamePlayer class and overriding this kind of Method, or implementing InventoryItem Subclass that trigger custom script when virtual method are called (OnEquip() etc...) matching the actual UseSlot() behavior ;)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Triggering a script by using an item?

Postby tegstewart » Sat Mar 04, 2017 5:14 pm

its not that nice but you could work around the script and create generetic inventory item or such that have an spell like spiritmaster pet bit modified and is loading teleport npctemplate or something.
That actually works perfectly for the teleport, since almost everybody would have a custom pet anyway. That pet is going to also be your teleporter. Very slick.

It doesn't help with having a huge list of summonable pets, though. I think I'll do a separate thread for that specific problem.

Thanks!
tegstewart
Developer
 
Posts: 102
Joined: Sun Dec 13, 2009 11:46 pm

Re: Triggering a script by using an item?

Postby PlanarChaosRvrtwo » Sat Mar 04, 2017 8:58 pm

Would be nice if you could give us an list of custom content you want add and we see then how and who can help you with what
(i leaded the server realm of darkness over an year and added lot of custom stuff without the ability to script biggest work is allways to use the db proper couse the db allready can do very crazy things if you know what to combine with what to make it work)
DOL dint only gaved me the data to start my server,
it also gaved me 16 amazing years with nice peeps,
and now its on me to return the favor.
User avatar
PlanarChaosRvrtwo
Database Team
 
Posts: 517
Joined: Thu Jul 07, 2016 6:21 am

Re: Triggering a script by using an item?

Postby tegstewart » Sun Mar 05, 2017 4:32 pm

We talked about this in chat, but for everybody else...

I run a local server I use to do PVE on my own. I'm adding content to make that more enjoyable. In this case, I settled on adding a base line spell every class gets called Utility. It gives things like the top tier skald run speed chant at level 1, the personal bind stone spell with the recast delay removed, and also gives extremely powerful custom pets.

The idea is to make as many classes as possible viable for end game soloing, and to make gameplay more interesting by having situationally useful and flavourful pets so you aren't using the same pet all the time. I'm trying to do this in a way that still makes champion levels useful so there is end-game advancement. For instance, the healer pet applies baseline str/con/dex buffs, but also uses the cleric spec shield buff so the champion shield buff stacks with it, and the champion str/con and dex/qui buffs are still valuable.
tegstewart
Developer
 
Posts: 102
Joined: Sun Dec 13, 2009 11:46 pm

Re: Triggering a script by using an item?

Postby ontheDOL » Sun Apr 09, 2017 8:09 pm

incase anyone else is interested in items triggering scripts , I found these threads helpful

http://www.dolserver.net/viewtopic.php? ... pe#p142810

http://www.dolserver.net/viewtopic.php? ... pe#p149061

http://www.dolserver.net/viewtopic.php? ... pe#p118958

all the links have some example script extracts of how to make a "classtype" for a templated item
- Unty -
Model Showroom and DOL guides
http://losojos-001-site1.btempurl.com
User avatar
ontheDOL
Developer
 
Posts: 311
Joined: Fri May 20, 2016 4:21 am
Location: Australian abroad


Return to “%s” DOL Development Discussion

Who is online

Users browsing this forum: No registered users and 1 guest