HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Add abilities via variables

06-02-2006, 01:01 PM#1
n13astra
Need your collective help again..

How do you add an ability to a unit via triggers?

I have a variable which is set to an ability.

When i try to add the ability to the unit, it does nothing.

Here is the code that doesnt work:
Trigger:
Unit - Add Item_Book_Ability_List[(Integer A)] to Item_Book_Player_Unit

This is the code that does:
Trigger:
Unit - Add Laser (Long) to Item_Book_Player_Unit

Item_Book_Ability_List[0] is initalised at the start to point to Laser (Long)
06-02-2006, 01:16 PM#2
Captain Griffen
Are you sure the if is ever true?

Are you sure you have set the ability array properly?

Are you sure Item_Book_Player_Unit is set correctly?
06-02-2006, 01:22 PM#3
n13astra
Yes - I display to the screen.

Yes - I've compared the Jass code

Yes - I've displayed it to the screen.

Ive i just change that single line of code, it works. If anything, its got something to do with that ability variable, but i dont know why.

Is this a BUG??? Because ive created a new map, and tried adding an ability from a variable and it doesnt work.

Someone help??? VEX?
06-02-2006, 03:33 PM#4
The)TideHunter(
Quote:
Originally Posted by n13astra
Someone help??? VEX?

Vex is a great great coder, but asking directly for him in a public post i find quite odd.

If you want Vex's help, then PM him, but if you want other Jassers, not just directly Vex, then do not state you want somebody just because youv seen some of there posts, and you go "Wow, he must be clever, il ask him!"
06-02-2006, 03:44 PM#5
TaintedReality
Post both complete triggers. Having just one line of GUI doesn't really help us much.
06-02-2006, 03:48 PM#6
Captain Griffen
If array[0] is set to something, how is array[1] going to give what array[0] was set to?
06-02-2006, 04:41 PM#7
n13astra
Sorry guys, its your help im after.

Here are the triggers involved.
Trigger:
Add Weapon
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Assimilate
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Item-class of (Target item of ability being cast)) Equal to Artifact
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Triggering unit) has (Target item of ability being cast)) Equal to True
Collapse Then - Actions
Collapse For each (Integer A) from 0 to 3, do (Actions)
Collapse Loop - Actions
Set Item_Book_Index = ((((Player number of (Triggering player)) - 1) x 4) + (Integer A))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Item_Book_Inventory[Item_Book_Index] Equal to (Item-type of No item)
Collapse Then - Actions
Set Item_Book_Inventory[Item_Book_Index] = (Item-type of (Target item of ability being cast))
Item - Make (Target item of ability being cast) Undroppable
Game - Display to (All players controlled by a ((Owner of (Triggering unit)) controller) player) the text: ((|c00ffff00 + (Name of (Target item of ability being cast))) + |r has been assimilated.)
Collapse For each (Integer A) from 0 to 10, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Item-type of (Target item of ability being cast)) Equal to Item_Book_Item_List[(Integer A)]
Collapse Then - Actions
Unit - Add Item_Book_Ability_List[(Integer A)] to (Triggering unit)
Item - Remove (Target item of ability being cast)
Skip remaining actions
Else - Actions
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Integer A) Equal to 3
Collapse Then - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cfffed312You have ...
Else - Actions
Collapse Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cfffed312You must ...
Collapse Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cfffed312You canno...

Trigger:
Initalise Item Abilities Array
Events
Conditions
Collapse Actions
Set Item_Book_Ability_List[0] = Artillery
Set Item_Book_Ability_List[1] = Basic Cannon
Set Item_Book_Ability_List[2] = Basic Magic
Set Item_Book_Ability_List[3] = Blaster Cannon
Set Item_Book_Ability_List[4] = Burning Projectiles
Set Item_Book_Ability_List[5] = Confusion Cannon
Set Item_Book_Ability_List[6] = Corrosive Acid
Set Item_Book_Ability_List[7] = Creep Killer
Set Item_Book_Ability_List[8] = Death Magic
Set Item_Book_Ability_List[9] = Electro Cannon
Set Item_Book_Ability_List[10] = Energy Balls
Trigger - Destroy (This trigger)

Trigger:
Initalise Item Items Array
Events
Conditions
Collapse Actions
Set Item_Book_Item_List[0] = Artillery
Set Item_Book_Item_List[1] = Basic Cannon
Set Item_Book_Item_List[2] = Basic Magic
Set Item_Book_Item_List[3] = Blaster Cannon
Set Item_Book_Item_List[4] = Burning Projectiles
Set Item_Book_Item_List[5] = Confusion Magic
Set Item_Book_Item_List[6] = Corrosive Acid
Set Item_Book_Item_List[7] = Creeper
Set Item_Book_Item_List[8] = Death Magic
Set Item_Book_Item_List[9] = Electro Cannon
Set Item_Book_Item_List[10] = Energy Balls
Trigger - Destroy (This trigger)

Also, can i add multiples of the same ability to a unit??? The abilities are passive and based on phoenix fire.
06-02-2006, 04:51 PM#8
Captain Griffen
Those initalisation triggers have no event, so won't happen.

You've nested a For loop integer A in a For loop integer A loop. Replace the second one with For loop integer B.

Quote:
Also, can i add multiples of the same ability to a unit??? The abilities are passive and based on phoenix fire.

Not normally, but I have an idea. One moment.

EDIT: Correction, you can, event if they are the same ability (passives only for this, and not all at that; I only tested pheonix fire, but I know movement speed passive doesn't work the same).
06-03-2006, 12:51 AM#9
n13astra
EXCELLENT, didnt spot that for loop, but sad news is that it still doesnt work.

The eventless triggers are called at initialisation via a Run Trigger ignoring conditions.

New trigger:
Trigger:
Add Weapon
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Assimilate
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Item-class of (Target item of ability being cast)) Equal to Artifact
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Triggering unit) has (Target item of ability being cast)) Equal to True
Collapse Then - Actions
Collapse For each (Integer B) from 0 to 3, do (Actions)
Collapse Loop - Actions
Set Item_Book_Index = ((((Player number of (Triggering player)) - 1) x 4) + (Integer B))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Item_Book_Inventory[Item_Book_Index] Equal to (Item-type of No item)
Collapse Then - Actions
Set Item_Book_Inventory[Item_Book_Index] = (Item-type of (Target item of ability being cast))
Item - Make (Target item of ability being cast) Undroppable
Game - Display to (All players controlled by a ((Owner of (Triggering unit)) controller) player) the text: ((|c00ffff00 + (Name of (Target item of ability being cast))) + |r has been assimilated.)
Collapse For each (Integer A) from 0 to 10, do (Actions)
Collapse Loop - Actions
Game - Display to (All players) the text: (Name of Item_Book_Ability_List[(Integer A)])
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Item-type of (Target item of ability being cast)) Equal to Item_Book_Item_List[(Integer A)]
Collapse Then - Actions
Unit - Add Item_Book_Ability_List[(Integer A)] to (Triggering unit)
Item - Remove (Target item of ability being cast)
Game - Display to (All players) the text: (String((Integer A)))
Skip remaining actions
Else - Actions
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Integer B) Equal to 3
Collapse Then - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cfffed312You have ...
Else - Actions
Collapse Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cfffed312You must ...
Collapse Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cfffed312You canno...

One other problem. When the Assimilate ability is cast, and the trigger gets to the line of code that removes the item, the cooldown of the assimilate abitlity (20 secs) resets. How can i fix this???
06-03-2006, 11:32 AM#10
Blade.dk
Removing an ability will always reset cooldown, not much you can do about that. And I assume the item has the ability, so that is the problem.

Try to add a game text message action to the trigger that sets up the array, to be 100% sure that it initializes them.
06-03-2006, 01:45 PM#11
Captain Griffen
Disabling rather than removing it can work. While not MUI if any one player has more than one, it works if you only have one/player.