Opposing Force: WEAPON_GRAPPLE prototype to play around with.

This commit is contained in:
Marco Cawthorne 2019-09-12 13:15:04 +02:00
parent 7c35269b79
commit 3265f76fb2
6 changed files with 126 additions and 40 deletions

View file

@ -42,6 +42,9 @@ class player
vector view_ofs; vector view_ofs;
float weapontime; float weapontime;
/* special for opfor */
entity hook;
/* Weapon specific */ /* Weapon specific */
int glock_mag; int glock_mag;
int mp5_mag; int mp5_mag;

View file

@ -16,7 +16,7 @@
enum enum
{ {
BARN_IDLE, BARN_IDLE1,
BARN_IDLE2, BARN_IDLE2,
BARN_IDLE3, BARN_IDLE3,
BARN_COUGH, BARN_COUGH,
@ -40,7 +40,7 @@ w_grapple_precache(void)
precache_sound("weapons/bgrapple_wait.wav"); precache_sound("weapons/bgrapple_wait.wav");
precache_model("models/v_bgrap.mdl"); precache_model("models/v_bgrap.mdl");
precache_model("models/v_bgrap_tonguetip.mdl"); precache_model("models/v_bgrap_tonguetip.mdl");
precache_model("models/w_grapple.mdl"); precache_model("models/w_bgrap.mdl");
precache_model("models/p_bgrap.mdl"); precache_model("models/p_bgrap.mdl");
} }
@ -48,7 +48,7 @@ void
w_grapple_updateammo(player pl) w_grapple_updateammo(player pl)
{ {
#ifdef SSQC #ifdef SSQC
Weapons_UpdateAmmo(pl, __NULL__, __NULL__, __NULL__); Weapons_UpdateAmmo(pl, -1, -1, -1);
#endif #endif
} }
@ -83,10 +83,48 @@ w_grapple_holster(void)
Weapons_ViewAnimation(BARN_HOLSTER); Weapons_ViewAnimation(BARN_HOLSTER);
} }
void Grapple_Touch(void)
{
player pl = (player)self.owner;
pl.hook.movetype = MOVETYPE_NONE;
pl.hook.touch = __NULL__;
pl.hook.velocity = [0,0,0];
pl.hook.solid = SOLID_NOT;
pl.hook.skin = 1; /* grappled */
pl.a_ammo1 = 1;
}
void void
w_grapple_primary(void) w_grapple_primary(void)
{ {
/* TODO, 25 damage */ player pl = (player)self;
if (pl.hook != __NULL__) {
/* play the looping reel anim once */
if (pl.a_ammo1 == 1) {
pl.a_ammo1 = 2;
Weapons_ViewAnimation(BARN_FIRETRAVEL);
}
return;
}
Weapons_MakeVectors();
pl.hook = spawn();
#ifdef CSQC
setmodel(pl.hook, "models/v_bgrap_tonguetip.mdl");
pl.hook.drawmask = MASK_ENGINE;
#endif
setorigin(pl.hook, Weapons_GetCameraPos() + (v_forward * 16));
pl.hook.owner = self;
pl.hook.velocity = v_forward * 800;
pl.hook.movetype = MOVETYPE_FLYMISSILE;
pl.hook.solid = SOLID_BBOX;
pl.hook.angles = vectoangles(pl.hook.velocity);
pl.hook.touch = Grapple_Touch;
pl.hook.skin = 0; /* ungrappled */
setsize(pl.hook, [0,0,0], [0,0,0]);
Weapons_ViewAnimation(BARN_FIRE);
} }
void void
@ -99,7 +137,37 @@ w_grapple_secondary(void)
void void
w_grapple_release(void) w_grapple_release(void)
{ {
player pl = (player)self;
if (pl.hook != __NULL__) {
pl.hook.skin = 0; /* ungrappled */
remove(pl.hook);
pl.hook = __NULL__;
Weapons_ViewAnimation(BARN_FIRERELEASE);
pl.w_idle_next = 1.0f;
}
if (pl.w_idle_next > 0.0) {
return;
}
int r = (float)input_sequence % 3;
switch (r) {
case 1:
Weapons_ViewAnimation(BARN_IDLE1);
pl.w_idle_next = 2.566667f;
break;
case 2:
Weapons_ViewAnimation(BARN_IDLE2);
pl.w_idle_next = 10.0f;
break;
default:
Weapons_ViewAnimation(BARN_IDLE3);
pl.w_idle_next = 1.35f;
break;
}
} }
float float

View file

@ -18,7 +18,7 @@
enum { enum {
M249_IDLE1, M249_IDLE1,
M249_IDLE2, M249_IDLE2,
M249_RELOAD, M249_RELOAD1,
M249_RELOAD2, M249_RELOAD2,
M249_HOLSTER, M249_HOLSTER,
M249_DRAW, M249_DRAW,
@ -88,11 +88,39 @@ w_m249_holster(void)
Weapons_ViewAnimation(M249_DRAW); Weapons_ViewAnimation(M249_DRAW);
} }
void
w_m249_release(void)
{
player pl = (player)self;
if (pl.w_idle_next > 0.0) {
return;
}
if (pl.a_ammo3 == 1) {
Weapons_ViewAnimation(M249_RELOAD2);
pl.a_ammo3 = 0;
pl.w_attack_next = 2.45f;
pl.w_idle_next = 15.0f;
return;
}
if (random() < 0.5) {
Weapons_ViewAnimation(M249_IDLE1);
} else {
Weapons_ViewAnimation(M249_IDLE2);
}
pl.w_idle_next = 15.0f;
}
void void
w_m249_primary(void) w_m249_primary(void)
{ {
player pl = (player)self; player pl = (player)self;
if (pl.w_attack_next > 0.0) { if (pl.w_attack_next > 0.0) {
w_m249_release();
return; return;
} }
@ -114,9 +142,9 @@ w_m249_primary(void)
#ifdef CSQC #ifdef CSQC
pl.a_ammo1--; pl.a_ammo1--;
View_SetMuzzleflash(MUZZLE_RIFLE); View_SetMuzzleflash(MUZZLE_RIFLE);
Weapons_ViewPunchAngle([-10,0,0]); Weapons_ViewPunchAngle([-5,0,0]);
#else #else
TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8, [0.05234,0.05234]); TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 8, [0.052,0.052]);
int r = (float)input_sequence % 3; int r = (float)input_sequence % 3;
switch (r) { switch (r) {
@ -143,10 +171,10 @@ w_m249_reload(void)
{ {
player pl = (player)self; player pl = (player)self;
if (pl.w_attack_next) { if (pl.w_attack_next) {
w_m249_release();
return; return;
} }
/* ammo check */
#ifdef CSQC #ifdef CSQC
if (pl.a_ammo1 >= 50) { if (pl.a_ammo1 >= 50) {
return; return;
@ -154,6 +182,7 @@ w_m249_reload(void)
if (pl.a_ammo2 <= 0) { if (pl.a_ammo2 <= 0) {
return; return;
} }
Weapons_ViewAnimation(M249_RELOAD1);
#else #else
if (pl.m249_mag >= 50) { if (pl.m249_mag >= 50) {
return; return;
@ -161,35 +190,13 @@ w_m249_reload(void)
if (pl.ammo_556 <= 0) { if (pl.ammo_556 <= 0) {
return; return;
} }
#endif
Weapons_ViewAnimation(M249_RELOAD2);
#ifdef SSQC
Weapons_ReloadWeapon(pl, player::m249_mag, player::ammo_556, 50); Weapons_ReloadWeapon(pl, player::m249_mag, player::ammo_556, 50);
Weapons_UpdateAmmo(pl, pl.m249_mag, pl.ammo_556, __NULL__); Weapons_UpdateAmmo(pl, pl.m249_mag, pl.ammo_556, __NULL__);
#endif #endif
pl.w_attack_next = 1.5f; pl.a_ammo3 = 1;
pl.w_idle_next = 10.0f; pl.w_attack_next = 10.0f;
} pl.w_idle_next = 1.5f;
void
w_m249_release(void)
{
player pl = (player)self;
if (pl.w_idle_next > 0.0) {
return;
}
if (random() < 0.5) {
Weapons_ViewAnimation(M249_IDLE1);
} else {
Weapons_ViewAnimation(M249_IDLE2);
}
pl.w_idle_next = 15.0f;
} }
void void

View file

@ -675,6 +675,7 @@ PMove_Run_Move(void)
void void
PMove_Run(void) PMove_Run(void)
{ {
player pl = (player)self;
#ifdef VALVE #ifdef VALVE
self.maxspeed = (self.flags & FL_CROUCHING) ? 135 : 270; self.maxspeed = (self.flags & FL_CROUCHING) ? 135 : 270;
@ -695,6 +696,14 @@ PMove_Run(void)
input_movevalues[2] = -240; input_movevalues[2] = -240;
} }
/* grappling hook stuff */
#ifdef GEARBOX
if (pl.hook.skin == 1) {
pl.velocity = (pl.hook.origin - pl.origin);
pl.velocity = (pl.velocity * (1 / (vlen(pl.velocity) / 1000)));
}
#endif
/* call accelerate before and after the actual move, /* call accelerate before and after the actual move,
* with half the move each time. this reduces framerate dependence. * with half the move each time. this reduces framerate dependence.
* and makes controlling jumps slightly easier * and makes controlling jumps slightly easier
@ -709,7 +718,6 @@ PMove_Run(void)
touchtriggers(); touchtriggers();
player pl = (player)self;
#ifdef VALVE #ifdef VALVE
pl.w_attack_next = max(0, pl.w_attack_next - input_timelength); pl.w_attack_next = max(0, pl.w_attack_next - input_timelength);
pl.w_idle_next = max(0, pl.w_idle_next - input_timelength); pl.w_idle_next = max(0, pl.w_idle_next - input_timelength);

View file

@ -149,10 +149,10 @@ void w_crossbow_primary(void)
Weapons_ViewPunchAngle([-2,0,0]); Weapons_ViewPunchAngle([-2,0,0]);
#endif #endif
if (pl.a_ammo1) { if (pl.a_ammo1) {
Weapons_ViewAnimation(CROSSBOW_FIRE1); Weapons_ViewAnimation(CROSSBOW_FIRE1);
} else { } else {
Weapons_ViewAnimation(CROSSBOW_FIRE3); Weapons_ViewAnimation(CROSSBOW_FIRE3);
} }
pl.w_attack_next = 0.75f; pl.w_attack_next = 0.75f;
pl.w_idle_next = 10.0f; pl.w_idle_next = 10.0f;
} }

View file

@ -273,12 +273,12 @@ void w_gauss_secondary(void)
#endif #endif
#ifdef CSQC #ifdef CSQC
if (pl.a_ammo1 < 255) if (pl.a_ammo1 < 255)
pl.a_ammo2--; pl.a_ammo2--;
#else #else
if (pl.a_ammo1 < 255) if (pl.a_ammo1 < 255)
pl.ammo_uranium--; pl.ammo_uranium--;
Weapons_UpdateAmmo(pl, pl.a_ammo1, pl.ammo_uranium, pl.a_ammo3); Weapons_UpdateAmmo(pl, pl.a_ammo1, pl.ammo_uranium, pl.a_ammo3);
#endif #endif
/* Set pitch sound shift */ /* Set pitch sound shift */