The Daily Click ::. Forums ::. Klik Coding Help ::. Seemingly impossible...for such a simple event!?
 

Post Reply  Post Oekaki 
 

Posted By Message

Tim*



Registered
  26/01/2005
Points
  77
9th January, 2006 at 04:14:19 -

Very annoyed...
Giving guys range which they attack you in... somehow NOT WORKING any way i try it ._.;;;;

E.g. (a little ascci art picture for "visual" learners)

-----------
----xx-----
---xxxx----
--xxExxx---
---xxxx----
----xx-----
-----------

The E is the enemy. The "circle" around him is ment to be his range so if you step into it you get shot at. I did this with active objs. (big circles) but this is stupid and it acts like a patriot missle in C&C: Generals- all enemies shoot at you regardless of where they are. I also tried it with X and Y positions to determine where you are compared to the enemy. But for some reason only one enemy had a range square and all the other ones just sat there like dumb shitheads. Fuckers.

Any help please? I'm getting quite literally angry here.


 
I have the ENTIRE C&C: Tiberian Dawn soundtrack. Extracted from the original game, in all it's succulent beauty. Oh baby, it's true. PM me for details on how to get it if you want.

Teapot

Does he even go here

Registered
  02/10/2003
Points
  2631

VIP Member
9th January, 2006 at 10:47:38 -

Hmmm, this is a pretty shit idea that works sometimes:

Have the enemies constantly shooting out little sensors in 32 directions that get destroyed by walls and stuff. You can limit their range by detroying them based on alterable values and you could also use random numbers in order to associate them with one particular enemy.

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
9th January, 2006 at 18:23:03 -

Back in the day, this article was a revelation to me:
http://www2.create-games.com/article.asp?id=1082

Alternatively, have you considered, um, placing your active object detector relative to the player rather than the enemies?

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
9th January, 2006 at 19:04:11 -

What my new game uses is an invisible active picture square that is set to always follow the main character around like so:

x--------
| |
| O |
| |
---------

Where the "o" is the guy, and it's set to like -50,-50 from the guy's position. When the enemy is "struck" by this invisible box, it activates its movement / flags / etc and you're all set.

You could realistically use similar boxes around each enemy, only make them different sizes depending on what their vision or line of sight rating would be. Then, when the player collides with one, it can shoot at him.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
9th January, 2006 at 19:04:46 -

Well, that box didn't come out quite like I hoped, LOL!

You get the idea, anyways.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
9th January, 2006 at 21:50:47 -

Or you can do it the ghetto way, it really only works if you don't have multiples of the same enemy overlapping.

Start of level - Make enemy shoot 1 detector (The big one)
Detector is overlapping Enemy - (Set pos. at X,Y from enemy)

----
The structure all your events like this

Player is overlapping Detector
Detector is overlapping enemy - (What ever you want)

You might need to throw a pick one of event in there, I don't have my code with me ATM, so I'm doing this from memory.

 
Craps, I'm an old man!

Rik N



Registered
  26/10/2003
Points
  32
10th January, 2006 at 11:54:02 -

Okay now I've been able to test it, this works:

Always

Set enemy alterable value A to:

Sqr( ( ( X( "enemy" ) - X( "hero" ) ) * ( X( "enemy" ) - X( "hero" ) ) ) + ( ( X( "enemy" ) - X( "hero" ) ) * ( X( "enemy" ) - X( "hero" ) ) ) )

[this is distance in pixels between enemy and hero]

If Alterable Value A of enemy < whatever then:

shoot an object [or something]


Image Edited by the Author.

 
n/a

Rik N



Registered
  26/10/2003
Points
  32
10th January, 2006 at 21:30:02 -

Oh ffs.. replace above formula with this:

Sqr( ( ( X( "enemy" ) - X( "hero" ) ) * ( X( "enemy" ) - X( "hero" ) ) ) + ( ( Y( "enemy" ) - Y( "hero" ) ) * ( Y( "enemy" ) - Y( "hero" ) ) ) )

NOW it works.

 
n/a

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
11th January, 2006 at 14:20:59 -

I'm working on a small example to do this.

My example sets a rule that for an enemy to 'see' you, it must:
a. Be visible on-screen, and...
b. Have a clear line of sight between it and you.

On every check of the events, it resets the ID of all the enemy objects to 0. Then it spreads a value only through the ones that are currently within -32px of the window's edge (that has the effect of making sure that the enemies are on-screen).

It then loops through each of these visible enemies and uses MoveSafely2 object to shoot a tracer from the player to each of the enemies. If the tracer passes through a wall, a flag is set ON. When the tracer finally hits its target, that flag is checked. If the flag is OFF, then there were no obstacles between the player and the enemy. That enemy is then set to 'Alert' mode.

This way it only loops through enemies that are in range, and only selects those ones that have a clear line of sight.

The engine could be adjusted very easily to only select enemies that are within X pixels of the player, instead of the on-screen ones.

It still has some tweaking to be done, but I may upload it later.

 
191 / 9999 * 7 + 191 * 7
   

Post Reply



 



Advertisement

Worth A Click