Forum posts

Posted 2 months ago2024-02-10 01:38:04 UTC
in Draw numbers in HUD Post #348568
Hey, just wanted to say that i find my solution months ago.
What i wanted is to show the amount of grenades without select them, so here's my code writed in SendAmmoUpdate in player.cpp :
void CBasePlayer::SendAmmoUpdate(void)
{
for (int i=0; i < MAX_AMMO_SLOTS;i++)
{
if (m_rgAmmo[i] != m_rgAmmoLast[i])
{
m_rgAmmoLast[i] = m_rgAmmo[i];

ASSERT( m_rgAmmo[i] >= 0 );
ASSERT( m_rgAmmo[i] < 255 );

MESSAGE_BEGIN(MSG_ONE, gmsgGrenades, NULL, pev);//send message with the hitgroup they were just hit
WRITE_BYTE(0); //For some reason, there is some weapon ammo that is impossible to get his index, so instead of writing the grenade index, we just put a 0
`WRITE_BYTE(V_max(V_min(m_rgAmmo[GetAmmoIndex("Hand Grenade)"], 254), 0));`
MESSAGE_END();

// send "Ammo" update message
MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev );
WRITE_BYTE( i );
WRITE_BYTE( V_max( V_min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte
MESSAGE_END();
}
}
}
The gmsgGrenades can be replaced whit gmsgAmmoX , but i created a separated code just in case.
Posted 7 months ago2023-09-08 23:37:07 UTC
in Draw numbers in HUD Post #347847
Hey, i was really interested in adding things to the HUD, and tried to create a new ammo counter for a specific weapon.
I take a look at the code and see the DrawHudNumber that some parts of the HUD like the ammo, health and battery have, so i was triyng to get this thing to work but it doesnt seems to have a result.

I tried to take a look at the Internet to see a way on getting my HUD to work, but surprisingly, i didn't find any, and the ones on this site seems to just show things like adding sprites similar to the flash light or the CS radar.

So i wanted to ask if someone haves a better idea on how these things work or if someone has a guide that can help me.
Posted 8 months ago2023-08-22 03:45:14 UTC
in Problem with sprites Post #347794
Hey, just fixed it, and i can't belive how i fixed it.
First, i writted the code much better and added a CBasePlayer to my void, which solved most of the problem, but then this message appeared: No model 175!
I spent hours trying to figure out the problem, and the answer is kinda surprising.
You see, the sprite wasn't supposed to be precached in the player's Precache(), so i precached the sprite in weapons.cpp, added an extern short to weapons.h and done!
//call medic
void CBasePlayer::MedicToogle(CBasePlayer* pPlayer)
{

if (gpGlobals->time < m_flCounter)
{
return;
}

switch (RANDOM_LONG(1, 2))
{
case 1:
EMIT_SOUND(ENT(pev), CHAN_VOICE, "speech/saveme1.wav", 1, ATTN_NORM);
m_flCounter = gpGlobals->time + 3.5;
break;
case 2:
EMIT_SOUND(ENT(pev), CHAN_VOICE, "speech/saveme2.wav", 1, ATTN_NORM);
m_flCounter = gpGlobals->time + 3.5;
break;
}

MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY, pPlayer->pev->origin);
WRITE_BYTE(TE_PLAYERATTACHMENT);
WRITE_BYTE((BYTE)pPlayer->entindex());
WRITE_COORD(45);
WRITE_SHORT(g_sModelIndexMedic);
WRITE_SHORT(30);
MESSAGE_END();

}
This is the new code.
Posted 8 months ago2023-08-20 05:21:56 UTC
in Problem with sprites Post #347788
Yeah, i'm kinda lost... tried to do that, but i just get errors and crashes, i think i'm missing something.
i'll see if i can figure this out later.

Edit: Still on this problem, the message directly doesn't recognize any model/sprite given and just finded this on my console: No model -24064! , so im kinda stuck now.
MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY); //here we start a message which draws a beam behind a player

WRITE_BYTE(TE_PLAYERATTACHMENT); //sets the beam to follow the entity(player)
WRITE_SHORT(entindex()); // entity
WRITE_COORD(20);
WRITE_SHORT(m_mCall); //model/sprite
WRITE_BYTE(20); //life

MESSAGE_END(); //ends the message we started above
m_mCall already has a precache with a sprite that worked, I tried other messages that were not "TE_PLAYERATTACHMENT" and they managed to make the sprite appear (to a certain extent), so I think something is misspelled.
I'm pretty sure i'm doing something wrong but i don't know what.
Posted 8 months ago2023-08-18 03:28:11 UTC
in Problem with sprites Post #347783
Hey, great everyone, I was doing a command where if you press a specific key, the player would ask for help from a medic just like in TFC or Sven Coop.
//call medic
void CBasePlayer::MedicToogle(void)
{
CSprite * m_pCall = NULL;

if (gpGlobals->time < m_flCounter)
{
return;
}

//const Vector Position = pev->origin + Vector(0, 45, 0);

switch (RANDOM_LONG(1, 2))
{
case 1:
EMIT_SOUND(ENT(pev), CHAN_VOICE, "speech/saveme1.wav", 1, ATTN_NORM);
m_flCounter = gpGlobals->time + 3.5;
break;
case 2:
EMIT_SOUND(ENT(pev), CHAN_VOICE, "speech/saveme2.wav", 1, ATTN_NORM);
m_flCounter = gpGlobals->time + 3.5;
break;
}
if (m_pCall == NULL)
{
m_pCall = CSprite::SpriteCreate("sprites/saveme.spr", Vector(0, 0, 45), TRUE);
if (m_pCall)
{
m_pCall->SetTransparency(kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation);
m_pCall->SetAttachment(edict(), 1);
m_pCall->SetScale(0.5);
m_pCall->TurnOn();
m_pCall->AnimateAndDie(20.0f); // different framerates = more visual variation
}
}
}
This inside` "Player.cpp"`.
Thing is that I'm using a sprite called "saveme.spr", from the TFC files, and it doesn't work as it should. This one remains invisible and does not appear, try with other sprites and most of them did appear when pressing the key, from what I understand, there's some sprites that must be added in a different way, like the "voiceicon.spr", so I wanted to know If any of you have any ideas and can tell me about this problem.

I'll wait for your answers.
Posted 1 year ago2023-02-21 22:34:43 UTC
in Team Player class model problem. Post #347359
Now i already fixed it, it was a problem on the ChangePlayerTeam function, maybe i could show something on the way!
Posted 1 year ago2023-02-18 23:18:20 UTC
in Team Player class model problem. Post #347347
Hi, i was modding in my half life build for a team play game, and i wanted my team classes to have different player models, in this case, i used the "t_team" code (that i declared on player.h and used to allow my classes to have different weapons after spawnning) to edit the ChangePlayerTeam and the ClientUserInfoChanged from "teamplay_gamerules.cpp"

The weapon player class code on "teamplay_gamerules.cpp":
BOOL CHalfLifeTeamplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
/Blah Blah Blah Code/
else if (FStrEq(pcmd, "scout") || FStrEq(pcmd, "soldier") || FStrEq(pcmd, "medic"))
{
/Blah Blah Blah Code/

if (FStrEq(pcmd, "scout"))
{
pPlayer->t_team = 1;
}

if (FStrEq(pcmd, "soldier"))
{
pPlayer->t_team = 2;
}

if (FStrEq(pcmd, "medic"))
{
pPlayer->t_team = 3;
}
And then in "multiplay_gamerules.cpp" i added on the part if (addDefault) something like this:
if (pPlayer->t_team == 1)
Code to give for the player
This code worked for the weapons, so i thought that would work for other things, but im having a little issue.
https://www.youtube.com/watch?v=cFt1XcfDQfg
As you see in this video, the model of the class doesn't change to the default model until I manually change the model to another one that I'm not currently using.
The code in theory works, but not as it should, I'm sure something is missing, but I don't know what it is, this is the code for class model change:
void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib )
{
int damageFlags = DMG_GENERIC;
int clientIndex = pPlayer->entindex();

if ( !bGib )
{
damageFlags |= DMG_NEVERGIB;
}
else
{
damageFlags |= DMG_ALWAYSGIB;
}

if ( bKill )
{
// kill the player, remove a death, and let them start on the new team
m_DisableDeathMessages = TRUE;
m_DisableDeathPenalty = TRUE;

entvars_t *pevWorld = VARS( INDEXENT(0) );
pPlayer->TakeDamage( pevWorld, pevWorld, 900, damageFlags );

m_DisableDeathMessages = FALSE;
m_DisableDeathPenalty = FALSE;
}

// copy out the team name from the model
strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH );

if (pPlayer->t_team == 1)
{
g_engfuncs.pfnSetClientKeyValue(clientIndex, g_engfuncs.pfnGetInfoKeyBuffer(pPlayer->edict()), "model", "scout");
}
else if (pPlayer->t_team == 2)
{
g_engfuncs.pfnSetClientKeyValue(clientIndex, g_engfuncs.pfnGetInfoKeyBuffer(pPlayer->edict()), "model", "soldier");
}
else if (pPlayer->t_team == 3)
{
g_engfuncs.pfnSetClientKeyValue(clientIndex, g_engfuncs.pfnGetInfoKeyBuffer(pPlayer->edict()), "model", "medic");
}
//g_engfuncs.pfnSetClientKeyValue(clientIndex, g_engfuncs.pfnGetInfoKeyBuffer(pPlayer->edict()), "model", pPlayer->m_szTeamName);
g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName );

// notify everyone's HUD of the team change
MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo );
WRITE_BYTE( clientIndex );
WRITE_STRING( pPlayer->m_szTeamName );
MESSAGE_END();

MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo );
WRITE_BYTE( clientIndex );
WRITE_SHORT( pPlayer->pev->frags );
WRITE_SHORT( pPlayer->m_iDeaths );
WRITE_SHORT( 0 );
WRITE_SHORT( g_pGameRules->GetTeamIndex( pPlayer->m_szTeamName ) + 1 );
MESSAGE_END();
}
void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer )
{
// an observer can change a lot, but isn''t visible so hasn''t got to do much here

if (pPlayer->m_afPhysicsFlags & PFLAG_OBSERVER)

return;

// prevent skin/color/model changes

char* mdls = g_engfuncs.pfnInfoKeyValue(infobuffer, "model");

//if the model name and the teamname are the same then return

if (pPlayer->t_team == 1)
{
if (!stricmp(mdls, "scout"))
return;
}
if (pPlayer->t_team == 2)
{
if (!stricmp(mdls, "soldier"))
return;
}
if (pPlayer->t_team == 3)
{
if (!stricmp(mdls, "medic"))
return;
}

//else make sure the player model is the same as the teamname
if (pPlayer->t_team == 1)
{
g_engfuncs.pfnSetClientKeyValue(pPlayer->entindex(), g_engfuncs.pfnGetInfoKeyBuffer(pPlayer->edict()), "model", "scout");
}
else if (pPlayer->t_team == 2)
{
g_engfuncs.pfnSetClientKeyValue(pPlayer->entindex(), g_engfuncs.pfnGetInfoKeyBuffer(pPlayer->edict()), "model", "soldier");
}
else if (pPlayer->t_team == 3)
{
g_engfuncs.pfnSetClientKeyValue(pPlayer->entindex(), g_engfuncs.pfnGetInfoKeyBuffer(pPlayer->edict()), "model", "medic");
}
//g_engfuncs.pfnSetClientKeyValue(pPlayer->entindex(), g_engfuncs.pfnGetInfoKeyBuffer(pPlayer->edict()), "model", pPlayer->m_szTeamName);
}
Posted 1 year ago2023-02-11 05:37:53 UTC
in Nail gun problems. (Please Help) Post #347329
Now i solved the problem, i used bad the UTIL_PrecacheOther();.
Maybe i could do a video showing the nailgun.
Posted 1 year ago2023-02-11 01:48:15 UTC
in Nail gun problems. (Please Help) Post #347328
Ok, so i already found a way to solve the cl_dll compilation problem, the client was detecting a cvar created by me in the player.h, that basically enables semiclip, because client wasnt capable to process this new cvar, the compilation gived errors, so i added an #ifndef / #endif on the void... and it works!

Now my main problem is still how to solve the issue of firing the projectile:
Host_Error: PF_precache_model_I: 'models/nail.mdl' Precache can only be done in spawn functions
Posted 1 year ago2023-02-11 00:38:00 UTC
in Nail gun problems. (Please Help) Post #347327
So, you see... i was trying to make a nail gun with no success, i always get this code error every time:
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CBasePlayer::Touch(class CBaseEntity *)" (?Touch@CBasePlayer@@UAEXPAVCBaseEntity@@@Z)
1>Debug\hl_cdll\client.dll : fatal error LNK1120: 1 unresolved externals
So at one point i give up and scrapped all the code, doing something more "easy" instead, and by easy i mean copy pasting the crossbow code. It did compile well, by the exception of the client syde, that get me the same error, so i just change the hldll. Everything was running preaty well, until it was the moment to shoot the gun:
Host_Error: PF_precache_model_I: 'models/nail.mdl' Precache can only be done in spawn functions
The only thing i want to know is what and how to solve this issue, if you ask what the code is, well... is the same as a Crossbow. But now the thing is... if the way to solve this problem is to compile the cl_dll, well... TOO BAD! because i dont know what is the main cause of the problem.
You would say that the weapon is bad writed on the hl_weapons.obj, like i thinked it was, but then i thinked on compiling the cl_dll of a separated source code, where i didnt even touch the client or the regular dlls. And this happens:
1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CBasePlayer::Touch(class CBaseEntity *)" (?Touch@CBasePlayer@@UAEXPAVCBaseEntity@@@Z)
1>Debug\hl_cdll\client.dll : fatal error LNK1120: 1 unresolved externals
It results... the main base code for the client that i worked whit was busted from the start all along, i need to clarify that im not using the SoloKillersSDK, im using the 2013 Valve realease.
If you know how to solve the problem whithout deleting all my progress, i will thank you a lot, words cannot describe my sheer fucking confusion right now...
Posted 1 year ago2023-02-09 22:08:32 UTC
in Client compiling Weapon problem. Post #347323
theres more if you need:

hl_weapons.cpp

// HLDM Weapon placeholder entities.
CNailGun g_Nailgun;
/Blah blah blah code/
CQuakeNail* CQuakeNail::CreateSuperNail(Vector vecOrigin, Vector vecAngles, CBaseEntity* pOwner)
{
return NULL;
}

CQuakeNail* CQuakeNail::CreateNail(Vector vecOrigin, Vector vecAngles, CBaseEntity* pOwner)
{
return NULL;
}
/////////////
Blah blah blah
/////////////
void HUD_InitClientWeapons( void )
/Blah blah blah code/
HUD_PrepEntity( &g_Nailgun , &player );

// FIXME, make this a method in each weapon? where you pass in an entity_state_t *?
switch ( from->client.m_iId )
{
case WEAPON_CROWBAR:
pWeapon = &g_Crowbar;
break;

/Blah blah blah code/

case WEAPON_NAILGUN:
pWeapon = &g_Nailgun;
break;
}

ev_hldm.cpp

extern C
{
//HLDM
/blah blah blah code/
void EV_NailgunFire(struct event_args_s* args);

void EV_TrainPitchAdjust( struct event_args_s *args );
}

/blah blah code/

void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType )
{
/blah blah code/
if ( pe && pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP)
{
switch( iBulletType )
{
case BULLET_PLAYER_9MM:
case BULLET_MONSTER_9MM:
case BULLET_PLAYER_MP5:
case BULLET_MONSTER_MP5:
case BULLET_PLAYER_BUCKSHOT:
case BULLET_PLAYER_357:
default:
// smoke and decal
EV_HLDM_GunshotDecalTrace( pTrace, EV_HLDM_DamageDecal( pe ) );
break;
}
}
}

/blah blah blah, too much code later/

//======================
// SQUEAK END
//======================
//======================
// NAIL START
//======================
enum ngun_e {
NGUN_IDLE1 = 0,
NGUN_FIDGETSWAY,
NGUN_FIDGETSHAKE,
NGUN_DOWN,
NGUN_UP,
NGUN_SHOOT
};

void EV_NailgunFire(event_args_t* args)
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t up, right, forward;

vec3_t ShellVelocity;
vec3_t ShellOrigin;
int shell;
vec3_t vecSrc, vecAiming;

idx = args->entindex;
VectorCopy(args->origin, origin);
VectorCopy(args->angles, angles);
VectorCopy(args->velocity, velocity);

AngleVectors(angles, forward, right, up);

shell = gEngfuncs.pEventAPI->EV_FindModelIndex("models/nail.mdl");

if (EV_IsLocal(idx))
gEngfuncs.pEventAPI->EV_WeaponAnimation(NGUN_SHOOT, 2);
EV_GetGunPosition(args, ShellOrigin, origin);
VectorMA(ShellOrigin, -4.0, up, ShellOrigin);
VectorMA(ShellOrigin, 2.0, right, ShellOrigin);
gEngfuncs.pEventAPI->EV_PlaySound(idx, origin, CHAN_WEAPON, "weapons/airgun_1.wav", gEngfuncs.pfnRandomFloat(0.95, 1.0), 0.8, 0, gEngfuncs.pfnRandomLong(0, 31) + 93);
VectorScale(forward, 1000.0, velocity);
gEngfuncs.pEfxAPI->R_Projectile(ShellOrigin, velocity, shell, 6, idx, EV_Quake_NailTouch);
if (EV_IsLocal(idx))
V_PunchAxis(0, -1.0);
}
//======================
// NAIL END
//======================

void EV_Quake_NailTouch(struct tempent_s* ent, pmtrace_t* ptr)
{
physent_t* pe;
char name;

pe = gEngfuncs.pEventAPI->EV_GetPhysent(ptr->ent);
if (pe && (pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP))
{
sprintf(&name, "{shot%i", gEngfuncs.pfnRandomLong(0, 4) + 1);
if (name)
{
if (ptr->fraction != 1.0)
EV_HLDM_GunshotDecalTrace(ptr, &name);
}
}
}
....
EV_NailgunFire is already declared on hl_events.cpp
Posted 1 year ago2023-02-09 22:07:37 UTC
in Client compiling Weapon problem. Post #347322
Well you see, i tried to replicate the quake nail of Deathmatch Classic to create this weapon... So you will see enough copy paste of the code triying to replicate it on the HL base code. Some of the functions for the nail projectiles where already on the Client files, so i dont know how much this causes the main problem. I don't even think this weapon shoots even, i really need someone to diagnose this terribleness.

nailgun.cpp

#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )

#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#include "decals.h"
#include "gamerules.h"

enum ngun_e {
NGUN_IDLE1 = 0,
NGUN_FIDGETSWAY,
NGUN_FIDGETSHAKE,
NGUN_DOWN,
NGUN_UP,
NGUN_SHOOT
};

enum firemode_e
{
FIREMODE_TRACK = 0,
FIREMODE_FAST
};

#ifndef CLIENT_DLL

LINK_ENTITY_TO_CLASS(quake_nail, CQuakeNail);

//=========================================================
CQuakeNail* CQuakeNail::CreateNail(Vector vecOrigin, Vector vecAngles, CBaseEntity* pOwner)
{
CQuakeNail* pNail = GetClassPtr((CQuakeNail*)NULL);

UTIL_SetOrigin(pNail->pev, vecOrigin);

pNail->pev->velocity = vecAngles * 1000;
pNail->pev->angles = UTIL_VecToAngles(vecAngles);
pNail->pev->owner = pOwner->edict();
pNail->Spawn();
pNail->pev->classname = MAKE_STRING("spike");

// don't send to clients.
pNail->pev->effects |= EF_NODRAW;

return pNail;
}

CQuakeNail* CQuakeNail::CreateSuperNail(Vector vecOrigin, Vector vecAngles, CBaseEntity* pOwner)
{
CQuakeNail* pNail = CreateNail(vecOrigin, vecAngles, pOwner);
pNail->pev->classname = MAKE_STRING("superspike");

// Super nails simply do more damage
pNail->pev->dmg = 18;
return pNail;
}

void CQuakeNail::Precache(void)
{
PRECACHE_MODEL("models/nail.mdl");
}

//=========================================================
void CQuakeNail::Spawn(void)
{
Precache();

// Setup
pev->movetype = MOVETYPE_FLYMISSILE;
pev->solid = SOLID_BBOX;

// Safety removal
pev->nextthink = gpGlobals->time + 6;
SetThink(&CQuakeNail::SUB_Remove);

// Touch
SetTouch(&CQuakeNail::NailTouch);

// Model
SET_MODEL(ENT(pev), "models/nail.mdl");
UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0));
UTIL_SetOrigin(pev, pev->origin);

// Damage
pev->dmg = 9;
}

//=========================================================
void CQuakeNail::NailTouch(CBaseEntity* pOther)
{
if (pOther->pev->solid == SOLID_TRIGGER)
return;

// Remove if we've hit skybrush
if (UTIL_PointContents(pev->origin) == CONTENT_SKY)
{
UTIL_Remove(this);
return;
}

// Hit something that bleeds
if (pOther->pev->takedamage)
{
CBaseEntity* pOwner = CBaseEntity::Instance(pev->owner);

if (g_pGameRules->PlayerRelationship(pOther, pOwner) != GR_TEAMMATE)
SpawnBlood(pev->origin, pOther->BloodColor(), pev->dmg);

pOther->TakeDamage(pev, pOwner->pev, pev->dmg, DMG_GENERIC);
}
else
{
if (pOther->pev->solid == SOLID_BSP || pOther->pev->movetype == MOVETYPE_PUSHSTEP)
{
TraceResult tr;
tr.vecEndPos = pev->origin;
tr.pHit = pOther->edict();

//Arent we doing this client side?
//UTIL_GunshotDecalTrace( &tr, DECAL_GUNSHOT1 + RANDOM_LONG( 0, 4 ) );
}
}

UTIL_Remove(this);
}
#endif

LINK_ENTITY_TO_CLASS(weapon_nailgun, CNailGun);

void CNailGun::Spawn()
{
Precache();
m_iId = WEAPON_NAILGUN;
SET_MODEL(ENT(pev), "models/w_hgun.mdl");

m_iDefaultAmmo = NAILGUN_DEFAULT_GIVE;
m_iFirePhase = 0;

pev->solid = SOLID_TRIGGER;

FallInit();// get ready to fall down.
}

void CNailGun::Precache(void)
{
PRECACHE_MODEL("models/v_tfc_nailgun.mdl");
PRECACHE_MODEL("models/w_hgun.mdl");
PRECACHE_MODEL("models/p_nailgun.mdl");
PRECACHE_SOUND("weapons/airgun_1.wav");

m_usNailFire = PRECACHE_EVENT(1, "events/wpn/Tf_nail.sc");

UTIL_PrecacheOther("nail");
}

int CNailGun::AddToPlayer(CBasePlayer* pPlayer)
{
if (CBasePlayerWeapon::AddToPlayer(pPlayer))
{

#ifndef CLIENT_DLL
if (g_pGameRules->IsMultiplayer())
{
// in multiplayer, all hivehands come full.
pPlayer->m_rgAmmo[PrimaryAmmoIndex()] = NAILGUN_MAX_CARRY;
}
#endif

MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev);
WRITE_BYTE(m_iId);
MESSAGE_END();
return TRUE;
}
return FALSE;
}

