
   /* AMXMOD script.
   *
   * (c) Copyright 2000-2002, Vantage
   * This file is provided as is (no warranties).
   *
   *    cs_assault.sma
   *
   *    Thanks to Lucky for making misc module!
   *
   *    Big thanks to parakeet for all his help in debugging!
   *
   *    ***    REQUIREMENTS:        *************************************
   *******
   *
   *    MODULES:
   *
   *    xtrafun,VexdUM for this version
   *
   *    xtrafun,misc for old version - Instructions below
   *
   *
   *    ***************************************************
   *
   *    SERVER CVARS : #(default)
   *
   *    assault_cams  :  0 = CT camera's can be destroyed and restored at
   start of next round. 1 = CT cameras can never be destroyed.
   *    assault_door_hits_req: 2 = Two(0 will disable) grenade hits, near
   door hinges, will destroy door. Will reset at end of round.
   *
   */
   //**********************  OLD     VERSION     COMPILE     INSTRUCTIONS
   ***********************************************
   // Add '//' to beginning of the '#define AMX_0_9_8_PLUS' line below if
   // you're having problems with new version. Save and manually compile.
   (wont work with AMX 0.9.8 though)
   #define AMX_0_9_8_PLUS
   #include <amxmod>
   #include <xtrafun>
   #if defined AMX_0_9_8_PLUS
       #include <Vexd_Utilities>
   #else
       #include <misc>
   #endif
   new ENT_NUM_DOOR
   new ENT_NUM_CAM1
   new ENT_NUM_CAM2
   new ENT_NUM_CAM3
   new ENT_NUM_EVIL
   new CAM_SPARK_POS[3] = { 340, 312, 282 }
   new DOOR_HITS_REQ
   new door_is_destroyed
   new cams_are_destroyed
   new door_hits
   public plugin_init()
   {
       register_plugin("Assault:Cams Fix+","0.9.6","Vantage")

       new mapname[16]
       get_mapname(mapname,15)
       if(equali("cs_assault",mapname)){
           set_task(10.0,"kill_evil_ent",0)
           register_event("23", "dish_kill","a","1=108","3<500","15=2")
           register_event("SendAudio","delay_reset","a","2=%!MRAD_terwin"
   ,"2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
           register_event("TextMsg","reset","a","1=4","2&#Game_C","2&#Gam
   e_w")
           register_event("23", "explosion","a","1=3","6=25")
           register_cvar("assault_cams","0")
           register_cvar("assault_door_hits_req","2")
       }

       return PLUGIN_CONTINUE
   }
   public kill_evil_ent()
   {
       ENT_NUM_DOOR = find_entity(0,classname,"func_door_rotating")
       ENT_NUM_CAM1 = find_entity(0,targetname,"cam1")
       ENT_NUM_CAM2 = find_entity(0,target,"cam2_targ")
       ENT_NUM_CAM3 = find_entity(0,targetname,"cam3")
       ENT_NUM_EVIL = find_entity(0,classname,"trigger_relay")
       #if defined AMX_0_9_8_PLUS
           RemoveEntity(ENT_NUM_EVIL)
       #else
           kill_entity(ENT_NUM_EVIL)
       #endif
       DOOR_HITS_REQ = get_cvar_num("assault_door_hits_req")
   }
   public dish_kill()
   {
       if(!get_cvar_num("assault_cams")){
           cams_are_destroyed = 1
           #if defined AMX_0_9_8_PLUS
               ENT_SetOrigin(ENT_NUM_CAM3,  Float:{704.0,  1584.0, -20.0}
   );
               ENT_SetOrigin(ENT_NUM_CAM2,  Float:{432.0,  2864.0, -20.0}
   );
               ENT_SetOrigin(ENT_NUM_CAM1,  Float:{-672.0, 1632.0, -20.0}
   );
           #else
               move_entity(ENT_NUM_CAM3, 704, 1584, -20)
               move_entity(ENT_NUM_CAM2, 432, 2864 , -20)
               move_entity(ENT_NUM_CAM1, -672, 1632, -20)
           #endif
           set_task(6.0,"deadcam_sparks",119,"",0,"b")
       }
       return PLUGIN_CONTINUE
   }
   public delay_reset()
   {
       set_task(5.0,"reset",0)
       return PLUGIN_CONTINUE
   }
   public reset()
   {
       if(cams_are_destroyed){
           cams_are_destroyed = 0
           #if defined AMX_0_9_8_PLUS
               ENT_SetOrigin(ENT_NUM_CAM3,  Float:{704.0,  1584.0, 368.0}
   );
               ENT_SetOrigin(ENT_NUM_CAM2,  Float:{432.0,  2864.0, 432.0}
   );
               ENT_SetOrigin(ENT_NUM_CAM1,  Float:{-672.0, 1632.0, 384.0}
   );
           #else
               move_entity(ENT_NUM_CAM3,   704,   1584,   368)   //  Move
   cameras
               move_entity(ENT_NUM_CAM2, 432, 2864 , 432)
               move_entity(ENT_NUM_CAM1, -672, 1632, 384)
           #endif
           remove_task(119)
       }
       if(door_is_destroyed){
           #if defined AMX_0_9_8_PLUS
               ENT_SetOrigin(ENT_NUM_DOOR, Float:{696.0, 2236.0, 48.0} );
           #else
               move_entity(ENT_NUM_DOOR, 696,2236,48)
           #endif
           door_is_destroyed = 0
       }
       door_hits = 0
       return PLUGIN_CONTINUE
   }
   public doorfly(xpos_offset,xvelocity)
   {
       message_begin( MSG_ALL, SVC_TEMPENTITY,{0,0,0})
       write_byte(108)
       write_coord( xpos_offset)
       write_coord( 2200)
       write_coord( 60)
       write_coord( 28)
       write_coord( 75)
       write_coord( 50)
       write_coord( xvelocity)
       write_coord( -2500)
       write_coord( 700)
       write_byte( 0 )
       write_short( 12 )
       write_byte( 1 )
       write_byte( 10 )
       write_byte( 8 )
       message_end()
   }
   public explosion()    // grenade hits , maybe others
   {
       if(DOOR_HITS_REQ){
           if(!door_is_destroyed){
               new Float:coord2         // Hold coords of grenade hit
               new Float:coord3
               new Float:coord4

               read_data(2,coord2)
               read_data(3,coord3)
               read_data(4,coord4)
               new c2 = floatround(coord2,floatround_round)
               if(c2  <  740 && c2 > 650){         // Check coords to see
   if near door hinges
                   new c3 = floatround(coord3,floatround_round)
                   if(c3 < 2245 && c3 > 2200){
                       new c4 = floatround(coord4,floatround_round)
                       if(c4 < 75 && c4 > 0){
                           ++door_hits
                           hinge_sparks()
                           if(door_hits == DOOR_HITS_REQ){
                               door_is_destroyed = 1
                               #if defined AMX_0_9_8_PLUS
                                   ENT_SetOrigin(ENT_NUM_DOOR,
   Float:{696.0, 2236.0, -54.0} );
                               #else
                                   move_entity(ENT_NUM_DOOR,
   696,2236,-54)
                               #endif
                               if(c2 <= 696)
                                   doorfly(740, 1500)
                               else
                                   doorfly(660,-1500)
                           }
                       }
                   }
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public hinge_sparks()
   {
       message_begin( MSG_ALL, SVC_TEMPENTITY,{0,0,0})
       write_byte(9)
       write_coord( 700)
       write_coord( 2240)
       write_coord( 80)
       message_end()
       message_begin( MSG_ALL, SVC_TEMPENTITY,{0,0,0})
       write_byte(9)
       write_coord( 700)
       write_coord( 2240)
       write_coord( 30)
       message_end()
       message_begin( MSG_ALL, SVC_TEMPENTITY,{0,0,0})
       write_byte(9)
       write_coord( 690)
       write_coord( 2240)
       write_coord( 80)
       message_end()
       message_begin( MSG_ALL, SVC_TEMPENTITY,{0,0,0})
       write_byte(9)
       write_coord( 690)
       write_coord( 2240)
       write_coord( 30)
       message_end()
   }
   public deadcam_sparks()
   {
       new posnum = random_num(0,2)
       message_begin(  MSG_ALL, SVC_TEMPENTITY,{0,0,0})
       write_byte(111)
       write_coord( 340)
       write_coord( CAM_SPARK_POS[posnum])
       write_coord( 57)
       write_byte(20)
       message_end()
   }
