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 »Script isn't working D:

Author Topic: Script isn't working D: (4 messages, Page 1 of 1)
Moderators: Dennis

DaGreat B R I A N
Joined: May 16, 2009

Move it, Marines!


Posted: Jun 14, 2009 09:00 AM    Msg. 1 of 4       
Ok, so here is my script that allows people to have their MP biped say random stuff when they press the flashlight button.
(global short x 0)

(global short plyrnum 0)

(script continuous plyrnum_stuff
(if
(= plyrnum 15)
(begin
(set plyrnum 0)
)
(begin
(set plyrnum (+ plyrnum 1))
)
)
)

(script continuous change_x
(set x (random_range 0 2) )
)

(script continuous taunt
(sleep_until (= (unit_get_current_flashlight_state (unit (list_get (players) plyrnum))) true))
(if
(= x 0)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\actions\shooting" (unit (list_get (players) plyrnum)) 1)
)
)
(if
(= x 1)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\groupcomm\searchreport" (unit (list_get (players) plyrnum)) 1)
)
)
(if
(= x 2)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\postcombatcomments\celebration" (unit (list_get (players) plyrnum)) 1)
)
)
(sleep_until (= (unit_get_current_flashlight_state (unit (list_get (players) 0))) false))
(if
(= x 0)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\actions\shooting" (unit (list_get (players) plyrnum)) 1)
)
)
(if
(= x 1)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\groupcomm\searchreport" (unit (list_get (players) plyrnum)) 1)
)
)
(if
(= x 2)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\postcombatcomments\celebration" (unit (list_get (players) plyrnum)) 1)
)
)
)


Problem? Well, simply put, when I press the flashlight button on the cyborg (to test) or the Marine biped I'm using, nothing plays. I'm not sure why either.


Polamee
Joined: Feb 25, 2008

MP2SPMT's founder


Posted: Jun 14, 2009 09:39 AM    Msg. 2 of 4       
Bleh. The part where you detected if x equaled 1, 2 or 0 in a single script was confusing. You want the player to play the sound impulse both when the flashlight state is flase and true?

/me simplifies some stuff...


(global "short" plyrnum 0) 
(global "short" x 0 )

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

(script continuous change_x
(set x (random_range 0 2))
)

(script continuous taunt
(sleep_until (= (unit_get_current_flashlight_state (unit (list_get (players) plyrnum))) true)) (if
(= x 0)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat \actions\shooting" (unit (list_get (players) plyrnum)) 1 ))
(if
(= x 1)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat \groupcomm\searchreport" (unit (list_get (players) plyrnum)) 1) ) )
(if
(= x 2)
(begin
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\postcombatcomments\celebration" (unit (list_get (players) plyrnum)) 1) ) )


Instead of bothering with all this, why not split the sound into permutations? :]


Gamma927
Joined: Jun 12, 2008

Steam: gamma927


Posted: Jun 14, 2009 10:33 AM    Msg. 3 of 4       
Actually Polamee, I believe it should be like that. It will play when you press the flashlight to turn it on, and also play when you turn it off.


Me KS
Joined: Feb 2, 2008

Desire is Reality. Xfire: jetmaster23


Posted: Jun 14, 2009 12:19 PM    Msg. 4 of 4       
Your script should have played the sound. Even though your script could use some clean up, it should work.

However, the "sleep_until" in this case has to go. You have the right idea, but we're dealing with multiple players here.

If one player turns on his flashlight and the plyrnum is set to him, then the script moves on to the next "sleep_until" which waits for the player to turn his flashlight off. Well, in the next tick, the next player is selected by the plyrnum, and if that player was just sitting around with his flashlight off, the script would play a sound for him out of nowhere.

In addition, if that next player did have his flashlight on, he actually wouldn't have the sound play. It would work backwards for whichever player is selected next.

So, I fixed it by just using one "if" test. It tests for whether the current player has his flashlight, and if he does, it just turns it off immediately and then plays the sound. This prevents any issues with the flashlight.

Since all players will have their flashlight shut off when their sound is played, we can safely test for just having the flashlight turned on instead of worrying about both on and off.

I also cleaned up the script and moved the plyrnum script after the taunt script.

Hopefully this script will work for you. If it compiles correctly, tell me. I saw a perfect opportunity for the "cond" test which I've never used before and I want to see if I got it right xD.

On a side note, even if this script works, you should do what Polamee said and just stick those three sounds into one sound tag as permutations. Either way, it will work the same, but it would be much easier to let the game choose randomly than have to script that in.

That way, you can eliminate the "x" variable and just check the flashlight, and then play that one sound. Whatever suits you best.

(global short x 0)
(global short plyrnum 0)

(script continuous change_x
(set x (random_range 0 2))
)

(script continuous taunt
(if
(= (unit_get_current_flashlight_state (unit (list_get (players) plyrnum))) 1)
(begin
(unit_set_desired_flashlight_state (unit (list_get (players) plyrnum)) 0)
(cond
(
(= x 0)
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\actions\shooting" (unit (list_get (players) plyrnum)) 1)
)
(
(= x 1)
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\groupcomm\searchreport" (unit (list_get (players) plyrnum)) 1)
)
(
(= x 2)
(sound_impulse_start "sound\dialog\marines\fitzgerald\conditional\combat2\postcombatcomments\celebration" (unit (list_get (players) plyrnum)) 1)
)
)
)
)
)

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

 

 
Previous Older Thread    Next newer Thread







Time: Thu January 19, 2023 7:19 AM 140 ms.
A Halo Maps Website