Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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), 838 guests, and 2 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
Q : Artificial intelligence ? #339568
08/27/10 19:55
08/27/10 19:55
Joined: Aug 2010
Posts: 131
Iran
Mafia_IR Offline OP
Member
Mafia_IR  Offline OP
Member

Joined: Aug 2010
Posts: 131
Iran
Hi ,
I want to create game like Assassin's Cread shocked ! (The sword fight grin ) and i have a question of artificial intelligence .

I want to know important keywords for create a small artificial intelligence.

help me please . tired
Thanks. smile

Re: Q : Artificial intelligence ? [Re: Mafia_IR] #339575
08/27/10 20:35
08/27/10 20:35
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
multi-state-machine

each AI has a variable or skill to recognize what to to

IDLE wait, walk around, what ever
ATTACK run to player, attack him, shoot at him, ...
RUNAWAY run away from player...
DIE no explanation

try something like this, it will work good and you will have very "goodlooking" results


Visit my site: www.masterq32.de
Re: Q : Artificial intelligence ? [Re: MasterQ32] #339578
08/27/10 21:02
08/27/10 21:02
Joined: Aug 2010
Posts: 131
Iran
Mafia_IR Offline OP
Member
Mafia_IR  Offline OP
Member

Joined: Aug 2010
Posts: 131
Iran
IDLE wait = without script .

walk around = follow path (I don't know script for this work.)
Can you help me for this work ? confused

attack him = confused
I have a problem for this work, because befor (attack him) enemy should be check the player position , Right ?
is it near or far? Up or down? and ...
How can i do that ? (scan Position)


I will continue

thanks . smile

Re: Q : Artificial intelligence ? [Re: Mafia_IR] #339583
08/27/10 21:29
08/27/10 21:29
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
okey, here a example:

Code:
#define status skill1
#define STATUS_IDLE 0
#define STATUS_WALK 1
#define STATUS_ATTACK 2
action enemy()
{
     my.status = STATUS_IDLE;
     while(me)
     {
          switch(my.status)
          {
               case STATUS_IDLE:          //wait until i see player
                    if(c_trace(me.x,player.x,IGNORE_PASSABLE))
                         my.status = STATUS_WALK;
                    break;
               case STATUS_WALK:          //walk to player
                    if(vec_dist(my.x,player.x) < 128)     we are close enough to attack him
                         my.status = STATUS_ATTACK;
                    VECTOR temp;
                    vec_set(temp,player.x);
                    vec_sub(temp,my.x);
                    vec_to_angle(temp,temp);
                    my.pan = temp.x;          //Turn to player
                    c_move(me,vector(5 * time_step,0,0),nullvector,GLIDE | IGNORE_PASSABLE);          //walk to player
                    break;
               case STATUS_ATTACK:          //Ok, now attack player
                    ent_animate(me,"attack,anim_status,ANM_CYCLE);
                    player.health -= 5;          //5 DMG per hit
                    if(vec_dist(me.x,player.x) > 192)     //Enemy lost player
                         my.status = STATUS_IDLE;
                    break;
          }
          wait(1);
     }
}



code not testet, but should work


Visit my site: www.masterq32.de
Re: Q : Artificial intelligence ? [Re: MasterQ32] #339618
08/28/10 08:31
08/28/10 08:31
Joined: Aug 2010
Posts: 131
Iran
Mafia_IR Offline OP
Member
Mafia_IR  Offline OP
Member

Joined: Aug 2010
Posts: 131
Iran
Thank you for this example laugh . I added some parameter to this example .
question : How can i delete enemy in this line (???)
I was wrote command for runaway from player , i think it is wrong . frown
Quote:



action enemy()
{
var anim_status ;
anim_status = 3*time_step;
if (anim_status > 100) anim_status -= 100;

my.Ehealth= 50;
my.status = STATUS_IDLE;
while(me)
{
switch(my.status)
{
case STATUS_IDLE: //wait until i see player
if(c_trace(me.x,player.x,IGNORE_PASSABLE))
my.status = STATUS_WALK;
break;
case STATUS_WALK: //walk to player
if(vec_dist(my.x,player.x) < 128) // we are close enough to attack him
my.status = STATUS_ATTACK;
VECTOR temp;
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_to_angle(temp,temp);
my.pan = temp.x; //Turn to player
c_move(me,vector(5 * time_step,0,0),nullvector,GLIDE | IGNORE_PASSABLE); //walk to player
break;
case STATUS_ATTACK: //Ok, now attack player
ent_animate(me,"attack",anim_status,ANM_CYCLE);
player.health -= 5; //5 DMG per hit
if(vec_dist(me.x,player.x) > 192) //Enemy lost player
my.status = STATUS_IDLE;
int a = random(3);
if(my.Ehealth < 10 && vec_dist(me.x,player.x) < 50 && player.health > 50 && a = 2)
my.status = STATUS_RUNAWAY ;
if(Ehealth < 1);
my.status = STATUS_DIE;
break;
case STATUS_RUNAWAY :
ent_animate(me,"run",anim_status,ANM_CYCLE);
my.pan = -(temp);
c_move(me,vector(5 * time_step,0,0),nullvector,GLIDE | IGNORE_PASSABLE);
if(me.x > player.x+150 && player.pan != enemy.pan)
???
break;
case STATUS_DIE :
ent_animate(me,"die",anim_status,ANM_CYCLE);
media_play("die_m.mp3",NULL,70);
???
break;

}
wait(1);
}
}





Re: Q : Artificial intelligence ? [Re: Mafia_IR] #339621
08/28/10 09:53
08/28/10 09:53
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
some tips:
i have only a very weak walking script, no gravity or something like this
also you can add a simple line at the top of your loop:
if(my.Ehealth < 0) my.status = STATUS_DIE; //Make sure that the enemy is in STATUS_DIE when he is dead


Visit my site: www.masterq32.de
Re: Q : Artificial intelligence ? [Re: MasterQ32] #339666
08/28/10 15:38
08/28/10 15:38
Joined: Aug 2010
Posts: 131
Iran
Mafia_IR Offline OP
Member
Mafia_IR  Offline OP
Member

Joined: Aug 2010
Posts: 131
Iran
Ok now tell me :

How can i delete enemy, when he is dead ?


Thanks

Last edited by Mafia_IR; 08/29/10 07:25.
Re: Q : Artificial intelligence ? [Re: Mafia_IR] #339678
08/28/10 16:40
08/28/10 16:40
Joined: Aug 2010
Posts: 131
Iran
Mafia_IR Offline OP
Member
Mafia_IR  Offline OP
Member

Joined: Aug 2010
Posts: 131
Iran
I found it

1- How can i delete enemy, when he is dead ?
ptr_remove
Removes an engine object.
object - pointer of the engine object to be removed; ENTITY*, STRING*, BMAP*, VIEW*, PANEL*, TEXT*, FONT*, SOUND*, or MATERIAL* pointers are supported by this function.

Last edited by Mafia_IR; 08/29/10 07:24.
Re: Q : Artificial intelligence ? [Re: Mafia_IR] #339796
08/29/10 11:04
08/29/10 11:04
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
you can also use ent_remove to remove a entity


Visit my site: www.masterq32.de
Re: Q : Artificial intelligence ? [Re: MasterQ32] #339980
08/30/10 14:16
08/30/10 14:16
Joined: Aug 2010
Posts: 131
Iran
Mafia_IR Offline OP
Member
Mafia_IR  Offline OP
Member

Joined: Aug 2010
Posts: 131
Iran
Thanks .

In my game, people should walk around my 3d city .

Now i have a new question :

I need the script for follow path ...
can you help me ?


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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