spot animation?

Discuss anything not covered by any of the other categories.
Mathuzzz
Posts: 21
Joined: Sun May 09, 2010 3:59 pm

spot animation?

Post by Mathuzzz »

How could I force my monster to make animation when he spot me? I have large noisy monster, but I want him to make certain animation, not just sight sound.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

I made something similar once. Here how I did:

EDITED:
1) create a new entity field, like this:

Code: Select all

.entity    mad_with;
2) in the monster spawn, make sure .mad_with= world;
3) in the first step of the run animation compare .enemy with .mad_with; if they are different, jump to the special animation sequence;
4) in the last step of the special animation, set .mad_with= .enemy, and the next animation step back to the first run animation step.

That's it. This has the added behavior of making your monster running the special animation every time it changes of enemy, too. If you don't want this, then use a different field (like .aflag or .cnt)
Last edited by frag.machine on Mon May 31, 2010 5:35 pm, edited 1 time in total.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Lardarse
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Post by Lardarse »

Overloading .owner like that will cause problems, because it affects collision detection. Using a float field is probably enough.
Roaming status: Testing and documentation
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Lardarse wrote:Overloading .owner like that will cause problems, because it affects collision detection. Using a float field is probably enough.
Are you sure ? The original shambler code uses .owner to hold the lightning entity without any collateral effect, so I assumed it was safe to reuse it.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
MauveBib
Posts: 634
Joined: Thu Nov 04, 2004 1:22 am

Post by MauveBib »

.owner is used in collision, don't overload it. Create a new field or use another unused one.
Apathy Now!
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Ouch, you guys were right :oops:, just found it in the C code.
Fixed, thanks for pointing that out.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Orion
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Post by Orion »

Lardarse is kinda right. Setting .owner to .enemy, will make the monster non-solid to the player (if the player is the monster's enemy, otherwise this monster would be non-solid to another monster). So the monster will ONLY take damage from explosives. Hitscan and projectile/grenade weapons will pass through it. But if a grenade or rocket explodes close enough to the monster he will take damage anyway.

Think the rocket actually spawns inside the player's body, not in the end of the gun's barrel. If the rocket has .owner set to world, the rocket will just explode in your face, and cause problems with death messages, which will be like 'player rides 's rocket', as world don't have a netname at all.

In the case of the shambler's external lightning model (s_light.mdl), the lightning owns the shambler, so the shambler is non-solid ONLY to the lightning, that's why there's no problem in these cases. :wink:


EDIT: Uhoh. I posted with other at the same time explaining the same thing lol!
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

Orion wrote:Lardarse is kinda right. Setting .owner to .enemy, will make the monster non-solid to the player (if the player is the monster's enemy, otherwise this monster would be non-solid to another monster). So the monster will ONLY take damage from explosives. Hitscan and projectile/grenade weapons will pass through it. But if a grenade or rocket explodes close enough to the monster he will take damage anyway.

Think the rocket actually spawns inside the player's body, not in the end of the gun's barrel. If the rocket has .owner set to world, the rocket will just explode in your face, and cause problems with death messages, which will be like 'player rides 's rocket', as world don't have a netname at all.

In the case of the shambler's external lightning model (s_light.mdl), the lightning owns the shambler, so the shambler is non-solid ONLY to the lightning, that's why there's no problem in these cases. :wink:


EDIT: Uhoh. I posted with other at the same time explaining the same thing lol!
He's not "kinda" right, he's completely right. :lol:
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Wazat
Posts: 771
Joined: Fri Oct 15, 2004 9:50 pm
Location: Middle 'o the desert, USA

Post by Wazat »

frag.machine wrote: 4) in the last step of the special animation, set .mad_with= .enemy, and the next animation step back to the first run animation step.
Actually, I recommend doing this in the first animation step. If you do it in the last animation step, then beating the monster is easy. Just keep shooting it each time it starts its spot animation, and it will never update its .mad_with field because its pain animation interrupts it. This will lock it in its spot animation until the player manages to kill it.

This is similar to coop -- two players can kill any non-boss monster, including a shambler, with axes simply by alternating which player is attacking so the shambler can never decide who to attack. I solved the coop bug in Conquest by giving monsters an anger chance, which lowers each time they change targets until they become dead set on one target. It's still exploitable, but at least the monster stops being paralyzed. ;)

Another way to fix this sight animation bug is to only play the animation when the monster chooses a new target, not in the run code. FoundTarget or HuntTarget in ai.qc should do, since sighting a target and getting mad from damage both channel through these functions. You could have your monster set its .think to the sight animation in hunt target instead of to its th_run.

To do this generically, add a new function: .th_sight. Set .th_sight in the monster spawn function (as with .th_pain, we'll set it up so that if some monsters don't set it, it simply isn't used by them).

Now, in HuntTarget, replace the self.think = self.th_run line with:

if(self.th_sight)
self.think = self.th_sight;
else
self.think = self.th_run;

This will do three things:
1) It solves the problem with getting caught in an infinite cycle when the player keeps attacking during the spot animation. If the monster is interrupted during its sight anim, it will finish its pain (or whatever) animation and start fighting as normal (skipping the rest of the sight anim). This means the player has to choose whether to attack during the sight animation -- if he needs a little time to position himself, it's a good idea to not shoot and let the monster yell and beat its chest while he runs for cover or a better weapon.
2) It removes the need for .mad_with, so that can be removed
3) It makes sight animations generic, so any monster can do one simply by setting .th_sight. Monsters without .th_sight just start moving as normal.

Viola

I hope that helps!
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.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Post by leileilol »

I would probably just shove in a direct animation call in SightSound
Wazat wrote: Viola

I hope that helps!
How would a musical instrument help QuakeC?
i should not be here
Mathuzzz
Posts: 21
Joined: Sun May 09, 2010 3:59 pm

Post by Mathuzzz »

Thank you very much for your replies, guys. All I was looking for was answered by Wazath. Thanks again!
Mathuzzz
Posts: 21
Joined: Sun May 09, 2010 3:59 pm

Post by Mathuzzz »

I have yet another question. It has nothing to do with spot animation, but it is the same monster I´m trying to finish. Actually it is replacement for shambler, so I had to make some changes to size, but now when he shoot, the lightning comes from his legs. How can I change the origin of the lightning? Same thing happened with other monsters I was trying to replace. Maybe it is trivial, but I can´t figure it out. Thank you
ajay
Posts: 559
Joined: Fri Oct 29, 2004 6:44 am
Location: Swindon, UK

Post by ajay »

In the original shambler.qc I think it's this bit:

Code: Select all

void() CastLightning =
{
	local	vector	org, dir;
	
	self.effects = self.effects | EF_MUZZLEFLASH;

	ai_face ();

        org = self.origin + '0 0 40';
The 40 is the height the lightning attack comes from.
I could be wrong, I'm far from expert re: quakec ;)
Mathuzzz
Posts: 21
Joined: Sun May 09, 2010 3:59 pm

Post by Mathuzzz »

Thanks
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Post by frag.machine »

leileilol wrote:I would probably just shove in a direct animation call in SightSound
Wazat wrote: Viola

I hope that helps!
How would a musical instrument help QuakeC?
Making music to monsters dance, of course!

Image
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Post Reply