//This void is a mix of requirements to meet for the emote to work, and the custom emote animation itself. void cm_TheEmote(int animation, gentity_t *ent, qboolean freeze) { //OpenRP - Emote + /me support void G_Say(gentity_t *ent, gentity_t *target, int mode, const char *chatText); char *msg = ConcatArgs(1); if (ent->client->sess.spectatorState == SPECTATOR_FOLLOW || ent->client->sess.spectatorState == SPECTATOR_FREE) { return; } if (ent->client->ps.groundEntityNum == ENTITYNUM_NONE){ return; } if (ent->client->ps.saberHolstered < 2){ ent->client->ps.saberHolstered = 2; } if (BG_SaberInAttack(ent->client->ps.saberMove) || BG_SaberInSpecialAttack(ent->client->ps.saberMove) || ent->client->ps.saberLockTime){ return; } if (freeze == qtrue) { if (ent->client->ps.forceDodgeAnim == animation) { //ent->client->emote_freeze=0; ent->client->ps.saberCanThrow = qtrue; ent->client->ps.forceDodgeAnim = 0; ent->client->ps.forceHandExtendTime = 0; } else { ent->client->ps.forceHandExtend = HANDEXTEND_TAUNT; ent->client->ps.forceDodgeAnim = animation; ent->client->ps.forceHandExtendTime = level.time + Q3_INFINITE; //ent->client->ps.persistant[PERS_REGEN] = 1; ent->client->ps.saberCanThrow = qfalse; //ent->client->emote_freeze=1; } } else { StandardSetBodyAnim(ent, animation, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_HOLD | SETANIM_FLAG_HOLDLESS); } //OpenRP - Emote + /me support if (trap->Argc() >= 2) G_Say(ent, NULL, SAY_ME, msg); trap->SendServerCommand(ent - g_entities, "print \"^3Note: Use the emote's command again to get out of the emote.\n\""); return; }
void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, int damage, int mod, int hitLoc, int voiceEvent ) { int pain_anim = -1; float pain_chance; //If we've already taken pain, then don't take it again if ( level.time < self->painDebounceTime && /*mod != MOD_ELECTROCUTE &&*/ mod != MOD_MELEE ) //rwwFIXMEFIXME: MOD_ELECTROCUTE { //FIXME: if hit while recoving from losing a saber lock, we should still play a pain anim? return; } if ( self->s.weapon == WP_THERMAL && self->client->ps.weaponTime > 0 ) { //don't interrupt thermal throwing anim return; } else if ( self->client->NPC_class == CLASS_GALAKMECH ) { if ( hitLoc == HL_GENERIC1 ) { //hit the antenna! pain_chance = 1.0f; // self->s.powerups |= ( 1 << PW_SHOCKED ); // self->client->ps.powerups[PW_SHOCKED] = level.time + Q_irand( 500, 2500 ); //rwwFIXMEFIXME: support for this } // else if ( self->client->ps.powerups[PW_GALAK_SHIELD] ) // {//shield up // return; // } //rwwFIXMEFIXME: and this else if ( self->health > 200 && damage < 100 ) { //have a *lot* of health pain_chance = 0.05f; } else { //the lower my health and greater the damage, the more likely I am to play a pain anim pain_chance = (200.0f-self->health)/100.0f + damage/50.0f; } } else if ( self->client && self->client->playerTeam == NPCTEAM_PLAYER && other && !other->s.number ) { //ally shot by player always complains pain_chance = 1.1f; } else { if ( other && other->s.weapon == WP_SABER || /*mod == MOD_ELECTROCUTE ||*/ mod == MOD_CRUSH/*FIXME:MOD_FORCE_GRIP*/ ) { pain_chance = 1.0f;//always take pain from saber } else if ( mod == MOD_MELEE ) { //higher in rank (skill) we are, less likely we are to be fazed by a punch pain_chance = 1.0f - ((RANK_CAPTAIN-self->NPC->rank)/(float)RANK_CAPTAIN); } else if ( self->client->NPC_class == CLASS_PROTOCOL ) { pain_chance = 1.0f; } else { pain_chance = NPC_GetPainChance( self, damage ); } if ( self->client->NPC_class == CLASS_DESANN ) { pain_chance *= 0.5f; } } //See if we're going to flinch if ( random() < pain_chance ) { int animLength; //Pick and play our animation if ( self->client->ps.fd.forceGripBeingGripped < level.time ) { //not being force-gripped or force-drained if ( /*G_CheckForStrongAttackMomentum( self ) //rwwFIXMEFIXME: Is this needed? ||*/ PM_SpinningAnim( self->client->ps.legsAnim ) || BG_SaberInSpecialAttack( self->client->ps.torsoAnim ) || PM_InKnockDown( &self->client->ps ) || PM_RollingAnim( self->client->ps.legsAnim ) || (BG_FlippingAnim( self->client->ps.legsAnim )&&!PM_InCartwheel( self->client->ps.legsAnim )) ) { //strong attacks, rolls, knockdowns, flips and spins cannot be interrupted by pain } else { //play an anim int parts; if ( self->client->NPC_class == CLASS_GALAKMECH ) { //only has 1 for now //FIXME: never plays this, it seems... pain_anim = BOTH_PAIN1; } else if ( mod == MOD_MELEE ) { pain_anim = BG_PickAnim( self->localAnimIndex, BOTH_PAIN2, BOTH_PAIN3 ); } else if ( self->s.weapon == WP_SABER ) { //temp HACK: these are the only 2 pain anims that look good when holding a saber pain_anim = BG_PickAnim( self->localAnimIndex, BOTH_PAIN2, BOTH_PAIN3 ); } /* else if ( mod != MOD_ELECTROCUTE ) { pain_anim = G_PickPainAnim( self, point, damage, hitLoc ); } */ if ( pain_anim == -1 ) { pain_anim = BG_PickAnim( self->localAnimIndex, BOTH_PAIN1, BOTH_PAIN18 ); } self->client->ps.fd.saberAnimLevel = FORCE_LEVEL_1;//next attack must be a quick attack self->client->ps.saberMove = LS_READY;//don't finish whatever saber move you may have been in parts = SETANIM_BOTH; if ( BG_CrouchAnim( self->client->ps.legsAnim ) || PM_InCartwheel( self->client->ps.legsAnim ) ) { parts = SETANIM_LEGS; } if (pain_anim != -1) { NPC_SetAnim( self, parts, pain_anim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); } } if ( voiceEvent != -1 ) { G_AddVoiceEvent( self, voiceEvent, Q_irand( 2000, 4000 ) ); } else { NPC_SetPainEvent( self ); } } else { G_AddVoiceEvent( self, Q_irand(EV_CHOKE1, EV_CHOKE3), 0 ); } //Setup the timing for it /* if ( mod == MOD_ELECTROCUTE ) { self->painDebounceTime = level.time + 4000; } */ animLength = bgAllAnims[self->localAnimIndex].anims[pain_anim].numFrames * fabs((float)(bgHumanoidAnimations[pain_anim].frameLerp)); self->painDebounceTime = level.time + animLength; self->client->ps.weaponTime = 0; } }
/* ================== TheEmote MJN/ClanMod ================== */ void TheEmote(int anim, gentity_t *ent, qboolean freeze ) { extern void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ); char *msg = ConcatArgs(1); int i = 0; if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW || ent->client->sess.spectatorState == SPECTATOR_FREE ) return; if (ent->client->ps.groundEntityNum == ENTITYNUM_NONE) return; if ( ent->client->ps.saberHolstered < 2 ) ent->client->ps.saberHolstered = 2; if ( BG_SaberInAttack(ent->client->ps.saberMove) || BG_SaberInSpecialAttack(ent->client->ps.saberMove) || ent->client->ps.saberLockTime ) return; //[OpenRP - Endlessly floating up bug] if(ent && ent->client && ent->client->forceLifting != -1) { g_entities[ent->client->forceLifting].client->ps.forceGripMoveInterval = 0; g_entities[ent->client->forceLifting].client->ps.forceGripChangeMovetype = PM_NORMAL; g_entities[ent->client->forceLifting].client->ps.pm_type = PM_NORMAL; g_entities[ent->client->forceLifting].client->underForceLift=qfalse; ent->client->forceLifting = -1; } //[/OpenRP - Endlessly floating up bug] ent->client->ps.forceHandExtend = HANDEXTEND_TAUNT; ent->client->ps.forceDodgeAnim = anim; // MJN - Entry for emotes //if (InSpecialEmote( anim ) ) if ( freeze ) { // MJN - Stop running Forcepowers while ( i < NUM_FORCE_POWERS ) { if ( ( ent->client->ps.fd.forcePowersActive & (1 << i) ) && i != FP_LEVITATION ) WP_ForcePowerStop(ent, i); i++; } ent->client->ps.forceHandExtendTime = level.time + 9999999; ent->client->saberKnockedTime = level.time + 9999999; ent->client->ps.weaponTime = 99999999; } else {// basejk ent->client->ps.forceHandExtendTime = level.time + BG_AnimLength(ent->localAnimIndex, (animNumber_t)anim); } if ( trap_Argc() >= 2 ) G_Say( ent, NULL, SAY_ME, msg ); return; /* if (freeze == qtrue) { if (ent->client->ps.forceDodgeAnim == anim) { StandardSetBodyAnim(ent, anim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_HOLDLESS); ent->client->emote_freeze = qfalse; ent->client->ps.saberCanThrow = qtrue; ent->client->ps.forceDodgeAnim = 0; ent->client->ps.forceHandExtendTime = 0; ent->client->ps.saberMove = LS_NONE; ent->client->saberKnockedTime = level.time; // Enable Saber ent->client->ps.weaponTime = 0; // Enable Weapons } else { M_HolsterThoseSabers(ent); ent->client->emote_freeze = qtrue; // MJN 1 ent->client->ps.saberMove = LS_NONE; ent->client->ps.saberBlocked = 0; ent->client->ps.saberBlocking = 0; ent->client->saberKnockedTime = level.time + 9999999; // Disable Saber ent->client->ps.weaponTime = 99999999; // Disable Weapons ent->client->ps.saberCanThrow = qfalse; ent->client->ps.forceHandExtend = HANDEXTEND_TAUNT; ent->client->ps.forceDodgeAnim = anim; ent->client->ps.forceHandExtendTime = level.time + Q3_INFINITE; StandardSetBodyAnim(ent, anim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_HOLDLESS); } } else { StandardSetBodyAnim(ent, anim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_HOLDLESS); } */ }