Jo Engine
2026.11.6
Jo Sega Saturn Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
jo_engine
jo
weapon.h
Go to the documentation of this file.
1
/*
2
** Jo Sega Saturn Engine
3
** Copyright (c) 2012-2026, Johannes Fetz (johannesfetz@gmail.com)
4
** All rights reserved.
5
**
6
** Redistribution and use in source and binary forms, with or without
7
** modification, are permitted provided that the following conditions are met:
8
** * Redistributions of source code must retain the above copyright
9
** notice, this list of conditions and the following disclaimer.
10
** * Redistributions in binary form must reproduce the above copyright
11
** notice, this list of conditions and the following disclaimer in the
12
** documentation and/or other materials provided with the distribution.
13
** * Neither the name of the Johannes Fetz nor the
14
** names of its contributors may be used to endorse or promote products
15
** derived from this software without specific prior written permission.
16
**
17
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
37
38
#ifndef __JO_WEAPON_H__
39
# define __JO_WEAPON_H__
40
41
#ifdef JO_COMPILE_WITH_FS_SUPPORT
42
44
# define JO_WEAPON_MAX (8)
46
# define JO_WEAPON_MAX_AMMO_TYPES (8)
47
49
# define JO_WEAPON_EVENT_FIRE (0x01)
// A shot: the bullet, the sound, the flash, the recoil
50
# define JO_WEAPON_EVENT_EMPTY (0x02)
// The trigger is pressed, nothing to fire (a click)
51
# define JO_WEAPON_EVENT_RELOAD (0x04)
// The reload starts
52
# define JO_WEAPON_EVENT_RELOAD_HALF (0x08)
// The middle of the reload: the new magazine goes in (the sound)
53
# define JO_WEAPON_EVENT_RELOAD_DONE (0x10)
// The magazine is full
54
# define JO_WEAPON_EVENT_SWITCH (0x20)
// The weapon changed (jo_weapons_current()): the new one comes up
55
57
typedef
struct
58
{
59
const
char
*
name
;
60
const
char
*
model
;
// JOM file ("": none)
61
const
char
*
flash
;
// Base name of the muzzle flashes
62
const
char
*
sound_shot
;
// PCM files
63
const
char
*
sound_reload
;
64
jo_fixed
x
;
// Position of the model in front of the camera (world units)
65
jo_fixed
y
;
66
jo_fixed
z
;
67
jo_fixed
muzzle_y
;
// The muzzle in the model
68
jo_fixed
muzzle_z
;
69
int
convergence
;
70
int
automatic
;
71
int
fire_delay
;
// Frames of the game (JO_FRAMERATE VBLANKs each) between 2 shots
72
int
damage
;
73
int
spread
;
74
int
recoil
;
75
int
kick
;
76
int
magazine
;
77
int
ammo_type
;
78
int
ammo_start
;
79
int
ammo_max
;
80
int
reload_time
;
// Frames of the game (counted in VBLANKs: the same time when the frame rate goes down)
81
int
switch_time
;
// Frames of the game
82
int
flash_size
;
83
int
casing
;
84
int
shot_volume
;
85
}
jo_weapon_def
;
86
92
int
jo_weapons_load
(
jo_level
*
const
level);
93
95
int
jo_weapons_count
(
void
);
96
100
const
jo_weapon_def
*
jo_weapons_def
(
const
int
index);
101
103
int
jo_weapons_current
(
void
);
104
109
void
jo_weapons_select
(
const
int
index);
110
118
unsigned
int
jo_weapons_update
(
const
bool
fire_held,
const
bool
fire_pressed,
const
bool
reload_pressed,
119
const
bool
switch_pressed);
120
122
int
jo_weapons_ammo
(
void
);
123
125
int
jo_weapons_reserve
(
void
);
126
128
int
jo_weapons_reload_progress
(
void
);
129
131
int
jo_weapons_lowered
(
void
);
132
137
void
jo_weapons_give_ammo
(
const
int
ammo_type,
const
int
count);
138
139
#endif
/* !JO_COMPILE_WITH_FS_SUPPORT */
140
141
#endif
/* !__JO_WEAPON_H__ */
142
143
/*
144
** END OF FILE
145
*/
jo_level
A loaded level.
Definition
level.h:51
jo_fixed
int jo_fixed
Fixed point Q16.16 number.
Definition
types.h:59
jo_weapons_def
const jo_weapon_def * jo_weapons_def(const int index)
Definition of a weapon.
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 swit...
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 a...
jo_weapon_def::sound_shot
const char * sound_shot
Definition
weapon.h:62
jo_weapon_def::kick
int kick
Definition
weapon.h:75
jo_weapon_def::sound_reload
const char * sound_reload
Definition
weapon.h:63
jo_weapons_count
int jo_weapons_count(void)
Number of weapons.
jo_weapon_def::magazine
int magazine
Definition
weapon.h:76
jo_weapon_def::casing
int casing
Definition
weapon.h:83
jo_weapon_def::muzzle_z
jo_fixed muzzle_z
Definition
weapon.h:68
jo_weapon_def::name
const char * name
Definition
weapon.h:59
jo_weapon_def::ammo_start
int ammo_start
Definition
weapon.h:78
jo_weapon_def::flash
const char * flash
Definition
weapon.h:61
jo_weapon_def::ammo_type
int ammo_type
Definition
weapon.h:77
jo_weapon_def::switch_time
int switch_time
Definition
weapon.h:81
jo_weapon_def::muzzle_y
jo_fixed muzzle_y
Definition
weapon.h:67
jo_weapon_def::damage
int damage
Definition
weapon.h:72
jo_weapon_def::y
jo_fixed y
Definition
weapon.h:65
jo_weapons_current
int jo_weapons_current(void)
The weapon in the hands (index).
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.
jo_weapon_def::fire_delay
int fire_delay
Definition
weapon.h:71
jo_weapon_def::convergence
int convergence
Definition
weapon.h:69
jo_weapon_def::model
const char * model
Definition
weapon.h:60
jo_weapons_reload_progress
int jo_weapons_reload_progress(void)
Reload of the current weapon: 0 (not reloading), else 1 to 256.
jo_weapon_def::ammo_max
int ammo_max
Definition
weapon.h:79
jo_weapons_ammo
int jo_weapons_ammo(void)
Bullets in the magazine of the current weapon.
jo_weapons_reserve
int jo_weapons_reserve(void)
Reserve of ammunition of the current weapon (its type).
jo_weapon_def::x
jo_fixed x
Definition
weapon.h:64
jo_weapon_def::shot_volume
int shot_volume
Definition
weapon.h:84
jo_weapon_def::spread
int spread
Definition
weapon.h:73
jo_weapon_def::automatic
int automatic
Definition
weapon.h:70
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_weapon_def::z
jo_fixed z
Definition
weapon.h:66
jo_weapon_def::recoil
int recoil
Definition
weapon.h:74
jo_weapon_def::reload_time
int reload_time
Definition
weapon.h:80
jo_weapons_give_ammo
void jo_weapons_give_ammo(const int ammo_type, const int count)
Give ammunition (a pickup).
jo_weapon_def::flash_size
int flash_size
Definition
weapon.h:82
jo_weapon_def
Definition of a weapon (the fields of the section WEAP).
Definition
weapon.h:58
Generated by
1.18.0