Weapons of the player: the definitions (section WEAP of a level, for instance a file of definitions shared by the levels, see Documentation/level_format.md) and their rules: ammunition, fire rate (automatic or one shot per press), reload, change of weapon. The game draws the weapon of jo_weapons_current() and makes the shots (the bullets, the sounds, the flash) on the events of jo_weapons_update().
More...
Go to the source code of this file.
|
| int | jo_weapons_load (jo_level *const level) |
| | Read the definitions of the weapons (section WEAP): the player has all of them, with full magazines and the reserve of ammo_start; the first one is taken.
|
| int | jo_weapons_count (void) |
| | Number of weapons.
|
| const jo_weapon_def * | jo_weapons_def (const int index) |
| | Definition of a weapon.
|
| int | jo_weapons_current (void) |
| | The weapon in the hands (index).
|
| void | jo_weapons_select (const int index) |
| | Take a weapon (a selection in a menu): the current one goes down, the new one comes up (like the switch button of jo_weapons_update(), which takes the next one).
|
| unsigned int | jo_weapons_update (const bool fire_held, const bool fire_pressed, const bool reload_pressed, const bool switch_pressed) |
| | Rules of the weapons, once per frame of the game.
|
| int | jo_weapons_ammo (void) |
| | Bullets in the magazine of the current weapon.
|
| int | jo_weapons_reserve (void) |
| | Reserve of ammunition of the current weapon (its type).
|
| int | jo_weapons_reload_progress (void) |
| | Reload of the current weapon: 0 (not reloading), else 1 to 256.
|
| int | jo_weapons_lowered (void) |
| | The weapon goes down and up when it is changed: 0 (in the hands) to 256 (out of the view).
|
| void | jo_weapons_give_ammo (const int ammo_type, const int count) |
| | Give ammunition (a pickup).
|
Weapons of the player: the definitions (section WEAP of a level, for instance a file of definitions shared by the levels, see Documentation/level_format.md) and their rules: ammunition, fire rate (automatic or one shot per press), reload, change of weapon. The game draws the weapon of jo_weapons_current() and makes the shots (the bullets, the sounds, the flash) on the events of jo_weapons_update().
- Author
- Johannes Fetz
◆ jo_weapon_def
Definition of a weapon (the fields of the section WEAP).
| Data Fields |
|
int |
ammo_max |
|
|
int |
ammo_start |
|
|
int |
ammo_type |
|
|
int |
automatic |
|
|
int |
casing |
|
|
int |
convergence |
|
|
int |
damage |
|
|
int |
fire_delay |
|
|
const char * |
flash |
|
|
int |
flash_size |
|
|
int |
kick |
|
|
int |
magazine |
|
|
const char * |
model |
|
|
jo_fixed |
muzzle_y |
|
|
jo_fixed |
muzzle_z |
|
|
const char * |
name |
|
|
int |
recoil |
|
|
int |
reload_time |
|
|
int |
shot_volume |
|
|
const char * |
sound_reload |
|
|
const char * |
sound_shot |
|
|
int |
spread |
|
|
int |
switch_time |
|
|
jo_fixed |
x |
|
|
jo_fixed |
y |
|
|
jo_fixed |
z |
|
◆ JO_WEAPON_EVENT_EMPTY
| #define JO_WEAPON_EVENT_EMPTY |
◆ JO_WEAPON_EVENT_FIRE
| #define JO_WEAPON_EVENT_FIRE |
◆ JO_WEAPON_EVENT_RELOAD
| #define JO_WEAPON_EVENT_RELOAD |
◆ JO_WEAPON_EVENT_RELOAD_DONE
| #define JO_WEAPON_EVENT_RELOAD_DONE |
◆ JO_WEAPON_EVENT_RELOAD_HALF
| #define JO_WEAPON_EVENT_RELOAD_HALF |
◆ JO_WEAPON_EVENT_SWITCH
| #define JO_WEAPON_EVENT_SWITCH |
◆ JO_WEAPON_MAX
◆ JO_WEAPON_MAX_AMMO_TYPES
| #define JO_WEAPON_MAX_AMMO_TYPES |
Types of ammunition at most.
◆ jo_weapons_ammo()
| int jo_weapons_ammo |
( |
void | | ) |
|
Bullets in the magazine of the current weapon.
◆ jo_weapons_count()
| int jo_weapons_count |
( |
void | | ) |
|
◆ jo_weapons_current()
| int jo_weapons_current |
( |
void | | ) |
|
The weapon in the hands (index).
◆ jo_weapons_def()
Definition of a weapon.
- Parameters
-
◆ jo_weapons_give_ammo()
| void jo_weapons_give_ammo |
( |
const int | ammo_type, |
|
|
const int | count ) |
Give ammunition (a pickup).
- Parameters
-
| ammo_type | Type of ammunition |
| count | Bullets (the reserve doesn't go over ammo_max, nor under 0; a reserve already over it stays) |
◆ jo_weapons_load()
| int jo_weapons_load |
( |
jo_level *const | level | ) |
|
Read the definitions of the weapons (section WEAP): the player has all of them, with full magazines and the reserve of ammo_start; the first one is taken.
- Parameters
-
| level | Level (it can be freed after) |
- Returns
- Number of weapons
◆ jo_weapons_lowered()
| int jo_weapons_lowered |
( |
void | | ) |
|
The weapon goes down and up when it is changed: 0 (in the hands) to 256 (out of the view).
◆ jo_weapons_reload_progress()
| int jo_weapons_reload_progress |
( |
void | | ) |
|
Reload of the current weapon: 0 (not reloading), else 1 to 256.
◆ jo_weapons_reserve()
| int jo_weapons_reserve |
( |
void | | ) |
|
Reserve of ammunition of the current weapon (its type).
◆ jo_weapons_select()
| void jo_weapons_select |
( |
const int | index | ) |
|
Take a weapon (a selection in a menu): the current one goes down, the new one comes up (like the switch button of jo_weapons_update(), which takes the next one).
- Parameters
-
| index | Index of the weapon (nothing happens when it is the current one, or while a weapon changes) |
◆ jo_weapons_update()
| unsigned int jo_weapons_update |
( |
const bool | fire_held, |
|
|
const bool | fire_pressed, |
|
|
const bool | reload_pressed, |
|
|
const bool | switch_pressed ) |
Rules of the weapons, once per frame of the game.
- Parameters
-
| fire_held | The fire button is held (automatic weapons) |
| fire_pressed | The fire button was pressed in this frame (the other weapons) |
| reload_pressed | The reload button was pressed |
| switch_pressed | The button to change of weapon was pressed: the next weapon |
- Returns
- JO_WEAPON_EVENT_xxx (bits)