Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Making a monster spawn another monster when it dies?

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
SamUK Joined: 17 Dec 2008 Posts: 98 Location: United Kingdom |

Posted: Tue Dec 01, 2009 7:11 pm Post subject: 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.

Code:
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

Back to top |

Team Xlink Joined: 25 Jun 2009 Posts: 320 |

Posted: Tue Dec 01, 2009 8:40 pm Post subject: |

Well do any of the things you called in your code have the AI routine in it? If not you need to add it. _________________

Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!

Back to top |

Dr. Shadowborg Inside3D Staff Joined: 16 Oct 2004 Posts: 726 |

Posted: Tue Dec 01, 2009 9:17 pm Post subject: |

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:
newmonster.think = evile_stand; newmonster.nextthink = time + 0.1;

_________________
"Roboto suggests Plasma Bazooka."

Back to top |

Team Xlink Joined: 25 Jun 2009 Posts: 320 |

Posted: Tue Dec 01, 2009 10:18 pm Post subject: |

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:
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?
_________________

Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!

Back to top |

Wazat Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA |

Posted: Tue Dec 01, 2009 10:40 pm Post subject: |

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
_________________
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.

Back to top |

SamUK Joined: 17 Dec 2008 Posts: 98 Location: United Kingdom |

Posted: Tue Dec 01, 2009 10:49 pm Post subject: |

Bare with me. Sure, Wazat.

Code:
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

Back to top |

frag.machine Joined: 25 Nov 2006 Posts: 728 |

Posted: Tue Dec 01, 2009 11:12 pm Post subject: |

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:

Code:
// 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
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/

Back to top |

SamUK Joined: 17 Dec 2008 Posts: 98 Location: United Kingdom |

Posted: Tue Dec 01, 2009 11:47 pm Post subject: |

Hmm, it's getting there. It moves now. Still doesn't attack though. _________________ Working on Solitude

Back to top |

Team Xlink Joined: 25 Jun 2009 Posts: 320 |

Posted: Wed Dec 02, 2009 1:11 am Post subject: |

SamUK may I have your permission to fix it and upload an improved version for us? _________________

Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!

Back to top |

Dr. Shadowborg Inside3D Staff Joined: 16 Oct 2004 Posts: 726 |

Posted: Wed Dec 02, 2009 1:19 am Post subject: |

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)

Code:
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!
_________________
"Roboto suggests Plasma Bazooka."

Back to top |

Wazat Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA |

Posted: Wed Dec 02, 2009 4:56 am Post subject: |

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.
_________________
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.

Back to top |

SamUK Joined: 17 Dec 2008 Posts: 98 Location: United Kingdom |

Posted: Sat Dec 05, 2009 3:38 pm Post subject: |

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.
_________________
Working on Solitude

Back to top |

Wazat Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA |

Posted: Sun Dec 06, 2009 5:55 am Post subject: |

Hurray! Congrats, man. _________________ 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.

Back to top |

Teiman Joined: 03 Jun 2007 Posts: 309 |

Posted: Fri Jan 08, 2010 5:33 pm Post subject: |

man, I hate these evil fungus

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group