Shared: Inherit weapon_common from Nuclide's base game

This commit is contained in:
Marco Cawthorne 2021-05-10 08:16:22 +02:00
parent ced4cb5bf8
commit f43ad5d661
29 changed files with 65 additions and 474 deletions

View File

@ -19,7 +19,7 @@ ClientGame_ConsoleCommand(void)
{
switch(argv(0)) {
default:
return FALSE;
return (0);
}
return TRUE;
return (1);
}

View File

@ -22,10 +22,10 @@ ClientGame_EntityUpdate(float id, float new)
w_tripmine_parse();
break;
default:
return FALSE;
return (0);
}
return TRUE;
return (1);
}
void

View File

@ -113,11 +113,11 @@ HUD_InSlotPos(int slot, int pos)
if (pl.g_items & g_weapons[i].id) {
return i;
} else {
return -1;
return (-1);
}
}
}
return -1;
return (-1);
}
void

View File

@ -94,31 +94,31 @@ Damage_CheckTrace(entity t, vector vecHitPos)
{
/* We're lazy. Who cares */
if (t.solid == SOLID_BSP) {
return TRUE;
return (1);
}
traceline(vecHitPos, t.origin, 1, self);
if (trace_fraction == 1) {
return TRUE;
return (1);
}
traceline(vecHitPos, t.origin + [15,15,0], 1, self);
if (trace_fraction == 1) {
return TRUE;
return (1);
}
traceline(vecHitPos, t.origin + [-15,-15,0], 1, self);
if (trace_fraction == 1) {
return TRUE;
return (1);
}
traceline(vecHitPos, t.origin + [-15,15,0], 1, self);
if (trace_fraction == 1) {
return TRUE;
return (1);
}
traceline(vecHitPos, t.origin + [15,-15,0], 1, self);
if (trace_fraction == 1) {
return TRUE;
return (1);
}
return FALSE;
return (0);
}
/* even more pain and suffering, mostly used for explosives */

View File

@ -159,8 +159,8 @@ HLMultiplayerRules::ConsoleCommand(base_player pp, string cmd)
Bot_AddQuick();
break;
default:
return FALSE;
return (0);
}
return TRUE;
return (1);
}

View File

@ -108,7 +108,7 @@ monster_alien_slave::AttackMelee(void)
/* functional */
think = AttackFlail;
nextthink = 0.25f;
return TRUE;
return (1);
}
void
@ -137,7 +137,7 @@ monster_alien_slave::AttackRanged(void)
/* functional */
think = AttackBeam;
nextthink = time + 1.5f;
return TRUE;
return (1);
}
void

View File

@ -111,7 +111,7 @@ monster_barney::AttackRanged(void)
v_angle = vectoangles(m_eEnemy.origin - origin);
TraceAttack_FireBullets(1, origin + [0,0,16], 8, [0.01,0.01], 2);
Sound_Play(this, CHAN_WEAPON, "weapon_glock.fire");
return TRUE;
return (1);
}
void

View File

@ -96,7 +96,7 @@ monster_headcrab::AttackRanged(void)
/* functional */
makevectors(vectoangles(m_eEnemy.origin - origin));
velocity = v_forward * 512 + [0,0,250];
return TRUE;
return (1);
}
void

View File

@ -83,7 +83,7 @@ monster_houndeye::AttackMelee(void)
think = AttackBlast;
nextthink = m_flAnimTime;
return TRUE;
return (1);
}
void

View File

@ -162,7 +162,7 @@ monster_human_grunt::AttackMelee(void)
/* functional */
think = AttackKick;
nextthink = 0.25f;
return TRUE;
return (1);
}
void
@ -197,7 +197,7 @@ monster_human_grunt::AttackRanged(void)
/* functional */
v_angle = vectoangles(m_eEnemy.origin - origin);
TraceAttack_FireBullets(1, origin + [0,0,16], 8, [0.01,0.01], 2);
return TRUE;
return (1);
}
void monster_human_grunt::Scream(void)

View File

@ -122,7 +122,7 @@ monster_zombie::AttackMelee(void)
/* functional */
think = AttackFlail;
nextthink = 0.25f;
return TRUE;
return (1);
}
void

View File

@ -2,7 +2,7 @@
entities.h
flags.h
player.qc
weapon_common.h
../../../base/src/shared/weapon_common.h
animations.h
animations.qc
pmove.qc
@ -32,6 +32,6 @@ w_shotgun.qc
w_snark.qc
w_tripmine.qc
weapons.qc
weapon_common.qc
../../../base/src/shared/weapon_common.qc
input.qc
#endlist

View File

@ -14,14 +14,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
=================
Input_Handle
Handles impulse and whatnot
=================
*/
void Game_Input(void)
void
Game_Input(void)
{
#ifdef SERVER
CGameRules rules = (CGameRules)g_grMode;
@ -31,18 +25,17 @@ void Game_Input(void)
return;
}
if (input_buttons & INPUT_BUTTON5) {
if (input_buttons & INPUT_BUTTON5)
Player_UseDown();
} else {
else
Player_UseUp();
}
if (self.impulse == 100) {
if (self.impulse == 100)
Flashlight_Toggle();
}
if (cvar("sv_cheats") == 1) {
player pl = (player)self;
if (self.impulse == 101) {
pl.health = 100;
pl.armor = 100;
@ -74,37 +67,17 @@ void Game_Input(void)
Weapons_AddItem(pl, WEAPON_SHOCKRIFLE, -1);
#endif
}
if (self.impulse == 102) {
// Respawn all the entities
for (entity a = world; (a = findfloat(a, ::identity, 1));) {
CBaseEntity caw = (CBaseEntity)a;
caw.Respawn();
caw.SendFlags |=
BASEFL_CHANGED_ORIGIN |
BASEFL_CHANGED_ANGLES |
BASEFL_CHANGED_MODELINDEX |
BASEFL_CHANGED_SIZE |
BASEFL_CHANGED_SOLID |
BASEFL_CHANGED_FRAME |
BASEFL_CHANGED_SKIN |
BASEFL_CHANGED_MOVETYPE |
BASEFL_CHANGED_EFFECTS;
}
bprint(PRINT_HIGH, "Respawning all map entities...\n");
}
}
self.impulse = 0;
#endif
if (input_buttons & INPUT_BUTTON0) {
if (input_buttons & INPUT_BUTTON0)
Weapons_Primary();
} else if (input_buttons & INPUT_BUTTON4) {
else if (input_buttons & INPUT_BUTTON4)
Weapons_Reload();
} else if (input_buttons & INPUT_BUTTON3) {
else if (input_buttons & INPUT_BUTTON3)
Weapons_Secondary();
} else {
else
Weapons_Release();
}
}

View File

@ -355,12 +355,12 @@ player::SendEntity(entity ePEnt, float fChanged)
{
/* remove our entity to other clients if we're dead */
if (health <= 0 && ePEnt != this) {
return FALSE;
return (0);
}
/* target client isn't real, they have no client-side. abandon */
if (clienttype(ePEnt) != CLIENTTYPE_REAL) {
return FALSE;
return (0);
}
/* other players don't need to know about these attributes */
@ -421,6 +421,6 @@ player::SendEntity(entity ePEnt, float fChanged)
WriteByte(MSG_ENTITY, mode_tempstate);
}
return TRUE;
return (1);
}
#endif

View File

@ -91,11 +91,11 @@ w_crossbow_pickup(int new, int startammo)
if (pl.ammo_bolt < MAX_A_BOLT) {
pl.ammo_bolt = bound(0, pl.ammo_bolt + 5, MAX_A_BOLT);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void

View File

@ -137,10 +137,10 @@ int w_egon_pickup(int new, int startammo)
if (pl.ammo_uranium < MAX_A_URANIUM) {
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM);
} else {
return FALSE;
return (0);
}
#endif
return TRUE;
return (1);
}
void w_egon_draw(void)

View File

@ -163,10 +163,10 @@ int w_gauss_pickup(int new, int startammo)
if (pl.ammo_uranium < MAX_A_URANIUM) {
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM);
} else {
return FALSE;
return (0);
}
#endif
return TRUE;
return (1);
}
void w_gauss_draw(void)

View File

@ -129,11 +129,11 @@ w_glock_pickup(int new, int startammo)
if (pl.ammo_9mm < MAX_A_9MM) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 18, MAX_A_9MM);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void

View File

@ -70,10 +70,10 @@ int w_handgrenade_pickup(int new, int startammo)
if (pl.ammo_handgrenade < MAX_A_HANDGRENADE) {
pl.ammo_handgrenade = bound(0, pl.ammo_handgrenade + 1, MAX_A_HANDGRENADE);
} else {
return FALSE;
return (0);
}
#endif
return TRUE;
return (1);
}
#ifdef SERVER

View File

@ -57,10 +57,10 @@ w_hornetgun_pickup(int new, int startammo)
/* only pick it up once */
if (new) {
pl.ammo_hornet = MAX_A_HORNET;
return TRUE;
return (1);
}
#endif
return FALSE;
return (0);
}
void

View File

@ -76,11 +76,11 @@ w_mp5_pickup(int new, int startammo)
if (pl.ammo_9mm < MAX_A_9MM) {
pl.ammo_9mm = bound(0, pl.ammo_9mm + 25, MAX_A_9MM);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void

View File

@ -71,11 +71,11 @@ w_python_pickup(int new, int startammo)
if (pl.ammo_357 < MAX_A_357) {
pl.ammo_357 = bound(0, pl.ammo_357 + 6, MAX_A_357);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void

View File

@ -78,11 +78,11 @@ int w_rpg_pickup(int new, int startammo)
if (pl.ammo_rocket < MAX_A_ROCKET) {
pl.ammo_rocket = bound(0, pl.ammo_rocket + 1, MAX_A_ROCKET);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void w_rpg_draw(void)

View File

@ -132,10 +132,10 @@ w_satchel_pickup(int new, int startammo)
if (pl.ammo_satchel < MAX_A_SATCHEL) {
pl.ammo_satchel = bound(0, pl.ammo_satchel + 1, MAX_A_SATCHEL);
} else {
return FALSE;
return (0);
}
#endif
return TRUE;
return (1);
}
void

View File

@ -130,11 +130,11 @@ w_shotgun_pickup(int new, int startammo)
if (pl.ammo_buckshot < MAX_A_BUCKSHOT) {
pl.ammo_buckshot = bound(0, pl.ammo_buckshot + 8, MAX_A_BUCKSHOT);
} else {
return FALSE;
return (0);
}
}
#endif
return TRUE;
return (1);
}
void

View File

@ -142,10 +142,10 @@ int w_snark_pickup(int new, int startammo)
if (pl.ammo_snark < MAX_A_SNARK) {
pl.ammo_snark = bound(0, pl.ammo_snark + 5, MAX_A_SNARK);
} else {
return FALSE;
return (0);
}
#endif
return TRUE;
return (1);
}
void w_snark_draw(void)

View File

@ -66,7 +66,7 @@ monster_tripmine::SendEntity(entity pvsent, float flags)
WriteCoord(MSG_ENTITY, angles[2]);
WriteByte(MSG_ENTITY, health);
WriteShort(MSG_ENTITY, modelindex);
return TRUE;
return (1);
}
void
@ -239,10 +239,10 @@ int w_tripmine_pickup(int new, int startammo)
if (pl.ammo_tripmine < MAX_A_TRIPMINE) {
pl.ammo_tripmine = bound(0, pl.ammo_tripmine + 1, MAX_A_TRIPMINE);
} else {
return FALSE;
return (0);
}
#endif
return TRUE;
return (1);
}
void w_tripmine_draw(void)

View File

@ -1,64 +0,0 @@
/*
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
typedef struct
{
string name;
int id; /* bitflag id */
int slot;
int slot_pos;
int allow_drop;
void(void) draw;
void(void) holster;
void(void) primary;
void(void) secondary;
void(void) reload;
void(void) release;
void(void) crosshair;
void(void) precache;
int(int, int) pickup;
void(player) updateammo;
string() wmodel;
string() pmodel;
string() deathmsg;
float() aimanim;
void(int, vector, float) hudpic;
} weapon_t;
void Weapons_Primary(void);
void Weapons_Secondary(void);
void Weapons_Reload(void);
void Weapons_Release(void);
float Weapons_GetAim(int);
void Weapons_Reload(void);
void Weapons_DrawCrosshair(void);
void Weapons_MakeVectors(void);
vector Weapons_GetCameraPos(void);
void Weapons_ViewAnimation(int);
void Weapons_ViewPunchAngle(vector);
int Weapons_IsPresent(player, int);
void Weapons_SetModel(string);
void Weapons_SetGeomset(string);
void Weapons_UpdateAmmo(base_player, int, int, int);
int Weapons_GetAnimation(void);
#ifdef CLIENT
string Weapons_GetPlayermodel(int);
void Weapons_HUDPic(int, int, vector, float);
#endif

View File

@ -1,318 +0,0 @@
/*
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef SERVER
void Decals_Init(void);
#endif
void Weapons_Init(void)
{
/* in the future we'll have no internal weapon table, then this will fill
* one up... */
/*searchhandle sh;
filestream fh;
string line;
sh = search_begin("scripts/weapon_*.txt", TRUE, TRUE);
for (int i = 0; i < search_getsize(sh); i++) {
fh = fopen(search_getfilename(sh, i), FILE_READ);
if (fh < 0) {
continue;
}
while ((line = fgets(fh))) {
int w = tokenize(line);
switch (argv(0)) {
case "name":
break;
case "slot":
break;
case "slot_pos":
break;
}
}
fclose(fh);
}*/
for (int i = 0; i < g_weapons.length; i++) {
if (g_weapons[i].precache != __NULL__) {
g_weapons[i].precache();
}
}
}
void Weapons_SetModel(string mdl)
{
#ifdef CLIENT
setmodel(pSeat->m_eViewModel, mdl);
#endif
}
void Weapons_SetGeomset(string set)
{
#ifdef CLIENT
setcustomskin(pSeat->m_eViewModel, "", set);
#endif
}
void Weapons_Draw(void)
{
player pl = (player)self;
int i = pl.activeweapon;
pl.w_attack_next = 0.5f;
pl.w_idle_next = 2.5f;
pl.viewzoom = 1.0f;
#ifdef CLIENT
entity eold = self;
self = pSeat->m_pWeaponFX;
spawnfunc_CBaseFX();
self = eold;
#endif
/* make sure this is all wiped */
pl.a_ammo1 = pl.a_ammo2 = pl.a_ammo3 = 0;
if (g_weapons[i].draw != __NULL__) {
g_weapons[i].draw();
}
if (g_weapons[i].updateammo != __NULL__) {
g_weapons[i].updateammo(pl);
}
}
void Weapons_Holster(void)
{
player pl = (player)self;
int i = pl.activeweapon;
if (g_weapons[i].holster != __NULL__) {
g_weapons[i].holster();
}
}
void Weapons_Primary(void)
{
player pl = (player)self;
int i = pl.activeweapon;
if (pl.flags & FL_NOATTACK)
return;
if (g_weapons[i].primary != __NULL__) {
g_weapons[i].primary();
}
if (g_weapons[i].updateammo != __NULL__) {
g_weapons[i].updateammo(pl);
}
}
void Weapons_AmmoUpdate(entity target)
{
player pl = (player)target;
int i = pl.activeweapon;
if (g_weapons[i].updateammo != __NULL__) {
g_weapons[i].updateammo(pl);
}
}
void Weapons_Secondary(void)
{
player pl = (player)self;
int i = pl.activeweapon;
if (pl.flags & FL_NOATTACK)
return;
if (g_weapons[i].secondary != __NULL__) {
g_weapons[i].secondary();
}
if (g_weapons[i].updateammo != __NULL__) {
g_weapons[i].updateammo(pl);
}
}
void Weapons_Reload(void)
{
player pl = (player)self;
int i = pl.activeweapon;
if (pl.flags & FL_NOATTACK)
return;
if (g_weapons[i].reload != __NULL__) {
g_weapons[i].reload();
}
if (g_weapons[i].updateammo != __NULL__) {
g_weapons[i].updateammo(pl);
}
}
void Weapons_Release(void)
{
player pl = (player)self;
int i = pl.activeweapon;
if (g_weapons[i].release != __NULL__) {
g_weapons[i].release();
}
pl.gflags &= ~GF_SEMI_TOGGLED;
}
void Weapons_DrawCrosshair(void)
{
player pl = (player)self;
int i = pl.activeweapon;
if (g_weapons[i].crosshair != __NULL__) {
g_weapons[i].crosshair();
}
}
string Weapons_GetWorldmodel(int id)
{
if (g_weapons[id].wmodel != __NULL__) {
return g_weapons[id].wmodel();
}
return "";
}
string Weapons_GetPlayermodel(int id)
{
if (g_weapons[id].pmodel != __NULL__) {
return g_weapons[id].pmodel();
}
return "";
}
string Weapons_GetDeathmessage(int id)
{
if (g_weapons[id].deathmsg != __NULL__) {
return g_weapons[id].deathmsg();
}
return "";
}
float Weapons_GetAim(int id)
{
if (g_weapons[id].aimanim != __NULL__) {
return g_weapons[id].aimanim();
}
return 0;
}
#ifdef CLIENT
void Weapons_HUDPic(int id, int s, vector pos, float a)
{
if (g_weapons[id].hudpic != __NULL__) {
g_weapons[id].hudpic(s, pos, a);
}
}
#endif
void Weapons_MakeVectors(void)
{
#ifdef SERVER
player pl = (player)self;
makevectors(pl.v_angle);
#else
makevectors(view_angles);
#endif
}
vector Weapons_GetCameraPos(void)
{
#ifdef SERVER
return self.origin + self.view_ofs;
#else
return getproperty(VF_ORIGIN);
#endif
}
void Weapons_ViewAnimation(int i)
{
#ifdef CLIENT
player pl = (player)pSeat->m_ePlayer;
View_PlayAnimation(i);
#else
player pl = (player)self;
#endif
pl.weapontime = 0.0f;
}
#ifdef CLIENT
int View_GetAnimation(void);
#endif
int
Weapons_GetAnimation(void)
{
#ifdef CLIENT
return View_GetAnimation();
#else
return 0;
#endif
}
void Weapons_ViewPunchAngle(vector add)
{
player pl = (player)self;
pl.punchangle += add;
}
int Weapons_IsPresent(player pl, int w)
{
if (pl.g_items & g_weapons[w].id) {
return TRUE;
} else {
return FALSE;
}
}
/*
=================
Weapons_UpdateAmmo
Sets .a_ammoX fields and clamps them so they can be networked as a single byte.
=================
*/
void
Weapons_UpdateAmmo(base_player pl, int a1, int a2, int a3)
{
/* no change */
if (a1 == -1) {
a1 = pl.a_ammo1;
}
if (a2 == -1) {
a2 = pl.a_ammo2;
}
if (a3 == -1) {
a3 = pl.a_ammo3;
}
/* networked as bytes, since we don't need more. Clamp to avoid errors */
pl.a_ammo1 = bound(0, a1, 255);
pl.a_ammo2 = bound(0, a2, 255);
pl.a_ammo3 = bound(0, a3, 255);
}