HLFX.Ru Forum
Показать все 8 сообщений этой темы на одной странице

HLFX.Ru Forum (https://hlfx.ru/forum/index.php)
- Half-Life SDK (https://hlfx.ru/forum/forumdisplay.php?forumid=8)
-- Re-spawning monsters in HL multiplayer? (https://hlfx.ru/forum/showthread.php?threadid=5381)


Отправлено Napoleon321 28-10-2019 в 17:36:

Half-Life Re-spawning monsters in HL multiplayer?

Hello Team!

I know we have some awesome coders in this community, and I was wondering can someone give me a heads up at my struggle?

I'm trying to make a re-spawn functions for the monsters in Half-Life. The basic idea is simple and it has being implemented in some mods, unfortunately none of them are open sourced, and with no reference... I'm sort of in the dark.

I have a code for giving players points for killing monsters, different amount based on the monster killed, and I wanted to have the monsters re-spawn after some time after being killed.

Do you know of any good example I could use? Or maybe you know of a tutorial I probably missed?

Your comments and feedback will be greatly appreciated.


Отправлено XaeroX 28-10-2019 в 17:44:

What type of respawn do you want to implement? Player-like (leave corpse and re-create monster) or resurrection-like (dead monster gets up)?

__________________

xaerox on Vivino


Отправлено Napoleon321 28-10-2019 в 19:09:

Leave corpse (or gibs) and re-create monster.


Отправлено XaeroX 29-10-2019 в 05:55:

Then I suggest to start with something like this.
1) Remember the initial origin and angles of the monster in its Spawn() function:

C++ Source Code:
m_vecSpawnOrigin = pev->origin;
m_vecSpawnAngles = pev->angles;

2) In TASK_DIE handler, replace:
C++ Source Code:
1
if ( ShouldFadeOnDeath() )
2
{
3
  // this monster was created by a monstermaker... fade the corpse out.
4
  SUB_StartFadeOut();
5
}
6
else
7
{
8
  // body is gonna be around for a while, so have it stink for a bit.
9
  CSoundEnt::InsertSound ( bits_SOUND_CARCASS, pev->origin, 384, 30 );
10
}

with:
C++ Source Code:
CBaseEntity::Create( pev->classname, m_vecSpawnOrigin,m_vecSpawnAngles , pev->owner );
SUB_StartFadeOut();

This will immediately respawn the monster at the original position, and fade out the corpse to eventually free up an edict (otherwise, you'll run out of them).
You can also add a check for multiplayer or gamerules (g_pGamerules->IsMultiplayer() or custom), and make a respawn delay by moving this code to a separate exported think function and using SetThink() with pev->nextthink with the respawn delay.
HtH.

__________________

xaerox on Vivino


Отправлено FreeSlave 29-10-2019 в 09:02:

Цитата:
Napoleon321 писал:
The basic idea is simple and it has being implemented in some mods


What mods are you referring to? Maybe they just use monstermaker with infinite monster count and max living monsters set to 1?

XaeroX, I think this method will work only for non-gibbed monsters, since gibbing deletes the entity. Also this does not preserve special monsters settings (like weapons, spawnflags, etc.).

__________________
I'm on github
I'm on opendesktop.org


Отправлено XaeroX 29-10-2019 в 09:16:

Цитата:
FreeSlave писал:
will work only for non-gibbed monsters, since gibbing deletes the entity

If TASK_DIE is not run on gibbage, then one should tackle that by adding the monster creation code to the other place, e.g. to GibMonster().
Цитата:
FreeSlave писал:
Also this does not preserve special monsters settings (like weapons, spawnflags, etc.).

Yes, they should be copied in the same way as origin and angles.
That's why I wrote "to start with".

__________________

xaerox on Vivino


Отправлено Napoleon321 29-10-2019 в 17:06:

Thank you for all the feedback.

FreeSlave, I'm referring to Scientist Hunt, I'm sure for this one it's not the monster make thing... since the barney re-spawns on crossfire... and he\s not made with monster-maker there.

Back on the topic or the code: I presume a similar thing is done for the re-spawning of the weapons and the ammo items... still I was not able to completely grasp the concept.


Отправлено JPEG 12-11-2019 в 18:54:

mostermaker? entity

__________________
МОЙ НОВЫЙ ПАБЛИК ПО ХЛ))


Временная зона GMT. Текущее время 22:36.
Показать все 8 сообщений этой темы на одной странице

На основе vBulletin версии 2.3.0
Авторское право © Jelsoft Enterprises Limited 2000 - 2002.
Дизайн и программирование: Crystice Softworks © 2005 - 2024