Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
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_LEVEL_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
57typedef 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
92int jo_weapons_load(jo_level * const level);
93
95int jo_weapons_count(void);
96
100const jo_weapon_def *jo_weapons_def(const int index);
101
103int jo_weapons_current(void);
104
109void jo_weapons_select(const int index);
110
118unsigned int jo_weapons_update(const bool fire_held, const bool fire_pressed, const bool reload_pressed,
119 const bool switch_pressed);
120
122int jo_weapons_ammo(void);
123
125int jo_weapons_reserve(void);
126
128int jo_weapons_reload_progress(void);
129
131int jo_weapons_lowered(void);
132
137void jo_weapons_give_ammo(const int ammo_type, const int count);
138
139#endif /* !JO_COMPILE_WITH_LEVEL_SUPPORT */
140
141#endif /* !__JO_WEAPON_H__ */
142
143/*
144** END OF FILE
145*/
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:48