Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ncw14 on Mon 31/12/2007 01:18:55

Title: Enemys Move
Post by: ncw14 on Mon 31/12/2007 01:18:55
I Currently only know how to make my character move but is there any way to make an npc/bad guy move around

ive read tons of the manual and beginers Faqs but cant find out how
Title: Re: Enemys Move
Post by: Baron on Mon 31/12/2007 05:19:22
cEnemy.Walk (int x, int y, optional BlockingStyle, optional WalkWhere);

where enemy is your character's name.  The third argument is either game blocking (eBlock) or goes on in the background while the game continues (eNoBlock).  The last argument is either eAnywhere, which ignores your rooms walkable areas, or leave it out if you want them to stay on your walkable areas.

If you mean how do you move your NPCs with something similar to artificial intelligence then you've probably still got a lot of reading ahead of you.  I'd set up some triggers under "Repeatedly Execute" like when the player character gets too close (e.g. cPlayer.x > cEnemy.x -20) or when a timer goes off (IsTimerExpired (1) ==1).

Baron

Title: Re: Enemys Move
Post by: ncw14 on Wed 23/01/2008 00:55:35
sorry about long time post but i dont use ints so it says parse error near int

EDIT

Odd the other charectar moves for me sometimes on the y axis when im in the room i use 2.7 so how could i fix this
Title: Re: Enemys Move
Post by: Khris on Wed 23/01/2008 03:04:16
There's something wrong with your code. That's really the only thing I can contribute here without taking wild, wild guesses.

Do you even WANT help? How are we supposed to do anything remotely similar to solving your problem if you don't show us even one line of the code you've used...??

Btw, did you fix the int problem (by reading the manual and looking at the example immediately below the Character.Walk command's explanation)?
Title: Re: Enemys Move
Post by: ncw14 on Wed 23/01/2008 04:01:05
havent been on Ags in while cant find where manual is

heres line i have

cBob.Walk (int x, int y, eBlock, eWalkableAreas);

in repeatedly execute

it says parse error in line 30 in expr near 'int'
Title: Re: Enemys Move
Post by: Baron on Wed 23/01/2008 04:26:59
Some quick research would lead you to the AGS wiki (http://americangirlscouts.org/agswiki/Contents_%28manual%29).  Isn't the manual packaged with AGS 2.7, accessible via the help menu in AGS itself?

I would recommend looking at the manual somewhere to closely inspect an example of character.Walk to see where you might be making your mistake.  In the online version you can find it under scripting -> character properties and functions.  In AGS itself there will be an alphabetical index.

Baron
Title: Re: Enemys Move
Post by: NiksterG on Wed 23/01/2008 20:36:57
If the code you have is literally

cBob.Walk (int x, int y, eBlock, eWalkableAreas);

then the int problem is pretty obvious. You can't put "int x" or "int y" right in the function call; you have to replace that with an actual value.

Like everyone else is *strongly* recommending, I think you should read the manual. Maybe take a look at the tutorial.
Title: Re: Enemys Move
Post by: ncw14 on Wed 23/01/2008 22:45:36
ya, i finished reading manual and i get it now, but i dont see how to make a character walk towards a moving character like in hero rpg, the enemys walk towards you and if you turn they still go towards you
i just dont get if theres a command like cBob.Walk (character*cEgo - 12, -12);
so they walk to my character but 12 off of him on x and y axis

fixed that sorry

but repeatly execute code only lets him stay in place then animate  as if hes walking, and he will turn to face me, but he doesnt walk towards me

heres the line in repeatedly execute i have
cBob.Walk (cEgo.x - 1, cEgo.y - 1);
Title: Re: Enemys Move
Post by: NiksterG on Thu 24/01/2008 02:28:57
That's because it's non-blocking by default, which means the character is continually flashing on screen. I recommend this code:

if (cEnemy.Walking == false) {
   cEnemy.Walk(Random(Room.Width), Random(Room.Height), eNoBlock, eWalkableAreas);
}


This code will make the enemy move randomly around the screen. If you want the enemy to actually follow the hero, look for the Character.Follow function in the manual.
Title: Re: Enemys Move
Post by: ncw14 on Thu 24/01/2008 03:44:26
ive tried follow but he just walks to where my character started in the room, not following my character
Title: Re: Enemys Move
Post by: Khris on Thu 24/01/2008 10:31:26
Did you try
cBob.FollowCharacter(cEgo, 0, 0);?

PLEASE, show us the code you've used.