Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game balance #1

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
98 changes: 58 additions & 40 deletions src/Enemies/Enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ static const int enemyPoints[]=
500,
500
};

AddToScore(enemyPoints[theEnemy->Kind]); // get points

QD3D_ExplodeGeometry(theEnemy, 570.0f, 0, EXPLODEGEOMETRY_DENOMINATOR, .4);

DeleteEnemy(theEnemy);
PlayEffect(EFFECT_ENEMYDIE);
}
Expand All @@ -98,24 +98,29 @@ Boolean DoEnemyCollisionDetect(ObjNode *theEnemy, uint32_t ctype)
{
ObjNode *hitObj;

/* AUTOMATICALLY HANDLE THE BORING STUFF */

HandleCollisions(theEnemy, ctype);


/* HANDLE LAVA */


/* AUTOMATICALLY HANDLE THE BORING STUFF */

HandleCollisions(theEnemy, ctype);


/******************************/
/* SCAN FOR INTERESTING STUFF */
/******************************/


for (int i = 0; i < gNumCollisions; i++)
{
if (gCollisionList[i].type == COLLISION_TYPE_OBJ)
{
hitObj = gCollisionList[i].objectPtr; // get ObjNode of this collision
ctype = hitObj->CType;




if (ctype & CTYPE_HURTENEMY)
{
if (EnemyGotHurt(theEnemy,hitObj,hitObj->Damage)) // handle hit (returns true if was deleted)
Expand All @@ -129,7 +134,34 @@ ObjNode *hitObj;
}
}
}


UInt16 enemyTile = GetTileAttribs(theEnemy->Coord.x, theEnemy->Coord.z);
if (enemyTile & TILE_ATTRIB_LAVA) {

float groundY = GetTerrainHeightAtCoord(theEnemy->Coord.x, theEnemy->Coord.z);
float enemyY = theEnemy->Coord.y;

if (enemyY >= groundY && enemyY - groundY < 100) {
if (EnemyGotHurt(theEnemy,hitObj,.01)) {
// handle hit (returns true if was deleted)
return(true);
}

theEnemy->LavaSmokeCounter += gFramesPerSecondFrac;
if (theEnemy->LavaSmokeCounter > .08f)
{
theEnemy->LavaSmokeCounter = 0.0f;
MakeSmokePuff(
(RandomFloat() - .5f) * 40.0f + theEnemy->Coord.x,
theEnemy->Coord.y,
(RandomFloat() - .5f) * 40.0f + theEnemy->Coord.z,
.1);

}
}
}


return(false);
}

Expand All @@ -149,20 +181,20 @@ Boolean EnemyGotHurt(ObjNode *theEnemy, ObjNode *theHurter, float damage)


/* LOSE HEALTH */

theEnemy->Health -= damage;


/* HANDLE DEATH OF ENEMY */

if (theEnemy->Health <= 0)
{
KillEnemy(theEnemy);
return(true);
}



return(false);
}

Expand All @@ -187,14 +219,14 @@ ObjNode *FindClosestEnemy(TQ3Point3D *pt, float *dist)
ObjNode *thisNodePtr,*best = nil;
float d,minDist = 100000;


thisNodePtr = gFirstNodePtr;

do
{
if (thisNodePtr->Slot >= SLOT_OF_DUMB) // see if reach end of usable list
break;

if (thisNodePtr->CType & CTYPE_ENEMY)
{
d = CalcQuickDistance(pt->x,pt->z,thisNodePtr->Coord.x, thisNodePtr->Coord.z);
Expand All @@ -203,7 +235,7 @@ float d,minDist = 100000;
minDist = d;
best = thisNodePtr;
}
}
}
thisNodePtr = (ObjNode *)thisNodePtr->NextNode; // next node
}
while (thisNodePtr != nil);
Expand All @@ -226,7 +258,7 @@ float d,minDist = 100000;
ObjNode *MakeEnemySkeleton(Byte skeletonType, float x, float z)
{
ObjNode *newObj;

/****************************/
/* MAKE NEW SKELETON OBJECT */
/****************************/
Expand All @@ -245,13 +277,13 @@ ObjNode *newObj;
newObj = MakeNewSkeletonObject(&gNewObjectDefinition);
if (newObj == nil)
DoFatalAlert("MakeEnemySkeleton: MakeNewSkeletonObject failed!");


/* SET DEFAULT COLLISION INFO */

newObj->CType = CTYPE_ENEMY | CTYPE_HURTIFTOUCH;
newObj->CBits = CBITS_ALLSOLID;

// SIDE_BITS_LEFT | SIDE_BITS_RIGHT | SIDE_BITS_FRONT | // not solid on bottom or top
// SIDE_BITS_BACK;
return(newObj);
Expand All @@ -275,7 +307,7 @@ float y;


/* SEE IF ON GROUND */

y = GetTerrainHeightAtCoord_Planar(gCoord.x, gCoord.z); // get center Y
if ((gCoord.y + flightHeight) < y)
{
Expand All @@ -287,17 +319,3 @@ float y;
theNode->StatusBits &= ~STATUS_BIT_ONGROUND;
return(false);
}














Loading