Client: Move Damage_Draw() and Damage_Precache() out of here, into the
game-specific realm
This commit is contained in:
parent
64eb0cc11d
commit
0a4b0ea795
9 changed files with 41 additions and 93 deletions
|
@ -72,7 +72,7 @@ You want this plugin if you want playback of a variety of media formats, includi
|
|||
This is the only component that requires a C++ compiler.
|
||||
|
||||
## Support
|
||||
Join us on irc.vera-visions.com and chat if you're interested in using this in production.
|
||||
Join us in #nuclide on irc.libera.chat and chat if you're interested in using this in production.
|
||||
**All this is provided to you for free as-is otherwise.**
|
||||
|
||||
## Special Thanks
|
||||
|
|
|
@ -14,66 +14,6 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
var string g_damage_spr_t;
|
||||
var string g_damage_spr_b;
|
||||
var string g_damage_spr_l;
|
||||
var string g_damage_spr_r;
|
||||
|
||||
void
|
||||
Damage_Precache(void)
|
||||
{
|
||||
g_damage_spr_t = spriteframe("sprites/640_pain.spr", 0, 0.0f);
|
||||
g_damage_spr_r = spriteframe("sprites/640_pain.spr", 1, 0.0f);
|
||||
g_damage_spr_b = spriteframe("sprites/640_pain.spr", 2, 0.0f);
|
||||
g_damage_spr_l = spriteframe("sprites/640_pain.spr", 3, 0.0f);
|
||||
}
|
||||
|
||||
void
|
||||
Damage_Draw(void)
|
||||
{
|
||||
vector center;
|
||||
vector rel_pos;
|
||||
float fw, fw_alpha;
|
||||
float rt, rt_alpha;
|
||||
|
||||
if (pSeat->m_flDamageAlpha <= 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
center = video_mins + (video_res / 2);
|
||||
|
||||
/* the pos relative to the player + view_dir determines which
|
||||
* and how bright each indicator is drawn. so first get the relative
|
||||
* position between us and the attacker, then calculate the strength
|
||||
* of each direction based on a dotproduct tested against our
|
||||
* camera direction.
|
||||
*/
|
||||
rel_pos = normalize(pSeat->m_vecDamagePos - getproperty(VF_ORIGIN));
|
||||
makevectors(getproperty(VF_CL_VIEWANGLES));
|
||||
fw = dotproduct(rel_pos, v_forward);
|
||||
rt = dotproduct(rel_pos, v_right);
|
||||
|
||||
fw_alpha = fabs(fw) * pSeat->m_flDamageAlpha;
|
||||
if (fw > 0.25f) {
|
||||
drawpic(center + [-64,-102], g_damage_spr_t,
|
||||
[128,48], [1,1,1], fw_alpha, DRAWFLAG_ADDITIVE);
|
||||
} else if (fw < -0.25f) {
|
||||
drawpic(center + [-64,70], g_damage_spr_b,
|
||||
[128,48], [1,1,1], fw_alpha, DRAWFLAG_ADDITIVE);
|
||||
}
|
||||
|
||||
rt_alpha = fabs(rt) * pSeat->m_flDamageAlpha;
|
||||
if (rt > 0.25f) {
|
||||
drawpic(center + [70,-64], g_damage_spr_r,
|
||||
[48,128], [1,1,1], rt_alpha, DRAWFLAG_ADDITIVE);
|
||||
} else if (rt < -0.25f) {
|
||||
drawpic(center + [-102,-64], g_damage_spr_l,
|
||||
[48,128], [1,1,1], rt_alpha, DRAWFLAG_ADDITIVE);
|
||||
}
|
||||
|
||||
pSeat->m_flDamageAlpha -= clframetime;
|
||||
}
|
||||
|
||||
/*
|
||||
* engine specific callback for when dmg_ fields are set on the client side.
|
||||
* might want to replace it at some point? probably not...
|
||||
|
|
|
@ -66,9 +66,6 @@ int g_iIntermission;
|
|||
/* this actually belongs in builtins.h since its an undocumented global */
|
||||
float clframetime;
|
||||
|
||||
/* prototypes */
|
||||
void Damage_Draw(void);
|
||||
|
||||
string(string modelname, int frame, float frametime) spriteframe = #0;
|
||||
|
||||
void
|
||||
|
|
|
@ -134,7 +134,6 @@ CSQC_RendererRestarted(string rstr)
|
|||
View_Init();
|
||||
ClientGame_RendererRestart(rstr);
|
||||
HUD_Init();
|
||||
Damage_Precache();
|
||||
|
||||
/* GS-Entbase */
|
||||
Fade_Init();
|
||||
|
|
|
@ -38,6 +38,7 @@ class env_glow:NSEntity /* change to renderablentity? */
|
|||
float m_flScale;
|
||||
|
||||
void(void) env_glow;
|
||||
|
||||
virtual float() predraw;
|
||||
virtual void(string, string) SpawnKey;
|
||||
virtual void(void) RendererRestarted;
|
||||
|
@ -169,7 +170,9 @@ env_glow::env_glow(void)
|
|||
drawmask = MASK_ENGINE;
|
||||
setsize(this, [0,0,0], [0,0,0]);
|
||||
effects &= ~EF_NOSHADOW;
|
||||
|
||||
Init();
|
||||
|
||||
RendererRestarted();
|
||||
setorigin(this, origin);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ class NSIO
|
|||
/* whenever gamerules want entities to respawn */
|
||||
virtual void(void) Respawn;
|
||||
|
||||
virtual void(float) Save;
|
||||
virtual void(float) Restore;
|
||||
|
||||
/* Handle incoming entities input messaging */
|
||||
virtual void(entity, string, string) Input;
|
||||
#endif
|
||||
|
|
|
@ -150,6 +150,17 @@ NSIO::Respawn(void)
|
|||
{
|
||||
// Respawn code goes here...
|
||||
}
|
||||
|
||||
void
|
||||
NSIO::Save(float handle)
|
||||
{
|
||||
|
||||
}
|
||||
void
|
||||
NSIO::Restore(float handle)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -61,7 +61,6 @@ entity eActivator;
|
|||
.float deaths;
|
||||
.float identity;
|
||||
.float botinfo;
|
||||
.void(float) Save;
|
||||
|
||||
/* in idTech the .owner field causes collisions to fail against set entity,
|
||||
* we don't want this all of the time. so use this as a fallback */
|
||||
|
|
|
@ -520,13 +520,6 @@ as they do not exist yet. Keep this in mind.
|
|||
*/
|
||||
var int autocvar_sv_levelexec = 1;
|
||||
|
||||
void
|
||||
worldspawn_save(float fh)
|
||||
{
|
||||
SAVE_VECTOR(fh, "origin", self.origin);
|
||||
SAVE_STRING(fh, "model", self.model);
|
||||
}
|
||||
|
||||
void
|
||||
worldspawn(void)
|
||||
{
|
||||
|
@ -561,8 +554,6 @@ worldspawn(void)
|
|||
}
|
||||
forceinfokey(world, "skyname", self.skyname);
|
||||
}
|
||||
|
||||
self.Save = worldspawn_save;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -669,9 +660,11 @@ SV_PerformLoad(float fh)
|
|||
entity eold;
|
||||
string l;
|
||||
float n;
|
||||
eold = self;
|
||||
e = world;
|
||||
|
||||
int inentity;
|
||||
int inworld;
|
||||
|
||||
/*
|
||||
while ((e=nextent(e))) {
|
||||
if (edict_num(1) != e)
|
||||
|
@ -680,6 +673,7 @@ SV_PerformLoad(float fh)
|
|||
*/
|
||||
|
||||
#if 1
|
||||
/* read line per line of our file handle */
|
||||
while ((l=fgets(fh))) {
|
||||
float braced = FALSE;
|
||||
float args = tokenize(l);
|
||||
|
@ -687,10 +681,6 @@ SV_PerformLoad(float fh)
|
|||
if (!args)
|
||||
break;
|
||||
|
||||
if (args != 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (argv(0) == "ENTITY") {
|
||||
string cname;
|
||||
n = stof(argv(1));
|
||||
|
@ -702,17 +692,16 @@ SV_PerformLoad(float fh)
|
|||
print(sprintf("Try spawning %s\n", cname));
|
||||
/* call the constructor if one is present, init the default fields */
|
||||
if (isfunction(strcat("spawnfunc_", cname))) {
|
||||
NSEntity willload;
|
||||
e.classname = cname;
|
||||
print(sprintf("I'm actually spawning %s\n", cname));
|
||||
|
||||
eold = self;
|
||||
self = e;
|
||||
callfunction(strcat("spawnfunc_", cname));
|
||||
e.classname = cname;
|
||||
self = eold;
|
||||
|
||||
setmodel(e, e.model);
|
||||
setsize(e, e.mins, e.maxs);
|
||||
setorigin(e, e.origin);
|
||||
inentity = TRUE;
|
||||
} else {
|
||||
print(sprintf("Could not spawn %s\n", cname));
|
||||
remove(e);
|
||||
|
@ -720,6 +709,13 @@ SV_PerformLoad(float fh)
|
|||
}
|
||||
} else if (argv(1) == "GLOBAL") {
|
||||
// TODO
|
||||
} else if (argv(0) == "{") {
|
||||
if (inentity)
|
||||
|
||||
willload = (NSEntity)e;
|
||||
willload.Restore(fh);
|
||||
} else if (argv(0) == "}") {
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -732,6 +728,7 @@ SV_PerformSave(float fh, float numents)
|
|||
entity e;
|
||||
|
||||
for (i = 0; i < numents; i++) {
|
||||
NSEntity willsave;
|
||||
e = edict_num(i);
|
||||
|
||||
if (e==world && i)
|
||||
|
@ -740,15 +737,14 @@ SV_PerformSave(float fh, float numents)
|
|||
if (wasfreed(e))
|
||||
continue;
|
||||
|
||||
if (e.Save) {
|
||||
entity oself = self;
|
||||
self = e;
|
||||
fputs(fh, sprintf("ENTITY \"%d\" %S\n", i, e.classname));
|
||||
fputs(fh, "{ ");
|
||||
e.Save(fh);
|
||||
fputs(fh, "}\n");
|
||||
self = oself;
|
||||
}
|
||||
if (e.identity == 0)
|
||||
continue;
|
||||
|
||||
willsave = (NSEntity)e;
|
||||
fputs(fh, sprintf("ENTITY \"%d\" %S\n", i, willsave.classname));
|
||||
fputs(fh, "{ ");
|
||||
willsave.Save(fh);
|
||||
fputs(fh, "}\n");
|
||||
}
|
||||
fclose(fh);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue