Scriptproblems


(Zer0Cool) #1

Hi,

i have a music-player that can be build an be destroyed by opposit team.
the object of my map is that to steal smth. and to bring it somewhere, then to build up the player, to keep it build(defend against attackers) and while it is build it shall play a song. The objective is to hear the song till the end. The song shall stop when the player is broken and it shall start again at the point it stopped when its built again. My problem is that i am not that good in scripting. My script wont work and I dont know why.

allied_gold         // <------------- objective         
{ 
    { 
    spawn                
    { 
    wait 200                    
           
    } 

    trigger stolen                      
    { 
    setstate target1 invisible                    
    setstate allied_gold_toi2 invisible           
    wm_announce  "Allies have taken the Axis gold!"    
    } 

    trigger returned                   
    { 
    wm_announce "Axis have returned the Allied gold!"   
    setstate target1 default                   
    setstate allied_gold_toi2 default          
    } 

    trigger captured                    
    { 
    wm_announce "The Allies have secured the Axis gold"         
    setstate target2 invisible                   
    wait 2000              
    trigger vinyl_player setup 
    } 
} 

vinyl_player  // <------------- func_constructible
{ 
    spawn 
    { 
    wait 200 
    constructible_class 2 
    constructible_chargebarreq 0.75 
    setstate real_vinyl_player invisible 
    setstate player_baumaterial invisible 
    setstate vinyl_player invisible 
    } 

    trigger setup  
    { 
    setstate real_vinyl_player invisible 
    setstate player_baumaterial default    
    setstate vinyl_player invisible 
    } 

    buildstart final 
    { 
    setstate real_vinyl_player underconstruction 
    setstate player_baumaterial default 
    setstate vinyl_player invisible 
    } 
     

    built final 
    { 
    setstate real_vinyl_player default 
    setstate player_baumaterial invisible
    setstate vinyl_player default 
    wm_announce "The Vinyl-Player is built!" 
    trigger music_player start 
    } 
     
    decayed final 
    { 
    setstate real_vinyl_player invisible 
    setstate player_baumaterial default 
    setstate vinyl_player invisible 
    } 
    death 
    { 
    setstate real_vinyl_player invisible 
    setstate player_baumaterial default 
    setstate vinyl_player invisible 
    wm_announce "Allies have destoyed the Vinyl-Player" /
    trigger music_player stop 
    } 
} 

music_player   // <------------- script_mover
{ 
  spawn 
  { 
      wait 200 
      accum 0 set 0  // enabled? 
      accum 1 set 200 //counter 
      wm_announce "funktioniert" 
  } 
   

   
  trigger start 
  { 
      accum 0 set 1 
      trigger music_player count_down 
      trigger music_player play_music 
      wm_announce "funktioniert auch"    
  } 
   
   
  trigger stop 
  { 
      accum 0 set 0 
      trigger music_player stop_music 
  } 
   
  trigger count_down 
  { 
      accum 0 abort_if_not_equal 1 
      accum 1 inc -1  
      wait 1000 
      //accum 1 trigger_if_equal 1 music_player set_winner 
      trigger music_player count_down 
  } 
   
  trigger play_music 
  { 
      accum 0 abort_if_not_equal 1 
      playsound sound/alchemytest/flywithme.wav volume 300 
      wm_announce "funktioniert3" 
  } 
   
  trigger stop_music 
  { 
      accum 0 abort_if_not_equal 0 
      //stopsound 
  } 
   
  trigger set_winner 
  { 
        wm_setwinner 0 
      wait 2000 
      wm_endround 
  }  
   
} 

I can bring the obj to the place it shoul be brought and then i can build up the player, but then nothing happens. I cant trigger any parts of the “music_player” the spawn-part sends me the wm_announce but not more.
I tried a lot but always my ET crashed or it just didnt work.
Can someone take a look on it, or even tell me how you would do it …


(S14Y3R) #2

Hi, I’m not sure if you can restart a sound in the middle of playing it. So if you really need to restart on a long .wav, you could chop it up into 5+ peices and set it up to play incrementaly(one at a time). Just a thought.

For your current script, in trigger start, count_down is resetting accum 1 before play_music can start.

You should have count_down trigger play_music, like this:


trigger start
  {
      accum 0 set 1
      trigger music_player count_down

      //trigger music_player play_music
      wm_announce "funktioniert auch"   
  }
   
   
  trigger stop
  {
      accum 0 set 0
      trigger music_player stop_music
  }
   
  trigger count_down
  {
      accum 0 abort_if_not_equal 1
      //accum 1 inc -1 
      wait 1000
      //accum 1 trigger_if_equal 1 music_player set_winner
      //trigger music_player count_down

      trigger music_player play_music
  }
   
  trigger play_music
  {
      accum 0 abort_if_not_equal 1
      accum 0 inc -1 
      playsound sound/alchemytest/flywithme.wav volume 300
      wm_announce "funktioniert3"

      //wait xx   //length of music
      //trigger xxx set_winner :)
  } 

see if that works before thinking of cutting the song. how long is the song btw? 8)


(Zer0Cool) #3

Thank You for the reply. It seems like I cant stop and then start at the position I have stopped,soooo … I splitted the song :slight_smile:

Zer0


(S14Y3R) #4

ah yea, well its easy to play the parts at least :slight_smile:

You’ll want to set it up like this:


spawn
{
	accum 0 set 0
}

trigger start
  {
      trigger music_player count_down

      wm_announce "funktioniert auch"   
  }
   
   
  trigger stop
  {
      trigger music_player stop_music
  }
   
  trigger count_down
  {
      accum 0 inc 1
      wait 500
      accum 0 trigger_if_equal 1 music_player play_music_1      
      accum 0 trigger_if_equal 2 music_player play_music_2      
      accum 0 trigger_if_equal 3 music_player play_music_3      
      accum 0 trigger_if_equal 4 music_player play_music_4      
      accum 0 trigger_if_equal 5 music_player play_music_5

  }
   
  trigger play_music_1
  {
      accum 0 abort_if_not_equal 1
      
      playsound sound/alchemytest/flywithme_1.wav volume 300
      wm_announce "part 1"
      wait (length of part)
      trigger music_player count_down
  }
 
  trigger play_music_2
  {
      accum 0 abort_if_not_equal 2
      
      playsound sound/alchemytest/flywithme_2.wav volume 300
      wm_announce "part 2"
      wait (length of part)
      trigger music_player count_down
  } 
  
  trigger play_music_3
  {
      accum 0 abort_if_not_equal 3
      
      playsound sound/alchemytest/flywithme_3.wav volume 300
      wm_announce "part 3"
      wait (length of part)
      trigger music_player count_down
  }
 
  trigger play_music_4
  {
      accum 0 abort_if_not_equal 4
      
      playsound sound/alchemytest/flywithme_4.wav volume 300
      wm_announce "part 4"
      wait (length of part)
      trigger music_player count_down
  }
 
  trigger play_music_5
  {
      accum 0 abort_if_not_equal 5
      
      playsound sound/alchemytest/flywithme_5.wav volume 300
      wm_announce "part 5"
      wait 1000
      trigger music_player check_state
  }

  trigger check_state
  {
	  accum 0 abort_if_not_equal 5
	  trigger game_manager team_wins
  }

That should play the next peice after one is played, and go back to where it stopped when rebuilt.
Should. :stuck_out_tongue: gl.