Forum posts

When i was working on the Armorman tutorial here

https://twhl.info/wiki/page/Monsters_Programming_-_Standard_and_Squad_Monsters

i ended up setting up a idle patrol routine that just traces a line to a wall and then switches to a task that turns him right when he reaches a certain distance to the wall.
I noticed that there are no tasks written to follow a path to a specific vector coordinate. All the follow tasks were instructing to follow an entity.

to do this i had to check the BuildRoute function and i noticed that it calls a function called:
CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist )

so inside this function i added a condition that says if there is no target entity and it just has a vector end location then it can return a valid move.

if (pTarget == NULL && vecEnd){
iReturn = LOCALMOVE_VALID;
break;
}

But yeah im surprised they didnt have this implemented already. The patrol rountine works, though obviously this is a test and not how id program the patrol for an actual game, this reminds me of my high school robotics class where i had to program the robot to sense wall and change direction, cool to see it digitally though haha.

Heres the video demo of the patrol routine.
ARMORMAN DEMO
My next project is going to me modelling a custom model, texturing, animating and then programming it into the mod.
Im a photorealism color artist as well as a 3d modeller and mapper so ill probably have what it takes to add quality models in the mod i think :)

I havent coded the patrol to resume after it is in combat so someone would need to modify it to do that but i will share the GitHub link so you can reference it if you are having issues with this tutorial. But the shield logic is all implemented, as well as reload, shoot, chase, etc.

https://github.com/TylerMaster/ICE1/blob/BRANDON_SMITH_Ex1/armorman.cpp

PS: i added a really jankie RNG script for the shots, the offset is a bit too much so you might want to copy how its done in the projectile monster tutorial here.
hah i noticed that in the forum comments. I actually learned a lot from your youtube videos so thank you for your efforts :P
Hey yall i thought i might share my solution to all the errors/bugs with the NPC projectile tutorial here

https://twhl.info/wiki/page/Tutorial%3A_Coding_NPCs_in_GoldSrc

I posted my solution in the comments but i might as well give yall a heads up.
since everyone has been having trouble with this and i needed to learn projectiles, i decided to work on fixing the bugs in this tutorial.
The integers that represent the animation events were not the same as what was written in the .qc for the melee attacks and reload so you had to change it to this
#define PDRONE_FIRE_SPIKE ( 1 )
#define PDRONE_MELEE_LEFT ( 2 )
#define PDRONE_MELEE_RIGHT ( 4 )
#define PDRONE_MELEE_BOTH ( 6 )
#define PDRONE_RELOAD ( 7 )
the return NULL under GetScheduleOfType was causing crashes so i changed it to:
return CBaseMonster::GetScheduleOfType(Type);
i had to make a custom checkAmmo function and override checkRangeAttack1 and explicitly call them in getSchedule.

and thats about it. heres a video preview of the changes i made and the showcasing it working. I will share the gitHub Code below so you can reference it.
PROJECTILE NPC
GITHUB FILES:
https://github.com/TylerMaster/ICE1/blob/BRANDON_SMITH_Ex1/wip_monster.cpp
https://github.com/TylerMaster/ICE1/blob/BRANDON_SMITH_Ex1/wip_monster.h
Posted 5 months ago2024-05-28 01:28:03 UTC
in HL custom entity/NPC AI can't walk/run Post #348833
i think its fine, once i have the spikes coded i think it will behave the way intended. thanks!
Posted 5 months ago2024-05-26 22:07:19 UTC
in HL custom entity/NPC AI can't walk/run 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 5 months ago2024-05-23 19:54:40 UTC
in HL custom entity/NPC AI can't walk/run 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 5 months ago2024-05-23 19:15:27 UTC
in HL custom entity/NPC AI can't walk/run 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 5 months ago2024-05-22 23:56:36 UTC
in HL custom entity/NPC AI can't walk/run 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");
}