    
     _    _  _                  _                                    
    | |  | || |                | |                                   
    | |__| || |_ _ __       ___| |_ __ _ _ ____      ____ _ _ __ ___   
    | '_ \__   _| '_ \     / __| __/ _` | '__\ \ /\ / / _` | '__/ __|      
    | |_) | | | | |_) |    \__ \ || (_| | |   \ V  V / (_| | |  \__ \      
    |_.__/  |_| | .__/     |___/\__\__,_|_|    \_/\_/ \__,_|_|  |___/        
                | |                                               
                |_|                                               

    ... a CS:S mod
    
    Version 2.0

    this code was written by me, b4p. and updated by Max42
    
    this is a server-side mod that will only run on dedicated servers.
    
    this mod should stick to the original CS:S gameplay as much as possible.  <-- read that twice
    
    please do not do any of the following:    
        do not distribute modified versions of this code
        do not drastically alter this code for use on public (non-passworded) servers
        do not distribute the materials, models, or sounds without README.txt and es_b4p_starwars.txt
    

    important notes for admins: 
        
        say "swadmin" in game to access the admin menu
        
        i added classic mode so that only 2 models are needed.
        server admins need to use sv_downloadurl so that clients can download the models quickly.
        if you do no use sv_downloadurl it is likely that very few people will want to play on your server.
        if you're using sv_downloadurl look into using bzip2.
        sv_downloadurl requires a webhost.  if you dont know what that is, just try using classic mode.
        links for sv_downloadurl and bzip2:
            http://forums.mattie.info/cs/forums/viewtopic.php?t=516
            http://forums.srcds.com/showthread.php?tid=1077
            http://www.mani-admin-plugin.com/oldsite/forums/viewtopic.php?t=8549


    notes:  

        other than bug fixes please do not modify this code (unless your server is passworded)
        
        changing default values for things is ok.
        now, having said that...
        please do not modify this code to contain any leveling systems, or experience-based systems.
        this mod was never intended to include such things.  there are already plenty of great
        mods that include that functionality.  

        this mod should stick to the original CS:S gameplay as much as possible.  <-- read that twice

        please try out classic mode on your servers.  
        it's really cool seeing a whole team of stormtroopers coming at you.
        
        in classic mode, if your server is configured properly, there will be only 2 models to download.
        this makes it much easier for people to join.
            
    
    basic features:
    
        - 12 starwars models
            - boba fett
            - c3po
            - chewbacca
            - imperial officer
            - jawa
            - rebel soldier
            - rodian (aka greedo)
            - snow trooper
            - storm trooper
            - tusken raider
            - vader
            - yoda            
        - menu for selecting models (if not in classic mode)
        - admin menu
        - weapon lasers
            - laser sounds for weapons
            - ability to adjust laser
                - style
                - origin
                - team colors
                - start/end width
        - light saber sound effects for knife
        - boba fett has a working jetpack with sounds
        - jedi have force lightning

    
    required plugins:
    
        eventscripts v1.1:
        http://forums.mattie.info/cs/forums/viewtopic.php?t=6388
        http://mattie.info/downloads/mattie_eventscripts.zip
    
        mani admin 1.2BetaM RC7:
        http://www.mani-admin-plugin.com
        
        es_tools plugin v.415:
        http://forums.mattie.info/cs/forums/viewtopic.php?t=3413
        http://forums.mattie.info/cs/forums/viewforum.php?f=42
    
    
    credits:
 
        almost all meshes, textures, and sounds created by raven software (http://www.ravensoft.com/)
        for "Jedi Knight 3: Jedi Academy".

        many models originated here (basemodels.zip):
        http://jediknight2.filefront.com/file/Raven_Animation_and_Model_Source_Files_Part_2;26625

        vader came from here (vadervm2.2.zip):
        http://jediknight2.filefront.com/file/Darth_Vader;41054
        credits for vader: Mars Marshall "NeoMarz1"

        animations came from Counter-Strike Source
        
        skeletons were heavily modified versions of the CS:S rig provided in the HL2 SDK
        all modifications to this rig were made by b4p
        
        all character models were manually converted to CS:S by b4p
        
        all code below was written by b4p
        
        special thanks to:
            SoftImage for making SoftImage|XSI (www.softimage.com)
            mattie and awuh0 over at forums.mattie.info/cs/forums


///////////////////////////
// code
///////////////////////////


    block load
    { 
        //////////////////////////////////////
        // Defaults
        //////////////////////////////////////
        
            es_xsetinfo phys_pushscale 5000

            es_xsetinfo b4p_sw_jediModeEnabled 0
            es_xsetinfo b4p_sw_jediShootLightning 1
            es_xsetinfo b4p_sw_classicModeEnabled 0

            es_xsetinfo b4p_sw_bobaJetsEnabled 1
            es_xsetinfo b4p_sw_weaponSoundsEnabled 1
            es_xsetinfo b4p_sw_charSoundsEnabled 1
            es_xsetinfo b4p_sw_lasers_trigEnabled 1
            es_xsetinfo b4p_sw_lasers_enabled 1
            es_xsetinfo b4p_sw_lasers_teamColorsEnabled 1

            es_xsetinfo b4p_sw_bobaFettGravity 0.25
            es_xsetinfo b4p_sw_normalGravity 1
            
            es_xsetinfo b4p_sw_jabbaLaughEnabled 1


        //////////////////////////////////////
        // Admins 
        //////////////////////////////////////
            // say "swadmin" in game to access the admin menu
            es_xsetinfo b4p_sw_admins "STEAM_0:0:00001"
            // example: es_xsetinfo b4p_sw_admins "STEAM_0:0:00001,STEAM_0:0:00002,STEAM_0:0:00003" 
			es_xsetinfo b4p_sw_admins "STEAM_0:1:12343893,STEAM_0:1:3485939"
        //////////////////////////////////////
        // laser offsets
        //////////////////////////////////////

            // the forward offset *should* be different for every gun, but this seems about right on average (at least for 3rd person view)
            // first person view looks better at around 32 or even maybe 30, so 36 is a good compromise
            es_xsetinfo b4p_sw_lasers_forwardOffset 36
            // these next two offsets look about perfect in my opinion
            es_xsetinfo b4p_sw_lasers_rightOffset 3
            es_xsetinfo b4p_sw_lasers_upOffset -3


        //////////////////////////////////////
        // laser colors, opacity, speed, style, and width
        //////////////////////////////////////

            // Team A is the Empire

            // Team A's default color is red
            es_xsetinfo b4p_sw_lasers_teamA_red 255
            es_xsetinfo b4p_sw_lasers_teamA_green 0
            es_xsetinfo b4p_sw_lasers_teamA_blue 0

            // Team B's default color is blue
            es_xsetinfo b4p_sw_lasers_teamB_red 255
            es_xsetinfo b4p_sw_lasers_teamB_green 0
            es_xsetinfo b4p_sw_lasers_teamB_blue 0

            // Default is white (if no team colors)
            es_xsetinfo b4p_sw_lasers_default_red 255
            es_xsetinfo b4p_sw_lasers_default_green 255
            es_xsetinfo b4p_sw_lasers_default_blue 255

            es_xsetinfo b4p_sw_lasers_opacity 255
            es_xsetinfo b4p_sw_lasers_speed 100

            es_xsetinfo b4p_sw_lasers_style b4p_tracer1
            es_xsetinfo b4p_sw_lasers_startWidth 3
            es_xsetinfo b4p_sw_lasers_endWidth 3
            es_xsetinfo b4p_sw_lightning_startWidth 5
            es_xsetinfo b4p_sw_lightning_endWidth 50

/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY BELOW THIS LINE
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////
        // Model Information
        //////////////////////////////////////

            es_xsetinfo b4p_sw_modelHome "player/b4p"

            es_xsetinfo b4p_sw_empireModelCount 5
            es_format b4p_sw_EmpireModelName1 "Storm Trooper {Short Range}"
            es_format b4p_sw_EmpireModelFileName1 "b4p_stormt"
            es_format b4p_sw_EmpireModelName2 "Snow Trooper {Sniper Elite}"
            es_format b4p_sw_EmpireModelFileName2 "b4p_snowtrooper"
            es_format b4p_sw_EmpireModelName3 "Rodian {Grenader}"
            es_format b4p_sw_EmpireModelFileName3 "b4p_rodian"
            es_format b4p_sw_EmpireModelName4 "Imperial Officer {Sniper}"
            es_format b4p_sw_EmpireModelFileName4 "b4p_imperial"
            es_format b4p_sw_EmpireModelName5 "Boba Fett {Assault}"
            es_format b4p_sw_EmpireModelFileName5 "b4p_bobafett"
            es_format b4p_sw_EmpireModelName6 "Darth Vader"
            es_format b4p_sw_EmpireModelFileName6 "b4p_vader"

            es_xsetinfo b4p_sw_rebelModelCount 5
            es_format b4p_sw_RebelModelName1 "Rebel Soldier {Assault}"
            es_format b4p_sw_RebelModelFileName1 "b4p_rebel"
            es_format b4p_sw_RebelModelName2 "Wookie {Sniper}"
            es_format b4p_sw_RebelModelFileName2 "b4p_chewbacca"
            es_format b4p_sw_RebelModelName3 "Jawa {Grenader}"
            es_format b4p_sw_RebelModelFileName3 "b4p_jawa"
            es_format b4p_sw_RebelModelName4 "Tusken Raider {Sniper Elite}"
            es_format b4p_sw_RebelModelFileName4 "b4p_tusken"
            es_format b4p_sw_RebelModelName5 "C3PO {Short Range}"
            es_format b4p_sw_RebelModelFileName5 "b4p_c3po"
            es_format b4p_sw_RebelModelName6 "Yoda"
            es_format b4p_sw_RebelModelFileName6 "b4p_yoda"


       //////////////////////////////////////
        // trig stuff
        //////////////////////////////////////

            // a temporary variable used to convert from coordinate systems
            es_xsetinfo b4p_sw_tempVar 0.0

            // the player's location    
            es_xsetinfo b4p_sw_playerX 0.0 
            es_xsetinfo b4p_sw_playerY 0.0
            es_xsetinfo b4p_sw_playerZ 0.0

            // the length of the laser before moving the origin.  used to find b4p_phi.  
            // it's our initial radius in polar coordinates
            es_xsetinfo b4p_sw_laserLength 0.0

            // the difference in location between the two points of the laser line before calculations
            es_xsetinfo b4p_sw_offsetX 0.0
            es_xsetinfo b4p_sw_offsetY 0.0
            es_xsetinfo b4p_sw_offsetZ 0.0

            // the above values squared
            es_xsetinfo b4p_sw_offsetXsqr 0.0
            es_xsetinfo b4p_sw_offsetYsqr 0.0
            es_xsetinfo b4p_sw_offsetZsqr 0.0

            // the length of the laser's XY projection, or sqrt[b4p_offsetXsqr + b4p_offsetYsqr]
            es_xsetinfo b4p_sw_offsetXY 0.0

            // used to represent polar coordinates.  
            // the first radius used is b4p_sw_laserLength
            // the new radius used is b4p_sw_lasers_forwardOffset
            es_xsetinfo b4p_sw_theta 0.0
            es_xsetinfo b4p_sw_phi 0.0

            // the distance the origin should move after making calculations
            es_xsetinfo b4p_sw_deltaX 0.0
            es_xsetinfo b4p_sw_deltaY 0.0
            es_xsetinfo b4p_sw_deltaZ 0.0


        //////////////////////////////////////
        // Misc
        //////////////////////////////////////

            // to be consistent across all servers, DO NOT MODIFY THIS TEAM NUMBER on public servers!
            es_xsetinfo b4p_sw_empireTeamNumber 3
            // 2 (terrorist) / 3 (counter-terrorist) 
            
            es_xsetinfo b4p_sw_randNum 0
            es_xsetinfo b4p_sw_teamNumber 0    
            es_xsetinfo b4p_sw_randPlayer 0
            es_xsetinfo b4p_sw_playerName 0
            es_xsetinfo b4p_sw_weapon_was_fired 0
            es_xsetinfo b4p_sw_modelName 0
            es_xsetinfo b4p_sw_modelPath 0

            es_keygroupdelete b4p_sw_key
            es_keygroupcreate b4p_sw_key

            es_xsetinfo b4p_starwars_mod_version 2.0
            es_makepublic b4p_starwars_mod_version
    }


    block unload
    {
        es_keygroupdelete b4p_sw_key
    }

    event es_map_start
    {
	downloadable sound\b4p\char\chewbacca\chewbacca1.Wav
b4p     downloadable sound\b4p\char\yoda\laugh1.wav
  	downloadable sound\b4p\char\jabba\laugh1.Wav
	downloadable sound\b4p\char\chewbacca\taunt.mp3
	downloadable sound\b4p\char\jawa\victory2.mp3
        downloadable sound\b4p\char\jawa\chatter2.mp3
	downloadable sound\b4p\char\tusken\taunt.mp3
        downloadable sound\b4p\char\tusken\confuse1.mp3
	downloadable sound\b4p\char\extras\bobbadeath.mp3
	downloadable sound\b4p\char\extras\c3podeath.mp3
	downloadable sound\b4p\char\extras\chewedeath.mp3
	downloadable sound\b4p\char\extras\iodeath.mp3
	downloadable sound\b4p\char\extras\jawadeath.mp3
	downloadable sound\b4p\char\extras\jump.mp3
	downloadable sound\b4p\char\extras\rebeldeath.mp3
	downloadable sound\b4p\char\extras\rodiandeath.mp3
	downloadable sound\b4p\char\extras\snowdeath.mp3
	downloadable sound\b4p\char\extras\ststardef.mp3
	downloadable sound\b4p\char\extras\stdef.mp3
	downloadable sound\b4p\char\extras\snowstardef.mp3
	downloadable sound\b4p\char\extras\snowdef.mp3
	downloadable sound\b4p\char\extras\rodstardef.mp3
	downloadable sound\b4p\char\extras\roddef.mp3
	downloadable sound\b4p\char\extras\iostardef.mp3
	downloadable sound\b4p\char\extras\iodef.mp3
	downloadable sound\b4p\char\extras\vaderstrdef.mp3
	downloadable sound\b4p\char\extras\bobastardef.mp3
	downloadable sound\b4p\char\extras\bobadef.mp3
	downloadable sound\b4p\char\extras\rebexplo.mp3
	downloadable sound\b4p\char\extras\rebplant.mp3
	downloadable sound\b4p\char\extras\3poexpl.mp3
	downloadable sound\b4p\char\extras\3poplant.mp3
	downloadable sound\b4p\char\extras\taunt2.mp3
	downloadable sound\b4p\char\extras\vaderdeuse.mp3
	downloadable sound\b4p\char\extras\yadoexplo.mp3
	downloadable sound\b4p\char\extras\stdeath.mp3
	downloadable sound\b4p\char\extras\taunt.mp3
	downloadable sound\b4p\char\extras\tauntb.mp3
	downloadable sound\b4p\char\extras\tuskendeath.mp3
	downloadable sound\b4p\char\extras\vaderdeath.mp3
	downloadable sound\b4p\char\extras\yodadeath.mp3
	downloadable sound\b4p\weapons\blaster\alt_fire.mp3
	downloadable sound\b4p\weapons\blaster\fire.mp3
	downloadable sound\b4p\weapons\boba\bf_flame.mp3
	downloadable sound\b4p\weapons\force\lightning.mp3
	downloadable sound\b4p\weapons\force\lightninghit1.mp3
	downloadable sound\b4p\weapons\force\lightninghit2.mp3
	downloadable sound\b4p\weapons\force\lightninghit3.mp3
	downloadable sound\b4p\weapons\saber\saberhup1.mp3
	downloadable sound\b4p\weapons\saber\saberhup2.mp3

	downloadable sound\b4p\weapons\saber\saberhup3.mp3

	downloadable sound\b4p\weapons\saber\saberhup4.mp3

	downloadable models\player\b4p\b4p_bobafett\b4p_bobafett.dx80.vtx
	downloadable models\player\b4p\b4p_bobafett\b4p_bobafett.dx90.vtx
	downloadable models\player\b4p\b4p_bobafett\b4p_bobafett.mdl
	downloadable models\player\b4p\b4p_bobafett\b4p_bobafett.phy
	downloadable models\player\b4p\b4p_bobafett\b4p_bobafett.sw.vtx
	downloadable models\player\b4p\b4p_bobafett\b4p_bobafett.vvd
	downloadable models\player\b4p\b4p_bobafett\b4p_bobafett.xbox.vtx
	downloadable models\player\b4p\b4p_c3po\b4p_c3po.dx80.vtx
	downloadable models\player\b4p\b4p_c3po\b4p_c3po.dx90.vtx
	downloadable models\player\b4p\b4p_c3po\b4p_c3po.mdl
	downloadable models\player\b4p\b4p_c3po\b4p_c3po.phy
	downloadable models\player\b4p\b4p_c3po\b4p_c3po.sw.vtx
	downloadable models\player\b4p\b4p_c3po\b4p_c3po.vvd
	downloadable models\player\b4p\b4p_chewbacca\b4p_chewbacca.dx80.vtx
	downloadable models\player\b4p\b4p_chewbacca\b4p_chewbacca.dx90.vtx
	downloadable models\player\b4p\b4p_chewbacca\b4p_chewbacca.mdl
	downloadable models\player\b4p\b4p_chewbacca\b4p_chewbacca.phy
	downloadable models\player\b4p\b4p_chewbacca\b4p_chewbacca.sw.vtx
	downloadable models\player\b4p\b4p_chewbacca\b4p_chewbacca.vvd
	downloadable models\player\b4p\b4p_imperial\b4p_imperial.dx80.vtx
	downloadable models\player\b4p\b4p_imperial\b4p_imperial.dx90.vtx
	downloadable models\player\b4p\b4p_imperial\b4p_imperial.mdl
	downloadable models\player\b4p\b4p_imperial\b4p_imperial.phy
	downloadable models\player\b4p\b4p_imperial\b4p_imperial.sw.vtx
	downloadable models\player\b4p\b4p_imperial\b4p_imperial.vvd
	downloadable models\player\b4p\b4p_jawa\b4p_jawa.dx80.vtx
	downloadable models\player\b4p\b4p_jawa\b4p_jawa.dx90.vtx
	downloadable models\player\b4p\b4p_jawa\b4p_jawa.mdl
	downloadable models\player\b4p\b4p_jawa\b4p_jawa.phy
	downloadable models\player\b4p\b4p_jawa\b4p_jawa.sw.vtx
	downloadable models\player\b4p\b4p_jawa\b4p_jawa.vvd
	downloadable models\player\b4p\b4p_jawa\b4p_jawa.xbox.vtx
	downloadable models\player\b4p\b4p_rebel\b4p_rebel.dx80.vtx
	downloadable models\player\b4p\b4p_rebel\b4p_rebel.dx90.vtx
	downloadable models\player\b4p\b4p_rebel\b4p_rebel.mdl
	downloadable models\player\b4p\b4p_rebel\b4p_rebel.phy
	downloadable models\player\b4p\b4p_rebel\b4p_rebel.sw.vtx
	downloadable models\player\b4p\b4p_rebel\b4p_rebel.vvd
	downloadable models\player\b4p\b4p_rebel\b4p_rebel.xbox.vtx
	downloadable models\player\b4p\b4p_rodian\b4p_rodian.dx80.vtx
	downloadable models\player\b4p\b4p_rodian\b4p_rodian.dx90.vtx
	downloadable models\player\b4p\b4p_rodian\b4p_rodian.mdl
	downloadable models\player\b4p\b4p_rodian\b4p_rodian.phy
	downloadable models\player\b4p\b4p_rodian\b4p_rodian.sw.vtx
	downloadable models\player\b4p\b4p_rodian\b4p_rodian.vvd
	downloadable models\player\b4p\b4p_snowtrooper\b4p_snowtrooper.dx80.vtx
	downloadable models\player\b4p\b4p_snowtrooper\b4p_snowtrooper.dx90.vtx
	downloadable models\player\b4p\b4p_snowtrooper\b4p_snowtrooper.mdl
	downloadable models\player\b4p\b4p_snowtrooper\b4p_snowtrooper.phy
	downloadable models\player\b4p\b4p_snowtrooper\b4p_snowtrooper.sw.vtx
	downloadable models\player\b4p\b4p_snowtrooper\b4p_snowtrooper.vvd
	downloadable models\player\b4p\b4p_stormt\b4p_stormt.dx80.vtx
	downloadable models\player\b4p\b4p_stormt\b4p_stormt.dx90.vtx
	downloadable models\player\b4p\b4p_stormt\b4p_stormt.mdl
	downloadable models\player\b4p\b4p_stormt\b4p_stormt.phy
	downloadable models\player\b4p\b4p_stormt\b4p_stormt.sw.vtx
	downloadable models\player\b4p\b4p_stormt\b4p_stormt.vvd
	downloadable models\player\b4p\b4p_stormt\b4p_stormt.xbox.vtx
	downloadable models\player\b4p\b4p_tusken\b4p_tusken.dx80.vtx
	downloadable models\player\b4p\b4p_tusken\b4p_tusken.dx90.vtx
	downloadable models\player\b4p\b4p_tusken\b4p_tusken.mdl
	downloadable models\player\b4p\b4p_tusken\b4p_tusken.phy
	downloadable models\player\b4p\b4p_tusken\b4p_tusken.sw.vtx
	downloadable models\player\b4p\b4p_tusken\b4p_tusken.vvd
	downloadable models\player\b4p\b4p_vader\b4p_vader.dx80.vtx
	downloadable models\player\b4p\b4p_vader\b4p_vader.dx90.vtx
	downloadable models\player\b4p\b4p_vader\b4p_vader.mdl
	downloadable models\player\b4p\b4p_vader\b4p_vader.phy
	downloadable models\player\b4p\b4p_vader\b4p_vader.sw.vtx
	downloadable models\player\b4p\b4p_vader\b4p_vader.vvd
	downloadable models\player\b4p\b4p_vader\b4p_vader.xboxvtx
	downloadable models\player\b4p\b4p_yoda\b4p_yoda.dx80.vtx
	downloadable models\player\b4p\b4p_yoda\b4p_yoda.dx90.vtx
	downloadable models\player\b4p\b4p_yoda\b4p_yoda.mdl
	downloadable models\player\b4p\b4p_yoda\b4p_yoda.phy
	downloadable models\player\b4p\b4p_yoda\b4p_yoda.sw.vtx
	downloadable models\player\b4p\b4p_yoda\b4p_yoda.vvd
	downloadable materials\b4p\b4p_tracers\b4p_tracer1.vmt
	downloadable materials\b4p\b4p_tracers\b4p_tracer1.vtf
	downloadable materials\b4p\b4p_tracers\b4p_tracer2.vmt
	downloadable materials\b4p\b4p_tracers\b4p_tracer2.vtf
	downloadable materials\b4p\b4p_tracers\b4p_tracer3.vmt
	downloadable materials\b4p\b4p_tracers\b4p_tracer3.vtf
	downloadable materials\b4p\b4p_tracers\b4p_tracer4.vmt
	downloadable materials\b4p\b4p_tracers\b4p_tracer4.vtf
	downloadable materials\b4p\b4p_tracers\b4p_tracer5.vmt
	downloadable materials\b4p\b4p_tracers\b4p_tracer5.vtf
	downloadable materials\b4p\b4p_tracers\b4p_tracer6.vmt
	downloadable materials\b4p\b4p_tracers\b4p_tracer6.vtf
	downloadable materials\b4p\b4p_tracers\b4p_tracer7.vmt
	downloadable materials\b4p\b4p_tracers\b4p_tracer7.vtf
	downloadable materials\b4p\b4p_tracers\b4p_tracer8.vmt
	downloadable materials\b4p\b4p_tracers\b4p_tracer8.vtf
	downloadable materials\models\player\b4p\chewbacca\chewbacca_1sided.vmt
	downloadable materials\models\player\b4p\chewbacca\chewbacca_1sided.vtf
	downloadable materials\models\player\b4p\chewbacca\chewbacca_2sided.vmt
	downloadable materials\models\player\b4p\chewbacca\chewbacca_2sided.vtf
	downloadable materials\models\player\b4p\chewbacca\chewbacca_body.vmt
	downloadable materials\models\player\b4p\chewbacca\chewbacca_body.vtf
	downloadable materials\models\player\b4p\chewbacca\chewbacca_head.vmt
	downloadable materials\models\player\b4p\chewbacca\chewbacca_head.vtf
	downloadable materials\models\player\b4p\chewbacca\chewbacca_sprites.vmt
	downloadable materials\models\player\b4p\chewbacca\chewbacca_sprites.vtf
	downloadable materials\models\player\b4p\c3po\c3po_arm_torso.vmt
	downloadable materials\models\player\b4p\c3po\c3po_arm_torso.vtf
	downloadable materials\models\player\b4p\c3po\c3po_face.vmt
	downloadable materials\models\player\b4p\c3po\c3po_face.vtf
	downloadable materials\models\player\b4p\c3po\c3po_hand.vmt
	downloadable materials\models\player\b4p\c3po\c3po_hand.vtf
	downloadable materials\models\player\b4p\c3po\c3po_leg.vmt
	downloadable materials\models\player\b4p\c3po\c3po_leg.vtf
	downloadable materials\models\player\b4p\bobafett\boba_body.vmt
	downloadable materials\models\player\b4p\bobafett\boba_body.vtf
	downloadable materials\models\player\b4p\bobafett\boba_hands.vmt
	downloadable materials\models\player\b4p\bobafett\boba_hands.vtf
	downloadable materials\models\player\b4p\bobafett\boba_head_revised.vmt
	downloadable materials\models\player\b4p\bobafett\boba_head_revised.vtf
	downloadable materials\models\player\b4p\bobafett\boba_jetpack.vmt
	downloadable materials\models\player\b4p\bobafett\boba_jetpack.vtf
	downloadable materials\models\player\b4p\imperial\basic_hand.vmt
	downloadable materials\models\player\b4p\imperial\basic_hand.vtf
	downloadable materials\models\player\b4p\imperial\boots_hips.vmt
	downloadable materials\models\player\b4p\imperial\boots_hips.vtf
	downloadable materials\models\player\b4p\imperial\face.vmt
	downloadable materials\models\player\b4p\imperial\face.vtf
	downloadable materials\models\player\b4p\imperial\head.vmt
	downloadable materials\models\player\b4p\imperial\head.vtf
	downloadable materials\models\player\b4p\imperial\mouth_eyes.vmt
	downloadable materials\models\player\b4p\imperial\mouth_eyes.vtf
	downloadable materials\models\player\b4p\imperial\officer_legs.vmt
	downloadable materials\models\player\b4p\imperial\officer_legs.vtf
	downloadable materials\models\player\b4p\imperial\officer_torso.vmt
	downloadable materials\models\player\b4p\imperial\officer_torso.vtf
	downloadable materials\models\player\b4p\jawa\jawa.vmt
	downloadable materials\models\player\b4p\jawa\jawa.vtf
	downloadable materials\models\player\b4p\jawa\jawa_eyes.vmt
	downloadable materials\models\player\b4p\jawa\jawa_eyes.vtf
	downloadable materials\models\player\b4p\jawa\jawa_hands.vmt
	downloadable materials\models\player\b4p\jawa\jawa_hands.vtf
	downloadable materials\models\player\b4p\murloc\murloc_darkgreen.vmt
	downloadable materials\models\player\b4p\murloc\murloc_darkgreen.vtf
	downloadable materials\models\player\b4p\murloc\murloc_grey.vmt
	downloadable materials\models\player\b4p\murloc\murloc_grey.vtf
	downloadable materials\models\player\b4p\murloc\murloc_normal.vtf
	downloadable materials\models\player\b4p\murloc\murloc_shine1.vtf
	downloadable materials\models\player\b4p\pyramidhead\ph1.vmt
	downloadable materials\models\player\b4p\pyramidhead\ph1.vtf
	downloadable materials\models\player\b4p\pyramidhead\ph1_normal.vtf
	downloadable materials\models\player\b4p\rebel\accessories.vmt
	downloadable materials\models\player\b4p\rebel\accessories.vtf
	downloadable materials\models\player\b4p\rebel\basic_hand.vmt
	downloadable materials\models\player\b4p\rebel\basic_hand.vtf
	downloadable materials\models\player\b4p\rebel\face_01.vmt
	downloadable materials\models\player\b4p\rebel\face_01.vtf
	downloadable materials\models\player\b4p\rebel\head_01.vmt
	downloadable materials\models\player\b4p\rebel\head_01.vtf
	downloadable materials\models\player\b4p\rebel\mouth_eyes.vmt
	downloadable materials\models\player\b4p\rebel\mouth_eyes.vtf
	downloadable materials\models\player\b4p\rebel\rebel_boots.vmt
	downloadable materials\models\player\b4p\rebel\rebel_boots.vtf
	downloadable materials\models\player\b4p\rebel\rebel_legs.vmt
	downloadable materials\models\player\b4p\rebel\rebel_legs.vtf
	downloadable materials\models\player\b4p\rebel\rebel_torso.vmt
	downloadable materials\models\player\b4p\rebel\rebel_torso.vtf
	downloadable materials\models\player\b4p\rodian\basic_hand.vmt
	downloadable materials\models\player\b4p\rodian\basic_hand.vtf
	downloadable materials\models\player\b4p\rodian\boots_belt_vest.vmt
	downloadable materials\models\player\b4p\rodian\boots_belt_vest.vtf
	downloadable materials\models\player\b4p\rodian\fins.vmt
	downloadable materials\models\player\b4p\rodian\fins.vtf
	downloadable materials\models\player\b4p\rodian\head.vmt
	downloadable materials\models\player\b4p\rodian\head.vtf
	downloadable materials\models\player\b4p\rodian\l_boot.vmt
	downloadable materials\models\player\b4p\rodian\l_boot.vtf
	downloadable materials\models\player\b4p\rodian\l_leg.vmt
	downloadable materials\models\player\b4p\rodian\l_leg.vtf
	downloadable materials\models\player\b4p\rodian\torso.vmt
	downloadable materials\models\player\b4p\rodian\torso.vtf
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_armor.vmt
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_armor.vtf
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_cape.vmt
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_cape.vtf
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_hands.vmt
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_hands.vtf
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_legs.vmt
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_legs.vtf
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_torso.vmt
	downloadable materials\models\player\b4p\snowtrooper\snowtrooper_torso.vtf
	downloadable materials\models\player\b4p\stormt\armor.vmt
	downloadable materials\models\player\b4p\stormt\armor.vtf
	downloadable materials\models\player\b4p\stormt\helmet.vmt
	downloadable materials\models\player\b4p\stormt\helmet.vtf
	downloadable materials\models\player\b4p\stormt\shoulder.vmt
	downloadable materials\models\player\b4p\stormt\shoulder.vtf
	downloadable materials\models\player\b4p\stormt\torso_legs.vmt
	downloadable materials\models\player\b4p\stormt\torso_legs.vtf
	downloadable materials\models\player\b4p\tusken\body.vmt
	downloadable materials\models\player\b4p\tusken\body.vtf
	downloadable materials\models\player\b4p\tusken\face.vmt
	downloadable materials\models\player\b4p\tusken\face.vtf
	downloadable materials\models\player\b4p\tusken\hands.vmt
	downloadable materials\models\player\b4p\tusken\hands.vtf
	downloadable materials\models\player\b4p\tusken\head.vmt
	downloadable materials\models\player\b4p\tusken\head.vtf
	downloadable materials\models\player\b4p\tusken\pockets.vmt
	downloadable materials\models\player\b4p\tusken\pockets.vtf
	downloadable materials\models\player\b4p\vader\alnewhope.vmt
	downloadable materials\models\player\b4p\vader\alnewhope.vtf
	downloadable materials\models\player\b4p\vader\beltxtras.vmt
	downloadable materials\models\player\b4p\vader\beltxtras.vtf
	downloadable materials\models\player\b4p\vader\darthshing.vmt
	downloadable materials\models\player\b4p\vader\darthshing.vtf
	downloadable materials\models\player\b4p\vader\dbreather.vmt
	downloadable materials\models\player\b4p\vader\dbreather.vtf
	downloadable materials\models\player\b4p\vader\dcape.vmt
	downloadable materials\models\player\b4p\vader\dcape.vtf
	downloadable materials\models\player\b4p\vader\handhope.vmt
	downloadable materials\models\player\b4p\vader\handhope.vtf
	downloadable materials\models\player\b4p\vader\headhope.vmt
	downloadable materials\models\player\b4p\vader\headhope.vtf
	downloadable materials\models\player\b4p\vader\helmethope.vmt
	downloadable materials\models\player\b4p\vader\helmethope.vtf
	downloadable materials\models\player\b4p\vader\hipsvader.vmt
	downloadable materials\models\player\b4p\vader\hipsvader.vtf
	downloadable materials\models\player\b4p\vader\legsvader.vmt
	downloadable materials\models\player\b4p\vader\legsvader.vtf
	downloadable materials\models\player\b4p\vader\shoulderhope.vmt
	downloadable materials\models\player\b4p\vader\shoulderhope.vtf
	downloadable materials\models\player\b4p\vader\torsovader.vmt
	downloadable materials\models\player\b4p\vader\torsovader.vtf
	downloadable materials\models\player\b4p\vader\vaderface.vmt
	downloadable materials\models\player\b4p\vader\vaderface.vtf
	downloadable materials\models\player\b4p\yoda\yoda_body.vmt
	downloadable materials\models\player\b4p\yoda\yoda_body.vtf
	downloadable materials\models\player\b4p\yoda\yoda_body_normal.vtf
	downloadable materials\models\player\b4p\yoda\yoda_head.vmt
	downloadable materials\models\player\b4p\yoda\yoda_head.vtf
	downloadable materials\models\player\b4p\yoda\yoda_head_normal.vtf
    }

    event round_start
    {
        // make sure only one sound is played for a beginplant
        es_xsetinfo b4p_sw_bombBeginPlant 0
        
        es_xsetinfo eventscripts_noisy 0
        es_delayed server_var(mp_freezetime) es_xsetinfo eventscripts_noisy 1
        
        if (server_var(b4p_sw_classicModeEnabled) == 0) do
        {
            es_msg #multi #green [StarWars] #lightgreen type #greenswmenu#lightgreen for the character menu
        }
        

        if (server_var(b4p_sw_jediModeEnabled) == 1) do
        {

            //////////////////////////
            // Assign someone to Vader
            //////////////////////////

            es_xsetinfo b4p_sw_randPlayer 0
            if (server_var(b4p_sw_empireTeamNumber) == 3) then est_RandPlayer b4p_sw_randPlayer #c
            if (server_var(b4p_sw_empireTeamNumber) == 2) then est_RandPlayer b4p_sw_randPlayer #t
            if (server_var(b4p_sw_randPlayer) != 0) do
            {
                es_format b4p_sw_modelPath "%1/b4p_vader/b4p_vader" server_var(b4p_sw_modelHome)
                es est_setmodel server_var(b4p_sw_randPlayer) server_var(b4p_sw_modelPath)
                es_keysetvalue b4p_sw_key server_var(b4p_sw_randPlayer) b4p_sw_key_tempModelName "b4p_vader"

		es_delayed 1 es_emitsound player server_var(b4p_sw_randPlayer) "b4p/char/extras/taunt.mp3" 1.0 0.5
		es est_Speed server_var(b4p_sw_randPlayer) 1.3
		es est_SetGravity server_var(b4p_sw_randPlayer) 0.6
		es_delayed 1.7 es est_Sethealth server_var(b4p_sw_randPlayer) 500
		es_delayed 1.7 es est_SetArmor server_var(b4p_sw_randPlayer) 100
		es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) item_nvgs
        	es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) item_assaultsuit
	        es_delayed 1.7 es playerset defuser server_var(b4p_sw_randPlayer) 1
   		es_delayed 1.4 es est_RemoveWeapon server_var(b4p_sw_randPlayer) 1  
		es_delayed 1.4 es est_RemoveWeapon server_var(b4p_sw_randPlayer) 2
		es_delayed 1.4 es est_RemoveWeapon server_var(b4p_sw_randPlayer) 3
		es_delayed 1.4 es est_RemoveWeapon server_var(b4p_sw_randPlayer) 4
		es_delayed 1.7 es est_SetAmmo server_var(b4p_sw_randPlayer) weapon_hegrenade 0
		es_delayed 1.7 es est_SetAmmo server_var(b4p_sw_randPlayer) weapon_smokegrenade 0
		es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) weapon_fiveseven
		es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) weapon_knife
		es_delayed 1.7 es est_SetAmmo server_var(b4p_sw_randPlayer) weapon_flashbang 2
		es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) weapon_flashbang

                es est_GetName b4p_sw_playerName server_var(b4p_sw_randPlayer)
                es_msg #multi #green server_var(b4p_sw_playerName) #lightgreen has spawned as #default Vader
            }

            //////////////////////////
            // Assign someone to Yoda
            //////////////////////////

            es_xsetinfo b4p_sw_randPlayer 0
            if (server_var(b4p_sw_empireTeamNumber) == 2) then est_RandPlayer b4p_sw_randPlayer #c
            if (server_var(b4p_sw_empireTeamNumber) == 3) then est_RandPlayer b4p_sw_randPlayer #t
            if (server_var(b4p_sw_randPlayer) != 0) do
            {
                es_format b4p_sw_modelPath "%1/b4p_yoda/b4p_yoda" server_var(b4p_sw_modelHome)
                es est_setmodel server_var(b4p_sw_randPlayer) server_var(b4p_sw_modelPath)
                es_keysetvalue b4p_sw_key server_var(b4p_sw_randPlayer) b4p_sw_key_tempModelName "b4p_yoda"

		es_delayed 1 es_emitsound player server_var(b4p_sw_randPlayer) "b4p/char/extras/tauntb.mp3" 1.0 0.5
		es est_Speed server_var(b4p_sw_randPlayer) 1.3
		es est_SetGravity server_var(b4p_sw_randPlayer) 0.6
		es_delayed 1.7 es est_Sethealth server_var(b4p_sw_randPlayer) 500
		es_delayed 1.7 es est_SetArmor server_var(b4p_sw_randPlayer) 100
		es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) item_nvgs 
        	es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) item_assaultsuit
   		es_delayed 1.4 es est_RemoveWeapon server_var(b4p_sw_randPlayer) 1  
		es_delayed 1.4 es est_RemoveWeapon server_var(b4p_sw_randPlayer) 2
		es_delayed 1.4 es est_RemoveWeapon server_var(b4p_sw_randPlayer) 3
		es_delayed 1.4 es est_RemoveWeapon server_var(b4p_sw_randPlayer) 4
		es_delayed 1.7 es est_SetAmmo server_var(b4p_sw_randPlayer) weapon_hegrenade 0
		es_delayed 1.7 es est_SetAmmo server_var(b4p_sw_randPlayer) weapon_smokegrenade 0
		es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) weapon_fiveseven
		es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) weapon_knife
		es_delayed 1.7 es est_SetAmmo server_var(b4p_sw_randPlayer) weapon_flashbang 2
		es_delayed 1.7 es_give server_var(b4p_sw_randPlayer) weapon_flashbang

                es est_GetName b4p_sw_playerName server_var(b4p_sw_randPlayer)
                es_msg #multi #green server_var(b4p_sw_playerName) #lightgreen has spawned as #default Yoda
            }
        }
    }


    event player_activate
    {
        es_keycreate b4p_sw_key event_var(userid)
        es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive 0
        es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName 0
    }


    event player_spawn
    {
        //////////////////////////////////////////////////////////////////
        // Important test code 
        // Used mainly for bots that spawn before activating.
        // Tests to see if the b4p_sw_key key has been created.  Sometimes bots can player_spawn before they player_activate
        // Creating a test key, checking the key, and then initializing b4p_sw_key if the test fails
        //////////////////////////////////////////////////////////////////

        // BEGIN TEST CODE //////////////////////////////////////////////////////////////
        es_setinfo b4p_sw_keyTest 0
        es_exists b4p_sw_keyTest key b4p_sw_key
        if (server_var(b4p_sw_keyTest) == 0) then es_keycreate b4p_sw_key event_var(userid)
        // END TEST CODE ////////////////////////////////////////////////////////////////


        /////////////////////////////////
        // spawn code
        /////////////////////////////////
	es_delayed 1 es_setplayerprop event_var(userid) CCSPlayer.m_iAccount 0
	es_fire event_var(userid) func_buyzone Disable
   	es est_RemoveWeapon event_var(userid) 1  
	es est_RemoveWeapon event_var(userid) 2
	es est_RemoveWeapon event_var(userid) 3
	es est_RemoveWeapon event_var(userid) 4
        es est_SetGravity event_var(userid) server_var(b4p_sw_normalGravity)
	es_delayed 1 est_SetPlayerColor event_var(userid) 255 255 255 255

	if (event_var(es_userteam) equalto "2") do
	{
		es_delayed 1 es est_SetArmor event_var(userid) 100
	        es_delayed 1 es_give event_var(userid) item_nvgs 
        	es_delayed 1 es_give event_var(userid) item_assaultsuit
	}
	if (event_var(es_userteam) equalto "3") do
	{
		es_delayed 1 es est_SetArmor event_var(userid) 100
	        es_delayed 1 es playerset defuser event_var(userid) 1 
        	es_delayed 1 es_give event_var(userid) item_assaultsuit
	        es_delayed 1 es_give event_var(userid) item_nvgs 
	}
        
        if (server_var(b4p_sw_classicModeEnabled) == 0) do
        {
            // Save the team number the player has just spawned in. used in randomModel block
            es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_teamNumber event_var(es_userteam)

            es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_modelName
            es_format b4p_sw_modelPath "%1/%2/%2" server_var(b4p_sw_modelHome) server_var(b4p_sw_modelName)

            if (server_var(b4p_sw_modelName) == 0) then es_xdoblock b4p_starwars/randomModel

            es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_modelName
            es_format b4p_sw_modelPath "%1/%2/%2" server_var(b4p_sw_modelHome) server_var(b4p_sw_modelName)

            if (server_var(b4p_sw_modelName) != 0) then es est_setmodel event_var(userid) server_var(b4p_sw_modelPath)

            es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_modelName
            es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_tempModelName server_var(b4p_sw_modelName)
        }

        if (server_var(b4p_sw_classicModeEnabled) == 1) do
        {
            if (event_var(es_userteam) == server_var(b4p_sw_empireTeamNumber)) do
            {
                es_format b4p_sw_modelPath "%1/b4p_stormt/b4p_stormt" server_var(b4p_sw_modelHome)
                es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_tempModelName "b4p_stormt"
            }
            if (event_var(es_userteam) != server_var(b4p_sw_empireTeamNumber)) do
            {
                es_format b4p_sw_modelPath "%1/b4p_rebel/b4p_rebel" server_var(b4p_sw_modelHome)
                es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_tempModelName "b4p_rebel"
            }
            es est_setmodel event_var(userid) server_var(b4p_sw_modelPath)
        }        

        // there is no boba fett in classic mode
        if (server_var(b4p_sw_classicModeEnabled) == 0) do
        {
            if (server_var(b4p_sw_bobaJetsEnabled) == 1) do
            {
                // b4p_sw_modelName should've been set above, so it will be the tempModelName as well
                if (server_var(b4p_sw_modelName) == "b4p_bobafett") then es est_SetGravity event_var(userid) server_var(b4p_sw_bobaFettGravity)
                if (server_var(b4p_sw_modelName) == "b4p_bobafett") then est_Speed event_var(userid) 0.9 
            }
        }
 
	if (server_var(b4p_sw_modelName) == "b4p_bobafett") do
   	    {
		es_delayed 1 es_give event_var(userid) weapon_m4a1
		es_delayed 1 es_give event_var(userid) weapon_glock
            }
   	if (server_var(b4p_sw_modelName) == "b4p_c3po") do
   	    {
		es_delayed 1 es_give event_var(userid) weapon_p90
		es_delayed 1 es_give event_var(userid) weapon_elite
            }
   	if (server_var(b4p_sw_modelName) == "b4p_chewbacca") do
   	    {
		es_delayed 1 es_give event_var(userid) weapon_scout
		es_delayed 1 es_give event_var(userid) weapon_deagle
            }
   	if (server_var(b4p_sw_modelName) == "b4p_imperial") do
   	    {
		es_delayed 1 es_give event_var(userid) weapon_scout
		es_delayed 1 es_give event_var(userid) weapon_deagle
            }
   	if (server_var(b4p_sw_modelName) == "b4p_jawa") do
   	    {
		es_delayed 1 es est_Sethealth event_var(userid) 150
		es_delayed 1.2 es est_SetAmmo event_var(userid) weapon_hegrenade 25
		es_delayed 1.2 es est_SetAmmo event_var(userid) weapon_smokegrenade 5
		es_delayed 1.2 es est_SetAmmo event_var(userid) weapon_flashbang 2
		es_delayed 1 es_give event_var(userid) weapon_flashbang
		es_delayed 1 es_give event_var(userid) weapon_hegrenade
		es_delayed 1 es_give event_var(userid) weapon_smokegrenade
		es_delayed 1 es_give event_var(userid) weapon_p228
            }
   	if (server_var(b4p_sw_modelName) == "b4p_rebel") do
   	    {
		es_delayed 1 es_give event_var(userid) weapon_ak47
		es_delayed 1 es_give event_var(userid) weapon_glock
            }
   	if (server_var(b4p_sw_modelName) == "b4p_rodian") do
   	    {
		es_delayed 1 es est_Sethealth event_var(userid) 150
		es_delayed 1.2 es est_SetAmmo event_var(userid) weapon_hegrenade 25
		es_delayed 1.2 es est_SetAmmo event_var(userid) weapon_smokegrenade 5
		es_delayed 1.2 es est_SetAmmo event_var(userid) weapon_flashbang 2
		es_delayed 1 es_give event_var(userid) weapon_flashbang
		es_delayed 1 es_give event_var(userid) weapon_hegrenade
		es_delayed 1 es_give event_var(userid) weapon_smokegrenade
		es_delayed 1 es_give event_var(userid) weapon_p228
            }
   	if (server_var(b4p_sw_modelName) == "b4p_snowtrooper") do
   	    {
		es_delayed 1 es_give event_var(userid) weapon_awp
		es_delayed 1 es_give event_var(userid) weapon_usp
            }
   	if (server_var(b4p_sw_modelName) == "b4p_stormt") do
   	    {
		es_delayed 1 es_give event_var(userid) weapon_p90
		es_delayed 1 es_give event_var(userid) weapon_elite
            }
   	if (server_var(b4p_sw_modelName) == "b4p_tusken") do
   	    {
		es_delayed 1 es_give event_var(userid) weapon_awp
		es_delayed 1 es_give event_var(userid) weapon_usp
            }
    }


    event player_team
    {
        // Save the team number the player has just joined
        es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_teamNumber event_var(team)

        es_xdoblock b4p_starwars/randomModel
    }


    event player_jump
    {
        es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_tempModelName
        
        if (server_var(b4p_sw_bobaJetsEnabled) == 1) do
        {
            if (server_var(b4p_sw_modelName) == "b4p_bobafett") do
            {
                 es est_PlayPlayer event_var(userid) "b4p/weapons/boba/bf_flame.mp3" 1
            }
            if (server_var(b4p_sw_modelName) == "b4p_yoda") do
            {
                 es est_PlayPlayer event_var(userid) "b4p/char/extras/jump.mp3" 1
            }
            if (server_var(b4p_sw_modelName) == "b4p_vader") do
            {
                 es est_PlayPlayer event_var(userid) "b4p/char/extras/jump.mp3" 1
            }
        }
    }


    event weapon_fire
    {
        es_xsetinfo b4p_sw_weapon_was_fired 1

        es est_GetGunCoord event_var(userid) b4p_sw_playerX b4p_sw_playerY b4p_sw_playerZ 

        if (event_var(weapon) == knife) do 
        {
            if (server_var(b4p_sw_weaponSoundsEnabled) == 1) do 
            {
                es_xdoblock b4p_starwars/playKnifeSound
            }
        }
    }


    event bomb_beginplant
    {
        if (server_var(b4p_sw_charSoundsEnabled) == 1) do
        {
            es_xsetinfo b4p_sw_modelName 0
            
            if (server_var(b4p_sw_bombBeginPlant) == 0) do
            {
                // make sure only one sound is played for a beginplant
                es_xsetinfo b4p_sw_bombBeginPlant 1

                es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_tempModelName

                // rebel
                if (server_var(b4p_sw_modelName) == "b4p_rebel") then es est_PlayPlayer event_var(userid) "b4p/char/extras/rebplant.mp3" 1
                // c3po
                if (server_var(b4p_sw_modelName) == "b4p_c3po") then es est_PlayPlayer event_var(userid) "b4p/char/extras/3poplant.mp3" 1
                // chewbacca
                if (server_var(b4p_sw_modelName) == "b4p_chewbacca") then es est_PlayPlayer event_var(userid) "b4p/char/chewbacca/chewbacca1.wav" 1
                // jawa
                if (server_var(b4p_sw_modelName) == "b4p_jawa") then es est_PlayPlayer event_var(userid) "b4p/char/jawa/chatter2.mp3" 1
            	// yoda
            	if (server_var(b4p_sw_modelName) == "b4p_yoda") then es est_PlayPlayer event_var(userid) "b4p/char/yoda/laugh1.wav" 1
            	// tusken
                if (server_var(b4p_sw_modelName) == "b4p_tusken") then es est_PlayPlayer event_var(userid) "b4p/char/tusken/confuse1.mp3" 1
             }
        }

    }


    event bomb_planted
    {
        // play a sound

        if (server_var(b4p_sw_charSoundsEnabled) == 1) do
        {
            es_xsetinfo b4p_sw_modelName 0

            es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_tempModelName

            // rebel
            if (server_var(b4p_sw_modelName) == "b4p_rebel") then es est_PlayPlayer event_var(userid) "b4p/char/extras/rebexplo.mp3" 1
            // c3po
            if (server_var(b4p_sw_modelName) == "b4p_c3po") then es est_PlayPlayer event_var(userid) "b4p/char/extras/3poexpl.mp3" 1
            // chewbacca
            if (server_var(b4p_sw_modelName) == "b4p_chewbacca") then es est_PlayPlayer event_var(userid) "b4p/char/chewbacca/taunt.mp3" 1
            // jawa
            if (server_var(b4p_sw_modelName) == "b4p_jawa") then es est_PlayPlayer event_var(userid) "b4p/char/jawa/victory2.mp3" 1
            // yoda
            if (server_var(b4p_sw_modelName) == "b4p_yoda") then es est_PlayPlayer event_var(userid) "b4p/char/extras/yadoexplo.mp3" 1
            // tusken
            if (server_var(b4p_sw_modelName) == "b4p_tusken") then es est_PlayPlayer event_var(userid) "b4p/char/tusken/taunt.mp3" 1
        }
    }


    event bomb_begindefuse
    {
        if (server_var(b4p_sw_charSoundsEnabled) == 1) do
        {
            es_xsetinfo b4p_sw_modelName 0

            es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_tempModelName

            // storm trooper
            if (server_var(b4p_sw_modelName) == "b4p_stormt") then es est_PlayPlayer event_var(userid) "b4p/char/extras/ststardef.mp3" 1
            // snow trooper
            if (server_var(b4p_sw_modelName) == "b4p_snowtrooper") then es est_PlayPlayer event_var(userid) "b4p/char/extras/snowstardef.mp3" 1
            // rodian
            if (server_var(b4p_sw_modelName) == "b4p_rodian") then es est_PlayPlayer event_var(userid) "b4p/char/extras/rodstardef.mp3" 1
            // imperial officer
            if (server_var(b4p_sw_modelName) == "b4p_imperial") then es est_PlayPlayer event_var(userid) "b4p/char/extras/iostardef.mp3" 1
            // bobafett
            if (server_var(b4p_sw_modelName) == "b4p_bobafett") then es est_PlayPlayer event_var(userid) "b4p/char/extras/bobastardef.mp3" 1
            // vader
            if (server_var(b4p_sw_modelName) == "b4p_vader") then es est_PlayPlayer event_var(userid) "b4p/char/extras/vaderstrdef.mp3" 1
        }
    }


    event bomb_defused
    {
        if (server_var(b4p_sw_charSoundsEnabled) == 1) do
        {
            es_xsetinfo b4p_sw_modelName 0

            es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_tempModelName

            // storm trooper
            if (server_var(b4p_sw_modelName) == "b4p_stormt") then es est_PlayPlayer event_var(userid) "b4p/char/extras/stdef.mp3" 1
            // snow trooper
            if (server_var(b4p_sw_modelName) == "b4p_snowtrooper") then es est_PlayPlayer event_var(userid) "b4p/char/extras/snowdef.mp3" 1
            // rodian
            if (server_var(b4p_sw_modelName) == "b4p_rodian") then es est_PlayPlayer event_var(userid) "b4p/char/extras/roddef.mp3" 1
            // imperial officer
            if (server_var(b4p_sw_modelName) == "b4p_imperial") then es est_PlayPlayer event_var(userid) "b4p/char/extras/iodef.mp3" 1
            // bobafett
            if (server_var(b4p_sw_modelName) == "b4p_bobafett") then es est_PlayPlayer event_var(userid) "b4p/char/extras/bobadef.mp3" 1
            // vader
            if (server_var(b4p_sw_modelName) == "b4p_vader") then es est_PlayPlayer event_var(userid) "b4p/char/extras/vaderdeuse.mp3" 1
        }
    }


    event bomb_exploded
    {
        if (server_var(b4p_sw_jabbaLaughEnabled) == 1) do
        {
            es_delayed 1 es_cexec event_var(userid) playgamesound "b4p/char/jabba/laugh1.wav"
        }
    }

    
    event player_death
    {
	es_delayed 0.1 es est_RemoveIdle weapon_knife
	es_delayed 0.1 es est_RemoveIdle weapon_flashbang
	es_delayed 0.1 es est_RemoveIdle weapon_smokegrenade
	es_delayed 0.1 es est_RemoveIdle weapon_hegrenade
	es_delayed 0.1 es est_RemoveIdle weapon_fiveseven
	es_delayed 0.1 es est_RemoveIdle weapon_m4a1
	es_delayed 0.1 es est_RemoveIdle weapon_glock
	es_delayed 0.1 es est_RemoveIdle weapon_p90
	es_delayed 0.1 es est_RemoveIdle weapon_elite
	es_delayed 0.1 es est_RemoveIdle weapon_scout
	es_delayed 0.1 es est_RemoveIdle weapon_deagle
	es_delayed 0.1 es est_RemoveIdle weapon_ak47
	es_delayed 0.1 es est_RemoveIdle weapon_p228
	es_delayed 0.1 es est_RemoveIdle weapon_awp
	es_delayed 0.1 es est_RemoveIdle weapon_usp
	es_delayed 0.1 es est_RemoveIdle item_defuser
	es_delayed 1 es_setplayerprop event_var(attacker) CCSPlayer.m_iAccount 0
        if (server_var(b4p_sw_charSoundsEnabled) == 1) do
        {
            es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_tempModelName

   	    if (server_var(b4p_sw_modelName) == "b4p_bobafett") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/bobbadeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_c3po") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/c3podeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_chewbacca") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/chewedeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_imperial") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/iodeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_jawa") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/jawadeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_rebel") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/rebeldeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_rodian") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/rodiandeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_snowtrooper") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/snowdeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_stormt") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/stdeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_tusken") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/tuskendeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_vader") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/vaderdeath.mp3" 1.0 0.5
            }
   	    if (server_var(b4p_sw_modelName) == "b4p_yoda") do
   	    {
		es_emitsound player event_var(userid) "b4p/char/extras/yodadeath.mp3" 1.0 0.5
            }
        }
    }
    

    event bullet_impact
    {


       //  this prevents weapons from playing the laser sound multiple times with one shot
        if (server_var(b4p_sw_weapon_was_fired) == 1) do
        {
            if (server_var(b4p_sw_weaponSoundsEnabled) == 1) do 
            {
                // this should probably be called from the weapon_fire event, but empty guns and knives trigger that event.
                // the bullet_impact event assures that a gun has actually been fired
                es_xdoblock b4p_starwars/playWeaponFireSound
            }
        }

        //es_xrand b4p_sw_randNum 1 3
        //if (server_var(b4p_sw_randNum) == 1) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit1.mp3" 1
        //if (server_var(b4p_sw_randNum) == 2) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit2.mp3" 1
        //if (server_var(b4p_sw_randNum) == 3) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit3.mp3" 1

        // es est_PlayPlayer - play a sound as if it was coming from the specified player (Syntax: est_PlayPlayer <identifier> <filename> [volume (default=1.0)]) 
        // Example: es est_PlayPlayer event_var(userid) "mysounds/cry.mp3" 0.5 


        if (server_var(b4p_sw_lasers_enabled) == 1) do
        {
            if (server_var(b4p_sw_lasers_trigEnabled) == 1) do
            {
                //  this prevents weapons from recalculating the laser origin multiple times
                if (server_var(b4p_sw_weapon_was_fired) == 1) do
                {            
                    es_xdoblock b4p_starwars/adjustLaserOrigin
                }
            }

            // draw the lasers
            es_xdoblock b4p_starwars/drawLasers
        }


        // very important, used in playing sounds and trig functions
        es_xsetinfo b4p_sw_weapon_was_fired 0
    }
    

    event player_disconnect
    {
        es_keydelete b4p_sw_key event_var(userid)
    }
    

    block playWeaponFireSound
    {
        es_xsetinfo b4p_sw_lightningSoundPlayed 0
        es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_tempModelName
        
        if (server_var(b4p_sw_modelName) == "b4p_vader") do
        {
            es_xrand b4p_sw_randNum 1 4
            if (server_var(b4p_sw_randNum) == 1) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightning.mp3" 1
            if (server_var(b4p_sw_randNum) == 2) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit1.mp3" 1
            if (server_var(b4p_sw_randNum) == 3) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit2.mp3" 1
            if (server_var(b4p_sw_randNum) == 4) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit3.mp3" 1
            es_xsetinfo b4p_sw_lightningSoundPlayed 1
        }
        
        if (server_var(b4p_sw_modelName) == "b4p_yoda") do
        {
            es_xrand b4p_sw_randNum 1 4
            if (server_var(b4p_sw_randNum) == 1) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightning.mp3" 1
            if (server_var(b4p_sw_randNum) == 2) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit1.mp3" 1
            if (server_var(b4p_sw_randNum) == 3) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit2.mp3" 1
            if (server_var(b4p_sw_randNum) == 4) then es est_PlayPlayer event_var(userid) "b4p/weapons/force/lightninghit3.mp3" 1
            es_xsetinfo b4p_sw_lightningSoundPlayed 1
        }
        
        if (server_var(b4p_sw_lightningSoundPlayed) != 1) do
        {
            es_xrand b4p_sw_randNum 1 2
            if (server_var(b4p_sw_randNum) == 1) then es est_PlayPlayer event_var(userid) "b4p/weapons/blaster/fire.mp3" 1
            if (server_var(b4p_sw_randNum) != 1) then es est_PlayPlayer event_var(userid) "b4p/weapons/blaster/alt_fire.mp3" 1
        }
        
        // es est_PlayPlayer - play a sound as if it was coming from the specified player (Syntax: est_PlayPlayer <identifier> <filename> [volume (default=1.0)]) 
        // Example: es est_PlayPlayer event_var(userid) "mysounds/cry.mp3" 0.5 
    }


    block playKnifeSound
    {
        es_xrand b4p_sw_randNum 1 4
        if (server_var(b4p_sw_randNum) == 1) then es est_PlayPlayer event_var(userid) "b4p/weapons/saber/saberhup1.mp3" 1
        if (server_var(b4p_sw_randNum) == 2) then es est_PlayPlayer event_var(userid) "b4p/weapons/saber/saberhup2.mp3" 1
        if (server_var(b4p_sw_randNum) == 3) then es est_PlayPlayer event_var(userid) "b4p/weapons/saber/saberhup3.mp3" 1
        if (server_var(b4p_sw_randNum) == 4) then es est_PlayPlayer event_var(userid) "b4p/weapons/saber/saberhup4.mp3" 1
    }


    block randomModel
    {
        // Set the player's model to some random model on his new team    

        es_setinfo b4p_sw_teamNumber 0

        es_keygetvalue b4p_sw_teamNumber b4p_sw_key event_var(userid) b4p_sw_key_teamNumber
        es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_modelName

        if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then es_xrand b4p_sw_randNum 1 server_var(b4p_sw_empireModelCount)
        if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then es_xrand b4p_sw_randNum 1 server_var(b4p_sw_rebelModelCount)

        es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName 0

        if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 1) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName1)
        if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 2) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName2)
        if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 3) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName3)
        if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 4) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName4)
        if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 5) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName5)

        if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 1) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName1)
        if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 2) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName2)
        if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 3) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName3)
        if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 4) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName4)
        if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then if (server_var(b4p_sw_randNum) == 5) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName5)

    }
    
    
    block adjustLaserOrigin
    {
        //  this prevents shotguns from recalculating the laser origin
        if (server_var(b4p_sw_weapon_was_fired) == 1) do
        {
            /////////////////////////////////////////////////////////////////////////////////
            // first we move the laser away from the player b4p_sw_lasers_forwardOffset units
            // to do that we convert from cartesian coordinates to polar coordinates
            /////////////////////////////////////////////////////////////////////////////////

                    // for reference:
                    // x = r * cos(phi) * cos(theta)
                    // y = r * cos(phi) * sin(theta)
                    // z = r * sin(phi)

                    // 1. find total length of laser (b4p_sw_laserLength)
                    // 2. find the offset on the XY plane
                    // 3. find b4p_sw_phi
                    // 4. find b4p_sw_theta
                    // 5. find x, y, and z offsets using b4p_sw_lasers_forwardOffset as the new radius
                    // 6. apply the deltas to X, Y, and Z

            // 1. find total length of laser (b4p_sw_laserLength)
            //    L = sqrt[(x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2]

            es_setinfo b4p_sw_offsetX event_var(x)
            es_math b4p_sw_offsetX - server_var(b4p_sw_playerX)
            es_setinfo b4p_sw_offsetXsqr server_var(b4p_sw_offsetX)
            es_math b4p_sw_offsetXsqr * server_var(b4p_sw_offsetXsqr)

            es_setinfo b4p_sw_offsetY event_var(y)
            es_math b4p_sw_offsetY - server_var(b4p_sw_playerY)
            es_setinfo b4p_sw_offsetYsqr server_var(b4p_sw_offsetY)
            es_math b4p_sw_offsetYsqr * server_var(b4p_sw_offsetYsqr)

            es_setinfo b4p_sw_offsetZ event_var(z)
            es_math b4p_sw_offsetZ - server_var(b4p_sw_playerZ)
            es_setinfo b4p_sw_offsetZsqr server_var(b4p_sw_offsetZ)
            es_math b4p_sw_offsetZsqr * server_var(b4p_sw_offsetZsqr)

            es_setinfo b4p_sw_laserLength 0.0
            es_math b4p_sw_laserLength + server_var(b4p_sw_offsetXsqr)
            es_math b4p_sw_laserLength + server_var(b4p_sw_offsetYsqr)
            es_math b4p_sw_laserLength + server_var(b4p_sw_offsetZsqr)
            es_math b4p_sw_laserLength root 2.0

            // 2. find the offset on the XY plane
            // b4p_sw_offsetXY = sqrt[b4p_sw_offsetXsqr + b4p_sw_offsetYsqr]

            es_setinfo b4p_sw_offsetXY server_var(b4p_sw_offsetXsqr)
            es_math b4p_sw_offsetXY + server_var(b4p_sw_offsetYsqr)
            es_math b4p_sw_offsetXY root 2.0

            // 3. find find b4p_sw_phi
            //    b4p_sw_phi = atan[b4p_sw_offsetZ / b4p_sw_offsetXY]

            es_setinfo b4p_sw_phi server_var(b4p_sw_offsetZ)
            es_math b4p_sw_phi / server_var(b4p_sw_offsetXY)
            es_math b4p_sw_phi atan

            // 4. find b4p_sw_theta
            // b4p_sw_theta = atan[b4p_sw_offsetY/b4p_sw_offsetX]

            es_setinfo b4p_sw_theta server_var(b4p_sw_offsetY)
            es_math b4p_sw_theta / server_var(b4p_sw_offsetX)
            es_math b4p_sw_theta atan

            // 5. find x, y, and z deltas using b4p_sw_lasers_forwardOffset as the new radius
            // make sure the angles are correct
            if (server_var(b4p_sw_offsetX) < 0) then es_math b4p_sw_theta + 3.14159

            // X
            // x = r * cos(phi) * cos(theta)        

            es_setinfo b4p_sw_deltaX server_var(b4p_sw_phi)
            es_math b4p_sw_deltaX cos
            es_math b4p_sw_deltaX * server_var(b4p_sw_lasers_forwardOffset)
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_theta)
            es_math b4p_sw_tempVar cos
            es_math b4p_sw_deltaX * server_var(b4p_sw_tempVar)


            // Y
            // y = r * cos(phi) * sin(theta)
            es_setinfo b4p_sw_deltaY server_var(b4p_sw_phi)
            es_math b4p_sw_deltaY cos
            es_math b4p_sw_deltaY * server_var(b4p_sw_lasers_forwardOffset)
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_theta)
            es_math b4p_sw_tempVar sin
            es_math b4p_sw_deltaY * server_var(b4p_sw_tempVar)

            // Z
            // z = r * sin(phi)
            es_setinfo b4p_sw_deltaZ server_var(b4p_sw_phi)
            es_math b4p_sw_deltaZ sin
            es_math b4p_sw_deltaZ * server_var(b4p_sw_lasers_forwardOffset)

            // 6. apply the offsets to X, Y, and Z

            es_math b4p_sw_playerX + server_var(b4p_sw_deltaX)
            es_math b4p_sw_playerY + server_var(b4p_sw_deltaY)
            es_math b4p_sw_playerZ + server_var(b4p_sw_deltaZ)

            /////////////////////////////////////////////////////////////////////////////////
            // now we move the laser origin down and to the right (to match the muzzle)
            // this will move the start of the laser to the player's right (-90 degree turn)
            /////////////////////////////////////////////////////////////////////////////////

            es_math b4p_sw_theta - 1.5708

            es_setinfo b4p_sw_deltaX server_var(b4p_sw_theta)
            es_math b4p_sw_deltaX cos        
            es_math b4p_sw_deltaX * server_var(b4p_sw_lasers_rightOffset)

            es_setinfo b4p_sw_deltaY server_var(b4p_sw_theta)        
            es_math b4p_sw_deltaY sin
            es_math b4p_sw_deltaY * server_var(b4p_sw_lasers_rightOffset)

            // once again we apply the offsets to X, Y, and Z
            es_math b4p_sw_playerX + server_var(b4p_sw_deltaX)
            es_math b4p_sw_playerY + server_var(b4p_sw_deltaY)
            es_math b4p_sw_playerZ + server_var(b4p_sw_lasers_upOffset)
        }
    }


    block drawLasers
    {

        if (server_var(b4p_sw_lasers_teamColorsEnabled) == 1) do
        {
            es_keygetvalue b4p_sw_teamNumber b4p_sw_key event_var(userid) b4p_sw_key_teamNumber
            
            
            if (server_var(b4p_sw_jediShootLightning) == 0) do
            {
                if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) do
                {
                    es ma_effect 1 event_var(x) event_var(y) event_var(z) server_var(b4p_sw_playerX) server_var(b4p_sw_playerY) server_var(b4p_sw_playerZ) server_var(b4p_sw_lasers_style) NULL 0 00.1 000.1 server_var(b4p_sw_lasers_endWidth) server_var(b4p_sw_lasers_startWidth) 0 0 server_var(b4p_sw_lasers_teamA_red) server_var(b4p_sw_lasers_teamA_green) server_var(b4p_sw_lasers_teamA_blue) server_var(b4p_sw_lasers_opacity) server_var(b4p_sw_lasers_speed)
                }
                if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) do
                {
                    es ma_effect 1 event_var(x) event_var(y) event_var(z) server_var(b4p_sw_playerX) server_var(b4p_sw_playerY) server_var(b4p_sw_playerZ) server_var(b4p_sw_lasers_style) NULL 0 00.1 000.1 server_var(b4p_sw_lasers_endWidth) server_var(b4p_sw_lasers_startWidth) 0 0 server_var(b4p_sw_lasers_teamB_red) server_var(b4p_sw_lasers_teamB_green) server_var(b4p_sw_lasers_teamB_blue) server_var(b4p_sw_lasers_opacity) server_var(b4p_sw_lasers_speed)
                }
            }

            if (server_var(b4p_sw_jediShootLightning) == 1) do
            {
                es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_tempModelName

                if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) do
                {
                    if (server_var(b4p_sw_modelName) == "b4p_vader") do
                    {
                        es ma_effect 1 event_var(x) event_var(y) event_var(z) server_var(b4p_sw_playerX) server_var(b4p_sw_playerY) server_var(b4p_sw_playerZ) lightning NULL 0 00.1 000.1 server_var(b4p_sw_lightning_endWidth) server_var(b4p_sw_lightning_startWidth) 0 0 server_var(b4p_sw_lasers_teamA_red) server_var(b4p_sw_lasers_teamA_green) server_var(b4p_sw_lasers_teamA_blue) server_var(b4p_sw_lasers_opacity) server_var(b4p_sw_lasers_speed)
                    }
                    
                    if (server_var(b4p_sw_modelName) != "b4p_vader") do
                    {
                        es ma_effect 1 event_var(x) event_var(y) event_var(z) server_var(b4p_sw_playerX) server_var(b4p_sw_playerY) server_var(b4p_sw_playerZ) server_var(b4p_sw_lasers_style) NULL 0 00.1 000.1 server_var(b4p_sw_lasers_endWidth) server_var(b4p_sw_lasers_startWidth) 0 0 server_var(b4p_sw_lasers_teamA_red) server_var(b4p_sw_lasers_teamA_green) server_var(b4p_sw_lasers_teamA_blue) server_var(b4p_sw_lasers_opacity) server_var(b4p_sw_lasers_speed)
                    }
                }
                if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) do
                {
                    if (server_var(b4p_sw_modelName) == "b4p_yoda") do
                    {
                        es ma_effect 1 event_var(x) event_var(y) event_var(z) server_var(b4p_sw_playerX) server_var(b4p_sw_playerY) server_var(b4p_sw_playerZ) lightning NULL 0 00.1 000.1 server_var(b4p_sw_lightning_endWidth) server_var(b4p_sw_lightning_startWidth) 0 0 server_var(b4p_sw_lasers_teamB_red) server_var(b4p_sw_lasers_teamB_green) server_var(b4p_sw_lasers_teamB_blue) server_var(b4p_sw_lasers_opacity) server_var(b4p_sw_lasers_speed)
                    }
    
                    if (server_var(b4p_sw_modelName) != "b4p_yoda") do
                    {
                        es ma_effect 1 event_var(x) event_var(y) event_var(z) server_var(b4p_sw_playerX) server_var(b4p_sw_playerY) server_var(b4p_sw_playerZ) server_var(b4p_sw_lasers_style) NULL 0 00.1 000.1 server_var(b4p_sw_lasers_endWidth) server_var(b4p_sw_lasers_startWidth) 0 0 server_var(b4p_sw_lasers_teamB_red) server_var(b4p_sw_lasers_teamB_green) server_var(b4p_sw_lasers_teamB_blue) server_var(b4p_sw_lasers_opacity) server_var(b4p_sw_lasers_speed)
                    }
                }
            }
        }

        if (server_var(b4p_sw_lasers_teamColorsEnabled) == 0) then es ma_effect 1 event_var(x) event_var(y) event_var(z) server_var(b4p_sw_playerX) server_var(b4p_sw_playerY) server_var(b4p_sw_playerZ) server_var(b4p_sw_lasers_style) NULL 0 00.1 000.1 server_var(b4p_sw_lasers_startWidth) server_var(b4p_sw_lasers_startWidth) 0 0 server_var(b4p_sw_lasers_default_red) server_var(b4p_sw_lasers_default_green) server_var(b4p_sw_lasers_default_blue) server_var(b4p_sw_lasers_opacity) server_var(b4p_sw_lasers_speed)

        // X Y Z - Start position of the beam = see above
        // X Y Z - End position of the beam = see above
        // Model Name = tracer
        // Halo Name = NULL
        // Frame Start Index - usually 0 (Byte) = 0
        // Frame Rate - Frame rate of the animation of the model (Byte) = 00.1
        // Life - Time in seconds that the effect lasts for (Float) = 000.1
        // Width - Width of the beam at the start position (Byte) = 2
        // End Width - Width of the beam at the end position (Byte)  = 2
        // Fade Length - Time in seconds of fade out (Byte) = 0
        // Noise - Noise coefficient (Byte) = 0
        // Red - Red component (Usually 255) (Byte) 125
        // Green - Green component (Usually 255) (Byte) 125 
        // Blue - Blue component (Ususally 255) (Byte) 125
        // Alpha - Translucancy of beam (usually 255) (Byte) 225
        // Speed - Speed of beam (Byte) 100
    }


    block help
    {
        es es_cexec event_var(userid) clear
        es es_cexec event_var(userid) showconsole

        es es_cexec event_var(userid) echo   b4p's StarWars mod 
        es es_cexec event_var(userid) echo  
        es es_cexec event_var(userid) echo   About: I really gotta put something here.
        es es_cexec event_var(userid) echo   
        es es_cexec event_var(userid) echo   
    }


