Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 1,405 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Player facing which enemy #237287
11/19/08 14:00
11/19/08 14:00
Joined: Jul 2008
Posts: 56
I
iam_ufo973 Offline OP
Junior Member
iam_ufo973  Offline OP
Junior Member
I

Joined: Jul 2008
Posts: 56
HI friends i have a very complicated problem please solve it.
if enemies have surrounded the player how do they know that the player is facing & fighting to which one of them? so they take decision to fight or defend.

Re: Player facing which enemy [Re: iam_ufo973] #237288
11/19/08 14:04
11/19/08 14:04
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
if i get home, and dont forget about it, i have a small piece of code, that checks a cone in front of a model.
send me a PM, i'll keep reminded that way wink

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Player facing which enemy [Re: Helghast] #237771
11/22/08 07:38
11/22/08 07:38
Joined: Jul 2008
Posts: 56
I
iam_ufo973 Offline OP
Junior Member
iam_ufo973  Offline OP
Junior Member
I

Joined: Jul 2008
Posts: 56
In player's action i put this code.

if ((c_scan(my.x, my.pan, vector(45, 60, 60), ignore_me) > 0))
{
if(you.skill51!=yes)
{
you.skill51 = yes;
front=you; //front is an entity pointer
}
}

It successfully assign the front pointer to the scanned entity and turn it's skill51 on but it doesn't turn it back off when player is not facing him anymore frown any idea?

Re: Player facing which enemy [Re: iam_ufo973] #237795
11/22/08 11:46
11/22/08 11:46

M
mercuryus
Unregistered
mercuryus
Unregistered
M



make front a global variable and check in the enemies action if front==me then you know (for each enemy if he is ment).

Code:
action player(){
   ...
   c_scan(...)
   front=you;
   ...
}

action enemy(){
   ...
   // I was ment by the player
   if(front==me){
     ....  // defend
   }else{
     ....  // attack
   }
}

mercuryus

Re: Player facing which enemy [Re: ] #237800
11/22/08 13:14
11/22/08 13:14
Joined: Jul 2008
Posts: 56
I
iam_ufo973 Offline OP
Junior Member
iam_ufo973  Offline OP
Junior Member
I

Joined: Jul 2008
Posts: 56
doesn't work tired

Re: Player facing which enemy [Re: iam_ufo973] #237806
11/22/08 14:42
11/22/08 14:42
Joined: Jul 2008
Posts: 56
I
iam_ufo973 Offline OP
Junior Member
iam_ufo973  Offline OP
Junior Member
I

Joined: Jul 2008
Posts: 56
Someone please help me how to know that player is facing which enemy?

Re: Player facing which enemy [Re: iam_ufo973] #237812
11/22/08 15:33
11/22/08 15:33
Joined: Nov 2005
Posts: 66
Spokane, WA, USA
Vonman Offline
Junior Member
Vonman  Offline
Junior Member

Joined: Nov 2005
Posts: 66
Spokane, WA, USA
I suppose you use a C-Scan to detect the enemies, assign a pointer to the two closest enemies, face the player toward the first closest, then when that enemy is dead aim at the second, then use c-scan again and start over.

Re: Player facing which enemy [Re: iam_ufo973] #237888
11/23/08 08:48
11/23/08 08:48

M
mercuryus
Unregistered
mercuryus
Unregistered
M




Re: Player facing which enemy [Re: ] #238033
11/24/08 10:00
11/24/08 10:00
Joined: May 2006
Posts: 53
Puerto Rico
monchito Offline
Junior Member
monchito  Offline
Junior Member

Joined: May 2006
Posts: 53
Puerto Rico
Hi:
Try this code maybe can help you. Set the skill51 when player is looking at the target enemy, otherwise reset skill51 to 0;
It's a simple solution, a more elaborate one must be done.
Code:
[/code]
function act_player();
function act_enemy();

entity* front;

font standard_font = "c:/windows/fonts/arial", 1, 22;

PANEL PanData   // show data on screen
{
  layer = 5;
  digits = 0,450,"Data:%3.0f",standard_font,1,front.skill51;
  flags = TRANSLUCENT,VISIBLE;
}

function main()
{
   fps_max = 50;
   level_load (NULL);
   wait(5);
// load the (player entity, assign position, and default function) 
   ent_create ("player.mdl", vector(40,0,0), act_player);   
   ent_create ("enemy.mdl", vector(100,0,0), act_enemy);   
   ent_create ("enemy.mdl", vector(100,50,0), act_enemy); 
   ent_create ("enemy.mdl", vector(100,-50,0), act_enemy);   
}

function act_player()
{
  var speed = 5;
  var rotation_speed = 3;
  my.scale_x = .5; 
  my.scale_y = .5;
  my.scale_z = .5;
  my.passable = on;
  player = my;
	
  while(1)      
  {
     move_mode = IGNORE_PASSABLE + USE_BOX;  
      
     if(key_w == 1)
     { 
        // perform movement
        c_move (my,vector(speed * time_step,0,0), nullvector, move_mode);
     }
     
     if(key_s == 1)
     {
       c_move (my,vector(-speed * time_step,0,0), nullvector,move_mode);
     }
     // perform rotation
     if(key_a == 1) { my.pan += rotation_speed * time_step; };
     if(key_d == 1) { my.pan -= rotation_speed * time_step; };
     if(key_q == 1) { my.tilt += 1; }
     if(key_z == 1) { my.tilt -= 1; }
    
     // set/reset skill51
     if ((c_scan(my.x, my.pan, vector(45, 60, 60), ignore_me) > 0))     
     {
       you.skill51 = 1;
       front = you;
     }
     else
     {
      	if(front)
        { 
          front.skill51 = 0;
        }
     }  
     wait(1);
  }
}

function act_enemy()
{
  var percent;
  
  my.scale_x = .5; 
  my.scale_y = .5;
  my.scale_z = .5;
	
  while(1) // see me moonwalk if skill51 active (player looking at me)     
  {
     if(my.skill51 == 1) 
     {
       percent += 3 * time_step;
       ent_animate(my,"walk", percent, ANM_CYCLE);
       percent %= 100;
     }
     wait(1);
  }
}
[code]


Re: Player facing which enemy [Re: monchito] #238174
11/25/08 11:37
11/25/08 11:37
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
just for the record, and use for other people;

here's the snippet i used and PM'd to iam_ufo...

Code:
if(plane)
{
	vec_set(temp.x, plane.x); 
	vec_sub(temp.x, my.x);
	vec_to_angle(movedirection.pan, temp.x);
	my.pan+=ang(movedirection.pan-my.pan)/110;
	my.tilt+=ang(movedirection.tilt-my.tilt)/110;
			
	if(vec_dist(plane.x, my.x) < 5000 && abs(ang(movedirection.pan-my.pan)) < 30)
	{
		if(bullet_down <= 0){ ent_playsound(my, bullet_fire, 1000); enemy_bullet_shoot(); bullet_down = 10; }
		bullet_down -= 1;
	}
}


actual check if its in view is in this piece of code:
Code:
 abs(ang(movedirection.pan-my.pan)) < 30 


however, this is still done in A6, might have to be converted to A7... i dunno, lol :P

anyway, have fun with this one wink

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1