Author |
Topic: Tweaking my elevator |
Norseman |
General Member Since: Aug 16, 2009 Posts: 30 Last: Jan 16, 2010 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Wednesday, Nov. 25, 2009 01:41 pm |
|
I have this elevator script that is very simple and works well except for one problem. If the trigger is activated while the elevator is already in motion the position of the elevator gets out of whack. I was wondering if it is possible to add a command to the script that makes the elevator ignore all triggers until the elevator is done moving or done with the current script? Any help would be great, thank you. Here is the script:
elevator1.gsc
main()
{
thread elevator();
}
elevator()
{
elevator=getent("elevator1","targetname");
trig=getent("trig_elevator1","targetname");
while(1)
{
trig waittill ("trigger");
elevator movez (-1204,3,1,1);
elevator waittill ("movedone");
wait(2);
elevator movez (1204,3,1,1);
elevator waittill ("movedone");
}
} |
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
|
|
Category: CoD2 MP Mapping Posted: Friday, Nov. 27, 2009 11:34 pm |
|
Code: main()
{
thread elevator();
}
elevator()
{
elevator=getent("elevator1","targetname");
trig=getent("trig_elevator1","targetname");
while(1)
{
oldpos = trig.origin;
trig waittill ("trigger");
trig.origin = (0,0,10000);
elevator movez (-1204,3,1,1);
elevator waittill ("movedone");
wait(2);
elevator movez (1204,3,1,1);
elevator waittill ("movedone");
trig.origin = oldpos;
}
This should move the trigger 10,000 units up in the sky after being triggered. Then moved back to its original position after the elevator has completed moving.
There is TriggerOn and TriggerOff functions that i believe do this exact same thing with moving the trigger origins. I just can't remember where they are located in the iwd files, so i cant thread them. |
|
|
|
Norseman |
General Member Since: Aug 16, 2009 Posts: 30 Last: Jan 16, 2010 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Saturday, Nov. 28, 2009 03:07 am |
|
liltc64 writes...Quote: what do u mean get out of wack??? im looking at the code and i see nothing wronge could u explain more of what happends?
If a player activates either trigger while the elevator is moving it starts the script in the middle of the elevator moving. The elevator then loses it's original position because it started running the script in the middle of moving with the original script. The elevator sometimes leaves the map never to return until the map is over.
Thank you codmp,I'll give this a try.It looks like it moves the trigger used but not the other trigger but it will help with my problem. thank you again for your response. |
|
|
|
clanhelio |
General Member Since: Aug 30, 2008 Posts: 223 Last: Mar 24, 2011 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Saturday, Nov. 28, 2009 04:31 am |
|
That script actually looks airtight, don't know why it would allow a trigger while it's moving, you can try this though, I just added a variable 'eleismoving'
Code: main()
{
thread elevator();
}
elevator()
{
eleismoving = 0;
elevator=getent("elevator1","targetname");
trig=getent("trig_elevator1","targetname");
while(1)
{
trig waittill ("trigger");
if( eleismoving == 0 )
{
eleismoving = 1;
elevator movez (-1204,3,1,1);
elevator waittill ("movedone");
wait(2);
elevator movez (1204,3,1,1);
elevator waittill ("movedone");
eleismoving = 0;
}
}
} |
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
Category: CoD2 MP Mapping Posted: Saturday, Nov. 28, 2009 03:47 pm |
|
yeah like clanhelio said ur orginal code looks fine... u can try there 2 codes i also got a trigger on and off code u can try if those dont work but they should.
Code: #include maps\mp\_utility;
main()
{
thread elevator();
}
elevator()
{
elevator=getent("elevator1","targetname");
trig=getent("trig_elevator1","targetname");
while(1)
{
trig waittill ("trigger");
trig triggerOff();
elevator movez (-1204,3,1,1);
elevator waittill ("movedone");
wait(2);
elevator movez (1204,3,1,1);
elevator waittill ("movedone");
trig triggerOn();
}
} |
|
|
|
Norseman |
General Member Since: Aug 16, 2009 Posts: 30 Last: Jan 16, 2010 [view latest posts] |
|
|
|
Norseman |
General Member Since: Aug 16, 2009 Posts: 30 Last: Jan 16, 2010 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Sunday, Nov. 29, 2009 05:52 pm |
|
I have given up on using the original script with 2 triggers, I can not get it to work the way I want with this script. If I name the triggers the same at the top and bottom the elevator becomes an always moving elevator. I wanted the elevator to go down and then back to the original position but I'm not good enough at this to make this work without flaws that happen in positioning. I have decided to use this script were the elevator only goes up or down, it seems my best option at this time. It works great, does not get out of position if you trigger it mid operation and I can make as many triggers with the same name and it still works great. Thanks for all the help everyone.
Code: main() {
level.elev1Down = true; // elev1 starts at bottom: true/false
level.elev1Moving = false; // elev1 is not currently moving
thread elev1_start();
}
elev1_start() {
elev1 = getentarray ("elev1switch","targetname");
if ( isdefined(elev1) )
for (i = 0; i < elev1.size; i++)
elev1[i] thread elev1_think();
}
elev1_think() {
while (1) {
self waittill ("trigger");
if (!level.elev1Moving)
thread elev1_move();
}
}
elev1_move() {
elev1model = getent ("elev1model", "targetname");
level.elev1Moving = true;
wait (2);
if (level.elev1Down) { // moves to top
elev1model moveZ (1204,5,2,2);
elev1model waittill ("movedone");
level.elev1Down = false;
}
else { // moves to bottom
elev1model moveZ (1204 - (1204 * 2), 5,2,2);
elev1model waittill ("movedone");
level.elev1Down = true;
}
level.elev1Moving = false;
}
|
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
Category: CoD2 MP Mapping Posted: Sunday, Nov. 29, 2009 11:06 pm |
|
sorry i wasnt on modsonline when u needed help with the 2 triggers could have helped u basicly all u do is make the triggers then select both of them and give them the targetname : trig, then in ur .gsc all u would have to do is.
Code: #include maps\mp\_utility;
main()
{
thread elevator();
}
elevator()
{
elevator=getent("elevator1","targetname");
trigger=getentarray("trig","targetname");
while(1)
{
trigger waittill ("trigger");
trigger triggerOff();
elevator movez (-1204,3,1,1);
elevator waittill ("movedone");
wait(2);
elevator movez (1204,3,1,1);
elevator waittill ("movedone");
trigger triggerOn();
}
}
and that should work fine. |
|
|
|