forked from Warzone2100/warzone2100
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojectile.h
142 lines (106 loc) · 5.08 KB
/
projectile.h
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2019 Warzone 2100 Project
Warzone 2100 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Warzone 2100 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __INCLUDED_SRC_PROJECTILE_H__
#define __INCLUDED_SRC_PROJECTILE_H__
#include "projectiledef.h"
#include "weapondef.h"
#include <glm/fwd.hpp>
/**
* @file projectile.h
* Projectile types and function headers
* @defgroup Projectile Projectile system
* @{
*/
/***************************************************************************/
extern BASE_OBJECT *g_pProjLastAttacker; ///< The last unit that did damage - used by script functions
#define PROJ_MAX_PITCH 45
#define PROJ_ULTIMATE_PITCH 80
#define BURN_TIME 10000 ///< How long an object burns for after leaving a fire.
#define BURN_DAMAGE 15 ///< How much damage per second an object takes when it is burning.
#define BURN_MIN_DAMAGE 30 ///< Least percentage of damage an object takes when burning.
#define ACC_GRAVITY 1000 ///< Downward force against projectiles.
/** How long to display a single electronic warfare shimmmer. */
#define ELEC_DAMAGE_DURATION (GAME_TICKS_PER_SEC/5)
bool proj_InitSystem(); ///< Initialize projectiles subsystem.
void proj_UpdateAll(); ///< Frame update for projectiles.
bool proj_Shutdown(); ///< Shut down projectile subsystem.
PROJECTILE *proj_GetFirst(); ///< Get first projectile in the list.
PROJECTILE *proj_GetNext(); ///< Get next projectile in the list.
void proj_FreeAllProjectiles(); ///< Free all projectiles in the list.
void setExpGain(int player, int gain);
int getExpGain(int player);
/// Calculate the initial velocities of an indirect projectile. Returns the flight time.
int32_t projCalcIndirectVelocities(const int32_t dx, const int32_t dz, int32_t v, int32_t *vx, int32_t *vz, int min_angle);
/** Send a single projectile against the given target. */
bool proj_SendProjectile(WEAPON *psWeap, SIMPLE_OBJECT *psAttacker, int player, Vector3i target, BASE_OBJECT *psTarget, bool bVisible, int weapon_slot);
/** Send a single projectile against the given target
* with a minimum shot angle. */
bool proj_SendProjectileAngled(WEAPON *psWeap, SIMPLE_OBJECT *psAttacker, int player, Vector3i target, BASE_OBJECT *psTarget, bool bVisible, int weapon_slot, int min_angle, unsigned fireTime);
/** Return whether a weapon is direct or indirect. */
bool proj_Direct(const WEAPON_STATS *psStats);
/** Return the maximum range for a weapon. */
int proj_GetLongRange(const WEAPON_STATS *psStats, int player);
/** Return the minimum range for a weapon. */
int proj_GetMinRange(const WEAPON_STATS *psStats, int player);
/** Return the short range for a weapon. */
int proj_GetShortRange(const WEAPON_STATS *psStats, int player);
UDWORD calcDamage(UDWORD baseDamage, WEAPON_EFFECT weaponEffect, BASE_OBJECT *psTarget);
bool gfxVisible(PROJECTILE *psObj);
/***************************************************************************/
glm::mat4 objectShimmy(BASE_OBJECT *psObj);
static inline void setProjectileSource(PROJECTILE *psProj, SIMPLE_OBJECT *psObj)
{
// use the source of the source of psProj if psAttacker is a projectile
psProj->psSource = nullptr;
if (psObj == nullptr)
{
}
else if (isProjectile(psObj))
{
PROJECTILE *psPrevProj = castProjectile(psObj);
if (psPrevProj->psSource && !psPrevProj->psSource->died)
{
psProj->psSource = psPrevProj->psSource;
}
}
else
{
psProj->psSource = castBaseObject(psObj);
}
}
int establishTargetHeight(BASE_OBJECT const *psTarget);
/* @} */
void checkProjectile(const PROJECTILE *psProjectile, const char *const location_description, const char *function, const int recurse);
/* assert if projectile is bad */
#define CHECK_PROJECTILE(object) checkProjectile((object), AT_MACRO, __FUNCTION__, max_check_object_recursion)
#define syncDebugProjectile(psProj, ch) _syncDebugProjectile(__FUNCTION__, psProj, ch)
void _syncDebugProjectile(const char *function, PROJECTILE const *psProj, char ch);
struct ObjectShape
{
ObjectShape() : isRectangular(false), size(0, 0) {}
ObjectShape(int radius) : isRectangular(false), size(radius, radius) {}
ObjectShape(int width, int breadth) : isRectangular(true), size(width, breadth) {}
ObjectShape(Vector2i widthBreadth) : isRectangular(true), size(widthBreadth) {}
int radius() const
{
return size.x;
}
bool isRectangular; ///< True if rectangular, false if circular.
Vector2i size; ///< x == y if circular.
};
ObjectShape establishTargetShape(BASE_OBJECT *psTarget);
#endif // __INCLUDED_SRC_PROJECTILE_H__