game_manager 
{ 
  spawn 
  { 
    wm_axis_respawntime 18 // 18 sec. 
    wm_allied_respawntime 15 // 15 sec. 
    wm_set_round_timelimit 40 // 40 Minuten 

    // Objectives 
    // 1: Primary: Destroy the entry to the second floor into Axis base
    // 2: Primary: Destroy the secret document safe into Axis base
    // 3: Primary: Escape with the secret documents and bring it to big radar station 
    // 4: Secondary: Destroy the Axis gate to the roof ;)
    // 5: Secondary: Destroy Flag cannon.
    // 6: Secondary: Construct a ramp to the Flag and radar station.
    // 7: Secondary: Destroy alternate entry on the roof.

      // Number of all objectives
      wm_number_of_objectives 7
      
      // Number of primary objectives
      wm_set_main_objective 3 0 
      wm_set_main_objective 3 1 

      // wm_objective_status <objective> <team> <status (0=neutral 1=complete 2=failed) 
      wm_objective_status 1 0 0 
      wm_objective_status 1 1 0 

      wm_objective_status 2 0 0 
      wm_objective_status 2 1 0
      
      wm_objective_status 3 0 0 
      wm_objective_status 3 1 0
      
      wm_objective_status 4 0 0
      wm_objective_status 4 1 0 
      
      wm_objective_status 5 0 0
      wm_objective_status 5 1 0

      wm_objective_status 6 0 0
      wm_objective_status 6 1 0
      
      wm_objective_status 7 0 0
      wm_objective_status 7 1 0 
      
    // Stopwatch Modedefending team 
    wm_set_defending_team 0 

    // Gewinner Team, wenn Zeit abläuft 
    wm_setwinner 0 

    wait 300
   
    // (0=Axis, 1=Allies)
    wm_addteamvoiceannounce 0 "defend_entrance_1" 
    wm_addteamvoiceannounce 0 "defend_secretdocs"
    wm_addteamvoiceannounce 1 "destroy_entrance_1" 
    wm_addteamvoiceannounce 1 "steal_secretdocus"   
  
    // Switch for slide door => init: red
    remapshader textures/lights/light_tp_m07off textures/lights/light_tp_m07
    remapshaderflush
  
  } // end spawn 

} // end game_manager

//////////////////////////////////////////
//// constructable team door for Allies //
//////////////////////////////////////////
cteamdoor1
{
  spawn
  {
    wait 50
    trigger self setup
    constructible_class 2 // Dyno+Satchel
    // constructible_constructxpbonus 5
  }

  trigger setup
  {
    setstate axisteamdoor1 invisible // team door entity
  }

  built final
  {
    setstate cteamdoor1_fake invisible // fake team door
    setstate axisteamdoor1 default // team door entity
    wm_announce "Allies Team have built a team door!"
  }

  decayed final
  {
    trigger self setup
  }

}


/////////////////////////////////////////// 
// Forward Spawn point - Initially neutral 
/////////////////////////////////////////// 

forwardspawn1_flag 
{ 
   spawn 
   { 
      wait 200 
      accum 0 set 2                            // Who owns flag: 0-Axis, 1-Allied 
      accum 9 set 0                            // Axis have not captures flag once yet 
      accum 8 set 0                            // Allies have not captured flag once yet 
      accum 2 set -1                           // wie lange ist die flagge gehalten 
      setstate forwardspawn1_wobj invisible    //remove Axis flag command map marker until captured 
   } 
    
  trigger axis_capture                         // Touched by an Axis player 
   { 
      accum 0 abort_if_equal 0                 // do Axis own flag? 
      accum 0 set 0                            // Axis own the flag 
      wm_announce "Axis reclaim the Forward Spawn!" 
      setstate forwardspawn1_wobj default 
        
      setautospawn "Forward Spawn"   0         // Set Axis to forward spawn 
        
      alertentity forwardspawn1_wobj           // Switch command map marker 
      accum 2 set -1 
      accum 8 abort_if_equal 1                 // Abort if Allies have captured flag once 
      accum 9 abort_if_equal 1                 // Abort if axis have captured flag once 
      alertentity forwardspawn1_wobj 
      accum 9 set 1                            // Allies have captured at least once 
   }

   trigger allied_capture                      // Touched by an allied player 
   { 
      accum 0 abort_if_equal 1                 // do Allies own flag? 
      accum 0 set 1                            // Allies own the flag 
      wm_announce "Allies capture the Forward Spawn!" 
      wm_announce "Defend the Forward Spawn longer than 2 minutes!"
      setstate forwardspawn1_wobj default 
      alertentity forwardspawn1_wobj           // Switch command map marker 
      setautospawn "Forward Spawn"   1         // Set Allies to forward spawn 
      accum 8 set 1                            // Allies have captured flag at least once 
      accum 2 set 0 
      trigger self count_seconds 
   } 

   trigger count_seconds 
   { 
      wait 1000 
      accum 2 abort_if_equal -1 
      accum 2 inc 1 
      trigger self kill 
      accum 2 abort_if_greater_than 119       // wartezeit weniger 1 sekunde 
      trigger self count_seconds 
   } 

   trigger force_allied 
   { 
      accum 0 abort_if_equal 1                // Do Allies own the flag? 
      alertentity forwardspawn1_wobj          // Switch command map marker 
      alertentity forwardspawn1_spawns        // Switch all spawnpoints 
      setautospawn "Forward Spawn"   1        // Set Allies to forward spawn 
      accum 2 set -1 
   } 
    
   trigger kill 
   { 
      printaccum 2
      accum 2 abort_if_less_than 120          // wartezeit in sec. 
      accum 2 set -1 
      remove                                  // Remove self (flag model) 
      playsound sound/hq_bunkercapd.wav
      wm_announce "Now Allies have forward spawn forever!"
   } 
} // end forwardspawn1_flag

//////////////////////////////////////////////////////////
// Destroy the entry to the second floor into Axis base
//////////////////////////////////////////////////////////

all_obj_1 
  { 
    spawn 
  { 
    wait 200 
    constructible_class 3 // 2 = satchel | 3 = dynamite 
  } 
    death 
    { 
      wait 500
      wm_announce "Allied team has destroyed the entry to second floor!" 
      
      // wm_objective_status <objective> <team> <status (0=neutral 1=complete 2=failed)
      wm_objective_status 1 0 2 
      wm_objective_status 1 1 1
    } 
}

///////////////////////////////////////////////////
// Destroy the secret document safe into Axis base
///////////////////////////////////////////////////

all_obj_2
{  
   spawn 
   { 
      wait 200 
      constructible_class 3  //classes: 1 (explosives), 2 (satchel), 3 (dynamite) 
   }

    death 
    { 
      wait 50
      wm_announce "Allied team has destroyed the safe for secret documents!"
      wm_announce "Escape with documents to radar station!" 

      // wm_objective_status <objective> <team> <status (0=neutral 1=complete 2=failed)
      wm_objective_status 2 0 2         // setzt den objective-Status 
      wm_objective_status 2 1 1
    } 
}

///////////////////////////////////////////////////////////////////////
// Escape with the secret documents and bring it to big radar station
///////////////////////////////////////////////////////////////////////

SecretDocuments 
{  
    death 
    { 
      wait 50
      wm_announce "Allied team escaped with the secret documents!" 

      // wm_objective_status <objective> <team> <status (0=neutral 1=complete 2=failed)
      wm_objective_status 3 0 2
      wm_objective_status 3 1 1

      wm_setwinner 1 // 1 = Allied | 0 = Axis 
      wait 3000
      wm_endround 
    } 
}

///////////////////////////////////////////////////
// Build/Destroy the Axis gate to the roof (ladder)
///////////////////////////////////////////////////

ladder 
{ 
    spawn 
  {
    wait 200   
    trigger self setup 
    constructible_class 3 
    constructible_destructxpbonus 5
  } 
  trigger setup 
  { 
    setstate ladder invisible 
    setstate baumaterial default 
  } 
  buildstart final 
  {  
    setstate ladder underconstruction 
    setstate baumaterial default 
  } 
  built final 
  { 
    setstate ladder default 
    setstate baumaterial invisible 
    wm_objective_status 4 0 1 
    wm_objective_status 4 1 2
    playsound sound/hq_conconst_a.wav
    wm_announce "The ladder and steel wall has been constructed!" 
  } 
  decayed final 
  { 
    setstate ladder invisible 
    setstate baumaterial default 
  } 
  death 
  { 
    wait 50
    setstate ladder invisible 
    setstate baumaterial default
    
    wm_objective_status 4 0 2 
    wm_objective_status 4 1 1 
    wm_announce "Allied team has destroyed the ladder and steel wall to roof!" 
  } 
  
}

////////////////////////
// Destroy Flak cannon
////////////////////////

all_obj_3 
{  
   spawn 
   { 
      wait 200 
      constructible_class 3  //classes: 1 (explosives), 2 (satchel), 3 (dynamite) 
      constructible_destructxpbonus 5
   }
    death 
    { 
      wait 50
      wm_announce "Allied team has destroyed the flak cannon!" 

      // wm_objective_status <objective> <team> <status (0=neutral 1=complete 2=failed)
      wm_objective_status 5 0 2
      wm_objective_status 5 1 1
    } 
}

///////////////////////////////////////////////////
// Construct a ramp to the Flag and radar station.
///////////////////////////////////////////////////

ladder2 
{ 
    spawn 
  {
    wait 200 
    trigger self setup 
    constructible_class 3 
    // constructible_constructxpbonus 8
    // constructible_destructxpbonus 5
  } 

  trigger setup 
  { 
    setstate ladder2 invisible 
    setstate baumaterial2 default 
  } 
  
  buildstart final 
  {  
    setstate ladder2 underconstruction 
    setstate baumaterial2 default 
  } 

  built final 
  { 
    setstate ladder2 default 
    setstate baumaterial2 invisible
    wait 50
    playsound sound/hq_rampcon.wav
    wm_announce "The ramp has been constructed!" 
    wm_objective_status 6 0 2
    wm_objective_status 6 1 1 
  } 

  decayed final 
  { 
    setstate ladder2 invisible 
    setstate baumaterial2 default 
  } 

  death 
  { 
    setstate ladder2 invisible 
    setstate baumaterial2 default  
    wm_announce "Axis team has destroyed the ramp!" 
    wm_objective_status 6 0 1
    wm_objective_status 6 1 2
  } 
  
}


////////////////////////////////////////////////////
// switches for slide door (red=close/green=open) //
////////////////////////////////////////////////////

slidedoor_switch
{
  trigger switch_green
  {
    remapshader textures/lights/light_tp_m06off textures/lights/light_tp_m06
    remapshaderflush
    wm_announce "Slide door for secret room is unlocked now!"
    wait 50
    remapshader textures/lights/light_tp_m07off textures/lights/light_tp_m07off
    remapshaderflush
  }

  trigger switch_red
  {
    remapshader textures/lights/light_tp_m07off textures/lights/light_tp_m07
    remapshaderflush
    wait 50
    remapshader textures/lights/light_tp_m06off textures/lights/light_tp_m06off
    remapshaderflush
  }
}
        

///////////////////////////////////////////////
// Destroy the alternate entry to second floor
///////////////////////////////////////////////
roofdoor
{ 
    spawn 
  { 
    wait 200 
    constructible_class 3 // 2 = satchel | 3 = dynamite 
  } 
    death 
    { 
      wait 50
      wm_announce "Allied team has destroyed the entry to second floor!"
      
      // wm_objective_status <objective> <team> <status (0=neutral 1=complete 2=failed)
      wm_objective_status 7 0 2 
      wm_objective_status 7 1 1
    }   


} // end script
