hi.. im making a new small GroupAI projekt, where im trying to implement some unit behaviour... My problem is that i cant find the shooting direction of the unit..
ive tryed to use the unitdef's weapon list... but this maindir is never changed and always point towards (1,0,0)... isent this function used ?
i then found that CUnit have a front and right vector, but i have problems getting the unit from the id... i tryed inclunding and using the unithandler:
CUnit* unit = uh->units[unitid];
but this cause the linker error:
error LNK2001: unresolved external symbol "class CUnitHandler * uh"
is there a easier way to do this ? or am i just not using the functions correctly??
Getting unit / weapon direction
Moderators: hoijui, Moderators
The thing with CUnits is bad because you'd need to compile the AI and spring in the same binary for it to work. the code says extern CUnitHandler* uh; which means its defined somewherelse, which means you'd need to include th cpp AND write uh = new CUnitHandler somewhere, which means you'd have 2 copies one in spring and one in your AI so it would not give the data you want at all, and if it did it wouldnt be correct.
What your wanting would require you wrote a patch for the AI interface to add a callback with which to get this information then send it to the devs on the mailing list to be reviewed and applied, then you'd get your callback in the next spring release.
What your wanting would require you wrote a patch for the AI interface to add a callback with which to get this information then send it to the devs on the mailing list to be reviewed and applied, then you'd get your callback in the next spring release.
There's no information on what direction a units facing, unless its a building in which its just N/S/E/W.
Finding what direction a unit's fcing would be useful for extrapolating the direction its moving in, and where a weapons or turret or gunbarrel is facing is probably out of the engine scope too as its handled by the units bos/cob script, the engien says aim at this and the script moves it over time and fires.
However there is a chance you could hack around and get the direction the unit is headed in and assume that is the direction the unit is facing. You would poll the engine for its position then keep repeating at set intervals, and you would find the direction by comparing the 2 positions last recorded.
Finding what direction a unit's fcing would be useful for extrapolating the direction its moving in, and where a weapons or turret or gunbarrel is facing is probably out of the engine scope too as its handled by the units bos/cob script, the engien says aim at this and the script moves it over time and fires.
However there is a chance you could hack around and get the direction the unit is headed in and assume that is the direction the unit is facing. You would poll the engine for its position then keep repeating at set intervals, and you would find the direction by comparing the 2 positions last recorded.
Waaaaait. The engine does specify where the weapon's vector is pointing, however it doesn't work like you think it does. If the weapon's value for Turret=1, then the weapon attempts to aim from whatever point is specified via the COB once the COB instructions regarding aiming have all been fulfilled. IOW, in Spring... the Maindir is used to evaluate whether aiming can take place... if the answer is "yes", then the COB conditions have to be met... THEN the weapon aims and fires... which is completely unlike OTA, where the COB actually controlled the vector.
This means that if you don't specify aiming behaviors, but leave Tolerance <65K, then the point where the shots are coming from actually turns to the "correct" angle... whether or not you want it to.
This is extremely irritating... I am working on getting rid of Spring's aiming behaviors within NanoBlobs, because I don't like the way the code works at all.
This means that if you don't specify aiming behaviors, but leave Tolerance <65K, then the point where the shots are coming from actually turns to the "correct" angle... whether or not you want it to.
This is extremely irritating... I am working on getting rid of Spring's aiming behaviors within NanoBlobs, because I don't like the way the code works at all.
ive looked more into it and found a way to do it :)
i just add a small function to the spring code.. to get a specific unit to my AI... and then use its weapon wanted direction to give me an idea of where its pointing.. this is probably not the precise direction.. but it seems to work :)
thanks for the help and pointers :)
i just add a small function to the spring code.. to get a specific unit to my AI... and then use its weapon wanted direction to give me an idea of where its pointing.. this is probably not the precise direction.. but it seems to work :)
thanks for the help and pointers :)