free Alien VS Predator radar code

Posted By: Superku

free Alien VS Predator radar code - 01/18/06 14:09

Hello.
A simple contribution :

short video
Download !

It works well for 'unlimited' (radar) objects using pan_create.
Have fun !

gOmO_3

EDIT :
Adjust the radar's range by changing the make_scan.z value :
function init_radar {
panel_radar.visible = on;
make_scan.z = 2000; // radar's range
panel_radar.pos_y = screen_size.y-198;
shadow_threshold = 30;
}

If you wanted constant radar elements, you should use this code :
Code:
 ///////////////////////////////////////////////////////////////////////////////////
// Radar code for unlimited objects
// by Felix Pohl aka gOmO_3 | 2006
// no credit required, though I would be grateful
// how to use : call "init_radar" once (for example in
// your main function) and assign "g3_handle_radar" to
// your actions. don't forget to include this wdl !
// Predator model : Kai Kieschnick (soulreaver2@gmx.de)
////////////////////////////////////////////////////////////////////////////

entity* ent_temp;

var make_scan;

bmap bmp_radar = <radar.tga>;
bmap bmp_radar_enemy = <enemy.tga>;

font fnt_dist = "Porky's",1,40;

panel panel_radar {
pos_x = 32;
pos_y = 570;
bmap = bmp_radar;
flags = refresh;
layer = 2;
}

panel* pan_temp;

function init_radar {
panel_radar.visible = on;
make_scan.z = 2000; // radar's range
panel_radar.pos_y = screen_size.y-198;
shadow_threshold = 30;
}

function g3_handle_radar {
while(me) {
if(vec_dist(my.x,camera.x) < make_scan.z) {
pan_temp = pan_create("bmap = bmp_radar_enemy; flags = visible,refresh,filter;",4);
my.skill92 = handle(pan_temp);
while(vec_dist(my.x,camera.x) < make_scan.z) {
pan_temp = ptr_for_handle(my.skill92);
vec_set(temp,camera.x);
vec_sub(temp,my.x);
vec_to_angle(my.skill97,temp);
my.skill98 = vec_dist(my.x,camera.x);
pan_temp.scale_x = 0.85-my.skill98/(make_scan.z*1.5);
pan_temp.scale_y = pan_temp.scale_x;
pan_temp.pos_x = panel_radar.pos_x+96-my.skill98/(make_scan.z*1.2/100)*sin(camera.pan-my.skill97)-16*pan_temp.scale_x;
pan_temp.pos_y = panel_radar.pos_y+96+my.skill98/(make_scan.z*1.2/100)*cos(camera.pan-my.skill97)-16*pan_temp.scale_x;
wait(1);
}
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
}
wait(1);
}
}



Posted By: Blattsalat

Re: free Alien VS Predator radar code - 01/18/06 19:51

loved that in the movies! one of the best radars i know

thanks and cheers
Posted By: Lion_Ts

Re: free Alien VS Predator radar code - 01/18/06 22:11

Thank you, gOmO_3!
good contrib, but have to look at code deeply (demo not functioning properly for me /A6_comm_3.14/, do you use 6.40 update ?)
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 01/19/06 00:10

A great contribution definately credits worthy thanks!
By the way, does anyone have some tips concerning a 'level radar' ? My plan is to make a radar on which also lines are visible from buildings (most probably they are models too, but I only want an outline), I remember I must have got some code which will draw a the boundary box lines, so it must be possible somehow.. I want to keep it simple though, anyone some suggestions for this?

Cheers
Posted By: Daedelus

Re: free Alien VS Predator radar code - 01/19/06 01:00

@Gomo_3: Awesome job!
@Phemox: I don't know how the lines would be drawn like you want 'em, but have you looked at Locoweed's Minimap/radar scripts?
Maybe the minimap would be a good start for this?
http://www.thekidgame.com/Locoweed3DGS/misc.htm
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 01/19/06 01:20

