With advanced direction object and fastloop, I've made a turret which shoot at the nearest enemy, and another program with several turrets which shoot at the player if he is near enough.
Now, I'm working on a more advanced and funny defend your crazy settlement-kinda game. I want to be able to construct several turrets, and have them shoot at a enemy within a certain distance.
How can I do this without dynamicly create more than one direction object? (which can't be made)
I'm trying to fastloop through all spreaded valued turrets with a loop index, as this seem to be the key to success. The problem with the only technique I came up with, is that the direction object need to be used twice.
*Always
______ Start loop ("detect") NObjects("turret") times
______ turret : Spread value 0 in alterable value A.
* On loop ("detect")
+ Alterable value A of turret = LoopIndex("detect")
+ Turret internal flag 0 is off
______ Direction object - Find distance and fixed of (Turret) to (0,0) Enemy.
* On loop ("detect")
+ Alterable value A of turret = LoopIndex("detect")
+ GetDistObj("Direction object", 0) < 100
+ Fixed value of turret = GetFixedObj("Direction object", 0)
______ turret = set internal flag 0 on
* On loop ("detect")
+ Alterable value A of turret = LoopIndex("detect")
+ Every 00:20
+ turret : internal flag 0 is on
______ SHOOT towards the enemy!
As you might see, this does not work, as MMF need to loop through one event in order to continue the next.
Has anyone any idea how to work around this? Maybe there is an example out there that I have not found?
I got it to work, And I've learned alot of new things! The problem now is, that MMFs built-in 32 directional accurancy is to cheap to satisfy. It's almost impossible to get both 360 degree accurancy AND targeting and locating of several enemies work at the same time. Alone their an easy nut to crack though.
Well, I'll leave this problem to the end of the game. These kind of annoying obstacles usually throw me off a game idea..