(Yes, I know I can find already-made system and copy it, but it isnt fun)
I have a custom map with a lot of recipes (200 for sure). Currently all recipes are written via GUI and scattered at ~30 triggers (sorted by type). Lately I thought about that and concluded that it takes tons of processing power (it works well and without delay tho).
I think about making one jass function with tons of inputs as base and one trigger to launch all possible combinations of recipes.
And then just lauch it 300+ times in response to casting Craft-skill.
The Questions are:
1) Will it take less processing power than GUI one? If no, then there is no point in doing this
2) How will my jass-base react to 'null' in itemtype input in recipes with less than 6 items?
2.1) If trigger itself is okay, how will RemoveItem react to 'null'?
3) Should I "set null" to all used variables in the end or it wont make a leak w/o that?
4) Is there a jass analogy of C's 'short-circuiting' logical operators?
I have a custom map with a lot of recipes (200 for sure). Currently all recipes are written via GUI and scattered at ~30 triggers (sorted by type). Lately I thought about that and concluded that it takes tons of processing power (it works well and without delay tho).
I think about making one jass function with tons of inputs as base and one trigger to launch all possible combinations of recipes.
-
Events
-
Unit casts a spell
-
-
Conditions
-
Spell Equal to Crafting
-
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Triggering unit) has an item of type Item1
-
(Triggering unit) has an item of type Item2
-
-
Then - Actions
-
Remove item of type Item1 from (Triggering unit)
-
Remove item of type Item2 from (Triggering unit)
-
Give item of type ItemRes to (Triggering unit)
-
-
Else - Actions
-
-
JASS:
function Craft takes unit crafter itemtype result itemtype item1 itemtype item2 .......... itemtype item6 returns nothing
if (Unit has an item of type item1) and (Unit has an item of type item2) .... then
Remove item of type item1 from crafter
Remove item of type item2 from crafter
.....
Give item of type result to crafter
endif
endfunction
//Too lazy to write actuall functions in
JASS:
call Craft(unit,I00A,I001,I002,I003....)
call Craft(unit,I00B,I004,I005,I006....)
call Craft(unit,I00C,I007,I008,I009....)
The Questions are:
1) Will it take less processing power than GUI one? If no, then there is no point in doing this
2) How will my jass-base react to 'null' in itemtype input in recipes with less than 6 items?
2.1) If trigger itself is okay, how will RemoveItem react to 'null'?
3) Should I "set null" to all used variables in the end or it wont make a leak w/o that?
4) Is there a jass analogy of C's 'short-circuiting' logical operators?