This radar code is great, I've changed somethings so it works as a regular radar, usable in my top-down game (i mean, camera indepent, player dependent, just changed 3 words in the code ) and it works great, I'm using A6.4 com btw...

@Daedelus: Thanks for the link to Locoweed's site, I think that his radar code will be pretty useful indeed for what I had in mind, thanks. I've also seen some other interesting topics there, like a simple AI example, I'm going to check those out asap...

Cheers
Posted By: Superku

Re: free Alien VS Predator radar code - 01/19/06 14:31

Thanks to everyone.
@Lion_Ts : I'm using the 6.40 Update but it should work with 6.314, too. The only new functions I have used are pan_create and panel.scale_x which have been available since 6.3. What is the error message ?

gOmO_3
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 01/19/06 17:30

Mmm, after some fiddling with this code, and changing it for my needs, there's something strange happening. At the edges of my radar, when the enemies are just getting in range (or just out of range) the dots get like twice the size, instead of being really small, or invisible. Anyone have an idea why this happens? Like I said in one of my previous posts, only things I've changed is camera.x into player.x, wherever the camera was involved. It must be the math when certain values get past some range, it's kinda confusing, because it's working fine, except this size blow-up when they are at the range area of the radar...
Code:

_____________
|O . . |
| * |
| * * * |
| . . |
|O_____O_____|



The zeros are my 'problem' , I want them either invisible, or super small sized, not twice the normal size ...

EDIT: Nevermind, I've got it solved ... I've just added ;
Code:
if(pan_temp.pos_x - rader.pos_x < 25){break;}
if(pan_temp.pos_y - rader.pos_y < 25){break;}
if(pan_temp.pos_x - rader.pos_x > 100){break;}
if(pan_temp.pos_y - rader.pos_y > 100){break;}




Cheers
Posted By: Lion_Ts

Re: free Alien VS Predator radar code - 01/19/06 22:43

gOmO_3,
hero in downloaded demo flies up, marks on radar not at the 'real' places (all at radar bottom). but nevermind. i think your code is good (for 6.4), i'll try to look closer at it (for my old 6.314 ), when have free time. thank you for contribution
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 01/20/06 00:20

How big is your radar panel? You might have to adjust certain values. The 96 in 'radar.pos_x+96' and radar.pos_y+96' has to be your panels size/2, to get the dots in the middle of your radar panel. Do you use the radar for a first person shooter? Because the way it's originally coded is for a radar dependent on the camera, not the player.

Cheers
Posted By: keinPlan86m

Re: free Alien VS Predator radar code - 01/20/06 10:17

"
pan_temp = pan_create("bmap = bmp_radar_enemy; flags = visible,refresh,filter;",4); my.skill92 = handle(pan_temp);
"


Thats it! I don't get this part ready! I thougt about something like exactly this, but i had no idea how to name the panels and let them be controlled by the units!

Greate contribution! Thanks!
Posted By: Superku

Re: free Alien VS Predator radar code - 01/20/06 13:57

Oh sorry, updated (relative to the player, not to the camera | bmap size) :

Code:
 function g3_handle_radar {
while(player == null) { wait(1); }
while(me) {
if(vec_dist(my.x,player.x) < make_scan.z) {
pan_temp = pan_create("bmap = bmp_radar_enemy; flags = visible,refresh,filter;",4);
my.skill92 = handle(pan_temp);
while(vec_dist(my.x,player.x) < make_scan.z) {
pan_temp = ptr_for_handle(my.skill92);
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(my.skill97,temp);
my.skill98 = bmap_width(bmp_radar)/192*vec_dist(my.x,player.x); // because the code was for 192pixel radar
pan_temp.scale_x = 0.85-vec_dist(my.x,player.x)/(make_scan.z*1.5);
pan_temp.scale_y = pan_temp.scale_x;
pan_temp.pos_x = panel_radar.pos_x+bmap_width(bmp_radar)/2-my.skill98/(make_scan.z*1.2/100)*sin(player.pan-my.skill97)-16*pan_temp.scale_x;
pan_temp.pos_y = panel_radar.pos_y+bmap_height(bmp_radar)/2+my.skill98/(make_scan.z*1.2/100)*cos(player.pan-my.skill97)-16*pan_temp.scale_x;
wait(1);
}
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
}
wait(1);
}
}



