A Community discussion forum for Halo Custom Edition, Halo 2 Vista, Portal and Halo Machinima

Home  Search Register  Login Member ListRecent Posts
  
 
»Forums Index »Halo Custom Edition (Bungie/Gearbox) »Halo CE Technical / Map Design »Camo Script

Author Topic: Camo Script (7 messages, Page 1 of 1)
Moderators: Dennis

PX173
Joined: Aug 22, 2009

It was worth it.


Posted: Jan 24, 2010 12:25 AM    Msg. 1 of 7       
For the stealth part of my project, I'm trying to make an active camo script, except I'm having some problems.


(script continuous camo
(sleep_until (= (unit_get_current_flashlight_state (unit (list_get (players) 0))) true))
(object_attach)
(object_detach)
(sleep 600)
(sleep_until (= (unit_get_current_flashlight_state (unit (list_get (players) 0))) false))
(object_attach)
(object_detach)
(sleep 600)
)

So that when you turn on the flashlight, you get camo. When you turn it off, you get camo again. I know this may cause problems when you rapidly tap the flashlight key, but there's a simple solution to that: don't tap it repeatedly.

Now I'm having problems with the attach and detach part, since I don't know what to put in. The active camo powerup name is camo, btw. And I don't have "Not placed automatically" checked.


Gamma927
Joined: Jun 12, 2008

Steam: gamma927


Posted: Jan 24, 2010 11:45 AM    Msg. 2 of 7       
First off, I believe the command is objects_attach or detach.

(objects_attach (unit (list_get (players) 0)) "" camo "")
(objects_detach (unit (list_get (players) 0)) camo)


Me KS
Joined: Feb 2, 2008

Desire is Reality. Xfire: jetmaster23


Posted: Jan 24, 2010 12:38 PM    Msg. 3 of 7       
^ That, and one other thing: are you using this for SP or MP? If it's MP, then you'll need to add checks for all 15 other players and change the script a bit or it won't work properly.

In SP it doesn't matter because there's only one player and the game restarts every time the player dies anyways.

But, the way the script is set up now won't work out in multiplayer.

After a player turns the flashlight on and gets camo, the script then waits for his flashlight to be off after 20 seconds. If after 20 seconds the player dies with his flashlight still on, then the script will still be waiting for his flashlight to be off. Since players always spawn with their flashlight off, he'll get camo right when he spawns.

If he dies with his flashlight on and respawns before the 20 seconds are up without turning it back on, he'll get camo out of nowhere without touching anything once the 20 seconds pass.


Gamma927
Joined: Jun 12, 2008

Steam: gamma927


Posted: Jan 24, 2010 02:30 PM    Msg. 4 of 7       
That's why you should modify the script that you have to turn off the flashlight, immediately after the player turns it on. The command is:

(unit_set_desired_flashlight_state (unit (list_get (players) 0)) false)

This is, of course, assuming your map is SP.


PX173
Joined: Aug 22, 2009

It was worth it.


Posted: Jan 25, 2010 04:07 AM    Msg. 5 of 7       
Quote: --- Original message by: Gamma927
That's why you should modify the script that you have to turn off the flashlight, immediately after the player turns it on. The command is:

(unit_set_desired_flashlight_state (unit (list_get (players) 0)) false)

This is, of course, assuming your map is SP.

So this would alter your flashlight state to be off almost immediately after you turn it on?

And yes, my map is SP.
Ed:Still got crap.

(script continuous camo
(object_create_anew camo)
(sleep_until (= (unit_get_current_flashlight_state (unit (list_get
(players) 0))) true))
(objects_attach (unit (list_get (players) 0)) "" camo "")
(objects_detach (unit (list_get (players) 0)) camo)
(sleep 600)
)


(script continuous flashlight
(unit_set_desired_flashlight_state (unit (list_get (players) 0)) false)
)

I've made two different scripts in two different files so the player's flashlight would always automatically turn off. Problem is, the camo part doesn't happen.
Edited by PX173 on Jan 25, 2010 at 04:57 AM


Me KS
Joined: Feb 2, 2008

Desire is Reality. Xfire: jetmaster23


Posted: Jan 25, 2010 02:50 PM    Msg. 6 of 7       
Ok. If I had to write this script, this is how I would do it:

(global short timer 0)

(script static "unit" player0)
(unit (list_get (players) 0))
)

(script continuous counter
(if
(> timer 0)
(set timer (- timer 1))
)
)

(script continuous camo
(if
(= (unit_get_current_flashlight_state (player0)) 1)
(begin
(unit_set_desired_flashlight_state (player0) 0)
(if
(<= timer 0)
(begin
(object_create_anew camo)
(objects_attach (player0) "" camo "")
(objects_detach (player0) camo)
(set timer 600)
)
)
)
)
)


It seems like a lot for something so simple, but it should work properly. The advantage here is that the flashlight will always be turned off regardless of whether you get camo or not when you turn it on.

In order to do that, I had to make sure the script never slept, so I used a variable for the timer instead along with (if) tests. The static script is just for the convenience of typing (player0) for referring to the player.

See if that works for you.


PX173
Joined: Aug 22, 2009

It was worth it.


Posted: Jan 26, 2010 04:25 AM    Msg. 7 of 7       
I just realized I forgot to save the scenario after I compiled the scripts. Thanks anyway.

 

 
Previous Older Thread    Next newer Thread







Time: Fri January 20, 2023 2:42 PM 266 ms.
A Halo Maps Website