en fr

es pl

sv de
direct download download direct download

howto/en/create a weapon

From Wormux

Create a new weapon

Creating a new weapon for Wormux requires a quite good knowledge of C++. If you are not able to program, you can suggest new ideas on page brainstorming.


Graphical part

  • create the beautiful pictures (in .png) that are needed ;-)
  • add the files in data/weapon/<weapon_name>/
  • "register" the files in data/weapons.xml

example of bazooka section in data/weapons.xml:

 <surface name="bazooka_ico" file="weapon/bazooka/bazooka_ico.png" />
 <surface name="bazooka" file="weapon/bazooka/bazooka.png" />
 <surface name="baz_cible" file="weapon/bazooka/baz_cible.png" />
 <sprite name="rocket">
   <image file="weapon/bazooka/missile.png">
     <grid pos="0,0" size="20,20" array="1,1" />
   </image>
 </sprite>

Go to source code ;-)

  • In file src/weapon/weapon.h, add a new value in the following enumeration:
typedef enum
{
       WEAPON_BAZOOKA,
       WEAPON_AUTOMATIC_BAZOOKA,
       WEAPON_GRENADE,
       WEAPON_HOLLY_GRENADE,
       WEAPON_CLUSTER_BOMB,
       WEAPON_GUN,
       WEAPON_UZI,
       WEAPON_BASEBALL,
       WEAPON_DYNAMITE,
       WEAPON_MINE,
       WEAPON_SUPERTUX,
       WEAPON_AIR_ATTACK,
       WEAPON_GNU,
       WEAPON_BOUNCE_BALL,
       WEAPON_TELEPORTATION,
       WEAPON_NINJA_ROPE,
       WEAPON_LOWGRAV,
       WEAPON_SUICIDE,
       WEAPON_SKIP_TURN,
       WEAPON_JETPACK,
       WEAPON_PARACHUTE,
       WEAPON_AIR_HAMMER
} Weapon_type;
  • In file src/weapon/all.h, add the include to your new weapon:
 #include "bazooka.h"
  • In file src/weapon/weapons_list.cpp, add the weapon in the weapons menu:
 Bazooka* bazooka = new Bazooka;
 AddToList(bazooka, 1);

1 is the column in which the weapon will appear in the weapon menu. This value must be 1,2,3,4 or 5.

  • Add your weapon in the makefile, edit file src/Makefile.am
  • And the most difficult, code your weapon and add the configuration value in data/game_mode/classic.xml:

For weapons which launch a projectile, the "launcher" should inherit from WeaponLauncher and the projectile from WeaponProjectile or WeaponBullet if the weapon is a sort of gun.

TO COMPLETE !!