shithub: choc

Download patch

ref: 415940729df099709b9ffc8bfdd3eb5a52b2823d
parent: 87185424769c6c2dd8207f0b63dc787f98011496
author: Samuel Villareal <svkaiser@gmail.com>
date: Wed Sep 1 23:50:59 EDT 2010

+ Thing z height clipping code added
+ Renamed MF_SKULLFLY to MF_BOUNCE
+ Updated P_ZMovement with Strife changes
+ Updates to PIT_CheckThing
+ Removed most references to MF_SKULLFLY

Subversion-branch: /branches/strife-branch
Subversion-revision: 1995

--- a/src/strife/p_enemy.c
+++ b/src/strife/p_enemy.c
@@ -1454,7 +1454,7 @@
 
 void A_SkullAttack (mobj_t* actor)
 {
-    mobj_t*		dest;
+/*    mobj_t*		dest;
     angle_t		an;
     int			dist;
 
@@ -1474,7 +1474,7 @@
     
     if (dist < 1)
 	dist = 1;
-    actor->momz = (dest->z+(dest->height>>1) - actor->z) / dist;
+    actor->momz = (dest->z+(dest->height>>1) - actor->z) / dist;*/
 }
 
 
--- a/src/strife/p_inter.c
+++ b/src/strife/p_inter.c
@@ -682,7 +682,8 @@
     mobjtype_t	item;
     mobj_t*	mo;
 	
-    target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY);
+    // villsa [STRIFE] MF_SPECIAL is added in the check
+    target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_BOUNCE|MF_SPECIAL);
 
     // villsa [STRIFE] unused
     /*if (target->type != MT_SKULL)
@@ -808,10 +809,11 @@
     if (target->health <= 0)
 	return;
 
-    if ( target->flags & MF_SKULLFLY )
+    // villsa [STRIFE] unused
+    /*if ( target->flags & MF_SKULLFLY )
     {
 	target->momx = target->momy = target->momz = 0;
-    }
+    }*/
 	
     player = target->player;
     if (player && gameskill == sk_baby)
@@ -910,7 +912,7 @@
     }
 
     if ( (P_Random () < target->info->painchance)
-	 && !(target->flags&MF_SKULLFLY) )
+	 /*&& !(target->flags&MF_SKULLFLY)*/ )  // villsa [STRIFE] unused flag
     {
 	target->flags |= MF_JUSTHIT;	// fight back!
 	
--- a/src/strife/p_local.h
+++ b/src/strife/p_local.h
@@ -220,6 +220,7 @@
 
 boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y);
 boolean P_TryMove (mobj_t* thing, fixed_t x, fixed_t y);
+boolean P_CheckPositionZ(mobj_t* thing, fixed_t z);   // villsa [STRIFE]
 boolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y);
 void	P_SlideMove (mobj_t* mo);
 boolean P_CheckSight (mobj_t* t1, mobj_t* t2);
--- a/src/strife/p_map.c
+++ b/src/strife/p_map.c
@@ -312,9 +312,18 @@
     // don't clip against self
     if (thing == tmthing)
 	return true;
+
+    // villsa [STRIFE] check thing z/height against tmthing's z
+    if(thing->height + thing->z < tmthing->z)
+        return true;
+
+    // villsa [STRIFE] check tmthing z/height against thing's z
+    if (tmthing->z + tmthing->height < thing->z)
+        return true;
     
+    // villsa [STRIFE] unused
     // check for skulls slamming into things
-    if (tmthing->flags & MF_SKULLFLY)
+    /*if (tmthing->flags & MF_SKULLFLY)
     {
 	damage = ((P_Random()%8)+1)*tmthing->info->damage;
 	
@@ -326,7 +335,7 @@
 	P_SetMobjState (tmthing, tmthing->info->spawnstate);
 	
 	return false;		// stop moving
-    }
+    }*/
 
     
     // missiles can hit other things
@@ -378,11 +387,11 @@
     if (thing->flags & MF_SPECIAL)
     {
 	solid = thing->flags&MF_SOLID;
-	//if (tmflags&MF_PICKUP) // villsa [STRIFE] TODO - verify
-	//{
+        if (tmthing->player) // villsa [STRIFE] no longer checks MF_PICKUP flag
+	{
 	    // can remove thing
 	    P_TouchSpecialThing (thing, tmthing);
-	//}
+	}
 	return !solid;
     }
 	
@@ -558,6 +567,81 @@
 		    P_CrossSpecialLine (ld-lines, oldside, thing);
 	    }
 	}
