mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-28 15:02:13 +00:00
Turn the stun baton into an "always active" weapon
movement still triggers the sound, but it will always shock an enemy when it makes contact
This commit is contained in:
parent
3c64fa7e3e
commit
c4cc218f8b
6 changed files with 77 additions and 5 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.drbeef.jkxr"
|
package="com.drbeef.jkxr"
|
||||||
android:versionCode="46"
|
android:versionCode="47"
|
||||||
android:versionName="0.7.6" android:installLocation="auto" >
|
android:versionName="0.7.7" android:installLocation="auto" >
|
||||||
|
|
||||||
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
||||||
<uses-feature android:glEsVersion="0x00030002" android:required="true"/>
|
<uses-feature android:glEsVersion="0x00030002" android:required="true"/>
|
||||||
|
|
|
@ -5528,6 +5528,13 @@ extern cvar_t *g_skippingcin;
|
||||||
// execute client events
|
// execute client events
|
||||||
ClientEvents( ent, oldEventSequence );
|
ClientEvents( ent, oldEventSequence );
|
||||||
|
|
||||||
|
//Stun Baton is _always_ firing
|
||||||
|
if (ent->s.weapon == WP_STUN_BATON)
|
||||||
|
{
|
||||||
|
//Use alt-fire to indicate not to make a noise, but do inflict damage
|
||||||
|
FireWeapon(ent, qtrue);
|
||||||
|
}
|
||||||
|
|
||||||
if ( pm.useEvent )
|
if ( pm.useEvent )
|
||||||
{
|
{
|
||||||
//TODO: Use
|
//TODO: Use
|
||||||
|
|
|
@ -27,6 +27,9 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "w_local.h"
|
#include "w_local.h"
|
||||||
#include "bg_local.h"
|
#include "bg_local.h"
|
||||||
|
|
||||||
|
std::map<int, int> damagedEntities;
|
||||||
|
extern weaponData_t weaponData[WP_NUM_WEAPONS];
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire )
|
void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire )
|
||||||
{
|
{
|
||||||
|
@ -34,7 +37,14 @@ void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire )
|
||||||
trace_t tr;
|
trace_t tr;
|
||||||
vec3_t mins, maxs, end, start;
|
vec3_t mins, maxs, end, start;
|
||||||
|
|
||||||
G_Sound( ent, G_SoundIndex( "sound/weapons/baton/fire" ));
|
// If alt_fire is false, then this was triggered by the EV_FIRE_WEAPON event, and we should only make the sound
|
||||||
|
// and return, if alt_fire is true, then the stun baton is checked every frame in ClientThink_real and shouldn't play
|
||||||
|
// a sound and should inflict damage
|
||||||
|
if (!alt_fire)
|
||||||
|
{
|
||||||
|
G_Sound(ent, G_SoundIndex("sound/weapons/baton/fire"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
vec3_t angs, forward;
|
vec3_t angs, forward;
|
||||||
if ( BG_UseVRPosition(ent))
|
if ( BG_UseVRPosition(ent))
|
||||||
|
@ -61,8 +71,27 @@ void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//First clear out any entities that can be damaged again
|
||||||
|
std::map<int, int> copyDamagedEntities = damagedEntities;
|
||||||
|
for (auto &damagedEntity : copyDamagedEntities)
|
||||||
|
{
|
||||||
|
if (damagedEntity.second <= level.time)
|
||||||
|
{
|
||||||
|
damagedEntities.erase(damagedEntity.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tr_ent = &g_entities[tr.entityNum];
|
tr_ent = &g_entities[tr.entityNum];
|
||||||
|
|
||||||
|
//Is it too soon to hurt this entity again?
|
||||||
|
if (damagedEntities.find(tr.entityNum) != damagedEntities.end())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//We are good to inflict damage, store this entity and the next time we can hurt them
|
||||||
|
damagedEntities[tr.entityNum] = level.time + weaponData[WP_STUN_BATON].fireTime;
|
||||||
|
|
||||||
if ( tr_ent && tr_ent->takedamage && tr_ent->client )
|
if ( tr_ent && tr_ent->takedamage && tr_ent->client )
|
||||||
{
|
{
|
||||||
G_PlayEffect( "stunBaton/flesh_impact", tr.endpos, tr.plane.normal );
|
G_PlayEffect( "stunBaton/flesh_impact", tr.endpos, tr.plane.normal );
|
||||||
|
|
|
@ -2923,6 +2923,13 @@ extern cvar_t *g_skippingcin;
|
||||||
// execute client events
|
// execute client events
|
||||||
ClientEvents( ent, oldEventSequence );
|
ClientEvents( ent, oldEventSequence );
|
||||||
|
|
||||||
|
//Stun Baton is _always_ firing
|
||||||
|
if (ent->s.weapon == WP_STUN_BATON)
|
||||||
|
{
|
||||||
|
//Use alt-fire to indicate not to make a noise, but do inflict damage
|
||||||
|
FireWeapon(ent, qtrue);
|
||||||
|
}
|
||||||
|
|
||||||
if ( pm.useEvent )
|
if ( pm.useEvent )
|
||||||
{
|
{
|
||||||
//TODO: Use
|
//TODO: Use
|
||||||
|
|
|
@ -29,6 +29,9 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "g_functions.h"
|
#include "g_functions.h"
|
||||||
#include "bg_local.h"
|
#include "bg_local.h"
|
||||||
|
|
||||||
|
std::map<int, int> damagedEntities;
|
||||||
|
extern weaponData_t weaponData[WP_NUM_WEAPONS];
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire )
|
void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire )
|
||||||
{
|
{
|
||||||
|
@ -36,7 +39,14 @@ void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire )
|
||||||
trace_t tr;
|
trace_t tr;
|
||||||
vec3_t mins, maxs, end, start;
|
vec3_t mins, maxs, end, start;
|
||||||
|
|
||||||
G_Sound( ent, G_SoundIndex( "sound/weapons/baton/fire" ));
|
// If alt_fire is false, then this was triggered by the EV_FIRE_WEAPON event, and we should only make the sound
|
||||||
|
// and return, if alt_fire is true, then the stun baton is checked every frame in ClientThink_real and shouldn't play
|
||||||
|
// a sound and should inflict damage
|
||||||
|
if (!alt_fire)
|
||||||
|
{
|
||||||
|
G_Sound(ent, G_SoundIndex("sound/weapons/baton/fire"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
vec3_t angs, forward;
|
vec3_t angs, forward;
|
||||||
if ( BG_UseVRPosition(ent))
|
if ( BG_UseVRPosition(ent))
|
||||||
|
@ -63,8 +73,27 @@ void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//First clear out any entities that can be damaged again
|
||||||
|
std::map<int, int> copyDamagedEntities = damagedEntities;
|
||||||
|
for (auto &damagedEntity : copyDamagedEntities)
|
||||||
|
{
|
||||||
|
if (damagedEntity.second <= level.time)
|
||||||
|
{
|
||||||
|
damagedEntities.erase(damagedEntity.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tr_ent = &g_entities[tr.entityNum];
|
tr_ent = &g_entities[tr.entityNum];
|
||||||
|
|
||||||
|
//Is it too soon to hurt this entity again?
|
||||||
|
if (damagedEntities.find(tr.entityNum) != damagedEntities.end())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//We are good to inflict damage, store this entity and the next time we can hurt them
|
||||||
|
damagedEntities[tr.entityNum] = level.time + weaponData[WP_STUN_BATON].fireTime;
|
||||||
|
|
||||||
if ( tr_ent && tr_ent->takedamage && tr_ent->client )
|
if ( tr_ent && tr_ent->takedamage && tr_ent->client )
|
||||||
{
|
{
|
||||||
G_PlayEffect( "stunBaton/flesh_impact", tr.endpos, tr.plane.normal );
|
G_PlayEffect( "stunBaton/flesh_impact", tr.endpos, tr.plane.normal );
|
||||||
|
|
|
@ -261,7 +261,7 @@
|
||||||
name none
|
name none
|
||||||
type ITEM_TYPE_TEXT
|
type ITEM_TYPE_TEXT
|
||||||
rect 0 455 640 40
|
rect 0 455 640 40
|
||||||
text "JKXR: https://www.quakevr.com/jkxr"
|
text "Join our Patreon: patreon.com/teambeef"
|
||||||
font 2
|
font 2
|
||||||
forecolor 1 0 0 1
|
forecolor 1 0 0 1
|
||||||
textscale 1.0
|
textscale 1.0
|
||||||
|
|
Loading…
Reference in a new issue