need help with a script

Topics regarding Scripting with Reality Factory
User avatar
vrageprogrammer
Posts: 566
Joined: Wed Oct 31, 2007 2:59 pm
Location: On top of a tree
Contact:

need help with a script

Post by vrageprogrammer »

I need one last script...
well, here's what it needs to do-
firstly, you need to kill 7 pawns...
after killing 7 pawns, a message is displayed , and level changes...
here is some pseudo code, i need help converting it into script.
It was not Possible to determine the dimensions of the image....
User avatar
vrageprogrammer
Posts: 566
Joined: Wed Oct 31, 2007 2:59 pm
Location: On top of a tree
Contact:

Post by vrageprogrammer »

here's the psuedo code-
set var x=0
if monster death order playing , x=x+1,
if x<8, show message and change level.
also, how do i get this script in the game?, thru a pawn?
Thanks...
It was not Possible to determine the dimensions of the image....
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

make x a player attribute:

in player.ini add:

[killedpawns]
initial=0
low=0
high=7

This adds a player attribute - a value that can be accessed by every script, must be a number, and is saved when you save the game. The value is auto-presetted to 0 (inital value).

And then in the death order of the pawns you use this attribute:

...
ModifyAttribute("killedpawns",1,"Player"); //Adds 1 to the killedpawns-attribute
if(GetAttribute("killedpawns","Player")=7) //if you have killed seven of them
{
SetEventState("ChangeLevel",true); //Set level-change-trigger on
SetAttribute("killedpawns",0,"Player"); //Set back attribute
}
...

Now you just have to make sure that the TriggerChange field of the ChangeLevel entity is set to the Trigger you set on (In this case "ChangeLevel")
Once you have killed seven of them, the level will change according to the ChangeLevel entity.

More information is in the docs under ChangeLevel entity and in the pawn scripting section.


This should help you.

EDIT: Oh sorry, i just saw that you wanted to show a text too. Well then this gets a bit more complicated.

Assuming that you use the code above, you must use a Message entity. I will not explain this entity too deeply here, search the docs for its usage. The trigger name of the message entity should be ChangeLevel, but the TriggerChange field of the ChangeLevel entity OT. Otherwise the message may not be displayed because the level ends before the message can be displayed....
For this, we need a system of LogicGates:

The first one is a LogicGate of the type 7 (HOLD). Trigger1Name should be our ChangeLevel and Delay is the number of seconds until the level change. Name it CLDelay
The second is a LogicGate of the type 4 (XOR, if the triggers are in different states return true). Trigger1Name is ChangeLevel and Trigger2Name CLDelay. The name is ChangeLevel2.

When the player has killed all the seven pawns, this will happen:
1. The Trigger ChangeLevel goes on. It stays on until the end of the level.
2. A Message is displayed on the screen
3. The first LogicGate CLDelay goes on and stays on for a specified number of seconds
4. The second LogicGate waits for the first to go off
5. When the first LogicGate goes off the level changes

You will then use the ChangeLevel2 trigger as a ChangeTrigger for you ChangeLevel entity...

That's it all. Hope this helps. :)
Everyone can see the difficult, but only the wise can see the simple.
-----
User avatar
zany_001
Posts: 1047
Joined: Fri Mar 02, 2007 8:36 am
Location: Aotearoa

Post by zany_001 »

if x<8, show message and change level.
this wouldnt work because x would always be less than 8, until 8 characters were killed.it would be x=7.otherwise it would play straight away.o is less than 8 u no.[/quote]
Once I was sad, and I stopped being sad and was awesome instead.
True story.
User avatar
vrageprogrammer
Posts: 566
Joined: Wed Oct 31, 2007 2:59 pm
Location: On top of a tree
Contact:

Post by vrageprogrammer »

thanks zany and jay!
it works now..
p.s- i have a Cutscene after the level so forget the message part..
It was not Possible to determine the dimensions of the image....
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post by darksmaster923 »

use x>6 cuz it might go to fast and miss 7 for some odd reason.
Herp derp.
User avatar
vrageprogrammer
Posts: 566
Joined: Wed Oct 31, 2007 2:59 pm
Location: On top of a tree
Contact:

Post by vrageprogrammer »

can't i use activatetrigger instead of SetEventState?(what's the difference?)
and thank you Dm, nice suggestion :wink:
It was not Possible to determine the dimensions of the image....
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

There is a difference between the two. The docs say that ActivateTrigger(..) is like when you push a world model that is a trigger, SetEventState(...) just sets the state. I could imagine that ActivateTrigger(...) also plays the animation of the world model which is associated with the trigger which is 'activated'. SetEventState() definitely does not do this. I have never used this feature, but i could imagine it would be cool in a cutscene where a pawn pulls a lever (which is a world model) just like the player would do. Which then does exactly the same as it would do when the player pulled the lever.
Everyone can see the difficult, but only the wise can see the simple.
-----
User avatar
bernie
RF Moderator
Posts: 1249
Joined: Tue Nov 15, 2005 10:07 am
Location: Ireland

Post by bernie »

Yes Jay that is correct. ActivateTrigger(...) does play the animation of a world model Set EventState(...) does not.
User avatar
vrageprogrammer
Posts: 566
Joined: Wed Oct 31, 2007 2:59 pm
Location: On top of a tree
Contact:

Post by vrageprogrammer »

well, ActivateTrigger ain't working...
It was not Possible to determine the dimensions of the image....
User avatar
bernie
RF Moderator
Posts: 1249
Joined: Tue Nov 15, 2005 10:07 am
Location: Ireland

Post by bernie »

Vrage, it does work I have used it in my demo quite a few times. It is a LowLevel only command, maybe that is causing you problems. SetEventState(...) is both Low and Highlevel.
User avatar
vrageprogrammer
Posts: 566
Joined: Wed Oct 31, 2007 2:59 pm
Location: On top of a tree
Contact:

Post by vrageprogrammer »

um...bernie, this is what i'm doing-
put the script jay gave me in my pawn's die order.(i only changed SetEventstate to activateTrigger and changed the trigger name)
then i created a trigger in my level calling it 'Change'(time off-1, time on-1)
also, this trigger is world model free.
A changelevel entity depends on this trigger..
Now, this script isn't working.
could you show me a sample of a similar script?
thanks!
:wink:
It was not Possible to determine the dimensions of the image....
User avatar
bernie
RF Moderator
Posts: 1249
Joined: Tue Nov 15, 2005 10:07 am
Location: Ireland

Post by bernie »

Heres the script I used to raise the steps to get the rod in talisman

{

Spawn[()
{
//Console(true);
LowLevel("DOit");
}
]

DOit[()
{
ActivateTrigger("trig1");
ActivateTrigger("trig2");
ActivateTrigger("trig3");
ActivateTrigger("trig4");
ActivateTrigger("trig5");
PlaySound("Stone_door_2.wav");
HighLevel("die");
}]

die[()
{
Remove(true);
}]

}
User avatar
vrageprogrammer
Posts: 566
Joined: Wed Oct 31, 2007 2:59 pm
Location: On top of a tree
Contact:

Post by vrageprogrammer »

NO!!!
it stillisn't working...here's my script:

Code: Select all

Die[()
{
DelTimerOrder(1);
    if(KO < 1)
    {
	AnimateStop(DIEANIM,true,"");
    }
FadeOut(FADETIME,10);
    if(RESPAWN)
    {
        ModifyAttribute("pawnkill",1,"Player"); //Adds 1 to the killedpawns-attribute 
        if(GetAttribute("pawnkill","Player")=1) //if you have killed seven of them 
        { 
        SetEventState("Change",true); //Set level-change-trigger on 
        SetAttribute("pawnkill",0,"Player"); //Set back attribute 
        LowLevel("HidePawn");
    }
    else
    {
 
    }  
NOTE: REPSPAWN IS ON
It was not Possible to determine the dimensions of the image....
User avatar
vrageprogrammer
Posts: 566
Joined: Wed Oct 31, 2007 2:59 pm
Location: On top of a tree
Contact:

Post by vrageprogrammer »

It Works now!
THANKS!
It was not Possible to determine the dimensions of the image....
Post Reply