How to detect the ending of Game

Topics regarding Scripting with Reality Factory
Post Reply
planebus
Posts: 29
Joined: Thu Jan 14, 2010 7:23 am

How to detect the ending of Game

Post by planebus » Mon Mar 29, 2010 10:48 am

Hi guys.

In my game, I have 5 robots and a girl which need to be rescued by me.
Here is my two plans
first. if I do not kill all of the robots and touch the girl, she will tell my like "you need to kill all the robot" automatically.
second. if I do kill all of the robots and touch the girl, The game will display like "you win " and end the game.

How do I do that ?
thx

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: How to detect the ending of Game

Post by metal_head » Mon Mar 29, 2010 3:59 pm

By dying, each robot will be giving a +1 to a specified attribute:

Code: Select all

ModifyAttribute("NAME", 1, "Player");
The girl will look at this attribute and when you're near her, she would check:

Code: Select all

if(GetAttribute("NAME", "Player") = 5)
{
AND do the things you wanna do
}
else
{
Say that you have to kill them all
}

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: How to detect the ending of Game

Post by QuestOfDreams » Mon Mar 29, 2010 8:12 pm

To end the game you need to use a ChangeLevel entity and leave its szNewLevel entry blank. When the player has completed his mission, activate it.

planebus
Posts: 29
Joined: Thu Jan 14, 2010 7:23 am

Re: How to detect the ending of Game

Post by planebus » Wed Mar 31, 2010 7:57 am

I have try the code, but it seems don't work
I also try to debug to see the change of attribute, but the result is the same, namely 0.

Death[ ()
{
debug(GetAttribute("name", "Player"));//output 0
ModifyAttribute("name", 1, "Player");
debug(GetAttribute("name", "Player"));//also output 0

AnimateStop("die", 0.5, "");
SetEventState("Enemy1Dead", true);
}]

any kind of problem in it?

planebus
Posts: 29
Joined: Thu Jan 14, 2010 7:23 am

Re: How to detect the ending of Game

Post by planebus » Wed Mar 31, 2010 8:06 am

QuestOfDreams wrote:To end the game you need to use a ChangeLevel entity and leave its szNewLevel entry blank. When the player has completed his mission, activate it.
Can you show me the code how do I activate it.
thx

planebus
Posts: 29
Joined: Thu Jan 14, 2010 7:23 am

Re: How to detect the ending of Game

Post by planebus » Fri Apr 09, 2010 7:11 am

can anyone help me?

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: How to detect the ending of Game

Post by metal_head » Tue Apr 20, 2010 7:47 pm

Code: Select all

SetEventState("Enemy1Dead", true);
You're activating a trigger, called "Enemy1Dead". You should put a trigger with the same name in the level and than associate it with the ChangeLevel entity :)

Post Reply