*big sad face*
The struct I made (thanks to an example made by a dude that I unfortunately can't remember) is absolutely fine, and works perfectly, but certain functions that I do using it keep stuffing up, and I tihnk I found out why. I'll try to give an example of the struct thingy.
That's what I can remember of it.
Now I got a trigger to set the hate values of a bunch of units in certain regions. Every unit in Region Red Tribe, hate every unit in Tribe Area matching not in Red Tribe kind of deal.
It looks vaguely like this.
The problem starts from about line 6 onwards. I'm trying just to get the struct of various units to use in the function, but instead it seems I am actually setting the initial struct to the units, instead of getting the struct from the unit, as it already has one from melee init.
Do you see what I mean?
Could someone puh-lease explain to me how to just get the structs without sticking them around? Otherwise I'm going to have a whole bunch of bored soldiers on my map with nothing but fuzzy feelings for each other, and that's no fun. We want WAR!
The struct I made (thanks to an example made by a dude that I unfortunately can't remember) is absolutely fine, and works perfectly, but certain functions that I do using it keep stuffing up, and I tihnk I found out why. I'll try to give an example of the struct thingy.
JASS:
scope test
struct Attribute
public real mass
public real strength
...
public integer array hate[8000]
endstruct
public function Add takes unit u returns nothing //This function is not really relevant to the problem. But it's here anyway. :D
local Attribute d = CreateAttribute()
set d = GetUnitUserData(u) //Sticks the struct to the unit's custom value.
endfunction
public function Get takes unit u returns nothing
local Attribute d = GetUnitUserData(u)
call DisplayTextToPlayer(Player(0), 0, 0, R2S(d.mass)) //I tihnk that's how it goes. You guys should know anyway. This function isn't important here.
endfunction
endscope
That's what I can remember of it.
Now I got a trigger to set the hate values of a bunch of units in certain regions. Every unit in Region Red Tribe, hate every unit in Tribe Area matching not in Red Tribe kind of deal.
It looks vaguely like this.
JASS:
function bleh takes nothing returns nothing //in response to GroupENumUnit thingy, or Pick Every unit/
local unit u = GetEnumUnit()
local Attribute d = GetUnitUserData(Unit1) //I'm just putting arbitrary unit values in here to save extended explanations.
set d.hate[GetUnitUserData(u)] = 100
set d = GetUnitUserData(Unit2)
set d.hate[GetUnitUserData(u)] = 100
...
endfunction
The problem starts from about line 6 onwards. I'm trying just to get the struct of various units to use in the function, but instead it seems I am actually setting the initial struct to the units, instead of getting the struct from the unit, as it already has one from melee init.
Do you see what I mean?
Could someone puh-lease explain to me how to just get the structs without sticking them around? Otherwise I'm going to have a whole bunch of bored soldiers on my map with nothing but fuzzy feelings for each other, and that's no fun. We want WAR!
Last edited: