Coding issue: the monstermaker entity Created 2 years ago2021-06-05 14:10:26 UTC by Alexis_of_Steel Alexis_of_Steel

Created 2 years ago2021-06-05 14:10:26 UTC by Alexis_of_Steel Alexis_of_Steel

Posted 2 years ago2021-06-05 14:10:26 UTC Post #345677
Hey there! I'm back with a new programming issue: the monstermaker entity edit.

Basically I would like to include these effects from this article about Alien Teleport Effect (HL1) in the code of monstermaker.cpp.

That is, I plan to include the following entities in one:
2 env_sprite's
2 ambient_generic's
1 light
1 env_beam

I'll show you what I've done so far. I have successfully included two sprites!
//=========================================================
// MakeMonster - this is the code that drops the monster
//=========================================================
void CMonsterMaker::MakeMonster( void )
{

// (...) original code

if (FBitSet(pev->spawnflags, SF_MONSTERMAKER_NEW_EFFECTS)) // NEW
    {
        // first sprite
        CSprite *pSprite1 = CSprite::SpriteCreate( "sprites/fexplo1.spr", pev->origin, TRUE );
        pSprite1->SetTransparency( kRenderTransAdd, 77, 210, 130, 255, kRenderFxNoDissipation ); // rendermode, rendercolor (r, g, b), renderamt, renderfx
        pSprite1->SetScale( 1.0 );
        pSprite1->pev->framerate = 10.0;
        pSprite1->TurnOn(); // idk
        pSprite1->AnimateAndDie( 10 );
        // second sprite
        CSprite *pSprite2 = CSprite::SpriteCreate( "sprites/xflare1.spr", pev->origin, TRUE );
        pSprite2->SetTransparency( kRenderTransAdd, 184, 250, 214, 255, kRenderFxNoDissipation ); // rendermode, rendercolor (r, g, b), renderamt, renderfx
        pSprite2->SetScale( 1.0 );
        pSprite2->pev->framerate = 10.0;
        pSprite2->TurnOn(); // idk
        pSprite2->AnimateAndDie( 10 );
    }
}
So far, what I did was set a condition: If the SF_MONSTERMAKER_NEW_EFFECTS flag is on, every time a monster spawns it will produce the effect I want to create.

By the way, here is the flag's identification number:
// Monstermaker spawnflags
#define SF_MONSTERMAKER_START_ON 1 // start active ( if has targetname )
#define SF_MONSTERMAKER_CYCLIC 4 // drop one monster every time fired.
#define SF_MONSTERMAKER_MONSTERCLIP 8 // Children are blocked by monsterclip
#define SF_MONSTERMAKER_NEW_EFFECTS 16 // NEW
And the precached sprites:
void CMonsterMaker :: Precache( void )
{
    CBaseMonster::Precache();

    UTIL_PrecacheOther( STRING( m_iszMonsterClassname ) );
    PRECACHE_MODEL("sprites/fexplo1.spr"); // NEW
    PRECACHE_MODEL("sprites/xflare1.spr"); // NEW
}
But I don't know how to include an env_beam that has the following:
Brightness: 150
Beam color: 197 243 169
Life: .5
Width: 1.8
Noise: 35
Sprite model: "sprites/lgtning.spr"
Strike again time: -.5
Random strike
End sparks

Please, can you help me? :biggrin:
Posted 2 years ago2021-06-05 15:00:12 UTC Post #345678
Take a look at the code used for the Alien Slave's attack: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/islave.cpp#L719-L763

You could also just use Blue Shift's env_warpball entity as a base: https://github.com/Solokiller/halflife-bs-updated/blob/17f13bc65ade2dd364b10dd69e64c7bcd798d359/dlls/effects.cpp#L2282-L2540

It does pretty much what you want to accomplish.
Posted 2 years ago2021-06-06 00:27:12 UTC Post #345679
Hey, Solokiller. Many thanks! That was very helpful.
You must be logged in to post a response.