Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
A.I questions; I suck at A.I in 3D :D
Topic Started: Jul 4 2006, 07:49 PM (318 Views)
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
I have done some A.I in the past, nothing fancy, pretty simple stuff but it has just been for 2D games. Now I have writen a new simple A.I script which I am trying to get to work properly in my game for my enemies and it goes something like this:
Code:
 
{
if( distance_to_object( character ) < distance )
{
 roty=direction;
 direction = point_direction( x, y, character.x, character.y );

 frame = .5;
 if !( distance_to_object( character ) < attackdistance - 1 )
 {
 
 
 } else if( distance_to_object( character ) > attackdistance - 1 ) speed = attackspeed;
 else
 {
  spd = 0;
  if( canAttack = true && spd = 0 )
  {
 
   {
       frame = .4;
   }
 
  alarm[0] = attackrate;
   canAttack = false;
      }
 }
}
 else
{
 random = random( 50 );
 if( random < 3 )
 {
  roty=direction;
  direction+=random(360);
  spd = movespeed;
  frame= .5;
  if!( distance_to_object( character ) < attackdistance - 1 )
  {
   
   
  }
 }
  else if( random > 49 )
 {
  spd = 0;
  frame = 0;
 }
} if( hp <= 0 ) instance_destroy();
}


It's not complete yet but this part will make the enemy move in random directions and is suppose to make the enemy move towards the player when the player is close by. The problem with this script is that the enemy model isn't rotating at all and will only move if the player is beside it. I want him to be able to move in all 360 degree directions and rotate to the direction his moving and move towards the player when the player is nearby. Any suggestions?
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
sherif
Jul 4 2006, 07:11 PM
delete this <_<

Ok :P
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
Anyone have any suggestions?
Offline Profile Quote Post Goto Top
 
Dazed and Cold
Member Avatar
Helper
[ *  *  *  * ]
for my "monsters" i have an alarm[0]

this is what is under it
Code:
 
speed = round(random(1.1));
direction = round(random(4))*90;


and this is what i put simply for the TEMPORARY a.i.
Code:
 
if dead = false{
if (distance_to_object(character)>1.5) {alarm[0] = round(random(70));attack = false;}


Yeah , i dont know... that is something you could do... it works for me? But then again
my game is going to be MMO so........ no need for A.I. it will be server side... client has to provide the Models//graphics and such :)

hope it helped
Offline Profile Quote Post Goto Top
 
Evolver
Member Avatar
Advanced Member
[ *  *  * ]
AI is most difficult to program at all.
I'm not sure where is error but this
"random = random( 50 );" seems to be variable "random" same name as
command random. How can it be?
And maybe you have wrong ID somewhere (common error), check it.
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
Sorry, this topic isn't of importance anymore. Help is no longer required.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply