Making a monster spawn another monster when it dies?
Moderator: InsideQC Admins
14 posts
• Page 1 of 1
Making a monster spawn another monster when it dies?
Yep.
I've started on a new monster, almost done with it. When I thought I was done, bang problem.
I want to make a monster that idle. It just sits on the wall, however you kill it, it spawns a bunch of creatures. I thought it'd be pretty simple.
However, when the pod dies, the infection monster spawns, but it's like it's not connected to the AI as it just stands there doing nothing. I can still kill it of course, it just doesn't do anything.
Any help?
(Warning, newbie here
)
I've started on a new monster, almost done with it. When I thought I was done, bang problem.
I want to make a monster that idle. It just sits on the wall, however you kill it, it spawns a bunch of creatures. I thought it'd be pretty simple.
- Code: Select all
void() pod_die =
{
// regular death
sound (self, CHAN_VOICE, "infection/death1.wav", 1, ATTN_NORM);
Monster_infection (Self.origin);
CreateFblood (self.origin);
pod_die1 (self.origin);
However, when the pod dies, the infection monster spawns, but it's like it's not connected to the AI as it just stands there doing nothing. I can still kill it of course, it just doesn't do anything.
Any help?
(Warning, newbie here
Working on Solitude
- SamUK
- Posts: 101
- Joined: Wed Dec 17, 2008 6:47 pm
- Location: United Kingdom
Well do any of the things you called in your code have the AI routine in it? If not you need to add it.
- Team Xlink
- Posts: 368
- Joined: Thu Jun 25, 2009 4:45 am
- Location: Michigan
Is it animating? If not you probably need to do something to initialize it in it's spawn function, probably something like this for example:
- Code: Select all
newmonster.think = evile_stand;
newmonster.nextthink = time + 0.1;
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
Dr. Shadowborg wrote:Is it animating? If not you probably need to do something to initialize it in it's spawn function, probably something like this for example:
- Code: Select all
newmonster.think = evile_stand;
newmonster.nextthink = time + 0.1;
Is it doing damage to the player?
If it is then I think Dr. Shadowborg is right.
Where exactly is your AI routine located?
- Team Xlink
- Posts: 368
- Joined: Thu Jun 25, 2009 4:45 am
- Location: Michigan
Also note that if you're not calling walkmosnter_start (or the corresponding fly/swim functions) you can have other problems, like your monster kill count not matching the maximum.
Make sure you're calling the _start function and that your animations are set up to loop properly (i.e. walk, stand, etc). The animations should also call the appropriate AI functions like ai_stand();
Mind if we take a gander at the Monster_infection function?
-Wazat
Make sure you're calling the _start function and that your animations are set up to loop properly (i.e. walk, stand, etc). The animations should also call the appropriate AI functions like ai_stand();
Mind if we take a gander at the Monster_infection function?
-Wazat
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
- Wazat
- Posts: 771
- Joined: Fri Oct 15, 2004 9:50 pm
- Location: Middle 'o the desert, USA
Bare with me.
Sure, Wazat.
No, it's doing nothing but spawn and die. Also, what do you mean by Ai routine, not up to scrtach with my coding jargon.
Sure, Wazat.
- Code: Select all
void() monster_infection =
{
if (deathmatch)
{
remove(self);
return;
}
precache_model ("progs/h_infected.mdl");
precache_model ("progs/infectedflood.mdl");
precache_model ("GFX/bflood.spr");
precache_sound ("infection/dattack1.wav");
precache_sound ("infection/ddeath.wav");
precache_sound ("infection/idle.wav");
self.solid = SOLID_SLIDEBOX;
self.movetype = MOVETYPE_STEP;
setmodel (self, "progs/infectedflood.mdl");
setsize (self, '-8 -8 -8', '8 8 8');
self.health = 1;
self.th_stand = infection_stand1;
self.th_walk = infection_walk1;
self.th_run = infection_run1;
self.th_die = infection_die; // Gibing only
self.th_melee = infection_atta1;
self.th_missile = infection_leap1;
walkmonster_start();
};
No, it's doing nothing but spawn and die. Also, what do you mean by Ai routine, not up to scrtach with my coding jargon.
Working on Solitude
- SamUK
- Posts: 101
- Joined: Wed Dec 17, 2008 6:47 pm
- Location: United Kingdom
I had a similar problem with my skeleton king monster; it spawns zombies to fight its enemies. I solved the zombies ignoring the skel's enemies with this:
EDIT: spellcheck, removed a bit of useless code and added a better comment
- Code: Select all
// let the spawned monster fight against the parent's enemies
// (assume self = the parent monster)
sight_entity = self;
sight_entity_time = time;
EDIT: spellcheck, removed a bit of useless code and added a better comment
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Hmm, what you've got there in monster_infection should only work for monster_infection placed in the map by the mapper. (Just guessing, but are you using Darkplaces or something? Don't worry, it's just that Darkplaces has a habit of allowing things that make stuff that should break normal engines not break, which while good, is also very bad for teaching proper modding techniques. Another problem I see there is that monster_infection isn't set up to take any vectors.)
Anyway, you need to make a separate spawn function for your pod spawned infection monsters that also takes into account the relativity factor. i.e. self in the case of pod_die() is the pod, not the monster_infection, hence when monster_infection is called it doesn't set up the monster_infection's functions, it just modifies your pod entity.
In short, you need to create a copy of monster_infection similiar to the following: (note, I've taken out the precaches and deathmatch removal, they should be defined within monster_pod or whatever)
Hope this helps!
Anyway, you need to make a separate spawn function for your pod spawned infection monsters that also takes into account the relativity factor. i.e. self in the case of pod_die() is the pod, not the monster_infection, hence when monster_infection is called it doesn't set up the monster_infection's functions, it just modifies your pod entity.
In short, you need to create a copy of monster_infection similiar to the following: (note, I've taken out the precaches and deathmatch removal, they should be defined within monster_pod or whatever)
- Code: Select all
void(vector org) monster_pod_infection =
{
local entity stemp;
newmis = spawn();
stemp = self;
self = newmis;
setorigin(self, org);
self.solid = SOLID_SLIDEBOX;
self.movetype = MOVETYPE_STEP;
setmodel (self, "progs/infectedflood.mdl");
setsize (self, '-8 -8 -8', '8 8 8');
self.health = 1;
self.th_stand = infection_stand1;
self.th_walk = infection_walk1;
self.th_run = infection_run1;
self.th_die = infection_die; // Gibing only
self.th_melee = infection_atta1;
self.th_missile = infection_leap1;
walkmonster_start();
self = stemp;
};
Hope this helps!
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
As Doc Shadowborg pointed out, your precache functions etc should be moved into the spawn function of the monster that creates these creatures on death. Precache should only ever happen during the map loading. Darkplaces handles it nicely, but other engines probably won't.
The fact that your monsters aren't performing their own target acquisition worries me though. Perhaps something is missing in the animations that handles the target searching (i.e. ai_stand etc). Can you post the code for the animations?
Actually, it may be that nothing is wrong with the animation code. It could very well be that the fix Dr. Shadowborg posted will fix it. As he said, your spawn function was modifying self instead of a newly spawned entity, so it was setting all this info on the pod. Perhaps something was going awry there. Although modifying the original entity and turning it into the infection shouldn't hurt anything presumably... You just can't spawn multiple infection monsters that way.
If Shadow's fixes don't get your spawnlings searching for the player, let's have a look at the walk, stand, run etc animations.
The fact that your monsters aren't performing their own target acquisition worries me though. Perhaps something is missing in the animations that handles the target searching (i.e. ai_stand etc). Can you post the code for the animations?
Actually, it may be that nothing is wrong with the animation code. It could very well be that the fix Dr. Shadowborg posted will fix it. As he said, your spawn function was modifying self instead of a newly spawned entity, so it was setting all this info on the pod. Perhaps something was going awry there. Although modifying the original entity and turning it into the infection shouldn't hurt anything presumably... You just can't spawn multiple infection monsters that way.
If Shadow's fixes don't get your spawnlings searching for the player, let's have a look at the walk, stand, run etc animations.
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
- Wazat
- Posts: 771
- Joined: Fri Oct 15, 2004 9:50 pm
- Location: Middle 'o the desert, USA
Ahh, cheers guys! It's working.
Note: The art is all wip. Something I made real quick to test it out. A decent sprite and texture should make all the difference.
Edit: Also, the muzzleflash has been replaced. I've just got an old build running on darkplaces.
Note: The art is all wip. Something I made real quick to test it out. A decent sprite and texture should make all the difference.
Edit: Also, the muzzleflash has been replaced. I've just got an old build running on darkplaces.
Working on Solitude
- SamUK
- Posts: 101
- Joined: Wed Dec 17, 2008 6:47 pm
- Location: United Kingdom
14 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest