ref: 3a0cc95c9cd16a78812a13535384888b7417649f
parent: e1060fb436dd45d2a7fb231a114f9df82848a1b3
author: levesqu8 <levesqu8@msu.edu>
date: Sat Sep 30 13:12:40 EDT 2017
initial setup of new alg
--- a/rott/rt_actor.c
+++ b/rott/rt_actor.c
@@ -3594,12 +3594,53 @@
}
}
-extern objtype* enemiesToRes;
+int DetermineTimeUntilEnemyIsResurrected(classtype obclass)
+{
+ switch(obclass)
+ {
+ case lowguardobj:
+ return gamestate.TimeCount/VBLCOUNTER + 60;
+ break;
+ case highguardobj:
+ return gamestate.TimeCount/VBLCOUNTER + 90;
+ break;
+ case overpatrolobj:
+ return gamestate.TimeCount/VBLCOUNTER + 75;
+ break;
+ case strikeguardobj:
+ return gamestate.TimeCount/VBLCOUNTER + 65;
+ break;
+ case blitzguardobj:
+ return gamestate.TimeCount/VBLCOUNTER + 60;
+ break;
+ case triadenforcerobj:
+ return gamestate.TimeCount/VBLCOUNTER + 200;
+ break;
+ case deathmonkobj:
+ return gamestate.TimeCount/VBLCOUNTER + 150;
+ break;
+ case dfiremonkobj:
+ return gamestate.TimeCount/VBLCOUNTER + 175;
+ break;
+
+ }
+
+
+
+}
+
+
+
+
+extern resItem* enemiesToRes;
extern unsigned int freeSlot;
-void AddEnemyToResurrectList(objtype * ob)
+void AddEnemyToResurrectList(resItem * res)
{
- SetReverseDeathState(ob);
- enemiesToRes[freeSlot] = *ob;
+ res->timeOfResurrect = DetermineTimeUntilEnemyIsResurrected(res->actor->obclass);
+ //res->timeOfResurrect = gamestate.TimeCount/VBLCOUNTER;
+ objtype * actor = res->actor;
+ SetReverseDeathState(actor);
+ enemiesToRes[freeSlot] = *res;
freeSlot++;
}
@@ -3672,15 +3713,24 @@
void ResurrectEnemies()
{
- objtype * actor;
+ resItem * thing;
- for (actor = &enemiesToRes[0]; actor < &enemiesToRes[freeSlot]; actor++)
+ if (&enemiesToRes[0] == 0)
{
- SD_PlaySoundRTP(SD_PLAYERSPAWNSND, actor->x, actor->y);
- SpawnDuringGameWithState (actor->obclass,actor->tilex,actor->tiley,actor->dir, 1, actor->state);
+ return;
}
- CleanUpResurrectList();
+ for (thing = &enemiesToRes[0]; thing < &enemiesToRes[freeSlot]; thing++)
+ {
+ if (gamestate.TimeCount/(VBLCOUNTER) >= actor->timeOfResurrect)
+ {
+ SD_PlaySoundRTP(SD_PLAYERSPAWNSND, actor->actor->x, actor->actor->y);
+ SpawnDuringGameWithState (actor->actor->obclass,actor->actor->tilex,actor->actor->tiley,actor->actor->dir, 1, actor->actor->state);
+ actor = 0;
+ freeSlot--;
+ }
+ }
+ //CleanUpResurrectList();
}
@@ -3779,7 +3829,7 @@
void SaveResurrectList(byte ** buffer, int *size)
{
- byte*tptr;
+ byte * tptr;
*size = sizeof(enemiesToRes);
*buffer = (byte*)SafeMalloc(*size);
@@ -3828,7 +3878,11 @@
memcpy(copyOfObject, ob, sizeof(objtype));
- AddEnemyToResurrectList(copyOfObject);
+ resItem * thingToAdd = malloc(sizeof(resItem));
+
+ thingToAdd->actor = copyOfObject;
+
+ AddEnemyToResurrectList(thingToAdd);
}
if ((ob->obclass == patrolgunobj) && (ob->temp1 == -1))
@@ -5320,7 +5374,7 @@
return false; \
}
-extern boolean ricochetingRocketsEnabled = 0;
+extern boolean ricochetingRocketsEnabled;
boolean MissileTryMove(objtype*ob,int tryx,int tryy,int tryz)
{
--- a/rott/rt_actor.h
+++ b/rott/rt_actor.h
@@ -259,6 +259,13 @@
} objtype;
+typedef struct resStruct
+{
+ unsigned int timeBeforeResurrect;
+ unsigned int timeOfResurrect;
+ objtype * actor;
+} resItem;
+
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -464,7 +464,6 @@
{
ShowKillsYoffset = KILLS_HEIGHT;
}
-
if (iGLOBAL_SCREENWIDTH == 640) {
//bna fix - not to good? but no one has 286 any more
//statusbar dosent cover hole screen, because its a lump picture width max 320
@@ -1443,41 +1442,36 @@
{
ammoInItem = 0;
}
- pstate->ammo = (int) newAmmoAmount;
+ pstate->ammo = (int)newAmmoAmount;
- //if (!gamestate.BattleOptions.WeaponPersistence)
- //{
if (pstate->ammo &&
(pstate->missileweapon != -1) &&
(!(WEAPON_IS_MAGICAL(which))) &&
(!(WEAPON_IS_MAGICAL(pstate->missileweapon))))
- {
- int nx,ny;
+ {
+ int nx,ny;
- nx = ob->tilex;
- ny = ob->tiley;
+ nx = ob->tilex;
+ ny = ob->tiley;
- //If the missile weapon still has ammo in it after taking ammo from it, spawn it on the ground
- if (ammoInItem)
+ //If the missile weapon still has ammo in it after taking ammo from it, spawn it on the ground
+ if (ammoInItem)
+ {
+ if (IsPlatform(nx,ny))
+ SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),9);
+ else
{
- if (IsPlatform(nx,ny))
- SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),9);
- else
- {
- int newz = sprites[ob->tilex][ob->tiley]->z;
- SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),-1);
- LASTSTAT->z = newz;
- }
-
- //update ammo count on missile weapon on ground
- LASTSTAT->ammo = (int) ammoInItem;
- EnableOldWeapon(pstate);
+ int newz = sprites[ob->tilex][ob->tiley]->z;
+ SpawnStatic(nx,ny,GetItemForWeapon(pstate->missileweapon),-1);
+ LASTSTAT->z = newz;
}
-
+ //update ammo count on missile weapon on ground
+ LASTSTAT->ammo = (int)ammoInItem;
+ EnableOldWeapon(pstate);
}
- //}
+ }
}
//******************************************************************************
@@ -5575,7 +5569,7 @@
if(enableZomROTT)
{
enemiesToRes = calloc(sizeof(objtype), gamestate.killtotal);
- memset(enemiesToRes, 0, sizeof(enemiesToRes));
+ memset(enemiesToRes, 0, sizeof(*enemiesToRes));
size = sizeof(enemiesToRes);
memcpy(enemiesToRes, bufptr, size);
bufptr += size;
--- a/rott/rt_main.c
+++ b/rott/rt_main.c
@@ -1893,10 +1893,9 @@
UpdateLightning ();
TriggerStuff();
CheckCriticalStatics();
- if (((gamestate.TimeCount/VBLCOUNTER) % 60 == 0) && gamestate.TimeCount/VBLCOUNTER >= 60 && enableZomROTT)
- {
+ if (enableZomROTT)
ResurrectEnemies();
- }
+
for(j=0; j<numclocks; j++)
if (Clocks[j].time1 &&
--- a/rott/rt_ted.c
+++ b/rott/rt_ted.c
@@ -5674,7 +5674,7 @@
{
FreeUpResurrectList();
}
- enemiesToRes = calloc(sizeof(objtype), gamestate.killtotal);
+ enemiesToRes = calloc(sizeof(resItem), gamestate.killtotal);
memset(enemiesToRes, 0, sizeof(enemiesToRes));
freeSlot = 0;