////////////////////////
// Menus
////////////////////////


    event player_say
    {        
        es_xsetinfo b4p_sw_teamNumber 0
        es_xsetinfo b4p_sw_playerIsAdmin 0

        es_keygetvalue b4p_sw_teamNumber b4p_sw_key event_var(userid) b4p_sw_key_teamNumber

        if (event_var(text) == swmenu) do
        {
        
            if (server_var(b4p_sw_classicModeEnabled) == 0) do
            {
                es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive 1
                es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_adminMenuActive 0

                if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then es_xdoblock b4p_starwars/empireMenuShow
                if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then es_xdoblock b4p_starwars/rebelMenuShow

                if (server_var(b4p_sw_teamNumber) == 1) then esnq ma_msay 6 event_var(userid) "Spectators are not allowed to access the StarWars menu."
                if (server_var(b4p_sw_teamNumber) == 0) then esnq ma_msay 6 event_var(userid) "Spectators are not allowed to access the StarWars menu."
            }
            if (server_var(b4p_sw_classicModeEnabled) == 1) then esnq ma_msay 6 event_var(userid) "the menu is not available in classic mode"
        }

        if (event_var(text) == swadmin) do
        {
            if (event_var(es_steamid) in server_var(b4p_sw_admins)) then es_setinfo b4p_sw_playerIsAdmin 1
            if (server_var(b4p_sw_playerIsAdmin) != 1) then esnq ma_msay 6 event_var(userid) "You are not an admin"
            
            if (server_var(b4p_sw_playerIsAdmin) == 1) do 
            {
                es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive 0
                es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_adminMenuActive 1
                es_xdoblock b4p_starwars/adminMenuShow
            }
        }
                
        if (event_var(text) == swhelp) then es_xdoblock b4p_starwars/help
    }
    
    
    event es_client_command
    {
        es_xsetinfo b4p_sw_modelMenuActive 0
        es_xsetinfo b4p_sw_adminMenuActive 0
        es_xsetinfo b4p_sw_teamNumber 0    

        es_keygetvalue b4p_sw_teamNumber b4p_sw_key event_var(userid) b4p_sw_key_teamNumber
        es_keygetvalue b4p_sw_modelMenuActive b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive
        es_keygetvalue b4p_sw_adminMenuActive b4p_sw_key event_var(userid) b4p_sw_key_adminMenuActive

        if (server_var(b4p_sw_modelMenuActive) == 1) do
        {
            
            es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive 0
            es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_adminMenuActive 0
            
            if (event_var(command) == menuselect) do
            {
                if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then es_xdoblock b4p_starwars/empireMenuAction
                if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then es_xdoblock b4p_starwars/rebelMenuAction
            }
        }

        if (server_var(b4p_sw_adminMenuActive) == 1) do
        {
            
            es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive 0
            es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_adminMenuActive 0
            
            if (event_var(command) == menuselect) do
            {
                es_xdoblock b4p_starwars/adminMenuAction
            }
        }
    }


    event player_disconnect
    {
	es_delayed 0.1 es est_RemoveIdle weapon_knife
	es_delayed 0.1 es est_RemoveIdle weapon_flashbang
	es_delayed 0.1 es est_RemoveIdle weapon_smokegrenade
	es_delayed 0.1 es est_RemoveIdle weapon_hegrenade
	es_delayed 0.1 es est_RemoveIdle weapon_fiveseven
	es_delayed 0.1 es est_RemoveIdle weapon_m4a1
	es_delayed 0.1 es est_RemoveIdle weapon_glock
	es_delayed 0.1 es est_RemoveIdle weapon_p90
	es_delayed 0.1 es est_RemoveIdle weapon_elite
	es_delayed 0.1 es est_RemoveIdle weapon_scout
	es_delayed 0.1 es est_RemoveIdle weapon_deagle
	es_delayed 0.1 es est_RemoveIdle weapon_ak47
	es_delayed 0.1 es est_RemoveIdle weapon_p228
	es_delayed 0.1 es est_RemoveIdle weapon_awp
	es_delayed 0.1 es est_RemoveIdle weapon_usp
	es_delayed 0.1 es est_RemoveIdle item_defuser
    }
    

    block adminMenuShow
    {   
        if (server_var(b4p_sw_lasers_enabled) == 1) then es_format b4p_sw_menuItem1 "disable lasers"
        if (server_var(b4p_sw_lasers_enabled) != 1) then es_format b4p_sw_menuItem1 "enable lasers"

        if (server_var(b4p_sw_weaponSoundsEnabled) == 1) then es_format b4p_sw_menuItem2 "disable weapon sounds"
        if (server_var(b4p_sw_weaponSoundsEnabled) != 1) then es_format b4p_sw_menuItem2 "enable weapon sounds"

        if (server_var(b4p_sw_charSoundsEnabled) == 1) then es_format b4p_sw_menuItem3 "disable character sounds"
        if (server_var(b4p_sw_charSoundsEnabled) != 1) then es_format b4p_sw_menuItem3 "enable character sounds"

        if (server_var(b4p_sw_lasers_trigEnabled) == 1) then es_format b4p_sw_menuItem4 "disable laser trig"
        if (server_var(b4p_sw_lasers_trigEnabled) != 1) then es_format b4p_sw_menuItem4 "enable laser trig"

        if (server_var(b4p_sw_lasers_teamColorsEnabled) == 1) then es_format b4p_sw_menuItem5 "disable team colors for lasers"
        if (server_var(b4p_sw_lasers_teamColorsEnabled) != 1) then es_format b4p_sw_menuItem5 "enable team colors for lasers"
        
        if (server_var(phys_pushscale) == 1) then es_format b4p_sw_menuItem6 "set phys_pushscale = 5000"
        if (server_var(phys_pushscale) != 1) then es_format b4p_sw_menuItem6 "set phys_pushscale = 1"
        
        if (server_var(b4p_sw_jediModeEnabled) == 1) then es_format b4p_sw_menuItem7 "disable jedi mode"
        if (server_var(b4p_sw_jediModeEnabled) != 1) then es_format b4p_sw_menuItem7 "enable jedi mode"
        
        if (server_var(b4p_sw_bobaJetsEnabled) == 1) then es_format b4p_sw_menuItem8 "disable boba fett's jets"
        if (server_var(b4p_sw_bobaJetsEnabled) != 1) then es_format b4p_sw_menuItem8 "enable boba fett's jets"
        
        if (server_var(b4p_sw_classicModeEnabled) == 1) then es_format b4p_sw_menuItem9 "disable classic mode"
        if (server_var(b4p_sw_classicModeEnabled) != 1) then es_format b4p_sw_menuItem9 "enable classic mode"

        es_setinfo b4p_sw_menu_text 0
        es_format b4p_sw_menu_text "choose an option:\n1. %1\n2. %2\n3. %3\n4. %4\n5. %5\n6. %6\n7. %7\n8. %8\n9. %9\n \n0. Close" server_var(b4p_sw_menuItem1) server_var(b4p_sw_menuItem2) server_var(b4p_sw_menuItem3) server_var(b4p_sw_menuItem4) server_var(b4p_sw_menuItem5) server_var(b4p_sw_menuItem6) server_var(b4p_sw_menuItem7) server_var(b4p_sw_menuItem8) server_var(b4p_sw_menuItem9)
        //es_format b4p_sw_menu_text "choose an option:\n1. %1\n2. %2\n3. %3\n4. %4\n5. %5\n6. %6\n7. %7\n8. %8\n \n0. Close" server_var(b4p_sw_menuItem1) server_var(b4p_sw_menuItem2) server_var(b4p_sw_menuItem3) server_var(b4p_sw_menuItem4) server_var(b4p_sw_menuItem5) server_var(b4p_sw_menuItem6) server_var(b4p_sw_menuItem7) server_var(b4p_sw_menuItem8)
        esnq ma_msay 10 event_var(userid) server_var(b4p_sw_menu_text)
    }


    block adminMenuAction
    {
        if (event_var(commandstring) == 1) do 
        {
            // toggle the value of b4p_tracers_enabled
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_lasers_enabled)
            if (server_var(b4p_sw_tempVar) == 1) do 
            {
                es_xsetinfo b4p_sw_lasers_enabled 0
                es_msg lasers disabled
            }
            if (server_var(b4p_sw_tempVar) != 1) do
            {
                es_xsetinfo b4p_sw_lasers_enabled 1
                es_msg lasers enabled
            }
        }
        if (event_var(commandstring) == 2) do 
        {
            // toggle the value of b4p_sw_weaponSoundsEnabled
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_weaponSoundsEnabled)
            if (server_var(b4p_sw_tempVar) == 1) do
            {
                es_xsetinfo b4p_sw_weaponSoundsEnabled 0
                es_msg weapon sounds disabled
            }
            if (server_var(b4p_sw_tempVar) != 1) do 
            {
                es_xsetinfo b4p_sw_weaponSoundsEnabled 1
                es_msg weapon sounds enabled
            }
        }
        if (event_var(commandstring) == 3) do 
        {
            // toggle the value of b4p_sw_charSoundsEnabled
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_charSoundsEnabled)
            if (server_var(b4p_sw_tempVar) == 1) do
            {
                es_xsetinfo b4p_sw_charSoundsEnabled 0
                es_msg character sounds disabled
            }
            if (server_var(b4p_sw_tempVar) != 1) do
            {
                es_xsetinfo b4p_sw_charSoundsEnabled 1
                es_msg character sounds enabled
            }
        }
        if (event_var(commandstring) == 4) do 
        {
            // toggle the value of b4p_sw_lasers_trigEnabled
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_lasers_trigEnabled)
            if (server_var(b4p_sw_tempVar) == 1) do
            {
                es_xsetinfo b4p_sw_lasers_trigEnabled 0
                es_msg tracer trig disabled
            }
            if (server_var(b4p_sw_tempVar) != 1) do
            {
                es_xsetinfo b4p_sw_lasers_trigEnabled 1
                es_msg laser trig enabled
            }
        }
        if (event_var(commandstring) == 5) do 
        {
            // toggle the value of b4p_sw_lasers_teamColorsEnabled
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_lasers_teamColorsEnabled)
            if (server_var(b4p_sw_tempVar) == 1) do
            {
                es_xsetinfo b4p_sw_lasers_teamColorsEnabled 0
                es_msg team colors for lasers disabled
            }
            if (server_var(b4p_sw_tempVar) != 1) do
            {
                es_xsetinfo b4p_sw_lasers_teamColorsEnabled 1
                es_msg team colors for lasers enabled
            }
        }
        if (event_var(commandstring) == 6) do 
        {
            // toggle the value of phys_pushscale
            es_setinfo b4p_sw_tempVar server_var(phys_pushscale)
            if (server_var(b4p_sw_tempVar) == 1) do
            {
                es_xsetinfo phys_pushscale 5000
                es_msg phys_pushscale changed to 5000
            }
            if (server_var(b4p_sw_tempVar) != 1) do
            {
                es_xsetinfo phys_pushscale 1
                es_msg phys_pushscale changed to 1
            }
        }
        if (event_var(commandstring) == 7) do 
        {
            // toggle the value of b4p_sw_jediModeEnabled
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_jediModeEnabled)
            if (server_var(b4p_sw_tempVar) == 1) do
            {
                es_xsetinfo b4p_sw_jediModeEnabled 0
                es_msg jedi mode will be disabled next round
            }
            if (server_var(b4p_sw_tempVar) != 1) do
            {
                es_xsetinfo b4p_sw_jediModeEnabled 1
                es_msg jedi mode will be enabled next round
            }
        }
        if (event_var(commandstring) == 8) do 
        {
            // toggle the value of b4p_sw_bobaJetsEnabled
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_bobaJetsEnabled)
            es_xsetinfo b4p_sw_tempUserIds 0
            if (server_var(b4p_sw_tempVar) == 1) do
            {
                es_xsetinfo b4p_sw_bobaJetsEnabled 0
                est_loop b4p_sw_tempUserIds #all "es est_SetGravity server_var(b4p_sw_tempUserIds) server_var(b4p_sw_normalGravity)"
                es_msg boba fett's jets disabled
            }
            if (server_var(b4p_sw_tempVar) != 1) do
            {
                es_xsetinfo b4p_sw_bobaJetsEnabled 1
                est_loop b4p_sw_tempUserIds #all es_xdoblock b4p_starwars/enableBobaJets
                es_msg boba fett's jets enabled
            }
        }
        if (event_var(commandstring) == 9) do 
        {
            // toggle the value of b4p_sw_classicModeEnabled
            es_setinfo b4p_sw_tempVar server_var(b4p_sw_classicModeEnabled)
            es_xsetinfo b4p_sw_tempUserIds 0
            if (server_var(b4p_sw_tempVar) == 1) do
            {
                es_xsetinfo b4p_sw_classicModeEnabled 0
                //est_loop b4p_sw_tempUserIds #all es_xdoblock b4p_starwars/disableClassicMode
                //es_msg classic mode disabled
                es_msg classic mode will be disabled next round
            }
            if (server_var(b4p_sw_tempVar) != 1) do
            {
                es_xsetinfo b4p_sw_classicModeEnabled 1
                //es_xdoblock b4p_starwars/enableClassicMode
                //es_msg classic mode enabled
                es_msg classic mode will be enabled next round
            }
        }
    }

    
    block disableClassicMode
    {
        es_keygetvalue b4p_sw_modelName b4p_sw_key server_var(b4p_sw_tempUserIds) b4p_sw_key_modelName
        es_format b4p_sw_modelPath "%1/%2/%2" server_var(b4p_sw_modelHome) server_var(b4p_sw_modelName)
        es est_setmodel server_var(b4p_sw_tempUserIds) server_var(b4p_sw_modelPath)
    }
    
    
    block enableClassicMode
    {
        est_loop b4p_sw_tempUserIds #all "es est_SetGravity server_var(b4p_sw_tempUserIds) server_var(b4p_sw_normalGravity)"

        if (server_var(b4p_sw_empireTeamNumber) == 3) do
        {
            est_loop b4p_sw_tempUserIds #c es_xdoblock b4p_starwars/setTeamStormTroopers
            est_loop b4p_sw_tempUserIds #t es_xdoblock b4p_starwars/setTeamRebels
        }
        if (server_var(b4p_sw_empireTeamNumber) == 2) do
        {
            est_loop b4p_sw_tempUserIds #t es_xdoblock b4p_starwars/setTeamStormTroopers
            est_loop b4p_sw_tempUserIds #c es_xdoblock b4p_starwars/setTeamRebels
        }
    }
    
    
    block setTeamStormTroopers
    {
        es_format b4p_sw_modelPath "%1/b4p_stormt/b4p_stormt" server_var(b4p_sw_modelHome)
        es est_setmodel server_var(b4p_sw_tempUserIds) server_var(b4p_sw_modelPath)
        es_keysetvalue b4p_sw_key server_var(b4p_sw_tempUserIds) b4p_sw_key_tempModelName "b4p_stormt"
    }
    
    block setTeamRebels
    {
        es_format b4p_sw_modelPath "%1/b4p_rebel/b4p_rebel" server_var(b4p_sw_modelHome)
        es est_setmodel server_var(b4p_sw_tempUserIds) server_var(b4p_sw_modelPath)
        es_keysetvalue b4p_sw_key server_var(b4p_sw_tempUserIds) b4p_sw_key_tempModelName "b4p_rebel"
    }
    
    block enableBobaJets
    {
        es_keygetvalue b4p_sw_modelName b4p_sw_key server_var(b4p_sw_tempUserIds) b4p_sw_key_tempModelName
        if (server_var(b4p_sw_modelName) == "b4p_bobafett") then es est_SetGravity server_var(b4p_sw_tempUserIds) server_var(b4p_sw_bobaFettGravity)
    }
    

    block rebelMenuShow
    {
        es_format b4p_sw_menuItem1 server_var(b4p_sw_RebelModelName1)
        es_format b4p_sw_menuItem2 server_var(b4p_sw_RebelModelName2)
        es_format b4p_sw_menuItem3 server_var(b4p_sw_RebelModelName3)
        es_format b4p_sw_menuItem4 server_var(b4p_sw_RebelModelName4)
        es_format b4p_sw_menuItem5 server_var(b4p_sw_RebelModelName5)
    //    es_format b4p_sw_menuItem6 server_var(b4p_sw_RebelModelName6)

        es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_modelName

        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_RebelModelFileName1)) then es_format b4p_sw_menuItem1 "* %1 *" server_var(b4p_sw_menuItem1)
        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_RebelModelFileName2)) then es_format b4p_sw_menuItem2 "* %1 *" server_var(b4p_sw_menuItem2)
        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_RebelModelFileName3)) then es_format b4p_sw_menuItem3 "* %1 *" server_var(b4p_sw_menuItem3)
        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_RebelModelFileName4)) then es_format b4p_sw_menuItem4 "* %1 *" server_var(b4p_sw_menuItem4)
        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_RebelModelFileName5)) then es_format b4p_sw_menuItem5 "* %1 *" server_var(b4p_sw_menuItem5)
    //    if (server_var(b4p_sw_modelName) == server_var(b4p_sw_RebelModelFileName6)) then es_format b4p_sw_menuItem6 "* %1 *" server_var(b4p_sw_menuItem6)

        es_setinfo b4p_sw_menu_text 0
    //    es_format b4p_sw_menu_text "choose a class:\n1. %1\n2. %2\n3. %3\n4. %4\n5. %5\n6. %6\n \n0. Cancel" server_var(b4p_sw_menuItem1) server_var(b4p_sw_menuItem2) server_var(b4p_sw_menuItem3) server_var(b4p_sw_menuItem4) server_var(b4p_sw_menuItem5) server_var(b4p_sw_menuItem6)
        es_format b4p_sw_menu_text "choose a class:\n1. %1\n2. %2\n3. %3\n4. %4\n5. %5\n \n0. Cancel" server_var(b4p_sw_menuItem1) server_var(b4p_sw_menuItem2) server_var(b4p_sw_menuItem3) server_var(b4p_sw_menuItem4) server_var(b4p_sw_menuItem5)
        esnq ma_msay 10 event_var(userid) server_var(b4p_sw_menu_text)
    }


    block rebelMenuAction
    {
        es_xsetinfo b4p_sw_teamNumber 0
        es_xsetinfo b4p_sw_modelMenuActive 0
        es_xsetinfo b4p_sw_previousModelName 0

        es_keygetvalue b4p_sw_previousModelName b4p_sw_key event_var(userid) b4p_sw_key_modelName
        
        es_keygetvalue b4p_sw_modelMenuActive b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive
        es_keygetvalue b4p_sw_teamNumber b4p_sw_key event_var(userid) b4p_sw_key_teamNumber

        if (server_var(b4p_sw_teamNumber) == server_var(b4p_sw_empireTeamNumber)) then es_setinfo commandstring 0

        if (event_var(commandstring) == 1) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName1)
        if (event_var(commandstring) == 2) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName2)
        if (event_var(commandstring) == 3) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName3)
        if (event_var(commandstring) == 4) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName4)
        if (event_var(commandstring) == 5) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName5)
        //if (event_var(commandstring) == 6) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_RebelModelFileName6)

        es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_menu 0
        /es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_modelName

        es_format b4p_sw_modelPath "%1/%2/%2" server_var(b4p_sw_modelHome) server_var(b4p_sw_modelName)
        if (server_var(b4p_sw_previousModelName) != server_var(b4p_sw_modelName)) then es est_Msg event_var(userid) your model will be changed next round
        
        //es est_Msg event_var(userid) Your model will be changed next round
    }


    block empireMenuShow
    {
        es_format b4p_sw_menuItem1 server_var(b4p_sw_EmpireModelName1)
        es_format b4p_sw_menuItem2 server_var(b4p_sw_EmpireModelName2)
        es_format b4p_sw_menuItem3 server_var(b4p_sw_EmpireModelName3)
        es_format b4p_sw_menuItem4 server_var(b4p_sw_EmpireModelName4)
        es_format b4p_sw_menuItem5 server_var(b4p_sw_EmpireModelName5)
    //    es_format b4p_sw_menuItem6 server_var(b4p_sw_EmpireModelName6)

        es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_modelName

        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_EmpireModelFileName1)) then es_format b4p_sw_menuItem1 "* %1 *" server_var(b4p_sw_menuItem1)
        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_EmpireModelFileName2)) then es_format b4p_sw_menuItem2 "* %1 *" server_var(b4p_sw_menuItem2)
        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_EmpireModelFileName3)) then es_format b4p_sw_menuItem3 "* %1 *" server_var(b4p_sw_menuItem3)
        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_EmpireModelFileName4)) then es_format b4p_sw_menuItem4 "* %1 *" server_var(b4p_sw_menuItem4)
        if (server_var(b4p_sw_modelName) == server_var(b4p_sw_EmpireModelFileName5)) then es_format b4p_sw_menuItem5 "* %1 *" server_var(b4p_sw_menuItem5)
    //    if (server_var(b4p_sw_modelName) == server_var(b4p_sw_EmpireModelFileName6)) then es_format b4p_sw_menuItem6 "* %1 *" server_var(b4p_sw_menuItem6)


        es_setinfo b4p_sw_menu_text 0
    //    es_format b4p_sw_menu_text "choose a class:\n1. %1\n2. %2\n3. %3\n4. %4\n5. %5\n6. %6\n \n0. Cancel" server_var(b4p_sw_menuItem1) server_var(b4p_sw_menuItem2) server_var(b4p_sw_menuItem3) server_var(b4p_sw_menuItem4) server_var(b4p_sw_menuItem5) server_var(b4p_sw_menuItem6)
        es_format b4p_sw_menu_text "choose a class:\n1. %1\n2. %2\n3. %3\n4. %4\n5. %5\n \n0. Cancel" server_var(b4p_sw_menuItem1) server_var(b4p_sw_menuItem2) server_var(b4p_sw_menuItem3) server_var(b4p_sw_menuItem4) server_var(b4p_sw_menuItem5)

        esnq ma_msay 10 event_var(userid) server_var(b4p_sw_menu_text)
    }


    block empireMenuAction
    {
        es_xsetinfo b4p_sw_teamNumber 0
        es_xsetinfo b4p_sw_modelMenuActive 0
        es_xsetinfo b4p_sw_previousModelName 0

        es_keygetvalue b4p_sw_previousModelName b4p_sw_key event_var(userid) b4p_sw_key_modelName
        es_keygetvalue b4p_sw_modelMenuActive b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive
        es_keygetvalue b4p_sw_teamNumber b4p_sw_key event_var(userid) b4p_sw_key_teamNumber

        if (server_var(b4p_sw_teamNumber) != server_var(b4p_sw_empireTeamNumber)) then es_setinfo commandstring 0

        if (event_var(commandstring) == 1) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName1)
        if (event_var(commandstring) == 2) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName2)
        if (event_var(commandstring) == 3) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName3)
        if (event_var(commandstring) == 4) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName4)
        if (event_var(commandstring) == 5) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName5)
        //if (event_var(commandstring) == 6) then es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelName server_var(b4p_sw_EmpireModelFileName6)

        es_keysetvalue b4p_sw_key event_var(userid) b4p_sw_key_modelMenuActive 0
        
        es_keygetvalue b4p_sw_modelName b4p_sw_key event_var(userid) b4p_sw_key_modelName
        
        if (server_var(b4p_sw_previousModelName) != server_var(b4p_sw_modelName)) then es est_Msg event_var(userid) your model will be changed next round

        //es_format b4p_sw_modelPath "%1/%2/%2" server_var(b4p_sw_modelHome) server_var(b4p_sw_modelName)

    }
