'HandleAnimEvent': member function not declared in 'CHEVScientist' Created 3 weeks ago2024-12-27 15:39:41 UTC by GoldSrcJuju GoldSrcJuju

Created 3 weeks ago2024-12-27 15:39:41 UTC by GoldSrcJuju GoldSrcJuju

Posted 3 weeks ago2024-12-27 15:39:41 UTC Post #349426
I am trying to make a HL mod, but this error comes up. Here is the code:

//=========================================================
// monster template
//=========================================================
// UNDONE: Holster weapon?

#include "extdll.h"
#include "plane.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
#include "animation.h"
#include "squadmonster.h"
#include "hgrunt.cpp"
#include "weapons.h"
#include "talkmonster.h"
#include "soundent.h"
#include "effects.h"
#include "customentity.h"

class CHEVScientist : public CSquadMonster
{
public:
void Spawn(void);
void Precache(void);
int iSpikes;
int Classify(void);
void SetYawSpeed(void);
};

LINK_ENTITY_TO_CLASS(monster_hev_survivor, CHEVScientist);

//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CHEVScientist::HandleAnimEvent(MonsterEvent_t* pEvent)
{
Vector vecShootDir;
Vector vecShootOrigin;

switch (pEvent->event)
{
case HGRUNT_AE_DROP_GUN:
{
if (GetBodygroup(GUN_GROUP) != GUN_NONE)
{
Vector vecGunPos;
Vector vecGunAngles;

GetAttachment(0, vecGunPos, vecGunAngles);

// switch to body group with no gun.
SetBodygroup(GUN_GROUP, GUN_NONE);

// now spawn a gun.
if (FBitSet(pev->weapons, HGRUNT_SHOTGUN))
{
DropItem("weapon_shotgun", vecGunPos, vecGunAngles);
}
else
{
DropItem("weapon_9mmAR", vecGunPos, vecGunAngles);
}
if (FBitSet(pev->weapons, HGRUNT_GRENADELAUNCHER))
{
DropItem("ammo_ARgrenades", BodyTarget(pev->origin), vecGunAngles);
}
}
}
break;

case HGRUNT_AE_RELOAD:
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "hgrunt/gr_reload1.wav", 1, ATTN_NORM);
m_cAmmoLoaded = m_cClipSize;
ClearConditions(bits_COND_NO_AMMO_LOADED);
break;

case HGRUNT_AE_GREN_TOSS:
{
UTIL_MakeVectors(pev->angles);
// CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector (0, 0, 32), m_vecTossVelocity, 3.5 );
CGrenade::ShootTimed(pev, GetGunPosition(), m_vecTossVelocity, 3.5);

m_fThrowGrenade = false;
m_flNextGrenadeCheck = gpGlobals->time + 6; // wait six seconds before even looking again to see if a grenade can be thrown.
// !!!LATER - when in a group, only try to throw grenade if ordered.
}
break;

case HGRUNT_AE_GREN_LAUNCH:
{
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/glauncher.wav", 0.8, ATTN_NORM);
CGrenade::ShootContact(pev, GetGunPosition(), m_vecTossVelocity);
m_fThrowGrenade = false;
if (g_iSkillLevel == SKILL_HARD)
m_flNextGrenadeCheck = gpGlobals->time + RANDOM_FLOAT(2, 5); // wait a random amount of time before shooting again
else
m_flNextGrenadeCheck = gpGlobals->time + 6; // wait six seconds before even looking again to see if a grenade can be thrown.
}
break;

case HGRUNT_AE_GREN_DROP:
{
UTIL_MakeVectors(pev->angles);
CGrenade::ShootTimed(pev, pev->origin + gpGlobals->v_forward * 17 - gpGlobals->v_right * 27 + gpGlobals->v_up * 6, g_vecZero, 3);
}
break;

case HGRUNT_AE_BURST1:
{
if (FBitSet(pev->weapons, HGRUNT_9MMAR))
{
Shoot();

// the first round of the three round burst plays the sound and puts a sound in the world sound list.
if (RANDOM_LONG(0, 1))
{
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "hgrunt/gr_mgun1.wav", 1, ATTN_NORM);
}
else
{
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "hgrunt/gr_mgun2.wav", 1, ATTN_NORM);
}
}
else
{
Shotgun();

EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/sbarrel1.wav", 1, ATTN_NORM);
}

CSoundEnt::InsertSound(bits_SOUND_COMBAT, pev->origin, 384, 0.3);
}
break;

case HGRUNT_AE_BURST2:
case HGRUNT_AE_BURST3:
Shoot();
break;

