need help with a script
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
need help with a script
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.
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....
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
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.
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.
-----
-----
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
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.
-----
-----
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
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!

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!
It was not Possible to determine the dimensions of the image....
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);
}]
}
{
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);
}]
}
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
NO!!!
it stillisn't working...here's my script:
NOTE: REPSPAWN IS ON
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
{
}
It was not Possible to determine the dimensions of the image....
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact: