+ Reply to Thread
Results 1 to 8 of 8

Thread: Weapon Config Scripting with HUD Elements

  1. #1
    Senior Member Fi is on a distinguished road
    Join Date
    Jan 2011
    Posts
    1,105

    Weapon Config Scripting with HUD Elements

    I wrote a script that tells you what weapon you are wielding, binds for rocket jumping and quick switch attacks for Rocket Launcher and Rail Gun that also switches back to the weapon you were wielding before when you release the key. If you want to instantly repeat fire, just hold the key.

    If the files or folders doesn't exist you just have to create them.

    Autoexec.cfg
    Code:
    exec scripts
    The exec line will work just fine if you add it to the bottom of your existing autoexec file. If you want it to work well with the QL Ranks script, just add it right above that. The whole thing can be initialized at any time by simply executing the scripts file. Adding it to autoexec will only make it persistent upon restarting the game.

    Scripts.cfg
    Code:
    //Scripts
    //aliases
    alias +fi_rocketjump "+moveup; wait; +attack; wait; -moveup"
    alias -fi_rocketjump "-attack"
    alias +fi_quickrocket "set cg_weaponConfig_rl vstr fi_null; weapon 5; wait 2; +attack"
    alias -fi_quickrocket "-attack; wait; vstr fi_back; set cg_weaponConfig_rl vstr fi_weapon_rl"
    alias +fi_quickrail "set cg_weaponConfig_rg vstr fi_null; weapon 7; wait 2; +attack"
    alias -fi_quickrail "-attack; wait; vstr fi_back; set cg_weaponConfig_rg vstr fi_weapon_rg"
    
    //binds
    bind x "+fi_rocketjump"
    bind y "+fi_quickrocket"
    bind z "+fi_quickrail"
    
    //cvars
    seta cg_hudFiles "ui/weapon.cfg"
    
    seta cg_weaponConfig_g "set fi_weapon 1; set fi_back weapon 1"
    seta cg_weaponConfig_mg "set fi_weapon 2; set fi_back weapon 2"
    seta cg_weaponConfig_sg "set fi_weapon 3; set fi_back weapon 3"
    seta cg_weaponConfig_gl "set fi_weapon 4; set fi_back weapon 4"
    seta cg_weaponConfig_rl "set fi_weapon 5; set fi_back weapon 5"
    seta cg_weaponConfig_lg "set fi_weapon 6; set fi_back weapon 6"
    seta cg_weaponConfig_rg "set fi_weapon 7; set fi_back weapon 7"
    seta cg_weaponConfig_pg "set fi_weapon 8; set fi_back weapon 8"
    seta cg_weaponConfig_bfg "set fi_weapon 9; set fi_back weapon 9"
    seta cg_weaponConfig_gh "set fi_weapon 10; set fi_back weapon 10"
    seta cg_weaponConfig_ng "set fi_weapon 11; set fi_back weapon 11"
    seta cg_weaponConfig_pl "set fi_weapon 12; set fi_back weapon 12"
    seta cg_weaponConfig_cg "set fi_weapon 13; set fi_back weapon 13"
    seta cg_weaponConfig "set fi_weapon 0"
    
    seta fi_null ""
    seta fi_weapon "2"
    seta fi_back "weapon 2"
    
    seta fi_weapon_rl "set fi_weapon 5; set fi_back weapon 5"
    seta fi_weapon_rg "set fi_weapon 7; set fi_back weapon 7"
    
    //calibrate
    weapon 2
    fi_weapon is the weapon you are wielding.
    fi_back is the command used to go back to the previous weapon when you quick attack.
    cg_weaponConfigs need to be modified or cleared upon quick switch, otherwise they will set themselves to the weapon to go back to.

    The text won't change when you quick switch. If you want the text to change, add "set fi_weapon 5" after "weapon 5" in the +quickrocket alias. The same can be done for the +quickrail alias with a minor change to the number.

    ui\weapon.cfg
    Code:
    // ========== Destiny Concept =====================================================
    // Version 0.0.1
    {
    	loadMenu { "ui/hud.menu" }
    	loadMenu { "ui/weapon.menu" }
    }
    ui\weapon.menu
    Code:
    // ========== Destiny Weapon ======================================================
    // Version 0.0.1
    
    #include "ui/menudef.h"
    
    // ========== Variables ===========================================================
    #define	def_menu			fullScreen MENU_FALSE visible MENU_TRUE
    #define	def_item			visible MENU_TRUE decoration
    
    #define var_g				.2	1	1
    #define var_mg				1	1	.2
    #define var_sg				1	.5	.2
    #define var_gl				.1	.7	.1
    #define var_rl				1	.2	.2
    #define var_lg				1	1	.75
    #define var_rg				.1	1	.1
    #define var_pg				1	.2	1
    #define var_bfg				.2	.3	1
    #define var_gh				1	1	1
    #define var_ng				.2	1	1
    #define var_pl				1	.2	.5
    #define var_cg				.8	.8	.8
    
    #define var_opaque			1
    
    #define var_weapon			.25
    
    // ========== Weapon ==============================================================
    menuDef {
    	def_menu
    	name "WeaponArea"
    	rect 5 460 100 10
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {1}
    		text "Gauntlet"
    		forecolor var_g var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {2}
    		text "Machine Gun"
    		forecolor var_mg var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {3}
    		text "Shotgun"
    		forecolor var_sg var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {4}
    		text "Grenade Launcher"
    		forecolor var_gl var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {5}
    		text "Rocket Launcher"
    		forecolor var_rl var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {6}
    		text "Lightning Gun"
    		forecolor var_lg var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {7}
    		text "Rail Gun"
    		forecolor var_rg var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {8}
    		text "Plasma Gun"
    		forecolor var_pg var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {9}
    		text "BFG"
    		forecolor var_bfg var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {10}
    		text "Grappling Hook"
    		forecolor var_gh var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {11}
    		text "Nailgun"
    		forecolor var_ng var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {12}
    		text "Proximity Mine"
    		forecolor var_pl var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    
    	itemDef {
    		def_item
    		cvarTest "fi_weapon"
    		showCvar {13}
    		text "Chain Gun"
    		forecolor var_cg var_opaque
    		textstyle ITEM_TEXTSTYLE_NORMAL
    		textscale var_weapon
    	}
    }
    The fi_weapon cvarTest can be used for almost any HUD element, like custom crosshairs, tailored ammo bars and other indicators.

    Update: Just tested this online and it seems to be working with ping 70 and below. Not tested with higher ping yet.
    Last edited by Fi; 12-19-2011 at 03:22 PM.

  2. #2
    Senior Member Fi is on a distinguished road
    Join Date
    Jan 2011
    Posts
    1,105
    For those of you that just want the quick rail plus switch back script. This is what you need.

    Scripts.cfg
    Code:
    //Scripts
    //aliases
    alias +fi_quickrail "set cg_weaponConfig_rg vstr fi_null; weapon 7; wait 2; +attack"
    alias -fi_quickrail "-attack; wait; vstr fi_back; set cg_weaponConfig_rg vstr fi_weapon_rg"
    
    //binds
    bind z "+fi_quickrail"
    
    //cvars
    seta cg_weaponConfig_g "set fi_back weapon 1"
    seta cg_weaponConfig_mg "set fi_back weapon 2"
    seta cg_weaponConfig_sg "set fi_back weapon 3"
    seta cg_weaponConfig_gl "set fi_back weapon 4"
    seta cg_weaponConfig_rl "set fi_back weapon 5"
    seta cg_weaponConfig_lg "set fi_back weapon 6"
    seta cg_weaponConfig_rg "set fi_back weapon 7"
    seta cg_weaponConfig_pg "set fi_back weapon 8"
    seta cg_weaponConfig_bfg "set fi_back weapon 9"
    seta cg_weaponConfig_gh "set fi_back weapon 10"
    seta cg_weaponConfig_ng "set fi_back weapon 11"
    seta cg_weaponConfig_pl "set fi_back weapon 12"
    seta cg_weaponConfig_cg "set fi_back weapon 13"
    seta cg_weaponConfig ""
    
    seta fi_null ""
    seta fi_back "weapon 2"
    
    seta fi_weapon_rg "set fi_back weapon 7"
    
    //calibrate
    weapon 2
    That is with the switch back. If you just want the quick rail, try this instead.

    Script.cfg
    Code:
    +alias fi_quickrail "weapon 7; wait 2; +attack"
    -alias fi_quickrail "-attack"
    
    bind x "+fi_quickrail"
    Since there is plenty of time to switch to any weapon after the rail gun fires, there is really no need to switch back automatically. Maybe if you are lazy, but timing the second rail can be just as crucial, so the auto-switch can get in the way.
    Last edited by Fi; 12-19-2011 at 03:22 PM.

  3. #3
    Senior Member Fi is on a distinguished road
    Join Date
    Jan 2011
    Posts
    1,105
    How often have you been amazed how the pro players open doors with the Machine Gun and then switch weapon so fast? I made a script for that too. Once you get the hang of it, it's quite easy.

    scripts.cfg
    Code:
    //poke
    alias +fi_poke "clearcvar cg_weaponConfig_mg; weapon 2; wait 2; +attack"
    alias -fi_poke "-attack; wait; vstr fi_back; set cg_weaponConfig_mg set fi_back weapon 2"
    
    bind x "+fi_poke"
    
    seta fi_back "weapon 2"
    
    seta cg_weaponConfig_g "set fi_back weapon 1"
    seta cg_weaponConfig_mg "set fi_back weapon 2"
    seta cg_weaponConfig_sg "set fi_back weapon 3"
    seta cg_weaponConfig_gl "set fi_back weapon 4"
    seta cg_weaponConfig_rl "set fi_back weapon 5"
    seta cg_weaponConfig_lg "set fi_back weapon 6"
    seta cg_weaponConfig_rg "set fi_back weapon 7"
    seta cg_weaponConfig_pg "set fi_back weapon 8"
    seta cg_weaponConfig_bfg "set fi_back weapon 9"
    seta cg_weaponConfig_gh "set fi_back weapon 10"
    seta cg_weaponConfig_ng "set fi_back weapon 11"
    seta cg_weaponConfig_pl "set fi_back weapon 12"
    seta cg_weaponConfig_cg "set fi_back weapon 13"
    seta cg_weaponConfig ""
    
    weapon 2
    Use the Machine Gun to poke with. Good for opening doors, finishing off opponents or making them weak enough for some other weapon to be a one shot kill.

    This time around I use clearcvar instead of a null variable. Since the value of the weapon config variable isn't supposed to change, I can set it directly without using another variable.

    Since I like to show, here is how-to double poke on Vertical Vengeance.
    QL Trick VerticalVengeance Fi Double Poke 20111219 Cobalt 01a
    Using the script to fast-switch, naturally.
    Last edited by Fi; 12-19-2011 at 03:37 PM.

  4. #4
    Senior Member Fi is on a distinguished road
    Join Date
    Jan 2011
    Posts
    1,105
    I zoom scroll script was requested a couple of minutes ago, so I made one. This will allow you to scroll weapons when zoom is off and allow zoom in and out when zoom is on.

    Script.cfg
    Code:
    //scroll zoom
    bind MOUSE2 "vstr fi_zbtn1"
    
    seta fi_zbtn1 "+zoom; vstr fi_z00; vstr fi_zon"
    seta fi_zbtn2 "+zoom; vstr fi_zoff"
    
    seta fi_zon "bind MWHEELDOWN vstr fi_zdown; bind MWHEELUP vstr fi_zup; bind MOUSE2 vstr fi_zbtn2"
    seta fi_zoff "bind MWHEELDOWN weapprev; bind MWHEELUP weapnext; bind MOUSE2 vstr fi_zbtn1"
    
    seta fi_zup ""
    seta fi_zdown "vstr fi_z01"
    
    seta fi_z00 "set cg_zoomfov 50; clearcvar fi_zup; set fi_zdown vstr fi_z01"
    seta fi_z01 "set cg_zoomfov 40; set fi_zup vstr fi_z00; set fi_zdown vstr fi_z02"
    seta fi_z02 "set cg_zoomfov 30; set fi_zup vstr fi_z01; set fi_zdown vstr fi_z03"
    seta fi_z03 "set cg_zoomfov 20; set fi_zup vstr fi_z02; set fi_zdown vstr fi_z04"
    seta fi_z04 "set cg_zoomfov 10; set fi_zup vstr fi_z03; clearcvar fi_zdown"
    
    seta cg_zoomtoggle "1"
    If or rather when this goes out of sync, you can enter "+zoom" once in console to toggle it back in phase. If that occurs frequently you better bind an extra key for that command alone.

    If you want this bound to space bar instead of second mouse button, just replace all MOUSE2 with SPACE and it will work just the same.

  5. #5
    *expilicious
    Guest
    Quote Originally Posted by Fi View Post
    I zoom scroll script was requested a couple of minutes ago, so I made one. This will allow you to scroll weapons when zoom is off and allow zoom in and out when zoom is on.

    Script.cfg
    Code:
    //scroll zoom
    bind MOUSE2 "vstr fi_zbtn1"
    
    seta fi_zbtn1 "+zoom; vstr fi_z00; vstr fi_zon"
    seta fi_zbtn2 "+zoom; vstr fi_zoff"
    
    seta fi_zon "bind MWHEELDOWN vstr fi_zdown; bind MWHEELUP vstr fi_zup; bind MOUSE2 vstr fi_zbtn2"
    seta fi_zoff "bind MWHEELDOWN weapprev; bind MWHEELUP weapnext; bind MOUSE2 vstr fi_zbtn1"
    
    seta fi_zup ""
    seta fi_zdown "vstr fi_z01"
    
    seta fi_z00 "set cg_zoomfov 50; clearcvar fi_zup; set fi_zdown vstr fi_z01"
    seta fi_z01 "set cg_zoomfov 40; set fi_zup vstr fi_z00; set fi_zdown vstr fi_z02"
    seta fi_z02 "set cg_zoomfov 30; set fi_zup vstr fi_z01; set fi_zdown vstr fi_z03"
    seta fi_z03 "set cg_zoomfov 20; set fi_zup vstr fi_z02; set fi_zdown vstr fi_z04"
    seta fi_z04 "set cg_zoomfov 10; set fi_zup vstr fi_z03; clearcvar fi_zdown"
    
    seta cg_zoomtoggle "1"
    If or rather when this goes out of sync, you can enter "+zoom" once in console to toggle it back in phase. If that occurs frequently you better bind an extra key for that command alone.

    If you want this bound to space bar instead of second mouse button, just replace all MOUSE2 with SPACE and it will work just the same.
    Thanks again Fi, I couldn't figure out how to get it to work with zoom toggle enabled.

    Here's the version I came up with that works with zoom toggle disabled =

    Code:
    bind space "+zoom; +zoomage" 
    
    alias +zoomage "bind mwheelup vstr zdn; bind mwheeldown vstr zup"
    alias -zoomage "bind mwheelup say_team enemy low; bind mwheeldown say_team enemy high; cg_zoomfov 50"
    
    set zdn vstr z00
    set zup vstr z01
    set z00 "set cg_zoomfov 50;set zdn vstr z00;set zup vstr z01"
    set z01 "set cg_zoomfov 40;set zdn vstr z00;set zup vstr z02"
    set z02 "set cg_zoomfov 30;set zdn vstr z01;set zup vstr z03"
    set z03 "set cg_zoomfov 20;set zdn vstr z02;set zup vstr z04"
    set z04 "set cg_zoomfov 10;set zdn vstr z03;set zup vstr z04"
    http://www.youtube.com/watch?v=FhELCqmdjNg
    Last edited by expilicious; 12-19-2011 at 06:13 PM.

  6. #6
    Member Downlink is on a distinguished road
    Join Date
    Oct 2011
    Location
    Under your bed
    Posts
    80
    cant shoot or jump and it isnt workingfor me, i done it it through the console, how do i turn it off

  7. #7
    *trolltk
    Guest
    i it possible to make script for showing weapon model on fov 90 while playing with higher fov?

  8. #8
    Senior Member ybl is on a distinguished road ybl's Avatar
    Join Date
    Aug 2010
    Posts
    1,487
    change cg_gunx and y, z
    CA with <16 slots is nothing.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts