Page 1 of 2

need help with a script

Posted: Sun Dec 30, 2007 2:12 pm
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.

Posted: Sun Dec 30, 2007 2:59 pm
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...

Posted: Sun Dec 30, 2007 6:10 pm
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. :)

Posted: Mon Dec 31, 2007 2:50 am
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]

Posted: Mon Dec 31, 2007 10:13 am
by vrageprogrammer
thanks zany and jay!
it works now..
p.s- i have a Cutscene after the level so forget the message part..

Posted: Mon Dec 31, 2007 5:56 pm
by darksmaster923
use x>6 cuz it might go to fast and miss 7 for some odd reason.

Posted: Mon Dec 31, 2007 7:07 pm
by vrageprogrammer
can't i use activatetrigger instead of SetEventState?(what's the difference?)
and thank you Dm, nice suggestion :wink:

Posted: Mon Dec 31, 2007 7:32 pm
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.

Posted: Tue Jan 01, 2008 11:09 am
by bernie
Yes Jay that is correct. ActivateTrigger(...) does play the animation of a world model Set EventState(...) does not.

Posted: Tue Jan 01, 2008 2:39 pm
by vrageprogrammer
well, ActivateTrigger ain't working...

Posted: Tue Jan 01, 2008 3:23 pm
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.

Posted: Tue Jan 01, 2008 4:00 pm
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:

Posted: Tue Jan 01, 2008 4:15 pm
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);
}]

}

Posted: Thu Jan 03, 2008 2:11 pm
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

Posted: Thu Jan 03, 2008 2:41 pm
by vrageprogrammer
It Works now!
THANKS!