int CNailGun::GetItemInfo(ItemInfo* p)
{
p->pszName = STRING(pev->classname);
p->pszAmmo1 = "9mm";
p->iMaxAmmo1 = NAILGUN_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 1;
p->iPosition = 3;
p->iId = m_iId = WEAPON_NAILGUN;
p->iFlags = 0;
p->iWeight = NAILGUN_WEIGHT;

return 1;
}

BOOL CNailGun::Deploy()
{
return DefaultDeploy("models/v_tfc_nailgun.mdl", "models/p_nailgun.mdl", NGUN_UP, "mp5",1);
}

void CNailGun::PrimaryAttack()
{
Reload();

if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
{
PlayEmptySound();
return;
}

m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
PLAYBACK_EVENT_FULL(1, ENT(m_pPlayer->pev), m_usNailFire, 0, (float*)&g_vecZero, (float*)&g_vecZero, 0, 0, 0, 0, 0, 0);
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_flTimeWeaponIdle = 10;
m_flNextPrimaryAttack = 0.1;

}

void CNailGun::WeaponIdle(void)
{
Reload();

if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
return;

int iAnim;
float flRand = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 0, 1);
if (flRand <= 0.75)
{
iAnim = NGUN_IDLE1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0 / 16 * (2);
}
else if (flRand <= 0.875)
{
iAnim = NGUN_FIDGETSWAY;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0;
}
else
{
iAnim = NGUN_FIDGETSHAKE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 35.0 / 16.0;
}
SendWeaponAnim(iAnim);
}

#endif

weapons.h

//constant items
/Blah blah blah code/
#define WEAPON_NAILGUN 16

// weapon weight factors (for auto-switching) (-1 = noswitch)
/Blah blah blah code/
#define NAILGUN_WEIGHT 10

// weapon clip/carry ammo capacities
/Blah blah blah code/
#define NAILGUN_MAX_CARRY 100

// Max clip section
/Blah blah blah code/
#define NAILGUN_MAX_CLIP WEAPON_NOCLIP

// the default amount of ammo that comes with each gun when it spawns
/Blah blah blah code/
#define NAILGUN_DEFAULT_GIVE 50

(Didnt write the ammo given to a player by an ammo item)

/Blah blah blah class code/

class CNailGun : public CBasePlayerWeapon
{
public:
void Spawn(void);
void Precache(void);
int iItemSlot(void) { return 2; }
int GetItemInfo(ItemInfo* p);
int AddToPlayer(CBasePlayer* pPlayer);

void PrimaryAttack(void);
BOOL Deploy(void);
void WeaponIdle(void);

int m_iFirePhase;// don't save me.

virtual BOOL UseDecrement(void)
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usNailFire;
};

class CQuakeNail : public CBaseEntity
{
public:
void Spawn(void);
void Precache(void);
static CQuakeNail* CreateNail(Vector vecOrigin, Vector vecAngles, CBaseEntity* pOwner);
static CQuakeNail* CreateSuperNail(Vector vecOrigin, Vector vecAngles, CBaseEntity* pOwner);
void EXPORT NailTouch(CBaseEntity* pOther);
};
Posted 1 year ago2023-02-09 02:36:09 UTC
in Client compiling Weapon problem. Post #347313
Hi, i recently created an account here just to ask for help about creating a Half-Life Weapon.
You see, im working on a nail gun like in TFC and because im really amateur at this, i get this error when compiling the cl_dll.

`1>hl_weapons.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CBasePlayer::Touch(class CBaseEntity *)" (?Touch@CBasePlayer@@UAEXPAVCBaseEntity@@@Z)
1>Debug\hl_cdll\client.dll : fatal error LNK1120: 1 unresolved externals`

Im most secure that is something simple, but i can't find anything related to it, so i'm completely lost.
Can someone know the reason?