Forum

SOLID_NOT

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

SOLID_NOT

Postby Junrall » Sun Feb 21, 2010 9:54 am

I noticed that some monsters are not set to self.solid = SOLID_NOT in their first death frame. Would it be a bad thing to do so?
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby Spike » Sun Feb 21, 2010 1:04 pm

solid_not means you can walk through them as soon as they die. it means your nails will suddenly start passing through and hitting the next monster instead of going 'tink' against dead flesh.

It doesn't really matter when they become nonsolid, really it ought to be whenever they're mostly on the ground and dead, rather than while they're still collapsing. gameplay is a little nicer if its instant though.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby c0burn » Sun Feb 21, 2010 1:35 pm

Note that the fish code for this is horrible and it needs to be a lot, lot sooner.
c0burn
 
Posts: 208
Joined: Fri Nov 05, 2004 12:48 pm
Location: Liverpool, England

Postby Orion » Sun Feb 21, 2010 2:29 pm

This is kinda unrealistic but I don't care too much...

But I made players and monsters gibbable by setting self.takedamage = DAMAGE_YES; on Killed() insted of DAMAGE_NO.

When a player or monster dies, it will maintain the original bounding box size, still SOLID_SLIDEBOX. When they're on their last death frame, their maxs_z wil be set to -8, so you can step over them and still gib'em.

Also I had to do deadflag checks on their death function otherwise they'll always get back to their first death frames and playing death sounds right after each other, and when I kill other players I'd be getting dozens of frags and death messages until they're gibbed.

In the case of players, I removed the bodyque functions and I created a particular SpawnCorpse() function, which copies the player's current frame, angles, velocity, etc and have 40 health. This one will be gibbed on 0 health, and will be removed after 10 + random()*10 seconds.
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby Junrall » Sun Feb 21, 2010 5:57 pm

Yep, I did notice my nails going through the monsters or in the case of spikes that stick to walls... they stick to solid dead monsters too, then are floating when the monster is down. In the nail's touch function I added a check for SOLID_NOT on the dieing monster then removed the nail if the monster was not solid. This certainly would take care of that pesky fish problem! 8)

At first I was setting a deadflag for the dieing monster, but preferred the above method as it did make game play a little nicer.

On the other hand I like the idea of being able to gib the dead monsters. An oldie but a goody!
I always wanted to do this, add in fall damage to the monsters, and make them jump back when shot or near an explosion. Then, when they get shot off of a high ledge they will gib when they land... SPLAT!
And Orion... I learned a lot from your Ricocheting Laser that is in the tutorial section... thanks!
Good God! You shot my leg off!
User avatar
Junrall
 
Posts: 191
Joined: Mon Sep 21, 2009 12:27 am
Location: North West Oregon, USA

Postby Orion » Sun Feb 21, 2010 7:36 pm

It's not hard to add falling damage or damage knockback to monsters.

To make monsters knock when taking damage, just go to T_Damage() (combat.qc) when you find a line like this:

if ( (inflictor != world) && (targ.movetype == MOVETYPE_WALK || targ.flags & FL_MONSTER) )
{
...
if (targ.flags & FL_ONGROUND)
targ.flags = targ.flags - FL_ONGROUND;

}

Just add the code in blue(don't replace anything), will check if the target(targ) is a monster. And the last 2 blue lines will unglue the monster from the floor, otherwise it won't be knocked at all.

It came from the top of my head, untested. So I think it'll be kinda messy for flying or swimming mosters though...


Now to put fall damage to monsters, the code is below:

Code: Select all
// add this at the end of StartFrame() (world.qc)
local entity monster, oself;
monster = find(world, wad, string_null); // cycle through ALL entities
while (monster) // repeat this until monster == world
{
   if (monster.health > 0) // entity must be alive
   if (monster.flags & FL_MONSTER) // the entity must be a monster
   {
      oself = self; // switch self/monster
      self = monster;
      MonsterFallDamage ();
      self = oself;
   }
   monster = find(monster, wad, string_null); // go for next entity in the list
}

// add this function above StartFrame()
void() MonsterFallDamage =
{
   local float damage;

   if (self.flags & FL_ONGROUND && self.jump_flag < -650)
   {
      if (self.jump_flag < -1000)
         damage = 50000; // gib the monster if jumping from too high
      else
      {
         damage = self.jump_flag * -1; // make it a positive number
         damage = damage / 80; // make it reasonable
      }
      T_Damage (self, world, world, damage);
   }

   if (!(self.flags & FL_ONGROUND))
      self.jump_flag = self.velocity_z;
};
Last edited by Orion on Mon Feb 22, 2010 4:25 pm, edited 1 time in total.
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby Lardarse » Mon Feb 22, 2010 6:36 am

Orion wrote:if (targ.flags & FL_ONGROUND)
targ.flags = targ.flags - FL_ONGROUND

This can be done a lot cleaner as targ.flags = targ.flags - (targ.flags & FL_ONGROUND); as demonstrated in the armor pickup code in items.qc

It can be done even more cleanly if the ~ operator is available (which it is in C), but I don't even think that FTEQCC supports it.

Don't forget the semicolon at the end, though. It's important...
Roaming status: Testing and documentation
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby Spike » Mon Feb 22, 2010 10:28 am

<offtopic>
The ~ operator only works on integers in C. You can't do a binary not on a float. The same is true in QC.
FTEQCC does support a "&~=" operator though, which does lhs = lhs - (lhs & rhs);
(HexenC notation means "(-)" could be used as the operator instead, with "(+)"=="|=").

So basically:
targ.flags &~= FL_ONGROUND;
</offtopic>
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby goldenboy » Mon Feb 22, 2010 4:40 pm

fteqcc is full of surprises.
User avatar
goldenboy
 
Posts: 924
Joined: Fri Sep 05, 2008 11:04 pm
Location: Kiel


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest