I want heroes to be able to buy spells in shops. The shops sells powerups which run simple triggers that add the spell. The players now need to get their money back if the spell they bought is already learnt by the hero (there's only 1 hero per player). I made this trigger which detects whether the item bought has already been bought by the player.
Item name: chain lightning
String: Skills[index]
TempBoolean is just a helper variable.
The problem is that there's a string created for every player and I heard strings take much place in the cache (or anywhere else). Also the search for a content in the string can include MANY comparisons.
I'm sure that there is a systematic solution for this problem - maybe in this forum. But I havent found it yet. Do you know anything else?
Item name: chain lightning
String: Skills[index]
TempBoolean is just a helper variable.
Code:
Chain Lightning
Events
Unit - Shop 0001 <gen> Sells an item
Conditions
(Item-type of (Sold Item)) Equal to Chain Lightning
Actions
For each (Integer A) from 1 to (Length of Skills[(Player number of (Owner of (Buying unit)))]), do (Actions)
Loop - Actions
For each (Integer B) from 1 to (Length of Skills[(Player number of (Owner of (Buying unit)))]), do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Conditions
(Name of (Sold Item)) Equal to (Substring(Skills[(Player number of (Owner of (Buying unit)))], (Integer A), (Integer B)))
'THEN'-Actions
Set TempBoolean = True
'ELSE'-Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
'IF'-Conditions
TempBoolean Equal to False
(Unit-type of (Buying unit)) Equal to Elemental Mage
'THEN'-Actions
Unit - Add Chain Lightning to (Buying unit)
Set Skills[(Player number of (Owner of (Buying unit)))] = (Skills[(Player number of (Owner of (Buying unit)))] + (Name of (Sold Item)))
'ELSE'-Actions
Player - Add 10 to (Owner of (Buying unit)) Current Gold
Display Text: 'Spell already bought or spell doesnt match with buying hero.'
Set TempBoolean = False
The problem is that there's a string created for every player and I heard strings take much place in the cache (or anywhere else). Also the search for a content in the string can include MANY comparisons.
I'm sure that there is a systematic solution for this problem - maybe in this forum. But I havent found it yet. Do you know anything else?