gOmO_3
Posted By: Nicolas_B

Re: free Alien VS Predator radar code - 01/27/06 22:28

hey gOmO_3,

veri nice work and thanks.

gg Nicolas_B
Posted By: Matt_Coles

Re: free Alien VS Predator radar code - 01/29/06 10:00

very nice contribution
Posted By: Superku

Re: free Alien VS Predator radar code - 01/29/06 15:36

Thanks.

gOmO_3
Posted By: MadMark

Re: free Alien VS Predator radar code - 04/15/06 07:32

What does "and assign "g3_handle_radar" to your actions. " mean?
Am I supposed to add "my.action = g3_handle_radar();" to my player's list of attributes?

How do I assign this function to something, and would that something be a player or an enemey or other?

Sorry, I'm struggling with programming.

Mark
Posted By: Superku

Re: free Alien VS Predator radar code - 04/15/06 19:29

You have to call two functions:
init_radar(); // only once, for example in your main function
and "g3_handle_radar" in the enemy's action:

action evil_enemy {
//....
g3_handle_radar(); // this functions creates an individual dot on the radar and must be called for every entity that should be visible in the radar
while(1) { ....

gOmO_3
Posted By: MadMark

Re: free Alien VS Predator radar code - 04/16/06 02:12

So, if I had an auto enemy creation function, and an enemy move function, I should place it ABOVE the while function in the move function as you have shown?

Not in the actual while loop?

Cheers!
Mark
Posted By: Grafton

Re: free Alien VS Predator radar code - 08/29/06 17:12

Does anyone know where the 1.2/100 figure comes from in the calculation of the position of the temp panel?
Code:

pan_temp.pos_x = panel_radar.pos_x+bmap_width(bmp_radar)/2-my.skill98/(make_scan.z*1.2/100)*sin(player.pan-my.skill97)-16*pan_temp.scale_x;



I understand this scales the radars range, but where did this number come from? What is it relevent to?
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 10/13/06 01:14

I know this is a terrible old thread, however I'm using this contribution and ran into a problem. I run the g3_handle_radar(); funktion in my enemies funktion, everything is fine.

However, at one point the enemy dies and get's removed. Panel creation of the radar script stops, but it leaves a fixed radar blip at the spot (on the radar) where the enemy died. So I was thinking, this panel didn't get removed at all.

What's wrong?

Summary;
-code works fine, when enemy that started the code isn't removed by ent_remove(me);
-radar blip continues to be visible after enemies death, but doesn't get updated on his position (which is zero, he's death after all).
-How can I really stop this funktion when the enemy who started the radar code is removed?

Cheers
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 10/14/06 13:29

bump..

Does anyone know how to kill the radar after an enemy died? It doesn't ever reach the part when the my entity is gone for some strange reason. It doesn't recognize any 'you' entity, eventhough my enemy's action started the radar code ... should be a valid pointer, right?

Anyways, the radar bitmap freezes when the enemy is removed, anyone?

Cheers
Posted By: vlau

Re: free Alien VS Predator radar code - 10/16/06 07:23

Just a guess : Probably the problem is in your
enemy's script, if it is really removed, it should
no longer call the g3_handle_radar().

EDIT
----
Maybe the enemy was removed, then it never
reach to these lines of code :

pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);



Posted By: Superku

Re: free Alien VS Predator radar code - 10/16/06 15:58

Oh...