+    }
+
+    return true;
+}
+
+//
+// P_CheckPositionZ
+// villsa [STRIFE] new function
+// Check colliding things on top of one another
+//
+
+boolean P_CheckPositionZ(mobj_t* thing, fixed_t height)
+{
+    fixed_t         x;
+    fixed_t         y;
+    fixed_t         z;
+    int             xl;
+    int             xh;
+    int             yl;
+    int             yh;
+    int             bx;
+    int             by;
+    subsector_t*    newsubsec;
+
+    x = thing->x;
+    y = thing->y;
+    z = thing->z;
+
+    thing->z = height;
+
+    tmthing = thing;
+    tmflags = thing->flags;
+    tmx = x;
+    tmy = y;
+
+    tmbbox[BOXTOP] = y + tmthing->radius;
+    tmbbox[BOXBOTTOM] = y - tmthing->radius;
+    tmbbox[BOXRIGHT] = x + tmthing->radius;
+    tmbbox[BOXLEFT] = x - tmthing->radius;
+
+    ceilingline = 0;
+    newsubsec = thing->subsector;
+
+    // The base floor / ceiling is from the subsector
+    // that contains the point.
+    // Any contacted lines the step closer together
+    // will adjust them.
+
+    tmfloorz = tmdropoffz = newsubsec->sector->floorheight;
+    tmceilingz = newsubsec->sector->ceilingheight;
+
+    if(tmflags & MF_NOCLIP)
+        return true;
+
+    // Check things first, possibly picking things up.
+    // The bounding box is extended by MAXRADIUS
+    // because mobj_ts are grouped into mapblocks
+    // based on their origin point, and can overlap
+    // into adjacent blocks by up to MAXRADIUS units.
+
+    xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT;
+    xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT;
+    yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT;
+    yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT;
+
+    for(bx = xl; bx <= xh; bx++)
+    {
+	for(by = yl; by <= yh; by++)
+        {
+	    if(!P_BlockThingsIterator(bx, by,PIT_CheckThing))
+            {
+                tmthing->z = z;
+		return false;
+            }
+        }
     }
 
     return true;
--- a/src/strife/p_mobj.c
+++ b/src/strife/p_mobj.c
@@ -95,10 +95,11 @@
 
     P_SetMobjState (mo, mobjinfo[mo->type].deathstate);
 
-    mo->tics -= P_Random()&3;
+    // villsa [STRIFE] unused
+    /*mo->tics -= P_Random()&3;
 
     if (mo->tics < 1)
-	mo->tics = 1;
+	mo->tics = 1;*/
 
     mo->flags &= ~MF_MISSILE;
 
@@ -120,8 +121,9 @@
     player_t*	player;
     fixed_t	xmove;
     fixed_t	ymove;
-			
-    if (!mo->momx && !mo->momy)
+
+    // villsa [STRIFE] unused
+    /*if (!mo->momx && !mo->momy)
     {
 	if (mo->flags & MF_SKULLFLY)
 	{
@@ -132,7 +134,7 @@
 	    P_SetMobjState (mo, mo->info->spawnstate);
 	}
 	return;
-    }
+    }*/
 	
     player = mo->player;
 		
@@ -200,7 +202,7 @@
 	return;
     }
 
-    if (mo->flags & (MF_MISSILE | MF_SKULLFLY) )
+    if (mo->flags & (MF_MISSILE | MF_BOUNCE) )  // villsa [STRIFE] replace skullfly flag with MF_BOUNCE
 	return; 	// no friction for missiles ever
 		
     if (mo->z > mo->floorz)
@@ -261,14 +263,24 @@
     }
     
     // adjust height
