• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Little Help with Item Trigger

Status
Not open for further replies.
Level 1
Joined
Aug 17, 2006
Messages
5
Vial
Events
Unit - A unit Finishes casting an ability
Conditions
(Ability being cast) Equal to Empty Vial (Hero All)
Actions
Item - Remove (Item carried by (Casting unit) of type Empty Vial])
Game - Display to (All players) for 30.00
Wait 0.05 seconds
Hero - Create Full Vial and give it to (Casting unit)


Trying to make it so when I use this ability (spirit link turned into dummy spell that only targets "suicidal" invuln/neutral/structure: fountains with suicidal tag). Anyways, the dummy spell fires perfectly; however, I was wondering how I can make an item be given to my hero. The above trigger isn't working, and not only that even if it did work how do I get the "full vial" to go into slot 6. Slot 6 is designated for the vials.

Idea is (probably overused but haven't been modding wc3 in about 1.5 years): Empty Vial ---> Goto fountain use dummy spell ---> Full Vial.

Anyhelp would be great.
 
Level 11
Joined
Feb 22, 2006
Messages
752
Vial
Events
Unit - A unit starts the effect of an ability
Conditions
(Ability being cast) Equal to Empty Vial (Hero All)
Actions
Item - Remove (Item carried by (Triggering unit) of type Empty Vial])
Game - Display to (All players) for 30.00
Wait 0.05 seconds
Custom Script: call UnitAddItemToSlotById(GetTriggerUnit(), 'I000', 5)

Replace the 'I000' with the raw code for your full vial. Using GetTriggerUnit(), or "Triggering unit" in GUI, when you can is always better than any of the equivalents ( Casting unit, Killing unit, etc.). It's faster, and it works after waits. Also, using Unit starts the effect of an ability is better than using Unit finishes casting an ability in conjunction with instant effect spells (like Spirit Link). Sometimes you get glitches with the latter where the game doesnt recognize the event.

Just so you know, the TriggerSleepAction() function (the Wait action) can't take any values below 0.28. If you enter in a value less than 0.28 seconds, the game will just wait 0.28 seconds instead of whatever you put in.
 
Level 11
Joined
Jul 12, 2005
Messages
764
you don't need a custom script here...
try to replace Casting Unit with Triggering Unit.
If it doesn't work, store the Triggering Unit into a unit variable.
And also exchange Finishes casting.. with Starts the effect...

but if this is an item ability (u click on the item, and after that on the fountain), you need a different event here! (unit uses an item, or i dunno)

is the message displayed on the screen?
 
Level 11
Joined
Jul 12, 2005
Messages
764
you don't need a custom script here...
try to replace Casting Unit with Triggering Unit.
If it doesn't work, store the Triggering Unit into a unit variable.
And also exchange Finishes casting.. with Starts the effect...

but if this is an item ability (u click on the item, and after that on the fountain), you need a different event here! (unit uses an item, or i dunno)

is the message displayed on the screen?
 
Level 1
Joined
Aug 17, 2006
Messages
5
Ok here's what I have now:




Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Empty Vial (Hero All)
Actions
Hero - Create Vial[(Random integer number between 0 and 4)] and give it to (Triggering unit)
Custom script: set Vial[0] = 'I001'
Custom script: set Vial[0] = 'I002'
Custom script: set Vial[0] = 'I003'
Custom script: set Vial[0] = 'I004'
Custom script: set Vial[0] = 'I005'
Item - Remove (Item carried by (Triggering unit) of type Empty Vial)
Custom script: call UnitAddItemToSlotById(GetTriggerUnit(), 'l002', 5)
Game - Display to (All players) for 30.00 seconds the text: TEST


My message "TEXT" fires as it should. Though I am not given the item.

I have decided that once the hero uses the empty vial item on the fountain the hero will be given 1 of 5 random items.


So bascially:
1.) Yes it's firing correctly, but I am not getting the custom script to actually give the item.

This also does not work:
Hero - Create Vial[(Random integer number between 0 and 4)] and give it to (Triggering unit)


2.) If I can get the item to be given to the hero, I want to make it so it is given a random item how would I alter the custom script for this?

3.) Double checking... My variable "vial" is an item variable with an array size of 0-4 (for 5 random items). Is this the correct way of approaching this? Is that the right custom script to add these items?
 
Level 11
Joined
Jul 12, 2005
Messages
764
here you go:

Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Empty Vial (Hero All)
Actions
Custom script: local integer array Vial
Custom script: set Vial[0] = 'I001'
Custom script: set Vial[1] = 'I002'
Custom script: set Vial[2] = 'I003'
Custom script: set Vial[3] = 'I004'
Custom script: set Vial[4] = 'I005'
Hero - Create Vial[(Random integer number between 0 and 4)] and give it to (Triggering unit)
Item - Remove (Item carried by (Triggering unit) of type Empty Vial)
Custom script: call UnitAddItemToSlotById(GetTriggerUnit(), 'l002', 5)
Game - Display to (All players) for 30.00 seconds the text: TEST

that's it
 
Level 11
Joined
Feb 22, 2006
Messages
752
ok i figured out the problem: I shouldn't have used UnitAddItemToSlotById. Ok here's what you need to do.

Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Empty Vial (Hero All)
Actions
Custom script: local integer a = GetRandomInt(0, 4)
Custom script: local integer array Vial
Custom script: set Vial[0] = 'I001'
Custom script: set Vial[1] = 'I002'
Custom script: set Vial[2] = 'I003'
Custom script: set Vial[3] = 'I004'
Custom script: set Vial[4] = 'I005'
Item - Remove (Item carried by (Triggering unit) of type Empty Vial)
Custom script: UnitAddItemByIdSwapped( Vial[a], GetTriggerUnit() )
Custom script: call UnitDropItemSlot(GetTriggerUnit(), bj_lastCreatedItem, 5)
Game - Display to (All players) for 30.00 seconds the text: TEST
 
Status
Not open for further replies.
Top