• 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.

buying abilities

Status
Not open for further replies.
Level 2
Joined
Dec 13, 2005
Messages
23
i've seen it done in The Great Strategy and a custom hero arena

How do you make it so you can buy abilities from shops???
i thaught of using triggers, but they would be lengthy... and i have a feeling there is another way, can some1 help me out here?
 
Level 4
Joined
Dec 8, 2005
Messages
58
I can't remember off hand how to do it but if you download my map "darthyoda's Alliance vs. Horde"(not my td(but you can download that to if you want :wink: )) you will find like 16 diffrent ability that can be bought however they are all used by Items. For example you can buy invis and you hero will become invis but you have to have the Item in your inventory, not sure if this is want you want but it's the best I can do(without triggers).
 
Level 7
Joined
Mar 12, 2006
Messages
407
Aktionen
Gegenstand - Set the custom value of (Sold Item) to 1
Set playernumber = (Player number of (Owner of (Buying unit)))
Einheit - Add Crushing Blow to (Buying unit)
Set skilll[(Player number of (Owner of (Buying unit)))] = (skilll[(Player number of (Owner of (Buying unit)))] + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
skused[1] Gleich False
skilll[(Player number of (Owner of (Buying unit)))] Gleich 1
'THEN'-Aktionen
Set skill1[(Player number of (Owner of (Buying unit)))] = Crushing Blow
'ELSE'-Aktionen
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
skilll[(Player number of (Owner of (Buying unit)))] Gleich 2
skused[1] Gleich False
'THEN'-Aktionen
Set skill2[(Player number of (Owner of (Buying unit)))] = Crushing Blow
'ELSE'-Aktionen
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
skilll[(Player number of (Owner of (Buying unit)))] Gleich 3
skused[1] Gleich False
'THEN'-Aktionen
Set skill3[(Player number of (Owner of (Buying unit)))] = Crushing Blow
'ELSE'-Aktionen
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
skused[1] Gleich True
skill1[playernumber] Gleich Crushing Blow
'THEN'-Aktionen
Set sk1[playernumber] = (sk1[playernumber] + 1)
Einheit - Increase level of skill1[playernumber] for (Buying unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
sk1[playernumber] Größer als 3
'THEN'-Aktionen
Spiel - Display to (All allies of (Owner of (Buying unit))) for 30.00 seconds the text: Max lvl reached!
Spieler - Add (Custom value of (Sold Item)) to (Owner of (Buying unit)) Aktuelles Gold
'ELSE'-Aktionen
'ELSE'-Aktionen
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
skused[1] Gleich True
skill2[playernumber] Gleich Crushing Blow
'THEN'-Aktionen
Set sk2[playernumber] = (sk2[playernumber] + 1)
Einheit - Increase level of skill2[playernumber] for (Buying unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
sk2[playernumber] Größer als 3
'THEN'-Aktionen
Spiel - Display to (All allies of (Owner of (Buying unit))) for 30.00 seconds the text: Max lvl reached!
Spieler - Add (Custom value of (Sold Item)) to (Owner of (Buying unit)) Aktuelles Gold
'ELSE'-Aktionen
'ELSE'-Aktionen
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
skused[1] Gleich True
skill3[playernumber] Gleich Crushing Blow
'THEN'-Aktionen
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Bedingungen
sk3[playernumber] Größer als 3
'THEN'-Aktionen
Spiel - Display to (All allies of (Owner of (Buying unit))) for 30.00 seconds the text: Max lvl reached!
Spieler - Add (Custom value of (Sold Item)) to (Owner of (Buying unit)) Aktuelles Gold
'ELSE'-Aktionen
Set sk3[playernumber] = (sk3[playernumber] + 1)
Einheit - Increase level of skill3[playernumber] for (Buying unit)
'ELSE'-Aktionen
Set skused[1] = True
My current script for ability 'crushing blow' of my actual map, maybe its useful to u, but as u can see its in german
 
Level 6
Joined
Feb 18, 2005
Messages
263
i did this a few times, but as far there is no (working) way to add abilities to hero without using abilities.

The way i used was simply and, as you put it, lengthy:

event: unit aquires item
cond:
start or
itemtype = ability_item_1
itemtype = ability_item_2
...
end or
event:
if itemtype = ability_item_1 then
add (ability_1) to (hero manipulating item)
call makeAbilityPermanent(ability_1)
endif


another way would be with custom code, i guess that would be way shorter, but you would need 2 instead of 1 trigger, but they are way shorter.
I'll write it as good as i can remember the propber jass code:

function init takes nothing returns nothing
//do this for each item/ability you want
//you cannot add more than one ability per item
StoreInteger(<your gamecache>, "Abilities", I2S('your item code here'), 'your ability code here')
//e.g. StoreInteger(udg_gamecache, "Abilities", I2S('I000'), I2S('A000'))
endfunction

function LearnAbilityFromItem takes unit whichHero, item whichItem returns nothing
//i dunno the exact function name, but i hope you understanad what i mean
local ability whichAbility = GetInteger(<your gamecache>, "Abilities", I2S('itemtype of(whichItem)'))
addAbilityToUnit(whichHero, whichAbility)
endfunction
 
Level 2
Joined
Dec 13, 2005
Messages
23
i know i can do it with a trigger for every item and an if/then/else for every level, but i would like a shorter way, and i dont understand JASS, so the whole script with a couple (insert blah blah's here) and a nice explenation... 40ish different triggers would suck.
 
Level 2
Joined
Dec 13, 2005
Messages
23
Hence asking for an explanation, incase you dont understand what that is, its basically a lesson, and lord raszul there are multiple levels (like 10) for each ability...

and also would it be any easier to work using tomes? because i think thats what they used (any other item would require inventory space)
 
Level 7
Joined
Mar 12, 2006
Messages
407
Sardrixx said:
Hence asking for an explanation, incase you dont understand what that is, its basically a lesson, and lord raszul there are multiple levels (like 10) for each ability...

and also would it be any easier to work using tomes? because i think thats what they used (any other item would require inventory space)
I think my script does all that ^^
there might be a shorter way but not a much shorter
 
Status
Not open for further replies.
Top