Forum posts

Posted 2 weeks ago2021-04-08 01:14:57 UTC
in Help me, Lords of coding!! Post #345518
Thanks, Captain P. I see that it's more complicated than what I thought :confused:
Posted 2 weeks ago2021-04-07 00:41:40 UTC
in Help me, Lords of coding!! Post #345516
Merci, Shepard62700FR! And of course, thanks to Dr. Orange and Bruce for their contributions too.
I think I did well what Shepard62700FR told me.
I mean, first I have removed BOOL m_fDamageDoubler from CBasePlayer class declaration (player.h). Right there I have written:
float m_flDoubleDamageBonusTime;

bool HasDoubleDamageBonus()
{
    return gpGlobals->time < m_flDoubleDamageBonusTime;
}
In CBasePlayer::Spawn (player.cpp) I have added:
m_flDoubleDamageBonusTime = gpGlobals->time + 15.0f;
And in TYPEDESCRIPTION (player.cpp) I have added too:
DEFINE_FIELD( CBasePlayer, m_flDoubleDamageBonusTime, FIELD_TIME ),
And finally the code of my item was like this (items.cpp):
class CDamageDoubler : public CItem
{
    void CDamageDoubler :: Spawn( void )
    {
        Precache();
        SET_MODEL(ENT(pev), "models/w_rad.mdl");
        CItem::Spawn();
    }

    void CDamageDoubler :: Precache( void )
    {
        PRECACHE_MODEL("models/w_rad.mdl");
        PRECACHE_SOUND("scientist/sci_pain3.wav"); // stahp sound
    }

    BOOL CDamageDoubler :: MyTouch( CBasePlayer *pPlayer )
    {
        if ( ( pPlayer->pev->weapons & (1<<WEAPON_SUIT) ) ) // The player can take this item only if he is wearing the HEV suit
        {
            ALERT( at_console, "You have picked up the damage doubler\n" ); // Display a message on the console.
            EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "scientist/sci_pain3.wav", 1, ATTN_NORM); // play the stahp sound
            pPlayer->HasDoubleDamageBonus(); // New line
            return TRUE;
        }
        return FALSE;
    }
};

LINK_ENTITY_TO_CLASS( item_damage_doubler, CDamageDoubler );
But I do not know exactly how to double the damage of both weapons that use FireBulletsPlayer and those that do not use this function. If you can give me a concrete example, it would be very helpful. :)
Posted 2 weeks ago2021-04-05 18:18:43 UTC
in Help me, Lords of coding!! Post #345510
Hello Dr. Orange! What you say sounds logical. But how would I make that effect last only 15 seconds? That question surpasses my rudimentary knowledge of programming in Half-Life :(
Posted 2 weeks ago2021-04-04 22:41:22 UTC
in Help me, Lords of coding!! Post #345507
Hello there. I'm back with a new issue.
I want to create an item that doubles all the damage done by the player, but I don't know how to achieve that.
As far as I know, there is nothing in the Half-Life source code that looks like the item I want to create, so that's why I'm asking for your help.

The concept is simple but at the same time complicated: Once you pick up the item, for 15 seconds all the damage you do with your weapons will be double. After 15 seconds, the item will be removed from your inventory, and the effect will end. Now you can pick up another item of these.

Oh, Lords of Coding, I invoke you!

I have only written the basic structure of my item, at the bottom of items.cpp:
// An item that doubles all the damage done.
class CDamageDoubler : public CItem
{
    void CDamageDoubler :: Spawn( void )
    {
        Precache();
        SET_MODEL(ENT(pev), "models/w_rad.mdl");
        CItem::Spawn();
    }

    void CDamageDoubler :: Precache( void )
    {
        PRECACHE_MODEL("models/w_rad.mdl");
        PRECACHE_SOUND("scientist/sci_pain3.wav"); // stahp sound
    }

    BOOL CDamageDoubler :: MyTouch( CBasePlayer *pPlayer )
    {
        if ( pPlayer->m_fDamageDoubler ) // If the player owns this item, then he cannot take another.
        {
            return FALSE;
        }

        if ( ( pPlayer->pev->weapons & (1<<WEAPON_SUIT) ) ) // The player can take this item only if he is wearing the HEV suit
        {
            ALERT( at_console, "You have picked up the damage doubler\n" ); // Display a message on the console.
            EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "scientist/sci_pain3.wav", 1, ATTN_NORM); // play the stahp sound
            pPlayer->m_fDamageDoubler = TRUE;
            return TRUE;
        }
        return FALSE;
    }
};

LINK_ENTITY_TO_CLASS( item_damage_doubler, CDamageDoubler );
m_fDamageDoubler is declared somewhere in player.h:
BOOL m_fDamageDoubler; // For my item that doubles the damage done
Thanks in advance!!!
Posted 2 months ago2021-02-12 20:15:52 UTC
in Lords of Coding, I need help!!11!!one Post #345340
Oh, I feel stupid :lol: Thank you, Solokiller. It works! My problem is solved! You're one of those Lords of coding!
Valve, we got a lord of coding here!Valve, we got a lord of coding here!
Posted 2 months ago2021-02-12 15:34:11 UTC
in Lords of Coding, I need help!!11!!one Post #345338
Hello Solokiller. Thanks for answering. When I replace WRITE_SHORT( entindex() ); with WRITE_SHORT(entindex() + (attachmentIndex << 12)); it says identifier "attachmentIndex" is undefined. And it fails to compile. :cry:
Posted 2 months ago2021-02-12 02:01:32 UTC
in Lords of Coding, I need help!!11!!one Post #345334
Hello hermanJnr, thank for your response! I still can't find a solution for my problem :(
Posted 2 months ago2021-02-11 19:10:03 UTC
in Lords of Coding, I need help!!11!!one Post #345332
Hey, Lord of coding, I know your knowledge of Half-Life programming is vastly superior to mine. For dat reason, I ask for your help! :D

I want the beam that I have created (simulating the orange beam of the tau cannon) to come out from an $attachment that I defined from the QC file of my model, and not from the model's origin, as you can see in the image that I attach here:
This is the problem!This is the problem!
This is the bunch of code I wrote so far:
void CHEVScientistGauss :: HandleAnimEvent( MonsterEvent_t *pEvent )
(...)
case HEVGAUSS_AE_SHOOT_GAUSS:
{
    if (m_hEnemy != NULL)
    {
        TraceResult tr;
        Vector vecSrc, vecAngles;
        vecAngles = ShootAtEnemy( vecSrc );
        UTIL_TraceLine( vecSrc, vecSrc + vecAngles * 1024, dont_ignore_monsters, ENT( pev ), &tr);
        CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
        if (pEntity != NULL && pEntity->pev->takedamage)
        {
            ClearMultiDamage();
            pEntity->TraceAttack( pev, gSkillData.hevscientistGaussDmg, pev->velocity, &tr, DMG_SHOCK );
            ApplyMultiDamage( pev, pev );
        }
        MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
            WRITE_BYTE( TE_BEAMENTPOINT );
            WRITE_SHORT( entindex() );
            WRITE_COORD( tr.vecEndPos.x );
            WRITE_COORD( tr.vecEndPos.y );
            WRITE_COORD( tr.vecEndPos.z );
            WRITE_SHORT( m_iBeam );
            WRITE_BYTE( 0 );
            WRITE_BYTE( 0 );
            WRITE_BYTE( 1 );
            WRITE_BYTE( 10 );
            WRITE_BYTE( 0 );
            WRITE_BYTE( 255 );
            WRITE_BYTE( 128 );
            WRITE_BYTE( 0 );
            WRITE_BYTE( 128 );
            WRITE_BYTE( 0 );
        MESSAGE_END();
        EMIT_SOUND( ENT(pev), CHAN_WEAPON, "weapons/gauss2.wav", 1, ATTN_NORM );
    }
}
break;
Thanks guys for your time. :glad:
Posted 5 months ago2020-11-21 23:34:33 UTC
in Need help with Activities and NPC coding Post #344919
I just tested your method. It compiled correctly, but for some reason I don't know the NPC animations are bugged. The NPC stay freeze.
Anyway, I really appreciate your help, guys. But I think it would be better if I create the NPC with all weapons separately. :confused:
Posted 5 months ago2020-11-20 18:21:24 UTC
in Need help with Activities and NPC coding Post #344909
Hello Captain P, thanks for your correction. :D
I just deleted that part (iSequence = LookupActivity ( NewActivity );), but unfortunately my NPC still plays all the idle animations :(
I'm starting to think it's more complicated than I thought...
Posted 5 months ago2020-11-20 13:28:16 UTC
in Need help with Activities and NPC coding Post #344906
Yep, I just did what you said. And here's the bunch of code I wrote:
case ACT_IDLE:
if (FBitSet(pev->weapons, HEVSCI_GLOCK)) // 9mm handgun hevscientist
{
    if ( m_fStanding )
    {
        iSequence = LookupSequence( "ref_aim_onehanded" );
    }
    else
    {
        iSequence = LookupSequence( "crouch_aim_onehanded" );
    }
}
else if (FBitSet(pev->weapons, HEVSCI_PYTHON)) // .357 Magnum hevscientist
{
    if ( m_fStanding )
    {
        iSequence = LookupSequence( "ref_aim_python" );
    }
    else
    {
        iSequence = LookupSequence( "crouch_aim_python" );
    }
}
else if (FBitSet(pev->weapons, HEVSCI_SHOTGUN)) // Shotgun hevscientist
{
    if ( m_fStanding )
    {
        iSequence = LookupSequence( "ref_aim_shotgun" );
    }
    else
    {
        iSequence = LookupSequence( "crouch_aim_shotgun" );
    }
}
else if (FBitSet(pev->weapons, HEVSCI_MP5)) // MP5 hevscientist
{
    if ( m_fStanding )
    {
        iSequence = LookupSequence( "ref_aim_mp5" );
    }
    else
    {
        iSequence = LookupSequence( "crouch_aim_mp5" );
    }
}
else if (FBitSet(pev->weapons, HEVSCI_CROSSBOW)) // Crossbow hevscientist
{
    if ( m_fStanding )
    {
        iSequence = LookupSequence( "ref_aim_bow" );
    }
    else
    {
        iSequence = LookupSequence( "crouch_aim_bow" );
    }
}
else if (FBitSet(pev->weapons, HEVSCI_RPG)) // RPG hevscientist
{
    if ( m_fStanding )
    {
        iSequence = LookupSequence( "ref_aim_rpg" );
    }
    else
    {
        iSequence = LookupSequence( "crouch_aim_rpg" );
    }
}
else if (FBitSet(pev->weapons, HEVSCI_GAUSS)) // Gauss hevscientist
{
    if ( m_fStanding )
    {
        iSequence = LookupSequence( "ref_aim_gauss" );
    }
    else
    {
        iSequence = LookupSequence( "crouch_aim_gauss" );
    }
}
iSequence = LookupActivity ( NewActivity );
break;
And my NPC still plays all the idling sequences without select one specifically. But I guess this is the way! And it seem that something's still missing...
Posted 5 months ago2020-11-20 01:31:36 UTC
in Need help with Activities and NPC coding Post #344897
Hey Shepard. I tried that method from hgrunt.cpp, but my NPC still plays all idling animations :(
In the QC file, I assigned to every idling sequence (glock, magnum, shotgun, etc.) the ACT_IDLE tag. Is that right?
Posted 5 months ago2020-11-19 12:25:06 UTC
in Need help with Activities and NPC coding Post #344889
Hello people. Will you believe me if I tell you that I've been trying for months the following coding issue with no satisfactory results? Yes, it took me several months of headaches, and I'm getting sad :(
So for dat reason I'm appealing to TWHL, specifically to Half-Life's Lords of Coding. :D

I'm trying out a new NPC that consists in hevscientist with multiple faces and weapons to choose (yeah, like those ones saw in Sweet Half-Life).
I want to assign a specific idling animation to every weapon the model has. For example, if the model has a RPG, the idling animation will be those that hold up an RPG. If the model has a crowbar, the idling animation will be the one that carry a crowbar, and so on.

The challenge, I guess, is make the NPC choose a certain animation when it has a given weapon. Note that if all idling sequences has ACT_IDLE attached to them, the NPC plays all idling animations without distinction.

But I can't get what I'm looking for. Is there something I gotta do in the code?
Thanks in advance, and have a nice day :cool:
Thanks Shepard! :cool:
Hello everyone! I'm making a NPC that can shoot the following weapons: Glock, Python (357. Magnum), Shotgun, MP5, Crossbow, RPG, Gauss and Egon!
Hard work I've chosen. I wrote up the code for Glock, Python, Shotgun and MP5. They basically are a slightly modified copy of a hgrunt.cpp's bunch of code. I'll show up as an example my Python's method:

//=========================================================
// PythonShoot
//=========================================================
void CMyNewNPC :: PythonShoot ( void )
{
Vector vecShootOrigin = GetGunPosition();
Vector vecShootDir = ShootAtEnemy( vecShootOrigin );

UTIL_MakeVectors ( pev->angles );

Vector vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT(40,90) + gpGlobals->v_up * RANDOM_FLOAT(75,200) + gpGlobals->v_forward * RANDOM_FLOAT(-40, 40);
EjectBrass ( vecShootOrigin - vecShootDir * -24, vecShellVelocity, pev->angles.y, m_iBrassShell, TE_BOUNCE_SHELL);
FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_357 );

pev->effects |= EF_MUZZLEFLASH;

m_cAmmoLoaded--;

Vector angDir = UTIL_VecToAngles( vecShootDir );
SetBlending( 0, angDir.x );
}

I wonder if you have the bunch of code for RPG, Crossbow, Gauss and Egon shoots! Due to I couldn't find them out through the Half-Life SDK yet. Or at least if you know where I can find them, please tell me! I suspect they are a little bit more complicated than the others I made! (I think they use different sprites, more sounds and models, beams...).

Thanks in advance,
Alexis.
I just couldn't get it. :\
Hello guys. Well I'm sorry if I sound kinda annoying, but you helped me some time ago. I'm very thankful with you. Now, I'm wondering again if you can help me one more time.
I can't figure out how to get NPCs show up their health points and name in vanilla Half-Life, just like they do in Sven Co-op. I wonder if you guys know how to do it... I think I'm gonna have to edit cl_dll, but certainly Idk.
Thanks in advance,
Alexis.
Posted 10 months ago2020-05-30 00:35:23 UTC
in Need help with player.mdl Post #344325
Thank you guys for your responses. I tried what abbadon said and it worked (about changing model's origin on QC file).
You're the best!
Problem solved!Problem solved!
Posted 10 months ago2020-05-28 04:34:49 UTC
in Need help with player.mdl Post #344313
Hello guys. I need your help again: When I'm implementing player.mdl (through monster_generic entity) into my map, it gets its lower half of the body under the floor, as you can see in the picture below:
player.mdl getting its lower half of the body under the floorplayer.mdl getting its lower half of the body under the floor
If you know how to fix that issue, you'd have helped me a lot. Because I coudn't fix it yet!
Alexis.
Posted 10 months ago2020-05-23 07:11:07 UTC
in Security guards reloading their gun Post #344282
I did it and it worked successfully. Thank you!
Posted 11 months ago2020-05-22 01:49:05 UTC
in Security guards reloading their gun Post #344266
Hello folks. I wonder if you know how to get, through programming, security guards (monster_barney) reloading their gun after firing 17 shots. I'm now using Visual Studio 2019 and Solokiller's updated Half-Life SDK that works with VS2019. I think it's possible since barney.mdl contains an animation doing so. But I couldn't find the bunch of code that allow security guards reload their gun :cry: . So, I need your help again!
Thanks in advance,
Alexis.
Posted 11 months ago2020-05-21 18:04:42 UTC
in About adding randomness to HL Post #344261
Thank you guys for answering. Solokiller's method worked perfectly! I've tested myself.
This thread is solved.
I'm in debt to you!
Alexis.
Posted 11 months ago2020-05-20 19:04:20 UTC
in About adding randomness to HL Post #344252
Hey there. I'm seeking out the way to add randomness to HL for triggering events. I wanna do it through editing its source code (using Microsoft Visual Studio 2010 and official Valve's Half-Life 1 SDK from GitHub). But I coudn't figure out how to do it :cry: . So, I'm wondering if you guys know how to do it. I was thinking about creating a new entity, like trigger_random or so.

I would appreciate your help of course. Greetings from Argentina!
Alexis.