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!

Author Topic: Scripting! (9 messages, Page 1 of 1)
Moderators: Dennis

Gamma927
Joined: Jun 12, 2008

Steam: gamma927


Posted: Mar 2, 2009 07:00 PM    Msg. 1 of 9       
Alright, so in a multiplayer map, if I wanted to create a script in which it sleeps until two players are inside a trigger volume, how would I set up the if part of the script?


sierra117
Joined: Jan 10, 2008

If sex is good exercise, why are there fat sluts?


Posted: Mar 3, 2009 05:18 AM    Msg. 2 of 9       
well um i would usume that you known about dormant scripts and it is kinda hard to explain and i havnt tried scripting trigger volumes in mp and so ill just give a example script of what ide think sould work:

Quote:
(script dormant player2
(sleep_until (volume_test_objects 2players (players)) 1)
(game_save or some other code)
)
(script startup player1
(sleep_until (volume_test_objects 2players (players)) 0)
(wake player2)
)


but the thing is im not sure on how to make it so both players have to be at the exact time unless the trigger was infront of a locked door and there was no gap between the door and the trigger volume like so:

Quote:
(script dormant player2_door
(sleep_until (volume_test_objects 2players_door (players)) 1)
(device_set_power door 1.0)
(device_set_position door 1.0)
(game_save or some other code)
)
(script startup player1_door
(sleep_until (volume_test_objects 2players_door (players)) 0)
(wake player2_door)
)


and you could add more dormant script if you wanted it to have more players to be in the trigger volume, but this would work with 2 players at best because with more players like 3 or 4 and player 3 made it to the trigger volume before player 1 (0) it would not wake player 2 so it would have to be in order player 1, 2, 3, 4 to reach the trigger volumes so i would reccommend using just 2 players and even then it would not work always like player2 could beat player1 to the trigger and it wont wake. (if only Bungie added script that would sleep a woken script)

PS. You may have to change the script a bit and fiddle around with it to get the best result and of course to make extra stuff happen.


Gamma927
Joined: Jun 12, 2008

Steam: gamma927


Posted: Mar 3, 2009 06:29 PM    Msg. 3 of 9       
Isn't there an "and" command? Something you can use after an if? Because I want to create a continuous script (don't ask why).


sierra117
Joined: Jan 10, 2008

If sex is good exercise, why are there fat sluts?


Posted: Mar 3, 2009 07:50 PM    Msg. 4 of 9       
i think there is... If there is ive never used it before and wait no i dont wanna ask why


Scott
Joined: Apr 4, 2005

No.


Posted: Mar 3, 2009 07:55 PM    Msg. 5 of 9       
I would assume you would use something similar to the door opening script for multiplayer campaign. I am not a scripter so I don't know the basics.


sierra117
Joined: Jan 10, 2008

If sex is good exercise, why are there fat sluts?


Posted: Mar 4, 2009 11:37 PM    Msg. 6 of 9       
thats the device_set_power and device_set_postition that i used in my 2nd quote. 1.0 mean open and 0.0 mean closed or locked


Gamma927
Joined: Jun 12, 2008

Steam: gamma927


Posted: Mar 4, 2009 11:49 PM    Msg. 7 of 9       
Doesn't matter now. I found it. For anyone who's interested, it's this:

(script continous script
(if
(and
([parameter])
([parameter])
(true
(begin
([stuff])
)
)
)


sierra117
Joined: Jan 10, 2008

If sex is good exercise, why are there fat sluts?


Posted: Mar 6, 2009 01:43 AM    Msg. 8 of 9       
keeping that for reference.


Me KS
Joined: Feb 2, 2008

Desire is Reality. Xfire: jetmaster23


Posted: Mar 6, 2009 11:20 PM    Msg. 9 of 9       
If you actually want to test for any two players at the exact same time, you'd have to use a combination of "and"s and "or"s for each possible combination of players from 0 to 15. Which means 16 players possible as the first player in the trigger times 16 players possible as the second player in the trigger = 256 tests....

Of course, nobody in their right mind has the patience to copy-paste the same lines of code 255 times and change the numbers. Neither do I. I forgot I made this when I read the topic a while back:



(global short plyrnum 0)
(global boolean first_is_in 0)

(global object first_in (list_get (players) 0))
(global object second_in (list_get (players) 0))

(script continuous "name"
(if
(and
(volume_test_object "volume" (list_get (players) plyrnum))
(= first_is_in 0)
)
(begin
(set first_in (list_get (players) plyrnum))
(set first_is_in 1)
)
(if
(and
(volume_test_object "volume" (list_get (players) plyrnum))
(= first_is_in 1)
)
(begin
(set second_in (list_get (players) plyrnum))
(if
(!= first_in second_in)
(begin
(set first_is_in 0)
"insert any commands here"
)
)
)
)
)
)


(script continuous plyrnum_manage
(set plyrnum (+ plyrnum 1))
(if
(> plyrnum 15)
(set plyrnum 0)
)
)



It uses the plyrnum idea from the backpack script and waits for one player to enter, then sets a variable to that first player. Then it waits for a second player, sets another variable to that player, and then checks to make sure both variables aren't set to the same player in order to conclude that two different players are in the volume and then take action. It then repeats the test over and over by setting the boolean back to false. You can make it test only once if you want by getting rid of the line (set first_is_in 0) near the end of the last "begin".

It doesn't check for two players at the exact same time since it has to cycle through the player indexes with the whole plyrnum deal, but it's still fast enough to be reliable.

I'm not sure if the (!=) test works with "object" variables, this isn't tested, I just thought it through. If you think it might be useful, test it out. If it actually works, sweet.
Edited by Me KS on Mar 6, 2009 at 11:23 PM

 

 
Previous Older Thread    Next newer Thread







Time: Thu January 19, 2023 1:42 PM 140 ms.
A Halo Maps Website