case HGRUNT_AE_KICK:
{
CBaseEntity* pHurt = Kick();

if (pHurt)
{
// SOUND HERE!
UTIL_MakeVectors(pev->angles);
pHurt->pev->punchangle.x = 15;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 100 + gpGlobals->v_up * 50;
pHurt->TakeDamage(pev, pev, gSkillData.hgruntDmgKick, DMG_CLUB);
}
}
break;

case HGRUNT_AE_CAUGHT_ENEMY:
{
if (FOkToSpeak())
{
SENTENCEG_PlayRndSz(ENT(pev), "HG_ALERT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch);
JustSpoke();
}
}
break;

default:
CSquadMonster::HandleAnimEvent(pEvent);
break;
}
}

void CHEVScientist ::Spawn()
{
Precache(); // So the model loads

SET_MODEL(ENT(pev), "models/hevsci.mdl"); // So you can see him

UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); // Let's make his size human. If you're smart enough (or have lots of patience) you can get replace the VEC_ stuff with "Vector( x, y, z)".

pev->solid = SOLID_SLIDEBOX; // SOLID SNAKE??
pev->movetype = MOVETYPE_STEP; // thump thump im walkin
m_bloodColor = BLOOD_COLOR_RED; // SPLATTY SPLAT SPLATA AAAh
pev->health = 30; // he's got bad health
pev->view_ofs = Vector(0, 0, 20); // eyes offset (he knows where you sleep)
m_flFieldOfView = 0.5; // how far can he see
m_MonsterState = MONSTERSTATE_NONE; // stupid idiot spawner

MonsterInit();
}

void CHEVScientist ::Precache()
{
PRECACHE_MODEL("models/hevsci.mdl");

PRECACHE_SOUND("construction/cn_pain1.wav");
PRECACHE_SOUND("construction/cn_pain2.wav");
PRECACHE_SOUND("construction/cn_pain3.wav");

}

int CHEVScientist ::Classify(void)
{
return CLASS_PLAYER_ALLY;
}

void CHEVScientist ::SetYawSpeed(void)
{
pev->yaw_speed = 90;
}

//=========================================================
// Monster's Anim Events Go Here
//=========================================================
#define HGRUNT_AE_RELOAD (2)
#define HGRUNT_AE_KICK (3)
#define HGRUNT_AE_BURST1 (4)
#define HGRUNT_AE_BURST2 (5)
#define HGRUNT_AE_BURST3 (6)
#define HGRUNT_AE_GREN_TOSS (7)
#define HGRUNT_AE_GREN_LAUNCH (8)
#define HGRUNT_AE_GREN_DROP (9)
#define HGRUNT_AE_CAUGHT_ENEMY (10) // grunt established sight with an enemy (player only) that had previously eluded the squad.
#define HGRUNT_AE_DROP_GUN (11) // grunt (probably dead) is dropping his mp5.
Posted 3 weeks ago2024-12-27 15:40:07 UTC Post #349427
(also if it helps, i'm new to HL coding.)
Posted 3 weeks ago2024-12-27 17:11:01 UTC Post #349429
I see issues like these a lot, where beginners try to add/edit NPC code, weapon code etc., but some basic error happens and they have no idea what they're doing nor how to fix it.

If you knew what the error meant, you would realise that this class here is declared as well as its methods like Spawn, Precache and others:
class CHEVScientist : public CSquadMonster
{
public:
void Spawn(void);
void Precache(void);
int iSpikes;
int Classify(void);
void SetYawSpeed(void);
};
However, you are defining or implementing a method down here:
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CHEVScientist::HandleAnimEvent(MonsterEvent_t* pEvent)
{
...
}
Which is not declared in your class above. If you don't understand what I'm saying (methods, implemented, declared), then:

Learn the basics of C++, learn what a function is, what classes are, what declaring is, what members are, spend a couple months experimenting with C++ writing console apps or maybe even using a simple framework like Raylib, write a mini Half-Life SDK for studying, learn how to read code and study it, and then come back to this. Do not learn C++ while simultaneously learning the HL SDK - you will have a really hard time otherwise.
Admer456 Admer456If it ain't broken, don't fox it!
Posted 3 weeks ago2024-12-27 17:16:22 UTC Post #349430
I'm familiar with C++, as I have done mods for other games using it + coded my own game. I just haven't been able to find this out.
Posted 3 weeks ago2024-12-27 17:27:46 UTC Post #349431
I have my doubts, but okay. In either case, you should have a good idea of what to do now, i.e. declare that method.
Admer456 Admer456If it ain't broken, don't fox it!
Posted 3 weeks ago2024-12-28 17:19:41 UTC Post #349434
OP says they're familiar with C++, but posts forum thread asking for help with the most basic beginner programming issue
You must be logged in to post a response.