PrimeXT icon indicating copy to clipboard operation
PrimeXT copied to clipboard

monster_human_grunt: broken weapon system (with FIX, but without compatibility with Half-Life)

Open Aynekko opened this issue 5 years ago • 0 comments

Currently, soldiers are trying to spawn with all weapons at once. The weapons field doesn't read bits correctly because in Xash there's no more pev->weapons. Can be fixed adding new field in the entity. Unfortunately, compatibility with HL will be lost, but the soldier will be choosing their equipment randomly if it's not set, which is good I think. FIX: Add: string_t wpns; and void KeyValue( KeyValueData *pkvd ); into class CHGrunt

Add: DEFINE_KEYFIELD( wpns, FIELD_STRING, "wpns" ), into BEGIN_DATADESC( CHGrunt )

Add new function:

void CHGrunt::KeyValue( KeyValueData *pkvd )
{
	if( FStrEq( pkvd->szKeyName, "wpns" ))
	{
		wpns = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else
		CBaseMonster::KeyValue(pkvd);
}

Next, in the CHGrunt :: Spawn(), replace:

if (!m_bHaveWeapons)
{
     AddWeapon(HGRUNT_9MMAR);
     AddWeapon(HGRUNT_HANDGRENADE);
}

to this:

if (FStrEq( STRING(wpns), "9mmar" ))
	{
		AddWeapon(HGRUNT_9MMAR);
	}
	else if (FStrEq( STRING(wpns), "9mmar_hg" ))
	{
		AddWeapon(HGRUNT_9MMAR);
		AddWeapon(HGRUNT_HANDGRENADE);
	}
	else if (FStrEq( STRING(wpns), "9mmar_gl" ))
	{
		AddWeapon(HGRUNT_9MMAR);
		AddWeapon(HGRUNT_GRENADELAUNCHER);
	}
	else if (FStrEq( STRING(wpns), "shotgun" ))
	{
		AddWeapon(HGRUNT_SHOTGUN);
	}
	else if (FStrEq( STRING(wpns), "shotgun_hg" ))
	{
		AddWeapon(HGRUNT_SHOTGUN);
		AddWeapon(HGRUNT_HANDGRENADE);
	}
	else if ( FStringNull(wpns) )
	{
		switch( RANDOM_LONG( 0, 3 ))
		{
		case 0:
			AddWeapon(HGRUNT_9MMAR);
			AddWeapon(HGRUNT_HANDGRENADE);
			break;
		case 1:
			AddWeapon(HGRUNT_SHOTGUN);
			break;
		case 2:
			AddWeapon(HGRUNT_9MMAR);
			AddWeapon(HGRUNT_GRENADELAUNCHER);
			break;
		case 3:
			AddWeapon(HGRUNT_SHOTGUN);
			AddWeapon(HGRUNT_HANDGRENADE);
			break;
		}
	}

That should be all.

Aynekko avatar Oct 26 '20 19:10 Aynekko