Hi all,
I would like that an item in my mod, "good meat", heal a little bit of HPs. How should I do for the script to fire when I use the Item ?
I created a script, tried various events (event_type_use, event_type_unique_power...) but nothing happens.
How to make item fire a custom script
Débuté par
mj crom
, déc. 12 2009 07:19
#1
Posté 12 décembre 2009 - 07:19
#2
Posté 12 décembre 2009 - 01:29
Basically you need to set up a new ability for that item (by extending ABI_base with an ABI_yourstuff m2DA) and then select it in the "activated ability" field when editing the item resource in the toolset.
Modifié par Phaenan, 12 décembre 2009 - 01:30 .
#3
Posté 12 décembre 2009 - 02:30
thzanks, but then, why is there a script line when you create a new item ?
#4
Posté 12 décembre 2009 - 03:27
A script line when a new item is created.
Hm. Not sure I get what you mean. ^_~
Ah !
The script attribute in the item resource ? Yeah, must be that. Sorry, I'm a bit slow between 3:22 and 3:24.
Well, that'd be the item event handler. But it's actually not used (dev explainations here) and it's not related to the items activated abilities. As a matter of fact, the event you were talking about ( EVENT_TYPE_USE ) is a placeable event, and not an item one.
The script fired by your item ability will be the one defined in the ABI_base m2DA entry for that ability.
Hm. Not sure I get what you mean. ^_~
Ah !
The script attribute in the item resource ? Yeah, must be that. Sorry, I'm a bit slow between 3:22 and 3:24.
Well, that'd be the item event handler. But it's actually not used (dev explainations here) and it's not related to the items activated abilities. As a matter of fact, the event you were talking about ( EVENT_TYPE_USE ) is a placeable event, and not an item one.
The script fired by your item ability will be the one defined in the ABI_base m2DA entry for that ability.
Modifié par Phaenan, 12 décembre 2009 - 03:29 .
#5
Posté 12 décembre 2009 - 08:57
Thanks a lot, Phaenan.
I tried to figure out how to simply create an item that could heal, say, 5-10 HP to the user.
The whole toolset is getting slowly on my nerves. I created mods in NWN and NWN2, and it wasn't such a pain to create simple objects like that.
I tried to figure out how to simply create an item that could heal, say, 5-10 HP to the user.
The whole toolset is getting slowly on my nerves. I created mods in NWN and NWN2, and it wasn't such a pain to create simple objects like that.
#6
Posté 19 décembre 2009 - 10:08
Been playing with this myself today and looking at other people's code, I finally managed to created a clickable item that will display my location (location code made by jwvanderbeck)
What I ended up doing was in my module's main script I added a case for the event type EVENT_TYPE_UNIQUE_POWER in there I check if the event is created by my item
object i = GetEventObject(ev,0);
if (GetTag(i)=="yite_locator_ring") // My item is yite_locator_ring.uti
And then do whatever I wanted to do (in my case throw the location on the screen) in your case do something with hitpoints i guess
What I ended up doing was in my module's main script I added a case for the event type EVENT_TYPE_UNIQUE_POWER in there I check if the event is created by my item
object i = GetEventObject(ev,0);
if (GetTag(i)=="yite_locator_ring") // My item is yite_locator_ring.uti
And then do whatever I wanted to do (in my case throw the location on the screen) in your case do something with hitpoints i guess
Modifié par Yite, 19 décembre 2009 - 10:10 .
#7
Posté 31 décembre 2009 - 02:13
Well, I actually used the same thing (EVENT_TYPE_UNIQUE_POWER) and that worked. But I wanted to have something more "portable" (not tied to module script) so I started messing with ABI_mystuff m2da. I created my ability ITEM_TELEPORT, my script attached to it. Gave my item the ability (base type quick item) and fired up the game. Everything went smoothly: Used the item, my script did what it's supposed to do...
BUT: My item's gone :/ So I start looking around and the wiki it states:
The number of uses for this ability will be decided by the script which will destroy the item when appropriate.
Well, I'm most certainly not destroying any items!
Any clues?
BUT: My item's gone :/ So I start looking around and the wiki it states:
The number of uses for this ability will be decided by the script which will destroy the item when appropriate.
Well, I'm most certainly not destroying any items!
Any clues?





Retour en haut






