Additional Information

Construct 2
Construct 3

What is Weapon System behavior?

Weapon System is a Construct behavior that serves as manager of weapons and their properties. It is mostly designed for shooter games but can be used with any other game where a player or enemy can have multiple weapons with various properties. Not only guns but melee weapons as well or even magical spells. 

Why should you use it?

Imagine you want to make a shooter game where you want to feature plenty of different weapons and several can be owned at the same time: pistols, rifles, rocket launchers, melee weapons or magical ones. Each of them has different properties such as damage, rate of fire, ammunition capacity, reloading time etc. 

Such a mechanic obviously requires you to handle large amounts of variables and functions with lots of correlations. Moreover, let’s assume you want it to be a multiplayer game, where each player can loot a weapon of the defeated opponent, along with its properties such as currently loaded ammunition or upgrades applied. This makes such a system even more complicated and harder to handle. 

With the Weapon System you can easily add, remove, alter, select and use weapons owned by a user (player/enemy/ally/whatever). It’s a behavior, therefore you can easily manage them independently for each instance. 

Weapon System allows you to set and change on the fly any property of the weapon such as: 

  • damage,
  • rate of fire,
  • reloading time,
  • ammunition stored by the weapon,
  • clip/magazine capacity,

or a custom property of your design if you like. 

With this addon you can also remove the weapon and “drop” it, so it can be “picked” by another instance or object that has the behavior. 

How do you use it?

Once the behavior is added, you will need to set just three crucial events: 

  1. Set a “Register weapon” action to add a weapon and it’s basic properties (id, name, damage, rate of fire, amount of ammunition), 
  2. Set “Shoot” action to indicate when a shot (attack) takes place – e.g. by clicking Left Mouse Button
  3. Set “On shot” condition to determine what happens on every shot – e.g. spawn a bullet. 

That’s enough for a most basic weapon setup. Optionally, you can add more events to enrich your games weaponry:

  • register (add) more weapons with unique properties (set manually or by loading the properties from a JSON string),
  • drop (remove) the weapon and save it’s properties as a JSON string,
  • set reloading properties: reloading time, enable/disable auto-reload, what happens when reloading starts/ends/is in progress (e.g. play a reloading sound effect), 
  • set, add and remove spare ammunition,
  • change the properties on the fly as a part of an upgrade system: damage, ammo capacity, rate of fire or a custom stat of your design. 
  • trigger a shot using a currently selected weapon or another weapon indicated by its ID.

Thanks to dedicated actions and expressions, you can easily change which of the owned weapons is to be used and respectively trigger a shot with a currently selected weapon or other weapon of your choice by indicating its ID. 

WEAPON SYSTEM BEHAVIOR ACTIONS, CONDITIONS AND EXPRESSIONS

Actions
Conditions
Expressions