function g3_handle_radar {
while(!player) { wait(1); }
while(me) {

if(vec_dist(my.x,player.x) < make_scan.z) {
pan_temp = pan_create("bmap = bmp_radar_enemy; flags= visible,refresh,filter;",4);
my.skill92 = handle(pan_temp);
while(vec_dist(my.x,player.x) < make_scan.z) {
[...]
wait(1);
}
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
my.skill92 = 0;
}

wait(1);
}
if(my.skill92 != 0) {
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
}

}

Should work.
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 10/16/06 19:09

Aaargh, this is confusing. You are right, it should work, but it doesn't. I keep having a panel on the radar visible, and it'll simply stop moving, frozen in place.

It must be some sort of pointer problem. I'm only calling the g3_radar code once at the start of the enemy's funktion, off course outside of his while loop.

Edit: The distance to the player is still within the range, doesn't that cause the problem and make it still create a new panel for the radar?

Code:

function g3_handle_radar {
while(!playerrr){wait(1);}
while(me) {
if(vec_dist(my.x,playerrr.x) < make_scan.z) {
pan_temp = pan_create("bmap = bmp_radar_enemy; flags = visible,refresh,filter;",101);
my.skill92 = handle(pan_temp);
while(vec_dist(my.x,playerrr.x) < make_scan.z) {
pan_temp = ptr_for_handle(my.skill92);
vec_set(temp,playerrr.x);
vec_sub(temp,my.x);
vec_to_angle(my.skill97,temp);
my.skill98 = vec_dist(my.x,playerrr.x); //was camera
pan_temp.scale_x = 0.50-my.skill98/(make_scan.z*2); //1.5
pan_temp.scale_y = pan_temp.scale_x;
pan_temp.pos_x = rader.pos_x+80-my.skill98/(make_scan.z*1.2/100)*sin
//pos_x+96 -> nu 85 , 75
(camera.pan-my.skill97)-16*pan_temp.scale_x;
pan_temp.pos_y = rader.pos_y+70+my.skill98/(make_scan.z*1.2/100)*cos

(camera.pan-my.skill97)-16*pan_temp.scale_x;
//solving bug problem
//
//dots appear at the edges .. fixed ni
//
if(pan_temp.pos_x - rader.pos_x < 25){break;}
if(pan_temp.pos_y - rader.pos_y < 25){break;}
if(pan_temp.pos_x - rader.pos_x > 100){break;}
if(pan_temp.pos_y - rader.pos_y > 100){break;}
//if(me==null){beep; pan_temp.visible = off;break;}

wait(1);
}
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
}
my.skill92 = 0;
wait(1);
}
if(my.skill92==0){beep;return;}
wait(1);
}



This doesn't beep when my enemy is dead and removed strangely enough. It should beep, right?

Cheers
Posted By: Superku

Re: free Alien VS Predator radar code - 10/17/06 16:33

Hm no it should be this I think:
wait(1);
}
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
my.skill92 = 0; //panel removed
}

wait(1);
}
if(my.skill92 != 0){ beep;return; } //only beep when panel was not removed
}

Felix
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 10/17/06 16:53

Code:
function g3_handle_radar {
while(!playerrr){wait(1);}
while(me) {
if(vec_dist(my.x,playerrr.x) < make_scan.z) {
pan_temp = pan_create("bmap = bmp_radar_enemy; flags = visible,refresh,filter;",101);
my.skill92 = handle(pan_temp);
while(vec_dist(my.x,playerrr.x) < make_scan.z) {
pan_temp = ptr_for_handle(my.skill92);
vec_set(temp,playerrr.x);
vec_sub(temp,my.x);
vec_to_angle(my.skill97,temp);
my.skill98 = vec_dist(my.x,playerrr.x); //was camera
pan_temp.scale_x = 0.50-my.skill98/(make_scan.z*2); //1.5
pan_temp.scale_y = pan_temp.scale_x;
pan_temp.pos_x = rader.pos_x+80-my.skill98/(make_scan.z*1.2/100)*sin
//pos_x+96 -> nu 85 , 75
(camera.pan-my.skill97)-16*pan_temp.scale_x;
pan_temp.pos_y = rader.pos_y+70+my.skill98/(make_scan.z*1.2/100)*cos

(camera.pan-my.skill97)-16*pan_temp.scale_x;
//solving bug problem
//
//dots appear at the edges .. fixed ni
//
if(pan_temp.pos_x - rader.pos_x < 25){break;}
if(pan_temp.pos_y - rader.pos_y < 25){break;}
if(pan_temp.pos_x - rader.pos_x > 100){break;}
if(pan_temp.pos_y - rader.pos_y > 100){break;}
//if(me==null){beep; pan_temp.visible = off;break;}

wait(1);
}
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
my.skill92 = 0;
}
wait(1);
}
if(my.skill92!=0){beep;return;}
//wait(1);
}



This is my code now, still doesn't work, but also doesn't beep

Perhaps this is an engine bug off some sort? Code-wise, this should work, however the radar dot of the enemy keeps freezing in place after I shot him, but there's no beep, eventhough the panel is still 'visible'.

Cheers
Posted By: Superku

Re: free Alien VS Predator radar code - 10/17/06 17:17

Here is a workaround (ignore my version of the radar code):

function g3_handle_radar {
my.skill99 = 1;
while(player == null) { wait(1); }
while(me && my.skill99 ) {
if(vec_dist(my.x,player.x) < 3100) {
if(my.hv_team == 1) { pan_temp = pan_create("bmap = bmp_radar_friend; flags = visible,refresh,filter;",4); }
else { pan_temp = pan_create("bmap = bmp_radar_enemy; flags = visible,refresh,filter;",4); }
my.skill92 = handle(pan_temp);
while(vec_dist(my.x,player.x) < 3100 && my.skill99 ) {
pan_temp = ptr_for_handle(my.skill92);
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(my.skill97,temp);
my.skill98 = bmap_width(bmp_radar)/192*vec_dist(my.x,player.x); // because the code was for 192pixel radar
pan_temp.scale_x = 0.85-vec_dist(my.x,player.x)/(4500);
pan_temp.scale_y = pan_temp.scale_x;
pan_temp.pos_x = panel_radar.pos_x+bmap_width(bmp_radar)/2-my.skill98/(36)*sin(player.pan-my.skill97)-16*pan_temp.scale_x;
pan_temp.pos_y = panel_radar.pos_y+bmap_height(bmp_radar)/2+my.skill98/(36)*cos(player.pan-my.skill97)-16*pan_temp.scale_x;
wait(1);
}
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
my.skill92 = 0;
}
wait(1);
}
if(my.skill92 != 0) {
pan_temp = ptr_for_handle(my.skill92);
pan_remove(pan_temp);
}
}

and when your enemy dies:

my.skill99 = 0;
wait(1);
ent_remove(me);

Felix
Posted By: PHeMoX

Re: free Alien VS Predator radar code - 10/17/06 18:43

The workaround works great! Thanks man, I owe you one (or two, or three hehehe). Thanks for looking into this for me,

Still, I don't quite understand why your first solution didn't work. A well, a 5 star rating well deserved.

Cheers
Posted By: Nems

Re: free Alien VS Predator radar code - 05/16/07 22:39

Recently found this thread and this is just what I needed for my tank type game.
Problem is I could not apply the work a round to remove the rader pan indicators.

Is it possible to get more examples or an updated version to the link files please?

Cheers
Posted By: Superku

Re: free Alien VS Predator radar code - 05/18/07 10:00

What do you need, a fixed radar (circle or rectangle?) that does not rotate with the camera/player?
Posted By: Nems

Re: free Alien VS Predator radar code - 05/18/07 18:27

To remove the enemy 'position panel indicators' when an enemy is removed and to control the size if the pulsing indicators.

I see you provided a solution for removal but how would I deploy it?

The panels as they are now are good and I assume I could edit the colors in a graphics prog so thanks for this contribution, its just what I needed.

Cheers
© 2024 lite-C Forums