Page 1 of 2

Hiding/Un-hiding is it Possible???

Posted: Mon Mar 10, 2003 3:20 pm
by Shifty
Would it be possible to use a trigger to hide/unhide things, i.e. if i walk to a location go through the trigger and something appears behind you. I'f so this would be very cool for my next Top Secret Map Plans 8)

Thanks

Posted: Mon Mar 10, 2003 4:20 pm
by jv_map
What kind of thing?

Posted: Mon Mar 10, 2003 5:44 pm
by MPowell1944
heh. I know exactly how you would go about this.

1. Create a trigger_multiple and give it a targetname of thetrigger.
2. Then create the object that you want to show/hide and give it a targetname of theobject.
3. In your .scr file, put in this code after level waittill spawn :

thread show_setup
end

show_setup:
$thetrigger waittill trigger
$theobject show
thread hide_setup
end

hide_setup:
$thetrigger waittill trigger
$theobject hide
thread show_setup
end


That should do it. Step in and out of the trigger to show and hide the object you want. Let me know if there is any other complications.

And jv, make sure I got it right this time. hehe :wink:

Posted: Mon Mar 10, 2003 6:05 pm
by Shifty
Cool thanks - if what im hoping to do works i'll put a little test map up :) if i cant get it to work ill let u know my idea and maybe some1 else can crack it.......

Posted: Mon Mar 10, 2003 6:21 pm
by jv_map
MPowell1944 wrote: thread show_setup
end

show_setup:
$thetrigger waittill trigger
$theobject show
thread hide_setup
end

hide_setup:
$thetrigger waittill trigger
$theobject hide
thread show_setup
end

And jv, make sure I got it right this time. hehe :wink:
You're a champion in dodgy code Powell ;). Better not link threads to each other, it's kinda like a goto :).

This is what you want - right? You can now easily see the code loops forever:

Code: Select all

while(1)
{
    $thetrigger waittill trigger
    $theobject show
    wait 2    
    $thetrigger waittill trigger
    $theobject hide
}
I added a 'wait 2' to prevent infinite loops. Note that it's probably better to use separate triggers for hiding and showing instead.

Posted: Mon Mar 10, 2003 6:28 pm
by MPowell1944
Directed at Shifty :

*Edit. Shifty I forgot to tell you to add $theobject hide after level waittill spawn in the first script I gave you. Just a heads up.*

I am the one that created working lights, and that involved showing and hiding the light and the corona, so I am positive that this will work. You can use different names if you want, I just used those as an example. Also, if you just want the object to show once and not have it show/hide, you can use these steps instead :

1. Create a trigger_multiple and give it a targetname of thetrigger and a setthread of showobject.
2. Then create the object that you want to show/hide and give it a targetname of theobject.
3. In your .scr file, put in this code after level waittill spawn :

$theobject hide
end

showobject:
$theobject show
$thetrigger remove
end

Directed at jv :

Your script is refined, and I know that mine threads other scripts, but I did this with my lights and it worked flawlessly. Oh and by the way, I finally caught a mistake you made. You have it to show from the beginning, but without it being hidden in the first place, you would have to reverse the script. No big deal, just pickin' on you.

Posted: Mon Mar 10, 2003 6:33 pm
by jv_map
I think your script will go crazy when a player stays in the trigger for a while :roll:.

Posted: Mon Mar 10, 2003 6:36 pm
by MPowell1944
It wont. The object will just keep showing and hiding. I would know.

I think you just like to argue with me alot. Fun fun fun. :wink:

Posted: Mon Mar 10, 2003 6:50 pm
by Slyk
Ok, so the threads work, one way or the other. Isn't just safe to make any 'walk-into' trigger as small as possible to eliminate any camping inside it and freaking the trigger??? As for lights and other 'switch' related things, I'd guess making a moving switch would be best then with the trigger operating the hide/unhide. Of course you need switch scripting then, which can be taken from the TOW maps easily. I also think JV's wait line is a good idea depending on the situation...in an MP map you could have sheer mayhem with this system. :shock:

Darn

Posted: Mon Mar 10, 2003 7:14 pm
by Shifty
Ok i'll let u into what im playing with

Basicly when i'm at work - I get bored my mind wonders and I think about what I can try mapping, anyway I was thinking it would be cool to be able to parachute into the map basicly the reason i want the hide/unhide is after you've parachuted in you walk past the trigger and your chute is behind you (but i donw want it to be seen as you drop in.

Only the dam thing (mockup of chute - looks nothing like one) is visible when u spawn aghhhh heres my script

Code: Select all

main:

// set scoreboard messages 
setcvar "g_obj_alliedtext1" "" 
setcvar "g_obj_alliedtext2" "" 
setcvar "g_obj_alliedtext3" "" 
setcvar "g_obj_axistext1" "" 
setcvar "g_obj_axistext2" "" 
setcvar "g_obj_axistext3" "" 

setcvar "g_scoreboardpic" "none" //your score board picture 

level waittill prespawn

exec global/DMprecache.scr 

level.script = "para_test.scr" // remember to put in your map name 

level waittill spawn

$theobject hide

thread show_setup 
end 

show_setup: 
$thetrigger waittill trigger 
$theobject show 
thread hide_setup 
end 

hide_setup: 
$thetrigger waittill trigger 
$theobject hide 
thread show_setup 
end 

Posted: Mon Mar 10, 2003 7:23 pm
by jv_map
MPowell1944 wrote:I think you just like to argue with me alot. Fun fun fun. :wink:
I don't :wink:

Posted: Mon Mar 10, 2003 7:25 pm
by MPowell1944
Well, if you want to use a switch to toggle the object visibilty, then check out this modified version of my lightswitch tutorial. Yes it uses the thread command, but it works 100%. So no refining by jv is needed this time.

1. Create a switch by selecting animate_equipment_electric>>switch>>nopulse

2. Give the switch a targetname of object_switch

3. Create a trigger_use around the switch and give it a targetname of switch_trigger

4. Now create the object that you want to show/hide and give it a targetname of theobject

5. Enter the following script after level waittill spawn in your .scr file :

$theobject hide
thread object_show
end

object_show:
$switch_trigger triggerable
$switch_trigger waittill trigger
$switch_trigger nottriggerable
$object_switch anim turn
$object_switch playsound alarm_switch
wait .25
$theobject show
wait .5
thread object_hide
end

object_hide:
$switch_trigger triggerable
$switch_trigger waittill trigger
$switch_trigger nottriggerable
$object_switch anim off
$object_switch playsound alarm_switch
wait .25
$theobject hide
wait .5
thread object_show
end

Its as simple as that. Taken directly from my lightswitch tutorial. :wink:

Posted: Mon Mar 10, 2003 7:30 pm
by Shifty
K thx ill try that

Posted: Mon Mar 10, 2003 7:47 pm
by Shifty
I know why it wasnt working before - for some reason the trigger keeps dissapearing i put it in the map save reopen it and its gone wot the hell is goin on there

Posted: Mon Mar 10, 2003 9:31 pm
by MPowell1944
Its Radiant. Sometimes its glitchy and deletes part of .map files.