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 »Scripting help; how to sync a device

Author Topic: Scripting help; how to sync a device (5 messages, Page 1 of 1)
Moderators: Dennis

OpsY
Joined: Feb 19, 2007

Frobisher Bay


Posted: Mar 24, 2009 11:18 AM    Msg. 1 of 5       
Hey there, I'm trying to add an elevator to my map and don't really know how to make it sync. I've added the device, the controls and the power group so it works on my own end in game but it's not at the point of syncing for whoever is not host.


I have EHS2 here and found out there's a pre programmed script for it but mind you, it's pretty complicated to understand what each box asks





I read the tutorial on Ghost's tutorial ressource and while it seemingly adds related stuff, I still need a walthrough, the placement of the objects and such
Edited by OpsY on Mar 24, 2009 at 02:46 PM


Me KS
Joined: Feb 2, 2008

Desire is Reality. Xfire: jetmaster23


Posted: Mar 24, 2009 04:27 PM    Msg. 2 of 5       
First things first: No device groups. It's better if the script handles the device.

By the way you worded it, it looks like you have more than one control and one device. So I'm sticking with that.

Only thing that I can't guess is how exactly do you want the elevator to work? What's your setup? As in, is it a switch for the lower floor and a switch for the upper floor, and both switches can make the elevator go up or down? Or is it a switch on both floors but that can only make the elevator move to their floor? Or is it one switch that can move the elevator both up and down? Etc.

I need to know the exact setup, because depending on how many switches and how you want each switch to move the elevator, the script and the syncing bipeds\hogs might have to be adapted for each setup.

Just set it up however you want, and post the setup exactly as you have it, and I'll walk you through it if you know how to script.
Edited by Me KS on Mar 24, 2009 at 04:27 PM


OpsY
Joined: Feb 19, 2007

Frobisher Bay


Posted: Mar 24, 2009 07:08 PM    Msg. 3 of 5       
thanks for your answer.



The current setup is:

2 switches and 1 lift.


I want one switch at the ''ground'' level that can make the elevator go up or down and one switch at the second floor that can do the same thing. The elevator is the one from B40 and the switches are the holo switches from Single player aswell.

to answer your edit: I don't know how to script. hopefully I can learn some stuff from it but those days I'm really out of time for anything like that.
Edited by OpsY on Mar 24, 2009 at 07:15 PM


Me KS
Joined: Feb 2, 2008

Desire is Reality. Xfire: jetmaster23


Posted: Mar 25, 2009 04:08 PM    Msg. 4 of 5       
Okay, that'll be harder. But, I'll make a script, 'cause I'm nice like that. And I like scripting.

Alright, so, setup:

-Have four hogs in some place that the player cannot reach. Make sure the ground is mostly flat and that the hogs are near each other, but not too close to each other. Set them not to spawn by default under any circumstances, and name them "up_hog", "moving_up_hog","moving_down_hog", and "down_hog", without quotes. Use the default "mp_warthog".

-Place one biped under each of these hogs. Make sure you name them according to their hog. Also, make sure that the hog is position right over the biped so it'll kill it when it spawns. Under "up_hog", name the biped "up_sync". Under "moving_up_hog", name the biped "moving_up_sync". For "moving_down_hog", name the biped "moving_down_sync", and under "down_hog", name the biped "down_sync". Make sure these bipeds all spawn by default. Also, just use default "cyborg_unarmed" bipeds. This way, they don't spill weapons uselessly every time they're killed.

-Name your two switches "up_switch" and "down_switch".

-Name the elevator ... "elevator".

-Place yet another hog, and name it "host_check". However, make sure this hog spawns in ALL game types BY DEFAULT. Preferably put this one in the same area as the other hogs, just not too close to any of them.

-These next items are very important, as I made my script assuming these conditions: Make sure that when the game starts, the elevator is on the BOTTOM floor, and that the elevator is at the "0" position when it's on the bottom floor. Make sure the elevator has its power set to "1" at game start. Also make sure that both Controls (the switches) are set to a position of "0" at the start of the game, and that their power is also set to "1" at start. You can check these both by typing these into Sapien's console: "device_get_position object_name" and "device_get_power object_name" without quotes. The checkboxes in the properties of each control and device are used for setting its start power and position. It should be fine as it is, but if not, look for the right checkboxes.

-That's about it for the setup.

-When I find myself in times of trouble, Mother Mary comes to me.

-So, once all that's done, compile this gigantic script:


(global boolean server 0)

(global boolean up 0)
(global boolean down 1)

(script startup i_like_apples
(unit_suspended up_sync 1)
(unit_suspended moving_up_sync 1)
(unit_suspended moving_down_sync 1)
(unit_suspended down_sync 1)
(if
(>= (unit_get_health host_check) 0)
(set server 1)
)
)

(script continuous server_side
(if
(= server 1)
(begin
(if
(and
(or
(> (device_get_position up_switch) 0)
(> (device_get_position down_switch) 0)
)
(= down 1)
)
(begin
(set down 0)
(device_set_position_immediate up_switch 0)
(device_set_position_immediate down_switch 0)
(device_set_power up_switch 0)
(device_set_power down_switch 0)
(object_destroy down_hog)
(object_create_anew down_sync)
(unit_suspended down_sync 1)
(object_create_anew moving_up_hog)
(sleep_until (?= (unit_get_health moving_up_sync) 0) 1)
(device_set_position elevator 1)
(sleep_until (>= (device_get_position elevator) 1) 1)
(object_destroy moving_up_hog)
(object_create_anew moving_up_sync)
(unit_suspended moving_up_sync 1)
(device_set_power up_switch 1)
(device_set_power down_switch 1)
(set up 1)
(object_create_anew up_hog)
)
)
(if
(and
(or
(> (device_get_position up_switch) 0)
(> (device_get_position down_switch) 0)
)
(= up 1)
)
(begin
(set up 0)
(device_set_position_immediate up_switch 0)
(device_set_position_immediate down_switch 0)
(device_set_power up_switch 0)
(device_set_power down_switch 0)
(object_destroy up_hog)
(object_create_anew up_sync)
(unit_suspended up_sync 1)
(object_create_anew moving_down_hog)
(sleep_until (?= (unit_get_health moving_down_sync) 0) 1)
(device_set_position elevator 0)
(sleep_until (?= (device_get_position elevator) 0) 1)
(object_destroy moving_down_hog)
(object_create_anew moving_down_sync)
(unit_suspended moving_down_sync 1)
(device_set_power up_switch 1)
(device_set_power down_switch 1)
(set down 1)
(object_create_anew down_hog)
)
)
)
(sleep_until (= 0 1))
)
)

(script continuous client_side_position
(if
(= server 0)
(begin
(if
(?= (unit_get_health up_sync) 0)
(device_set_position_immediate elevator 1)
)
(if
(?= (unit_get_health down_sync) 0)
(device_set_position_immediate elevator 0)
)
)
(sleep_until (= 0 1))
)
)

(script continuous client_side_movement
(if
(= server 0)
(begin
(if
(?= (unit_get_health moving_up_sync) 0)
(begin
(device_set_position up_switch 1)
(device_set_position down_switch 1)
(device_set_power up_switch 0)
(device_set_power down_switch 0)
(object_create_anew down_sync)
(unit_suspended down_sync 1)
(device_set_position elevator 1)
(sleep_until (>= (device_get_position elevator) 1) 1)
(object_create_anew moving_up_sync)
(unit_suspended moving_up_sync 1)
(device_set_power up_switch 1)
(device_set_power down_switch 1)
(device_set_position_immediate up_switch 0)
(device_set_position_immediate down_switch 0)
)
)
(if
(?= (unit_get_health moving_down_sync) 0)
(begin
(device_set_position up_switch 1)
(device_set_position down_switch 1)
(device_set_power up_switch 0)
(device_set_power down_switch 0)
(object_create_anew up_sync)
(unit_suspended up_sync 1)
(device_set_position elevator 0)
(sleep_until (?= (device_get_position elevator) 0) 1)
(object_create_anew moving_down_sync)
(unit_suspended moving_down_sync 1)
(device_set_power up_switch 1)
(device_set_power down_switch 1)
(device_set_position_immediate up_switch 0)
(device_set_position_immediate down_switch 0)
)
)
)
(sleep_until (= 0 1))
)
)


It's not tested, but I've done syncing before and I thought this script through pretty damn well, so it should work.

EDIT: The forums delete everything between "<>", so I replaced all of the "<" symbols with question marks "?". Remember to change those back to "<" before compiling.
Edited by Me KS on Mar 25, 2009 at 04:15 PM


OpsY
Joined: Feb 19, 2007

Frobisher Bay


Posted: Mar 25, 2009 10:38 PM    Msg. 5 of 5       
Thanks alot, it did work:)


Edited by OpsY on Mar 26, 2009 at 05:45 PM

 

 
Previous Older Thread    Next newer Thread







Time: Fri January 20, 2023 8:53 PM 141 ms.
A Halo Maps Website