- Joined
- Nov 3, 2013
- Messages
- 989
Edit: Icemanbo helped me out and I think I can manage the rest.
I put together some trigger for testing how I would allow a unit to basically browse a shop and go through categories/lists of abilities to learn (in a single shop). since it was just for testing i quickly made some if statements and got it to work
I thought if I used a Hashtable and then predetermine what each dummy ID would have for values bound to them I could load the value(s) I needed from the IDs instead of using billions of ifs or looping through arrays.
From tutorials I had read it was usually just about making abilities mui and not really getting lots of different values from one value in the way I intend, at least I don't think so.
So I put together something I thought would kind of do something like it, although I don't really know what I'm doing tbh.
If uType would be 0 it should mean that the unit type of the sold unit represented an ability (instead of a category) and it would not change what units are being sold
I put together some trigger for testing how I would allow a unit to basically browse a shop and go through categories/lists of abilities to learn (in a single shop). since it was just for testing i quickly made some if statements and got it to work
-
CusAbi 2
-
Events
-
Unit - A unit Sells a unit
-
-
Conditions
-
Actions
-
Set tempUnit = (Sold unit)
-
Set tempUtype = (Unit-type of tempUnit)
-
Unit - Remove tempUnit from the game
-
Set tempUnit = (Buying unit)
-
Set tempPlayer = (Owner of tempUnit)
-
-------- Find player number --------
-
For each (Integer i) from 1 to 12, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Player(i)) slot status) Equal to Is playing
-
tempPlayer Equal to (Player(i))
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
tempUtype Equal to Return to the all catagories tab (dummy unit)
-
-
Then - Actions
-
-------- Clear --------
-
Neutral Building - Remove Return to the all catagories tab (dummy unit) from cusAbi_unit_shop[i]
-
Neutral Building - Remove Berserk (no target dummy) from cusAbi_unit_shop[i]
-
ETC
-
-------- Add Categories --------
-
Neutral Building - Add No target abilities tab (dummy unit) to cusAbi_unit_shop[i] with 0 in stock and a max stock of 1
-
Neutral Building - Add PBAoE abilities tab (dummy unit) to cusAbi_unit_shop[i] with 0 in stock and a max stock of 1
-
ETC
-
-
Else - Actions
-
-------- Check which category was selected --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
tempUtype Equal to No target abilities tab (dummy unit)
-
-
Then - Actions
-
-------- Clear --------
-
Neutral Building - Remove No target abilities tab (dummy unit) from cusAbi_unit_shop[i]
-
Neutral Building - Remove PBAoE abilities tab (dummy unit) from cusAbi_unit_shop[i]
-
ETC
-
-------- Add Categories --------
-
Neutral Building - Add Berserk (no target dummy) to cusAbi_unit_shop[i] with 0 in stock and a max stock of 1
-
-------- Return & Next page --------
-
Neutral Building - Add Return to the all catagories tab (dummy unit) to cusAbi_unit_shop[i] with 0 in stock and a max stock of 1
-
-
Else - Actions
-
-------- Continue Forever and Ever --------
-
-------- No category was selected --------
-
-------- An ability dummy is bought --------
-
Set cusAbi_Int_AbiAmount[i] = (cusAbi_Int_AbiAmount[i] + 1)
-
-------- Check which ability was picked --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
tempUtype Equal to Berserk (no target dummy)
-
-
Then - Actions
-
-------- Check if Ability hasn't already been picked --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Berserk (Engineering 1-5) for tempUnit) Equal to 0
-
-
Then - Actions
-
-------- add ability --------
-
Player - Disable Berserk (Spellbook 1-5) for tempPlayer
-
Unit - Add Berserk (Spellbook 1-5) to tempUnit
-
Unit - Set level of Berserk (Engineering 1-5) for tempUnit to cusAbi_Int_AbiAmount[i]
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
cusAbi_Int_AbiAmount[i] Equal to 1
-
-
Then - Actions
-
Unit - Add Berserk (slot 1) to tempUnit
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
cusAbi_Int_AbiAmount[i] Equal to 2
-
-
Then - Actions
-
Unit - Add Berserk (slot 2) to tempUnit
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
cusAbi_Int_AbiAmount[i] Equal to 3
-
-
Then - Actions
-
Unit - Add Berserk (slot 3) to tempUnit
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
cusAbi_Int_AbiAmount[i] Equal to 4
-
-
Then - Actions
-
Unit - Add Berserk (slot 4) to tempUnit
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
cusAbi_Int_AbiAmount[i] Equal to 5
-
-
Then - Actions
-
Unit - Add Berserk (slot 5) to tempUnit
-
-
Else - Actions
-
-
-
-
-
-
-
-
-
-
-
Else - Actions
-
-------- Already have ability --------
-
Set cusAbi_Int_AbiAmount[i] = (cusAbi_Int_AbiAmount[i] - 1)
-
Game - Display to (Player group(tempPlayer)) the text: You can't have more...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From tutorials I had read it was usually just about making abilities mui and not really getting lots of different values from one value in the way I intend, at least I don't think so.
So I put together something I thought would kind of do something like it, although I don't really know what I'm doing tbh.
-
Untitled Trigger 001
-
Events
-
Unit - A unit Sells a unit
-
-
Conditions
-
Actions
-
Custom script: local unit u = GetSoldUnit()
-
Custom script: local player p = GetTriggerPlayer()
-
Custom script: local integer uType = LoadInteger(udg_hash, GetUnitTypeId(u), 0)
-
Custom script: if uType != 0 then
-
Custom script: set i = uType - 12 (number of dummies per page)
-
Custom script: loop
-
Custom script: exitwhen i == uType
-
Custom script: call AddUnitToStock(udg_cusAbi_unit_shop[(GetConvertedPlayerId(p)], udg_cusAbi_uType[i], 0, 1)
-
Custom script: set i = i + 1
-
Custom script: endloop
-
Custom script: else
-
-
If uType would be 0 it should mean that the unit type of the sold unit represented an ability (instead of a category) and it would not change what units are being sold
Last edited: