HL custom entity/NPC AI can't walk/run Created 6 months ago2024-05-22 23:56:36 UTC by sleepye sleepye

Created 6 months ago2024-05-22 23:56:36 UTC by sleepye sleepye

Posted 6 months ago2024-05-22 23:56:36 UTC Post #348816
Hey im pretty new to modding with half life. I followed Source Modding channel on youtube to get the initial mod setup going as well as adding a custom static entity with collision boxs including a visualizer, etc. I have experience with c/c++, also just finished a 2 year "computer programming" program at Sheridan College Trafalgar Campus in Ontario Canada so im decently familiar with programming,

Anyways, since there is no more video tutorials there i came here to follow this NPC tutorial and im reading through the entity programming manual here as well.

The tutorial above didn't specify the method to place the npc in game so i just modified the .fgd file and added this so i can place the entity into my map through hammer editor.
@PointClass base(Monster) color(0 255 0) size(-20 -20 -20, 20 20 20) studio() = wip_MonsterPitDrone : "wip_MonsterPitDrone"
[
model(studio) : "Model"
]
I can share the code for my custom entity .cpp file at the bottom of this post so you can see what i have at the moment.

The issue im running into is the npc is not running or walking towards me as it should be according to the tutorial im following.
The npc does however do the "yaw" rotation to track my position when im in the set distance to trigger that, and if i go right up to it, it starts to attack me.
Im trying to troubleshoot why those actions are working but the chasing is not. Ive been trying to set up flags in the code as console alerts so i can check if its failing to create the route to execute the movement but im not sure how to write to the halflife/steam console, all the attempts ive tried didnt work.

Help would be greatly appreciated, thanks!

I can post a video here so you guys can see the npc's behavior.
VIDEO
#include "wip_monster.h"

class CPitDrone : public CBaseMonster
{
public:
void Spawn(void);
void Precache(void);
int iSpikes;
int Classify(void);
void SetYawSpeed(void);

};

LINK_ENTITY_TO_CLASS(wip_MonsterPitDrone, CPitDrone);

void CPitDrone::Spawn()
{
Precache();

SET_MODEL(ENT(pev), "models/pit_drone.mdl");


UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);

pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_RED;
pev->health = 100; // Health -
pev->view_ofs = Vector(0, 0, 20);
m_flFieldOfView = 0.5;
m_MonsterState = MONSTERSTATE_NONE;

MonsterInit();

iSpikes = 6;
}

int CPitDrone::Classify(void)
{
return CLASS_ALIEN_MONSTER;
}

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

void CPitDrone::Precache()
{
PRECACHE_MODEL("models/pit_drone_spike.mdl"); //Loads the model for the spike
PRECACHE_MODEL("models/pit_drone.mdl"); //Loads the NPC model in the game

// Bunch of pretty self-explanatory sounds
PRECACHE_SOUND("pitdrone/pit_drone_melee_attack1.wav");
PRECACHE_SOUND("pitdrone/pit_drone_melee_attack2.wav");
PRECACHE_SOUND("pitdrone/pit_drone_attack_spike1.wav");
PRECACHE_SOUND("pitdrone/pit_drone_eat.wav");
PRECACHE_SOUND("pitdrone/pit_drone_die1.wav");
PRECACHE_SOUND("pitdrone/pit_drone_die2.wav");
PRECACHE_SOUND("pitdrone/pit_drone_die3.wav");
PRECACHE_SOUND("pitdrone/pit_drone_hunt3.wav");
}
Posted 6 months ago2024-05-23 18:55:55 UTC Post #348817
Hey
I'm not a coder myself but tell me ? Is your goal to create something entirely new. A npc that's totally different than anything else we know from Hl1 and Opposing Force? If that answer is yes. Then you must wait till somebody who can code helps you out.

If the answer is no and you just wanted new skins or additional body groups for your models then I suggest to you to use

Featureful SDK:

It's primarily made for people that can't code themselves. That being said it already contains all Opposing Force Monsters such as Pit Drones, Voltigores, shock troopers, functioning Ropes, model and sound replacements (including npc death sounds) and so many more amazing features. Tomorrow a new update is scheduled to get released. So it's actively maintained and the author tries to implement feature requests made by us the users.
https://github.com/FreeSlave/halflife-featureful
SDK Features: https://github.com/FreeSlave/halflife-featureful/wiki
Their Discord: https://discord.gg/MTnE6Y2X

Unified SDK

If your desire is learning how to code yourself then I suggest you use Unified SDK instead. It has 1000 of Engine bug fixes, new features for script and audio usage and is by far the most advanced & stable- bug fixed SDK out there. That SDK requires you to be able to code yourself and having intermediate knowledge.
https://github.com/twhl-community/halflife-unified-sdk
SDK Features: https://github.com/twhl-community/halflife-unified-sdk?tab=readme-ov-file#half-life-unified-sdk
More Info: https://twhl.info/thread/view/20055?page=1

This Forum isn't so active anymore The golden ages of website forums are over. I strongly recommend you to join this very websites own Discord Server instead:
TWHL Discord: https://discord.gg/UgPkNwzK
Posted 6 months ago2024-05-23 19:15:27 UTC Post #348818
i joined just now.
And yeah the goal would be to make something entirely new, but im still learning the ins and outs of the sdk, and i had no clue about the unified sdk, i think i will give that a try, thanks
Posted 6 months ago2024-05-23 19:25:50 UTC Post #348819
Ok, sounds good.. Make absolutely sure to join the Discord Server. There you will receive help almost in real time. Although lesser help than it would be the case, say for mapping. There are obviously lesser coders around in the hl community than mappers.
Posted 6 months ago2024-05-23 19:54:40 UTC Post #348820
i have a lot of experience with mapping and modelling for counter strike 1.6, source, and the specialists. modding has always been the last step for me
Posted 6 months ago2024-05-26 22:07:19 UTC Post #348828
-------SOLVED-----
SOLVED ISSUE
I figured it out!

what i think was happening is that i havent coded in its ranged "spike" attack yet and its trying to do that but cant, and since im in range that method is taking precedence over the walking or chasing method.

once i comment out the range attack then he chases!
void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist )
{
.................
/*if ( m_afCapability & bits_CAP_RANGE_ATTACK1 )
{
if ( CheckRangeAttack1 ( flDot, flDist ) )
SetConditions( bits_COND_CAN_RANGE_ATTACK1 );
}
if ( m_afCapability & bits_CAP_RANGE_ATTACK2 )
{
if ( CheckRangeAttack2 ( flDot, flDist ) )
SetConditions( bits_COND_CAN_RANGE_ATTACK2 );
}*/
if ( m_afCapability & bits_CAP_MELEE_ATTACK1 )
{
if ( CheckMeleeAttack1 ( flDot, flDist ) )
SetConditions( bits_COND_CAN_MELEE_ATTACK1 );
}
if ( m_afCapability & bits_CAP_MELEE_ATTACK2 )
{
if ( CheckMeleeAttack2 ( flDot, flDist ) )
SetConditions( bits_COND_CAN_MELEE_ATTACK2 );
}
}
Posted 6 months ago2024-05-27 21:21:06 UTC Post #348832
Good job. I'm glad you figured it out. At present judging by the video the drone is still somewhat slower than in other importations that make use of it.
Posted 6 months ago2024-05-28 01:28:03 UTC Post #348833
i think its fine, once i have the spikes coded i think it will behave the way intended. thanks!
You must be logged in to post a response.