Forum

Increasing monster's speed?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Increasing monster's speed?

Postby franqutrass » Sat Jan 11, 2014 8:00 pm

Hello everybody, I was wondering how I could increase monster's speed once they have low life, I've already added this code (http://www.inside3d.com/qctut/qctut-36.shtml) in order to change the enemy's skin but what I want is to change their speed.
-----------------------------------------------------------
if (self.health < 20) // if helath under 20 - added

{ // - added

self.skin = 1; // make the skin "1" - added

} // - added
----------------------------------------------------------
I'm not sure, but I think that I can add something else in that code in order to change their speed, Does anyone know?
hello
User avatar
franqutrass
 
Posts: 69
Joined: Wed Dec 30, 2009 6:29 pm
Location: peru

Re: Increasing monster's speed?

Postby Dr. Shadowborg » Sat Jan 11, 2014 8:58 pm

That mainly has to do with pain. As is, you can't increase monster speed that way.

Create something like this:

Code: Select all
.float metabolism;
.void() monsterthink;


Then create:
Code: Select all
void() monster_think =
{
 self.nextthink = time + self.metabolism;
};


Then all you have to do is assign self.monsterthink = monster_think;, set your self.metabolism to 0.1 or less, and place references to self.monsterthink(); in ai_run, ai_run_melee, ai_run_missile, etc.

The bonus you get from doing this is that you can now give your monsters LOTS of fun new things...Like enviromental awareness. :D
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm

Re: Increasing monster's speed?

Postby ceriux » Sun Jan 12, 2014 4:58 am

is movement speed based on the monsters animation? maybe he could make a limping animation thats slower? would be cool.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: Increasing monster's speed?

Postby Cobalt » Sun Jan 12, 2014 7:05 am

Changing .think will make them think faster....they wont move faster, their reaction time will be faster. If you mean physical velocity, try:

Code: Select all
if (self.health < 20)
self.velocity = self.velocity * 1.5; // 50% faster



Usually when something has low health, they move slower, not faster.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: Increasing monster's speed?

Postby Cobalt » Sun Jan 12, 2014 7:18 am

You could check in t_damage () , there is a float I think .dmg , which holds the last value of damage the target sustained. You could hack into the animaiton frames of either the monster or player so that if the take is 50% of current health value, change the frame to another frame that represents alot of pain being taken...and or make the current .nextthink something like : time + (0.5 + (random () * 0.5)) .... which is a small delay of one half, to one second for example.

Limping might be accomplished a similar way, by adding the delay every walk frame, and moving the pitch angle from about 45 to -45 gradually within the frameset. I have done this with the player model with decent success. Not sure about the monsters.

ceriux wrote:is movement speed based on the monsters animation? maybe he could make a limping animation thats slower? would be cool.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: Increasing monster's speed?

Postby franqutrass » Sun Jan 12, 2014 4:23 pm

In fact, I want the enemies to move faster, but already tried this: "self.velocity = self.velocity * 1.5; // 50% faster", but it doesn't work seems to need something else. I wanted the enemie to get angry as the patriarch from killing floor.
hello
User avatar
franqutrass
 
Posts: 69
Joined: Wed Dec 30, 2009 6:29 pm
Location: peru

Re: Increasing monster's speed?

Postby Cobalt » Sun Jan 12, 2014 8:08 pm

Hmm, it may have to do with the fact mosters use the walkmove () built-in in their AI. Im not familiar with too much monster AI stuff.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: Increasing monster's speed?

Postby frag.machine » Mon Jan 13, 2014 1:46 am

Place this in ai.qc, just after ai_run:
Code: Select all
void (float v) ai_berserk =
{
  if (self.health > 25)
  {
    ai_run (v);
  }
  else
  {
    ai_run (v * 1.5); // adjust to your taste
    self.nextthink = time + 0.075; // adjust to your taste
  }
};


Then replace all calls to ai_run(value) in the monster's run code with ai_berserk(value). Be aware though, maps with too many monsters "thinking" too frequently can bog down the engine.
EDIT: for spelling
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: Increasing monster's speed?

Postby Dr. Shadowborg » Tue Jan 14, 2014 6:59 pm

Cobalt wrote:Changing .think will make them think faster....they wont move faster, their reaction time will be faster.


Most monsters don't use self.velocity to move around, which is why speeding up their reaction time (and thus their animation time) will also make them move faster. :wink:

frag.machine wrote:Place this in ai.qc, just after ai_run:
Code: Select all
void (float v) ai_berserk =
{
if (self.health > 25)
{
ai_run (v);
}
else
{
ai_run (v * 1.5); // adjust to your taste
self.nextthink = time + 0.075; // adjust to your taste
}
};


Then replace all calls to ai_run(value) in the monster's run code with ai_berserk(value). Be aware though, maps with too many monsters "thinking" too frequently can bog down the engine.
EDIT: for spelling


That above will work, though it's an awful lot of code to replace given how monsters are put together by default...also be careful about setting your movement value too high, otherwise it's gonna look jerky.)

One would think that if a monster MOVES quicker at low health, it would also REACT faster too...but that's just me. :P
User avatar
Dr. Shadowborg
InsideQC Staff
 
Posts: 1110
Joined: Sat Oct 16, 2004 3:34 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest