Making characters chase the player

Started by sameeralord, Mon 20/06/2005 13:38:10

Previous topic - Next topic

sameeralord

Hi Guys,
I have already made my first game and currently making the second. I want to know how I can make person chase you and if he catches you gameover. The style they had in 7 days a skeptics. If you can help me in this it would be greatly appreciated. Thanks.
Friend in need is a friend indeed!!

strazer

Making a character follow another:

Code: ags

  cWelder.FollowCharacter(player); // check manual for options, also check out game.following_room_timer variable


Check continously if characters are colliding (Menu "Script" -> "repeatedly_execute"):

Code: ags

  if (cWelder.IsColldingWithChar(player) == true) {
    Display("Game over!");
  }

sameeralord

#2
Thanks for the help but I still don't know how to do it. I'm new to this sripting business and could you please explain bit more. Thank you very much!!.By the way how do I do something like you got 10 minutes or you'll die. Style in abstructed 10 minutes. Please helpÃ,  Ã, ???(I would put the peron who helped me in the credits of my upcoming game. Just to help me more I'm going to supply these,

The script name of my player charcater is:  MANAKEN
The script name of the peron who should be following my character is: ARMYGUYA
My game over screen is: room 6

If you can add this to your code I can straight away copy paste and have no problems. If you need anymore data from me ask me.Thanks heaps!!
Friend in need is a friend indeed!!

strazer

#3
Quote from: sameeralord on Tue 21/06/2005 12:58:58Thanks for the help but I still don't know how to do it. I'm new to this sripting business and could you please explain bit more.

Where you have to put the code depends on when you want the character start chasing the player.
If you want it to start at the beginning of the game, put it into the game_start function (menu "Script" -> "game_start").
If you want it to happen when the player interacts with a certain object, for example:
- Load the room
- Go to the Room/Objects pane
- Select the object
- Click the "Interaction..." button
- Right-click "Interact with object"
- Choose "New action..."
- Select "Run script"
- Click the "Edit script..." button
- Paste the code

Quote from: sameeralord on Tue 21/06/2005 12:58:58By the way how do I do something like you got 10 minutes or you'll die. Style in abstructed 10 minutes.

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=17017

Edit:

Code: ags

  cArmyguya.FollowCharacter(player);


Code: ags

  if (cArmyguya.IsColldingWithChar(player) == true) {
    player.ChangeRoom(6);
  }

sameeralord

Thanks Strada. Your reply is clear and straight forward but when I paste the code an error message comes undefined token!!. Help please
Friend in need is a friend indeed!!

strazer

Which line does the error message point to?
Btw, this code only works with AGS v2.7 and above.

sameeralord

There we go I'm using the older version. That is why cause I tried many different ways!!. If you can could you please give me the older version  2.6 code or if it is not possible I'll download 2.7. The only reason I didn't download 2.7 is because I have got used 2.6 a lot. I'm getting excited knowing that the code would actually work!!. It would be really appreciated if you can tell me the code for 2.6 and I will surely write your name in big CAPITAL letters in the credits. Thanks!!
Friend in need is a friend indeed!!

Gilbert

Just direct conversion form Strazer's codes:


Code: ags

Ã,  FollowCharacter (GUYA, GetPlayerCharacter());


Code: ags

Ã,  if (AreCharactersColliding(GUYA, GetPlayerCharacter())) {
Ã,  Ã,  NewRoom(6);
Ã,  }


sameeralord

Thanks but still. Your code was perfect and it didn't have any errors but when I tested the game the person who was supposed to follow me was following me but when we intercact,collide with each other I don't go to the room I need!!. Please help!!. I'm sure I put the right room number and all that.
Friend in need is a friend indeed!!

strazer

Where have you put the "AreCharactersColliding" code?

sameeralord

Yeeehhhhhha it is working!!. I accidently didn't take much notice for your writing the code in repeatedly executing thing. Now everything is working perfectly thanks Straza for your great help. Really appreciate it!!Also thanks goes to gilbert for 2.6 code. I'll put both of your names in credits. Thanks!!
Friend in need is a friend indeed!!


SMF spam blocked by CleanTalk