Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (7th_zorro), 927 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Working on a simple patrol "AI" #332503
07/10/10 06:02
07/10/10 06:02
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
I am now working on the enemies in my side scroller game. Currently, I am trying to get them to patrol a certain area of the level, and when they spot the player, they go after him (and some, shoot him) until a certain point.

-Skip until questions if you want-

Now, I'm not going to start coding tons of things to make this AI work. This is my first 3D game using Gamestudio, and first 3D game using any code. My plan is to have each enemy between 2 "patrol points." Simple white boxes that are passable and invisible in-game. The enemy is always moving, but whenever it reaches a patrol point, it turns around (with a simple pan function).

The enemy will have 3 modes (or more depending on it's type). Patrol, Caution, and Return. Patrolling is just that. Caution, is when the player enters a certain range, and the enemy begins chasing him. When in this mode, the enemy does not notice the patrol points. It will go after the player until reaching a Caution Point (another box). If it reaches a Caution Point, it will go in to Return mode.

Return mode is when the enemy loses interest in the player and begins returning to its Origin Point, the place it spawned (in between the Patrol Points). It will not notice Patrol Points until it reaches the Origin Point, where it will go back to Patrol mode.

Now, I've been trying to get one part of this working (patrolling), through Flags and other ways which don't work well. With this, I realized I needed to use Skills, but I need some help with them.

-Questions-

First, I want to make the Patrol Points a certain Skill. Does it matter what Skill I choose for this? Is there some rule where Skill22 has to be the player? Should I go about setting the skill in WED or SED?

Next, how should I have the enemy's check for touching a Patrol Point? C_trace and c_scan are slow, is there any other way?

Once the enemy knows something is nearby it, how do I have it check if the thing it's touching has a certain Skill set to a certain number? I tried using c_trace and then
if(you.skill22 == 1)
but that brought up an error in the enemy's action.

I'm sure I'm missing something, but currently those are the questions I can think of that I need help with. Sorry for the long post, and thanks in advance (I apologize if I don't understand certain things that people explain, I'm not too great with C-lite yet :P).

Re: Working on a simple patrol "AI" [Re: Valdsator] #332505
07/10/10 06:58
07/10/10 06:58
Joined: Dec 2003
Posts: 988
Germany, Magdeburg
JoGa Offline
User
JoGa  Offline
User

Joined: Dec 2003
Posts: 988
Germany, Magdeburg
-
Quote:
Remarks:
Entity.skill1..entity.skill20 are used for entering default properties in WED. Entity.skill21..entity.skill50 are used by the template scripts, except for entity.skill41..Entity.skill44, which are used for shaders. Entity.skill51..entity.skill100 are free for the user.
-manual

- Yoou can search in the manual for a patrol-example, search for "path_scan", there is a example of patroling, if you work in WED with paths, you can use this way of patroling:
Code:
// move along a path loop
 // uses _FORCE, _MOVEMODE
 action patrol_path()
 {
 // attach entity to nearest path
  result = path_scan(me,my.x,my.pan,vector(360,180,1000));
  if (result == 0) { return; } // no path found
 
 // find first waypoint
  var node = 1; // start at first node
  path_nodepos(my,node,my._TARGET_X);
 
  while (my._MOVEMODE)
  {
 // find direction
    result = vec_to_angle(angle,vec_diff(temp,my._TARGET_X,my.x));
 
 // near target? Find next waypoint of the path
    if (result < 25) {
      node = path_nextnode(my,node,1);
      path_nodepos(my,node,my._TARGET_X);
    }
 
 // turn and walk towards target
    actor_turnto(angle.PAN);
    actor_moveahead(MY._FORCE);
    wait(1);
  }
}


- If the enemy checks, if something touching him, you can set entity.enable_entity = on
Code:
my.ENABLE_ENTITY = ON; // make entity sensitive for entity collision
  my.event = bounce_event;


and in the function bounce_event, the other entity is called by "you", so you can check
Code:
define our_hero, 1;
function bounce_event()
{
  if(you.skill22=our_hero)
  {
    //attack
  }
}


I dont test it, it's just theory, but I hope, it helps =)

Re: Working on a simple patrol "AI" [Re: JoGa] #332540
07/10/10 16:29
07/10/10 16:29
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Tell more about your sidescrolling game, player move on the fixed line (straight forward and backward), or he can move around like in Georges sidescroller game? I've made some simple AI that move around the level, for fixed on the straight line moving games, some of them even shoot player, you can find them in my project GRAVITY in script. I didn't put them in demo levels (only turrent), I hope that it will help you bro. PM me if you need some help.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Working on a simple patrol "AI" [Re: 3run] #333036
07/13/10 18:15
07/13/10 18:15
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Currently, using paths is a bit too complicated for me, and I'd like to attempt to make my own sort of AI, even if it's slow and inefficient.

This side scroller is a bit like Duke Nukem: Manhattan Project. You move left or right, shoot enemies, and jump around. I just need those questions in the original post answered, and I'll see what I can make.

Re: Working on a simple patrol "AI" [Re: Valdsator] #333162
07/14/10 14:08
07/14/10 14:08
Joined: Dec 2005
Posts: 116
T
tD_Datura_v Offline
Member
tD_Datura_v  Offline
Member
T

Joined: Dec 2005
Posts: 116
Quote:
First, I want to make the Patrol Points a certain Skill.

Quote:
Does it matter what Skill I choose for this?

To some extent, the skill selection is left up to the "client programmer".
Here a "client programmer" is defined as a lite-c programmer for a game made with 3D Gamestudio.
The "client programmer" might be you.
You might select any ENTITY skill number not already assigned or used for some other purpose.
Quote:
Is there some rule where Skill22 has to be the player?

(I do not know of any such rule.) Such rules might be set by the "client programmer".
Quote:
Should I go about setting the skill in WED or SED?

The first 20 or so skills might be set in WED. However, in the case of a simple patrol AI, a skill or skills might be more likely set via script using lite-c and SED.
Quote:
Next, how should I have the enemy's check for touching a Patrol Point?

The answer to that might depend upon the definition of "Patrol Point".
If a "Patrol Point" is an path, than path instructions might be used. If it is an ENTITY, than c_scan or other instructions might be used.
Quote:
Once the enemy knows something is nearby it, how do I have it check if the thing it's touching has a certain Skill set to a certain number?

If c_scan is used with the enemy to detect a something (ENTITY) nearby, than an event might be fired, and inside that event the "you" pointer might be set to that nearby thing (ENTITY). Skills of that "you" pointer might be evaluated.




Re: Working on a simple patrol "AI" [Re: tD_Datura_v] #333226
07/14/10 22:52
07/14/10 22:52
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Originally Posted By: tD_Datura_v

If c_scan is used with the enemy to detect a something (ENTITY) nearby, than an event might be fired, and inside that event the "you" pointer might be set to that nearby thing (ENTITY). Skills of that "you" pointer might be evaluated.


Thanks for the answers. What I'm wondering about this though, is what sort of code should I use to check if "you" has a certain skill set to a certain number? Like I said, I used if(you.skill22 == 1){ but that crashed the enemy action. Is there some other way I check for the skill, or am I just typing something incorrectly?

Re: Working on a simple patrol "AI" [Re: Valdsator] #333227
07/14/10 23:01
07/14/10 23:01
Joined: Jul 2009
Posts: 1,198
Berlin, Germany
L
Liamissimo Offline
Serious User
Liamissimo  Offline
Serious User
L

Joined: Jul 2009
Posts: 1,198
Berlin, Germany
Just if(you) and then if(you.skill22 == 1). Because if there is no you it crashes I think grin


"Ich weiss nicht genau, was Sie vorhaben, aber Sie können keine Triggerzonen durch Ihr Level kullern lassen."
-JCL, 2011
Re: Working on a simple patrol "AI" [Re: Liamissimo] #333247
07/15/10 03:49
07/15/10 03:49
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Ah, I see. I was actually thinking if that was the problem, just didn't know how to check if you was being used.

Thanks. laugh

Re: Working on a simple patrol "AI" [Re: Valdsator] #333556
07/17/10 04:53
07/17/10 04:53
Joined: Mar 2009
Posts: 186
V
Valdsator Offline OP
Member
Valdsator  Offline OP
Member
V

Joined: Mar 2009
Posts: 186
Alright, I've done some work and got the enemy to begin moving and turning every time it touches a patrol point. But I've run in to a problem. Bullets push the enemy back a little (which sometimes causes a bug where the enemy doesn't notice the patrol point), and a good way to fix that was to just make it's c_move ignore FLAG2, which the bullets were set to. But, the player is also set to FLAG2, making the enemy move through the player.

Question:
Is it possible to somehow have the c_move ignore a different flag? FLAG3 for instance? If so, how?

Thanks in advance.

Re: Working on a simple patrol "AI" [Re: Valdsator] #333570
07/17/10 09:09
07/17/10 09:09
Joined: Jul 2010
Posts: 2
VA
G
ghdfans2010 Offline
Guest
ghdfans2010  Offline
Guest
G

Joined: Jul 2010
Posts: 2
VA
In my opinion,I'd like to attempt to make my own sort of AI, even if it's slow and inefficient.How do you think?


Page 1 of 2 1 2

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