-    mo->z += mo->momz;
+    // villsa [STRIFE] check for things standing on top of other things
+    if(!P_CheckPositionZ(mo, mo->z + mo->momz))
+    {
+        if(mo->momz >= 0)
+            mo->ceilingz = mo->height + mo->z;
+        else
+            mo->floorz = mo->z;
+
+    }
+
+    //mo->z += mo->momz; // villsa [STRIFE] unused
 	
     if ( mo->flags & MF_FLOAT
 	 && mo->target)
     {
 	// float down towards target if too close
-	if ( !(mo->flags & MF_SKULLFLY)
-	     && !(mo->flags & MF_INFLOAT) )
+	if ( /*!(mo->flags & MF_SKULLFLY)   // villsa [STRIFE] unused
+	     &&*/ !(mo->flags & MF_INFLOAT) )
 	{
 	    dist = P_AproxDistance (mo->x - mo->target->x,
 				    mo->y - mo->target->y);
@@ -311,12 +323,19 @@
         // So we need to check that this is either retail or commercial
         // (but not doom2)
 	
-	int correct_lost_soul_bounce = gameversion >= exe_ultimate;
+	//int correct_lost_soul_bounce = gameversion >= exe_ultimate;
 
-	if (correct_lost_soul_bounce && mo->flags & MF_SKULLFLY)
+	if (/*correct_lost_soul_bounce &&*/ mo->flags & MF_BOUNCE)
 	{
 	    // the skull slammed into something
-	    mo->momz = -mo->momz;
+            // villsa [STRIFE] affect reactiontime
+            // momz is also shifted by 1
+	    mo->momz = -mo->momz >> 1;
+            mo->reactiontime >>= 1;
+
+            // villsa [STRIFE] get terrain type
+            if(P_GetTerrainType(mo) != FLOOR_SOLID)
+                mo->flags &= ~MF_FEETCLIPPED;
 	}
 	
 	if (mo->momz < 0)
@@ -329,6 +348,14 @@
 		// after hitting the ground (hard),
 		// and utter appropriate sound.
 		mo->player->deltaviewheight = mo->momz>>3;
+
+                // villsa [STRIFE] fall damage
+                if(mo->momz < -(20*FRACUNIT))
+                {
+                    P_DamageMobj(mo, NULL, mo, (mo->momz >> 32) / -25000);
+                    mo->player->centerview = 1;
+                }
+
 		S_StartSound (mo, sfx_oof);
 	    }
 	    mo->momz = 0;
@@ -342,13 +369,20 @@
 	// hit by a raising floor this incorrectly reverses its Y momentum.
 	//
 
-        if (!correct_lost_soul_bounce && mo->flags & MF_SKULLFLY)
-            mo->momz = -mo->momz;
+        // villsa [STRIFE] unused
+        /*if (!correct_lost_soul_bounce && mo->flags & MF_SKULLFLY)
+            mo->momz = -mo->momz;*/
 
+        // villsa [STRIFE] also check for MF_BOUNCE
 	if ( (mo->flags & MF_MISSILE)
-	     && !(mo->flags & MF_NOCLIP) )
+	     && !(mo->flags & (MF_NOCLIP|MF_BOUNCE)) )
 	{
-	    P_ExplodeMissile (mo);
+            // villsa [STRIFE] check against skies
+	    if(mo->subsector->sector->ceilingpic == skyflatnum)
+                P_RemoveMobj(mo);
+            else
+                P_ExplodeMissile (mo);
+
 	    return;
 	}
     }
@@ -362,6 +396,15 @@
 	
     if (mo->z + mo->height > mo->ceilingz)
     {
+        // villsa [STRIFE] replace skullfly flag with MF_BOUNCE
+        if (mo->flags & MF_BOUNCE)
+        {
+	    // villsa [STRIFE] affect reactiontime
+            // momz is also shifted by 1
+	    mo->momz = -mo->momz >> 1;
+            mo->reactiontime >>= 1;
+        }
+
 	// hit the ceiling
 	if (mo->momz > 0)
 	    mo->momz = 0;
@@ -368,16 +411,17 @@
 	{
 	    mo->z = mo->ceilingz - mo->height;
 	}
-
-	if (mo->flags & MF_SKULLFLY)
-	{	// the skull slammed into something
-	    mo->momz = -mo->momz;
-	}
 	
+        // villsa [STRIFE] also check for MF_BOUNCE
 	if ( (mo->flags & MF_MISSILE)
-	     && !(mo->flags & MF_NOCLIP) )
+	     && !(mo->flags & (MF_NOCLIP|MF_BOUNCE)) )
 	{
-	    P_ExplodeMissile (mo);
+            // villsa [STRIFE] check against skies
+            if(mo->subsector->sector->ceilingpic == skyflatnum)
+                P_RemoveMobj(mo);
+            else
+                P_ExplodeMissile (mo);
+
 	    return;
 	}
     }
--- a/src/strife/p_mobj.h
+++ b/src/strife/p_mobj.h
@@ -203,9 +203,8 @@
     // Not to be activated by sound, deaf monster.
     MF_AMBUSH		= 0x800000,
 
-    // Special handling: skull in flight.
-    // Neither a cacodemon nor a missile.
-    MF_SKULLFLY		= 0x1000000,
+    // villsa [STRIFE] flag used for bouncing projectiles
+    MF_BOUNCE		= 0x1000000,
 
     // Don't spawn this object
     //  in death match mode (e.g. key cards).