File size: 2,711 Bytes
00e6582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef ITEM_H_INCLUDED
#define ITEM_H_INCLUDED
#include <stdio.h>
#include "../engine.h"

#pragma pack(push, 1)

#define GRASP_MODE_TWO_HANDED 1
#define GRASP_MODE_ONE_HANDED 2
#define GRASP_MODE_HOLD_WITH_ONE_HAND 3
#define GRASP_MODE_HOLD_WITH_TWO_HAND 4
#define GRASP_MODE_LIFT 5

struct _Weapon_Entry
{
    char Name[256];
    int Grasp_Mode; //Two-handed, one-handed, hold with one hand, hold with two hands, Lift.
    char Weapon_Model_Filepath[256];
    char Weapon_Texture_Filepath[256];
    char Weapon_Icon_Filepath[256];
    int Weapon_Unholster_Sound_ID; //Use one of the Universal Sounds. -1 means No Sound.
    int Weapon_Holster_Sound_ID; //Use one of the Universal Sounds.
    int Weapon_Fire_Sound_ID; //Use one of the Universal Sounds.
    int Weapon_Reload_Sound_ID; //Use one of the Universal Sounds.

    int Current_Ammo;
    bool Allowed_To_Reload;
    double Reload_Speed;
    int Ammo_Mode; //Homing, projectile, grenade
    double Ammo_Lifetime_In_Seconds;
    double Ammo_Maximum_Distance_In_Meters;
    int Ammo_Moving_Through_Space_Sound_ID; //Use one of the Universal Sounds. -1 means No Sound.
    int Ammo_Rolling_Sound_ID; //Use one of the Universal Sounds. -1 means No Sound.
    int Ammo_Striking_Object_Sound_ID; //Use one of the Universal Sounds. -1 means No Sound.
    int Ammo_Exploding_Object_Sound_ID; //Use one of the Universal Sounds. -1 means No Sound.

    double Ammo_Collision_Radius;
    double Ammo_Mass;
    double Cooldown_Speed;

    int Ammo_Per_Clip;
    int Current_Stored_Ammo;

    int Damage;
    int Status_Effect;
};

#pragma pack(pop)

struct _Weapon_Object
{
    struct _Weapon_Entry Weapon_Entry;
    struct _SE3_Model* Weapon_Model;
    int Using_This_Projectile_Model;
    struct _Image* Weapon_Icon;
};

struct _Weapon_Round_Object
{
    double x;
    double y;
    double z;

    Vec3 localRight;
    Vec3 localUp;
    Vec3 localForward;

    double Velocity;

    double Time_Created;

    bool Dead;

    int Using_This_Weapon_Round_Model;

};

void Write_Weapon(const char* Filename);
void Load_Weapon(struct _Engine* Engine, int ID, const char* Filename);

void Give_Weapon(struct _Engine* Engine, int ID, int Destination_ID);

void Handle_Weapon_Inputs(struct _Engine* Engine, struct _Keypad Keypad, int ID);
void Process_Weapon(struct _Engine* Engine, int ID);
void Render_Weapon(struct _Engine* Engine, int ID);

void Create_Weapon_Round(struct _Engine* Engine, Vec3 localRight, Vec3 localUp, Vec3 localForward);
void Process_Weapon_Round(struct _Engine* Engine, int ID);
void Render_Weapon_Round(struct _Engine* Engine, int ID);
void Handle_Weapon_Round_Inputs(struct _Engine* Engine, struct _Keypad Keypad);
#endif // ITEM_H_INCLUDED