WeaponMod

Sections

  1. Installation
  2. CVARs
  3. Commands
  4. Mod Support
  5. Building a weapon
  6. Credits and copyrights

I. Installation

WeaponMod requires AMX Mod X 1.76c or above with FakeMeta module enabled.

To install the mod, follow these directions:

  1. Extract WeaponMod package into your addons/amxmodx directory
  2. Open addons/amxmodx/configs/weaponmod directory configure the cfg files to suit your needs
  3. Open addons/amxmodx/configs/plugins.ini And add the following
  4. Restart your HLDS server, and you're done!

II. CVARs

The following table only contains CVARs defined by WeaponMod and the Gameinfo plugins. They can be changed inside addons/amxmodx/configs/weaponmod/weaponmod.cfg. CVARs defined by addons are available in addons/amxmodx/configs/weaponmod/addons.cfg.

WeaponMod CVARs
Name Information Default Value
wpn_enabled Enables or disables WeaponMod
  1. Disables WeaponMod
  2. Enables WeaponMod
1
wpn_logmode Defines the mode how errors should be logged
  1. No logging
  2. Print to console
  3. Print to console and write log file
0
wpn_friendlyfire Enables or disables friendlyfire for WeaponMod
This setting will be ignored in non teamplay games
  1. Disables friendlyfire for WeaponMod
  2. Enables friendlyfire for WeaponMod
1
wpn_kickback_force Force of the kickback on enemies done by explosions whereas 1.0 is equal to 100%
This can be more or less than 1.0
1.0
wpn_kickback_force_ff Same as wpn_kickback_force except that this one is for teammates
This setting will be ignored in non teamplay games or if WeaponMod's friendlyfire is disabled
1.0
wpn_monster_frags Defines the amount of frags given when a player kills a Monster using a WeaponMod weapon 0
wpn_impact_through_objects Defines if damage and kickback effect on explosions can go through walls and objects (like boxes)
  1. Disables impact through walls
  2. Enables impact through walls
0
GameInfo CVARs
Name Information Default Value
wpn_playerkill_money Mod specific
Defines how much money a player earns for killing a player
300
wpn_monsterkill_money Mod specific
Defines how much money a player earns for killing a monster
800

III. Commands

WeaponMod Commands
Command Information Type
weaponmod
version displays weaponmod version info
team displays weaponmod team info
credits displays weaponmod credits info
weapons displays weaponmod weapons info
Client/Server

IV. Mod Support

GameInfo Plugins
Mod File Supported Notes
Counter-Strike wpn_gameinfo_cs.amxx 95%
  • Weaponlist missing
Condition Zero wpn_gameinfo_cz.amxx 95%
  • partically tested
  • Weaponlist missing
The Specialists wpn_gameinfo_ts.amxx 85%
  • Weaponlist missing
  • Speed dependant on free/used slots missing
Beside that you need to install this plugin to enable TS support, you have to uncomment "TS_FIX" at the top the file weaponmod.sma and recompile it.
Day of Defeat wpn_gameinfo_dod.amxx 70%
  • Weaponlist missing
  • Ammo display missing
Team Fortress Classic wpn_gameinfo_tfc.amxx 95%
  • partically tested
  • Weaponlist missing

V. Building a weapon

Building a very, very basic WeaponMod weapon is quite easy, but you still need some basic skills in PAWN/AMXX scripting.
I'll leave the plugin registration, file precaching and other things out and come to the weapon mod basics.

First thing you need to do is, of course, include the WeaponMod libraries.

// Basic WeaponMod functions, implements weaponmod_const.inc
#include <weaponmod>

// Not required, but it has a set of useful stocks
#include <weaponmod_stocks>

To keep the plugin_init() function clean, we use a private function to register a weapon. Remember, this has to be called manually since it's not automatically executed (e.g. inside plugin_init()).

// We need this later
new wpnid

// Call me inside plugin_init
create_weapon()
{
	// Register the weapon and store the returned value because we need it
	wpnid = wpn_register_weapon("Example Weapon", "example")
	if(!wpnid) return PLUGIN_CONTINUE	// Registration failed
	
	// Define the models to use (of course, they have to be precached)
	wpn_set_string(wpnid, wpn_viewmodel, "models/v_357.mdl")
	wpn_set_string(wpnid, wpn_weaponmodel, "models/p_357.mdl")
	wpn_set_string(wpnid, wpn_worldmodel, "models/w_357.mdl")
	
	// Basic settings
	wpn_set_float(wpnid, wpn_run_speed, 240.0)	// Running speed
	wpn_set_integer(wpnid, wpn_ammo1, 6)		// Primary Ammo
	wpn_set_integer(wpnid, wpn_ammo2, 60)	// Secondary Ammo
	wpn_set_integer(wpnid, wpn_cost, 3000)	// Cost of this weapon
	
	// Do we just use attack 1, we do not have to define attack 2 values
	wpn_set_float(wpnid, wpn_refire_rate1, 0.3)
	wpn_set_integer(wpnid, wpn_bullets_per_shot1, 1)
	wpn_set_float(wpnid, wpn_recoil1, 7.0)
	
	// Define the amount of time a player needs to reload
	wpn_set_float(wpnid, wpn_reload_time, 1.0)
	
	// Finally we register our event handle
	wpn_register_event(wpnid, event_attack1, "wpnEventAttack1")
	
	return PLUGIN_CONTINUE
}

We have now successfully registered our new weapon. Since WeaponMod manages everything itself, we do not have to do anything else than just handling the registered events. Registered event handles will only execute when a player is using a registered weapon.

// WeaponMod executes me as soon as attack 1 is pressed
public wpnEventAttack1(id)
{
	// Doing the actions is your task, but to show how easy it is, 
	// I'll execute a native provided by WeaponMod
	wpn_bullet_shot(wpnid, id, 10, random_num(30, 40))
}

To build more powerful weapons, it might be a good idea taking a look in some of the weapons which have already been released (either in the default package, or in the weapon forums). To use animations in your weapons, you just need to execute wpn_playanim(id, animation) when the specific event occurs.

Beside the possibility of easily building powerful weapons, WeaponMod's API allows also building new external plugins which interact with WeaponMod. If you want to write such an addon, take a look in one of the default addons provided in the WeaponMod package, or watch the addons forum.

VI. Credits and copyrights

/* Copyright (C) 2006-2008 Space Headed Productions
*
* WeaponMod is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeaponMod; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
WeaponMod Team:
Lead Developer: Christoph "DevconeS" Amrein
Special Thanks:
Arkshine
Phil "Orangutanz" Poland
Beta Testers
cs1.6
Lord_Destros