HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Get the ability used.

05-31-2006, 01:43 PM#1
n13astra
Is there any way of getting the ability linked to an item? Not during attack or anything, just the ability that is linked.
05-31-2006, 01:51 PM#2
Soultaker
Could you be a bit more specific? You are able to insert abilities on items, and use them like a healing potion or whatever.

- Soultaker
05-31-2006, 02:14 PM#3
n13astra
what im trying to do is this:

-unit clicks on an ability and targets an item in inventory
-the trageted item has an ability when used, and i want to be able to retrieve that ability the item uses via a trigger and store it.
-the item is removed.
-the ability the item used is added permantely to the unit
05-31-2006, 02:33 PM#4
Blade.dk
You can use gamecache to set up some kind of database for it at map initialization, and then load from it, but there is no simple way of doing it.
05-31-2006, 02:46 PM#5
n13astra
so that means that im going to have to initials every item and its used ability into my trigger code??

I have 129 items!
05-31-2006, 03:35 PM#6
Blade.dk
Yes.

Be happy that you don't have 5000. CnP'ing a line of code and changing something 129 times is not a big problem, it is annoying, yes, but it shouldn't take extremely long.
05-31-2006, 04:08 PM#7
The)TideHunter(
Slightly Offtopic: It is time consuming, but something that would be even more time consuming is rearranging every thread on a board into alphabetical order without using a system, doing it by hand
05-31-2006, 06:24 PM#8
Rising_Dusk
What I would do is make a function with all abilities hardwired into the map.
That way you might be able to do this...

Collapse JASS:
function GetItemAbility takes item i returns integer
    if GetItemTypeId(i) = someId then //Replace someId with whatever your first item's ID is.
        return someAbilityRaw //Replace someAbilityRaw with the raw code for the ability attached to it.
    elseif ... //Continue as necessary.
endfunction
05-31-2006, 06:27 PM#9
blu_da_noob
Storing in gamecache would be much more efficient.
05-31-2006, 08:47 PM#10
Soulprovider
Slightly offtopic:
The real troubles comes when you want to save your character. for what you are planning I would recommend not instituting a save load code, or institute it with only the hero level saving.
06-01-2006, 02:28 PM#11
n13astra
New problem. Very annoying problem too.

I have 3 triggers, which are as follows;

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 No item
Collapse Then - Actions
Set Item_Book_Inventory[Item_Book_Index] = (Target item of ability being cast)
Set Item_Book_Player_Unit = (Triggering unit)
Trigger - Run What Weapon Check <gen> (ignoring conditions)
Skip remaining 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:
Remove Weapon
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to De-Assimilate
Collapse 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))
Set Item_Book_Player_Unit = (Triggering unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Item_Book_Inventory[(Integer A)] Not equal to No item
Collapse Then - Actions
Game - Display to (All players controlled by a ((Owner of Item_Book_Player_Unit) controller) player) the text: ((Name of Item_Book_Inventory[Item_Book_Index]) + |c00ffff00 has been De-Assimilated.|r)
Unit - Remove Laser (Long) from Item_Book_Player_Unit
Item - Create (Item-type of Item_Book_Inventory[Item_Book_Index]) at (Random point in (Rect centered at (Position of (Triggering unit)) with size (100.00, 100.00)))
Set Item_Book_Inventory[Item_Book_Index] = No item
Else - Actions

Trigger:
What Weapon Check
Events
Conditions
Collapse Actions
Trigger - Turn off (This trigger)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Item-type of Item_Book_Inventory[Item_Book_Index]) Equal to Laser (Long)
Collapse Then - Actions
Item - Remove Item_Book_Inventory[Item_Book_Index]
Game - Display to (All players controlled by a ((Owner of Item_Book_Player_Unit) controller) player) the text: ((Name of Item_Book_Inventory[Item_Book_Index]) + |c00ffff00 has been permanently added to the vehicles weapons.|r)
Unit - Add Laser (Long) to Item_Book_Player_Unit
Else - Actions

Now, i have an item in the heros inventory. The player clicks on an ability called "Assimilate" and selects the item they would like to assimilate. This triggers the "Add Weapon" trigger. This checks if the item is a weapon, etc etc. It checks if the hero has the item in it invertory. It then runs a loop to check if the hero has room for the item in the virtual invertory "Item_Book_Inventory". If it finds one that is eqaul to "NO ITEM" it then sets the value of Item_Book_Inventory to the targetted item. Sets the Item_Player_Unit to the unit that cast the assimilate spell.

It then runs "Which Weapon Check", which removes the item stored at Item_Book_Inventory.

Here lies the problem. After this "Remove item", the Next line displays to the player that the "item name" was succesfully assimilated, although in game it just displays an empty item name. Now if i put this display to player before the remove item, it displays the correct "item name"

So, What the hell is happening here, and am i doing it wrong???

P.S. When the assimilate ability is click and an item is selected, it should have a cooldown of 20secs, but for some reason it doesn't. If one of the errors occur, ie "Virtual Item Book full" or "Cant assimilate that item" the cooldown works.

I want to try and avoid having a dummy unit to carry the assimilated items follow the unit everywhere.
06-01-2006, 02:52 PM#12
blu_da_noob
If you have removed an item, the item no longer exists, so how could the game possibly get the name of it? Either show the message before you remove the item, or store the name in a variable.
06-01-2006, 02:57 PM#13
n13astra
well, then my system wont work because i store the item in an array of items, so that when they de-assimilate, it can look at this array and restore the items.

Could i set the item array[x] to the targeted item, and then remove item of type from unit?
06-01-2006, 04:24 PM#14
MysticGeneral
Here's what you can do.

1. When a unit picks up an item, create a dummy unit somewhere in the distant world.

2. Give a duplicate item to the dummy unit.

3. Make that dummy unit use the item on a dummy enemy unit.

4. If dummy unit casts an ability, set IAbility[0] = ability being cast (Use Ix function as the array)

5. When you need to get the ability of an item, refer to IAbility[].