| 11-05-2007, 02:16 AM | #1 |
What is a good way to store data on units besides game cache? I want to keep track of the number of times each unit is affected by a certain spell. |
| 11-05-2007, 02:34 AM | #2 |
SetUnitUserData command is one option, it saves integers. And if you need to save more data, use structs. This is an example: JASS:struct MyDAta real data1 boolean data2 // and so on... endstruct function StoreDataOnUnit takes unit u, real r, boolean b returns nothing // Links a real and a boolean to a unit local MyDAta MD = MyDAta.create() set MD.data1 = r set MD.data2 = b call SetUnitUserData(u, integer(MD)) endfunction function GetUnitMyDAta takes unit u returns MyDAta // Retrieves the Data linked to the specified unit return MyDAta( GetUnitUserData(u) ) endfunction |
| 11-05-2007, 10:18 PM | #3 |
Or the simplest way, CSCache. |
| 11-22-2007, 03:18 AM | #4 |
what is a struct? and what is CSCache? |
| 11-22-2007, 06:36 AM | #5 |
Download NewGen. |
| 11-22-2007, 11:34 AM | #6 | |
Quote:
so yeah, it leads to struct or simply use an unit array stack + parallel array... |
| 11-22-2007, 02:12 PM | #7 |
If its just unit than Cohadar's "Perfect Unit Index" system is what you are looking for, its got allocation, deallocation, and maintenance done for you so all you have to do is call one function to get a struct unique to each unit. Check his signature a few replies up. |
