mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 20:01:34 +00:00
SERVER/CLIENT: Move away from sprite-based revive icon.
This commit is contained in:
parent
3a56ad265c
commit
545eb52673
8 changed files with 113 additions and 31 deletions
|
@ -96,6 +96,15 @@ float broadcast_time;
|
|||
float broadcast_type;
|
||||
string broadcast_string;
|
||||
|
||||
var struct revive_s {
|
||||
float draw;
|
||||
float timer;
|
||||
float state;
|
||||
float org[3];
|
||||
} revive_icons[4];
|
||||
|
||||
float active_revive_icons;
|
||||
|
||||
float weaponframetime;
|
||||
float weapon2frametime;
|
||||
float oldweaponframe;
|
||||
|
|
|
@ -1399,6 +1399,30 @@ void(float width, float height) HUD_PlayerNames =
|
|||
}
|
||||
}
|
||||
|
||||
void(float width, float height) HUD_ReviveIcons =
|
||||
{
|
||||
for (float i = 0; i < active_revive_icons; i++) {
|
||||
if (revive_icons[i].draw == true) {
|
||||
revive_icons[i].timer += frametime;
|
||||
vector revive_origin;
|
||||
revive_origin_x = revive_icons[i].org[0];
|
||||
revive_origin_y = revive_icons[i].org[1];
|
||||
revive_origin_z = revive_icons[i].org[2];
|
||||
vector screen_position = project(revive_origin);
|
||||
screen_position_x -= (0.075*height)/2;
|
||||
|
||||
if (screen_position_z > 0) {
|
||||
// being revived
|
||||
if (revive_icons[i].state == 2)
|
||||
drawpic(screen_position, "gfx/hud/revive_icon.tga", [0.075*height, 0.075*height, 1], [1,1,1], 1);
|
||||
else {
|
||||
drawpic(screen_position, "gfx/hud/revive_icon.tga", [0.075*height, 0.075*height, 1], [1,1 - (revive_icons[i].timer/30),0], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************
|
||||
* HUD Draw *
|
||||
*******************/
|
||||
|
@ -1409,7 +1433,6 @@ void(float width, float height) HUD_Draw =
|
|||
return;
|
||||
|
||||
HUD_Achievements(width, height);
|
||||
HUD_PlayerNames(width, height);
|
||||
|
||||
|
||||
if (!getstatf(STAT_SPECTATING) && (getstatf(STAT_HEALTH) > 10) && !score_show)
|
||||
|
@ -1451,6 +1474,9 @@ void(float width, float height) HUD_Draw =
|
|||
scrollopacity = 1;
|
||||
scrollheight = 0.80;
|
||||
}
|
||||
|
||||
HUD_PlayerNames(width, height);
|
||||
HUD_ReviveIcons(width, height);
|
||||
} else {
|
||||
HUD_Waypoint(width, height);
|
||||
}
|
||||
|
|
|
@ -1007,6 +1007,29 @@ noref void() CSQC_Parse_Event =
|
|||
broadcast_type = readbyte();
|
||||
broadcast_string = readstring();
|
||||
break;
|
||||
case EVENT_REVIVECHANGE:
|
||||
float revivechange_id = readbyte();
|
||||
float state = readbyte();
|
||||
revive_icons[revivechange_id].state = state;
|
||||
break;
|
||||
case EVENT_REVIVEON:
|
||||
float reviveon_id = readbyte();
|
||||
revive_icons[reviveon_id].org[0] = readcoord();
|
||||
revive_icons[reviveon_id].org[1] = readcoord();
|
||||
revive_icons[reviveon_id].org[2] = readcoord();
|
||||
revive_icons[reviveon_id].state = 1;
|
||||
revive_icons[reviveon_id].draw = true;
|
||||
active_revive_icons++;
|
||||
break;
|
||||
case EVENT_REVIVEOFF:
|
||||
float reviveoff_id = readbyte();
|
||||
revive_icons[reviveoff_id].org[0] = 0;
|
||||
revive_icons[reviveoff_id].org[1] = 0;
|
||||
revive_icons[reviveoff_id].org[2] = 0;
|
||||
revive_icons[reviveoff_id].state = 0;
|
||||
revive_icons[reviveoff_id].draw = false;
|
||||
active_revive_icons--;
|
||||
break;
|
||||
case EVENT_POINTUPDATE:
|
||||
float playernum = readbyte();
|
||||
float temppoints = readlong();
|
||||
|
|
|
@ -177,6 +177,46 @@ void(string to, float skin) UpdateV2model =
|
|||
#endif
|
||||
}
|
||||
|
||||
void(float index, float state) ChangeReviveIconState =
|
||||
{
|
||||
#ifndef HANDHELD
|
||||
#ifndef NX
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EVENT_REVIVECHANGE);
|
||||
WriteByte(MSG_MULTICAST, index);
|
||||
WriteByte(MSG_MULTICAST, state);
|
||||
multicast('0 0 0', MULTICAST_ALL);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void(float index, vector org) EnableReviveIcon =
|
||||
{
|
||||
#ifndef HANDHELD
|
||||
#ifndef NX
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EVENT_REVIVEON);
|
||||
WriteByte(MSG_MULTICAST, index);
|
||||
WriteCoord(MSG_MULTICAST, org_x);
|
||||
WriteCoord(MSG_MULTICAST, org_y);
|
||||
WriteCoord(MSG_MULTICAST, org_z);
|
||||
multicast('0 0 0', MULTICAST_ALL);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void(float index) DisableReviveIcon =
|
||||
{
|
||||
#ifndef HANDHELD
|
||||
#ifndef NX
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EVENT_REVIVEOFF);
|
||||
WriteByte(MSG_MULTICAST, index);
|
||||
multicast('0 0 0', MULTICAST_ALL);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void(entity who, float broadcast_time, float type, string str) BroadcastMessageToClient =
|
||||
{
|
||||
#ifndef HANDHELD
|
||||
|
@ -202,7 +242,6 @@ void(float broadcast_time, float type, string str) BroadcastMessage =
|
|||
WriteByte(MSG_MULTICAST, type);
|
||||
WriteString(MSG_MULTICAST, str);
|
||||
multicast('0 0 0', MULTICAST_ALL);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -80,22 +80,6 @@ void() EndGame =
|
|||
self.nextthink = time + 33;
|
||||
}
|
||||
|
||||
// removes revive icon from downed player heads, used as a recursive think function
|
||||
void() remove_revive =
|
||||
{
|
||||
if (self.owner.beingrevived)
|
||||
setmodel (self, "models/sprites/revive_white.spr");
|
||||
else
|
||||
setmodel (self, "models/sprites/revive.spr");
|
||||
|
||||
if (!self.owner.downed || self.owner.isspec)
|
||||
SUB_Remove ();
|
||||
else {
|
||||
self.think = remove_revive;
|
||||
self.nextthink = time + 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
// when dead and other players exist and are alive, throw user into spectate mode
|
||||
void() startspectate =
|
||||
{
|
||||
|
@ -177,6 +161,7 @@ void() rec_downed =
|
|||
{
|
||||
self.downedloop++;
|
||||
if (self.downedloop >= 300) {
|
||||
DisableReviveIcon(self.electro_targeted);
|
||||
startspectate();
|
||||
return;
|
||||
}
|
||||
|
@ -332,18 +317,9 @@ void() GetDown =
|
|||
|
||||
// Spawn Revive Sprite in Co-Op
|
||||
if (coop) {
|
||||
entity revive_sprite;
|
||||
|
||||
revive_sprite = spawn();
|
||||
revive_sprite.owner = self;
|
||||
revive_sprite.movetype = MOVETYPE_NONE;
|
||||
revive_sprite.solid = SOLID_NOT;
|
||||
revive_sprite.think = remove_revive;
|
||||
revive_sprite.nextthink = time + 0.1;
|
||||
|
||||
setmodel(revive_sprite, "models/sprites/revive.spr");
|
||||
revive_sprite.origin = self.origin + VEC_VIEW_OFS;
|
||||
setorigin(revive_sprite, revive_sprite.origin);
|
||||
EnableReviveIcon(revive_index, self.origin + VEC_VIEW_OFS);
|
||||
self.electro_targeted = revive_index;
|
||||
revive_index++;
|
||||
}
|
||||
|
||||
self.think = rec_downed;
|
||||
|
@ -401,6 +377,8 @@ void(entity ent) CheckRevive =
|
|||
{
|
||||
if (self.invoke_revive) {
|
||||
GetUp();
|
||||
DisableReviveIcon(self.electro_targeted);
|
||||
revive_index--;
|
||||
self.invoke_revive = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -519,4 +519,6 @@ float sndActivCnt;
|
|||
.float rendermode;
|
||||
.float renderamt;
|
||||
.vector rendercolor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float revive_index;
|
|
@ -2311,6 +2311,7 @@ void() CheckPlayer =
|
|||
ent.beingrevived = true;
|
||||
|
||||
if (!self.progress_bar_percent) {
|
||||
ChangeReviveIconState(ent.electro_targeted, 2);
|
||||
self.movetype = MOVETYPE_NONE;
|
||||
Set_W_Frame (0, 21, 0, 0, SPRINT, SUB_Null, "models/weapons/morphine/v_morphine.mdl", false, S_BOTH);
|
||||
|
||||
|
@ -2338,6 +2339,7 @@ void() CheckPlayer =
|
|||
}
|
||||
}
|
||||
else if (!self.button7 && self.reviving) {
|
||||
ChangeReviveIconState(ent.electro_targeted, 1);
|
||||
self.movetype = MOVETYPE_WALK;
|
||||
ent.beingrevived = false;
|
||||
W_TakeOut();
|
||||
|
|
|
@ -50,6 +50,9 @@ const float EVENT_HUDUPDATE = 33;
|
|||
const float EVENT_EXPLOSION = 34;
|
||||
const float EVENT_BLOOD = 35;
|
||||
const float EVENT_ACHIEVEMENTPROGRESS = 36;
|
||||
const float EVENT_REVIVEON = 37;
|
||||
const float EVENT_REVIVEOFF = 38;
|
||||
const float EVENT_REVIVECHANGE = 39;
|
||||
|
||||
// Define our PC version if we don't have NX or PSP
|
||||
#ifndef NX
|
||||
|
|
Loading…
Reference in a new issue