2 registered members (AndrewAMD, Ayumi),
838
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Q : Artificial intelligence ?
#339568
08/27/10 19:55
08/27/10 19:55
|
Joined: Aug 2010
Posts: 131 Iran
Mafia_IR
OP
Member
|
OP
Member
Joined: Aug 2010
Posts: 131
Iran
|
Hi , I want to create game like Assassin's Cread ! (The sword fight ) and i have a question of artificial intelligence . I want to know important keywords for create a small artificial intelligence. help me please . Thanks.
|
|
|
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
Expert
|
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
|
|
|
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
OP
Member
|
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 ? attack him = 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 .
|
|
|
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
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
okey, here a example:
#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
|
|
|
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
OP
Member
|
OP
Member
Joined: Aug 2010
Posts: 131
Iran
|
Thank you for this example . 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 .
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: MasterQ32]
#339666
08/28/10 15:38
08/28/10 15:38
|
Joined: Aug 2010
Posts: 131 Iran
Mafia_IR
OP
Member
|
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
OP
Member
|
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.
|
|
|
|