View previous topic :: View next topic |
Author |
Message |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Tue Apr 27, 2010 3:46 pm Post subject: Respawning dead enemies |
|
|
I'm trying to write a simple respawning function. If an enemy is killed by the player, after an X amount of seconds another enemy is spawned in a random entity from the map.
Any ideas? Thanks in advance!  |
|
Back to top |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Tue Apr 27, 2010 4:10 pm Post subject: |
|
|
I'd say the "any entity" idea is prone to run-time problems like spawning monsters into walls. A more easier to do way would be "any other dead monster", like in doom nightmare mode. Also, you'll need to precache all required monster models and sounds during startup. Otherwise, it's kinda straight code. _________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Tue Apr 27, 2010 4:22 pm Post subject: |
|
|
frag.machine wrote: | I'd say the "any entity" idea is prone to run-time problems like spawning monsters into walls. A more easier to do way would be "any other dead monster", like in doom nightmare mode. Also, you'll need to precache all required monster models and sounds during startup. Otherwise, it's kinda straight code. |
Oh, by any entity i meant any "info_mymonster" on the map.
How can i know when the monster is dead, so i can call the monster spawn function again? |
|
Back to top |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Tue Apr 27, 2010 7:40 pm Post subject: |
|
|
From the top of my mind, this should do the trick:
Code: |
if ((monster.health <= 0) && (monster.solid == SOLID_NOT)) {
// spawn another monster
}
|
_________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Tue Apr 27, 2010 8:09 pm Post subject: |
|
|
What about the random entity info_monster?  |
|
Back to top |
|
 |
MauveBib

Joined: 04 Nov 2004 Posts: 602
|
Posted: Tue Apr 27, 2010 10:22 pm Post subject: |
|
|
I'd do it as part of the monster's death animation. The last death frame for each monster sets nextthink to time + 0.1 and think to SUB_Null. Set think to your respawning function, and nextthink to a random time that you like. _________________ Apathy Now! |
|
Back to top |
|
 |
Swift
Joined: 26 Jan 2010 Posts: 44
|
Posted: Thu Apr 29, 2010 5:47 pm Post subject: |
|
|
Haha. Idea: Have death animations play in reverse in the respawning function MauveBib described. |
|
Back to top |
|
 |
Pulseczar

Joined: 12 Aug 2006 Posts: 37
|
Posted: Thu Apr 29, 2010 8:06 pm Post subject: |
|
|
Swift wrote: | Haha. Idea: Have death animations play in reverse in the respawning function MauveBib described. |
The Gizmo's CustomTF Coop does that when you resurrect/revive a dead player. |
|
Back to top |
|
 |
|