The Daily Click ::. Forums ::. Klik Coding Help ::. Several turrets shooting at several enemies?
 

Post Reply  Post Oekaki 
 

Posted By Message

Retainer



Registered
  02/06/2005
Points
  218
30th November, 2005 at 10:45:35 -

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?


Image Edited by the Author.

 
Alien Invasion. Going forward!
http://www.create-games.com/project.asp?id=1092

Long John Kickbag



Registered
  26/08/2002
Points
  148
30th November, 2005 at 11:38:48 -

This example should do what you want: www.clicksplat.com/Files/Examples/Click/Closest%20object.cca

 
Resize! - www.clicksplat.com/comparison.html

Retainer



Registered
  02/06/2005
Points
  218
5th December, 2005 at 07:38:32 -

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..

 
Alien Invasion. Going forward!
http://www.create-games.com/project.asp?id=1092
   

Post Reply



 



Advertisement

Worth A Click