Page 1 of 1
Trigger use, for only axis...
Posted: Tue Mar 16, 2004 7:36 pm
by chrisjbooth2001
how would i make a trigger use, so only axis could use it?
So far ive got this...
//------------------------------------------
axis_switch:
//------------------------------------------
$axis1 thread axisdoor
Jvmap told me this but i dunno how to incorporate it to the scripts...
if(parm.other.dmteam == axis)
Re: Trigger use, for only axis...
Posted: Wed Mar 17, 2004 12:32 am
by dcoshea
chrisjbooth2001 wrote:how would i make a trigger use, so only axis could use it?
So far ive got this...
//------------------------------------------
axis_switch:
//------------------------------------------
$axis1 thread axisdoor
Jvmap told me this but i dunno how to incorporate it to the scripts...
if(parm.other.dmteam == axis)
I assume the trigger_use has its 'setthread' property set to 'axis_switch' so that 'axis_switch' is called/executed when the trigger is USEd?
Anyway, assuming axis_switch is being called somehow, this will make it only call axisdoor when it's an Axis player who hit the "switch":
Code: Select all
//------------------------------------------
axis_switch:
//------------------------------------------
if (parm.other.dmteam == "axis") {
$axis1 thread axisdoor
}
end
It of course is checking if parm.other (the Player who triggered the trigger) belongs to the Axis team, and only if they do is it calling the axisdoor thread.
Regards,
David
Posted: Wed Mar 17, 2004 5:20 pm
by chrisjbooth2001
now if i didnt have the setthread, how would i do it?
Posted: Wed Mar 17, 2004 6:06 pm
by jv_map
chrisjbooth2001 wrote:now if i didnt have the setthread, how would i do it?
Add the setthread

Posted: Wed Mar 17, 2004 6:28 pm
by chrisjbooth2001
If i couldnt add one because i only had the bsp?
Posted: Wed Mar 17, 2004 6:29 pm
by jv_map
Then add one by script

Posted: Wed Mar 17, 2004 6:32 pm
by chrisjbooth2001
I love the little comments lol,
How?
Posted: Wed Mar 17, 2004 11:54 pm
by dcoshea
chrisjbooth2001 wrote:I love the little comments lol,
How?
Assuming the trigger's targetname is "bob", you'd use:
When you use 'setthread', it's pretty much like doing this:
Code: Select all
$bob thread my_fake_setthread
my_fake_setthread:
while (1) { // loop forever
self waittill trigger // wait until the trigger is triggered
self thread axis_switch // call the thread
}
end
That's what 'setthread' does - call your thread when the trigger is triggered. The difference is that 'setthread' only allows one thread to be specified whereas with the 'my_fake_setthread' you could call a bunch of threads. Of course, the thread that 'setthread' calls could just call a bunch of threads itself.
Instead of using 'setthread', you could just use 'waittill trigger' in your code if you like.
Regards,
David
Posted: Thu Mar 18, 2004 4:38 pm
by chrisjbooth2001
Thanks ill try it!

Posted: Thu Mar 18, 2004 6:13 pm
by chrisjbooth2001
Ok, if i use the setthread method.. How would i make it so you trigger the thread, and once the thread finishes it allows ya to reuse it..
I think the command is waitthread ?
Posted: Fri Mar 19, 2004 3:40 am
by dcoshea
chrisjbooth2001 wrote:Ok, if i use the setthread method.. How would i make it so you trigger the thread, and once the thread finishes it allows ya to reuse it..
I think the command is waitthread ?
If you were using the "this is how setthread works" code I posted:
Code: Select all
$bob thread my_fake_setthread
my_fake_setthread:
while (1) { // loop forever
self waittill trigger // wait until the trigger is triggered
self thread axis_switch // call the thread
}
end
you could change 'thread' to 'waitthread' to prevent axis_switch from being called concurrently, i.e. it won't be called a second time until the first time has finished.
However, you asked about doing this with 'setthread'. 'waitthread' won't help you directly, although in your case since the axis_switch thread calls the axisdoor thread, it will be needed. The game will call the thread that 'setthread' points to every time the trigger is triggered (as far as I know), and it's up to you to prevent concurrent calls if you don't want them. Try something like this:
Code: Select all
axis_switch:
if (level.axis_switch_thread_active) {
// we are already running this thread, don't run it again
end
}
level.axis_switch_thread_active = 1
// call using waitthread instead of thread so that we know when it's done
$axis1 waitthread] axisdoor
// axisdoor is done, so we're done, and we can set the flag indicating we're active back to 0, allowing this thread to execute again
level.axis_switch_thread_active = 0
end
[Edit: got rid of ignored bold tags]
Of course, if you think about it, if two copies of that thread were called simultaneously and executed in a truly parallel fashion, they could both check level.axis_switch_thread_active at the same time, both see it's not set, then both set it simultaneously, thus both running 'axisdoor' at the same time, but I don't believe the game really runs threads with that level of concurrency - I think it will only run another thread when the thread it is currently running gets to a 'wait' statement.
I'm thinking co-operative/non-pre-emptive multi-tasking, in case there's anyone who knows exactly what I'm thinking and happens to know that I'm wrong
Regards,
David
Posted: Fri Mar 19, 2004 11:43 pm
by chrisjbooth2001
I will take a look at this thx