AIscripted sequence structure First AIscripted sequence Second AIscripted sequence Multimanager setup Trigger Auto setup Monster setup Qc file in GuiStudio It "works". It plays ok the animations but showing 0.5-1 sec of the idle animation just before the second aiscripted sequence is played. Oh. It seem to ignore the player or the bots, it does not attack them...
And, sorry for posting ALL the code...
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
//=========================================================
// HandOfGod Monster (10-7-2015) First Attempt.
// Modificado 19/11/2019
//=========================================================
// UNDONE: Don't flinch every time you get hit
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
// New Includes
#include "weapons.h"
#include "effects.h"
//=========================================================
// Monster's Anim Events Go Here
//=========================================================
#define HOG_AE_ATTACK_RIGHT 0x01
class CHog : public CBaseMonster
{
public:
void Spawn( void );
void Precache( void );
void SetYawSpeed( void );
int Classify ( void );
void HandleAnimEvent( MonsterEvent_t *pEvent );
int IgnoreConditions ( void );
int IRelationship( CBaseEntity *pTarget );
void IdleSound( void );
void AttackSound( void );
static const char *pAttackSounds[];
static const char *pIdleSounds[];
static const char *pAttackHitSounds[];
static const char *pAttackMissSounds[];
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType );
void PrescheduleThink( void );
};
LINK_ENTITY_TO_CLASS( monster_hog, CHog );
const char *CHog::pAttackHitSounds[] =
{
"sentinel/slash1.wav",
"sentinel/slash2.wav",
};
const char *CHog::pAttackMissSounds[] =
{
"drone/claw_miss1.wav",
"drone/claw_miss2.wav",
};
const char *CHog::pAttackSounds[] =
{
"drone/attack1.wav",
"drone/attack2.wav",
};
const char *CHog::pIdleSounds[] =
{
"drone/idle1.wav",
"drone/idle2.wav",
"drone/idle3.wav",
"drone/idle4.wav",
};
//=========================================================
// Classify - indicates this monster's place in the
// relationship table.
//=========================================================
int CHog :: Classify ( void )
{
return CLASS_ALIEN_MILITARY;
}
//=========================================================
// Relationship - El bichito tiene ahora muchas cosas
// a las que atacar.
//=========================================================
int CHog::IRelationship( CBaseEntity *pTarget )
{
if ( FClassnameIs( pTarget->pev, "player" ) )
{
return R_HT; // Probar R_NM;
}
if ( FClassnameIs( pTarget->pev, "monster_crane" ) )
{
return R_NO;
}
return CBaseMonster::IRelationship( pTarget );
}
//=========================================================
// SetYawSpeed - allows each sequence to have a different
// turn rate associated with it.
//=========================================================
void CHog :: SetYawSpeed ( void )
{
int ys;
ys = 180;
#if 0
switch ( m_Activity )
{
}
#endif
pev->yaw_speed = ys;
}
int CHog :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
// Take 10% damage from bullets
if ( bitsDamageType == DMG_BULLET )
{
Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5;
vecDir = vecDir.Normalize();
float flForce = DamageForce( flDamage );
pev->velocity = pev->velocity + vecDir * flForce;
flDamage *= 0.1;
}
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
}
void CHog :: IdleSound( void )
{
int pitch = 95 + RANDOM_LONG(0,9);
// Play a random idle sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pIdleSounds[ RANDOM_LONG(0,ARRAYSIZE(pIdleSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
}
void CHog :: AttackSound( void )
{
// Play a random attack sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAttackSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CHog :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
switch( pEvent->event )
{
case HOG_AE_ATTACK_RIGHT:
{
CBaseEntity *pHurt = CheckTraceHullAttack( 70, RANDOM_LONG (2,10), DMG_SLASH );
if ( pHurt )
{
if ( pHurt->pev->flags & (FL_FAKECLIENT|FL_CLIENT) )
{
pHurt->pev->punchangle.z = -300;
pHurt->pev->punchangle.x = 300;
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 550;
}
// Play a random attack hit sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
}
else // Play a random attack miss sound
EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) );
if (RANDOM_LONG(0,1))
AttackSound();
pev->nextthink = gpGlobals->time + 10;//Tiempo de espera entre éste ataque y el siguiente
}
break;
default:
CBaseMonster::HandleAnimEvent( pEvent );
break;
}
}
//=========================================================
// Spawn
//=========================================================
void CHog :: Spawn()
{
Precache( );
SET_MODEL(ENT(pev), "models/monster_hog.mdl");
//UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX );//Buscar tamaño del tentacle
UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) );
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_FLY;
m_bloodColor = DONT_BLEED;
pev->health = 10000;
pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin.
m_flFieldOfView = VIEW_FIELD_FULL;
m_MonsterState = MONSTERSTATE_COMBAT;
//m_afCapability = bits_CAP_DOORS_GROUP;
MonsterInit();
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
void CHog :: Precache()
{
int i;
PRECACHE_MODEL("models/monster_hog.mdl");
for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ )
PRECACHE_SOUND((char *)pAttackHitSounds[i]);
for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ )
PRECACHE_SOUND((char *)pAttackMissSounds[i]);
for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ )
PRECACHE_SOUND((char *)pAttackSounds[i]);
for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ )
PRECACHE_SOUND((char *)pIdleSounds[i]);
}
//=========================================================
// AI Schedules Specific to this monster
//=========================================================
int CHog::IgnoreConditions ( void )
{
int iIgnore = CBaseMonster::IgnoreConditions();
if ((m_Activity == ACT_MELEE_ATTACK1))
{
#if 0
if (pev->health < 20)
iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE);
else
#endif
}
return iIgnore;
}
//====================================================
// Hog TraceAttack Definitions
//====================================================
void CHog::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType )
{
bitsDamageType &= DMG_GENERIC;
if ( bitsDamageType == 0)
{
if ( pev->dmgtime != gpGlobals->time || (RANDOM_LONG(0,100) < 20) )
{
UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT(0.5,1.5) );
pev->dmgtime = gpGlobals->time;
}
flDamage *= 0.1;
}
CBaseMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType );
}
void CHog :: PrescheduleThink( void )
{
}
Any ideas?.