void T_BatPast (objtype *ob) { id0_long_t move; //id0_long_t deltax,deltay,size; move = ob->speed*tics; do { if (move < ob->distance) { MoveObj (ob,move); break; } actorat[ob->tilex][ob->tiley] = 0; // pick up marker from goal ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2; ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2; move -= ob->distance; BatRunThink (ob); actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); // set down a new goal marker //actorat[ob->tilex][ob->tiley] = ob; // set down a new goal marker } while (0); //(move) CalcBounds (ob); }
void T_Bat (objtype *ob) { id0_long_t move; id0_long_t deltax,deltay,size; move = ob->speed*tics; size = (id0_long_t)ob->size + player->size + move; do { deltax = ob->x - player->x; deltay = ob->y - player->y; if (deltax <= size && deltax >= -size && deltay <= size && deltay >= -size && !ob->temp1) { TakeDamage (4); ob->temp1 = 2; } if (move < ob->distance) { MoveObj (ob,move); break; } actorat[ob->tilex][ob->tiley] = 0; // pick up marker from goal if (ob->dir == nodir) ob->dir = north; ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2; ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2; move -= ob->distance; if (ob->temp1) { Walk (ob); // go straight if (!--ob->temp1) { ob->state = &s_batpast; ob->ticcount = ob->state->tictime; } } else BatChaseThink (ob); // head towards player actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); // set down a new goal marker //actorat[ob->tilex][ob->tiley] = ob; // set down a new goal marker } while (0); // just once CalcBounds (ob); }
void SpawnNewObj (id0_unsigned_t x, id0_unsigned_t y, statetype *state, id0_unsigned_t size) { GetNewObj (false); newobj->size = size; newobj->state = state; newobj->ticcount = BE_Cross_Brandom (state->tictime)+1; newobj->tilex = x; newobj->tiley = y; newobj->x = ((id0_long_t)x<<TILESHIFT)+TILEGLOBAL/2; newobj->y = ((id0_long_t)y<<TILESHIFT)+TILEGLOBAL/2; CalcBounds(newobj); newobj->dir = nodir; actorat[newobj->tilex][newobj->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(newobj); //actorat[newobj->tilex][newobj->tiley] = newobj; }
id0_boolean_t Chase (objtype *ob, id0_boolean_t diagonal) { id0_long_t move; id0_long_t deltax,deltay,size; ob->flags &= ~of_damagedone; move = ob->speed*tics; size = (id0_long_t)ob->size + player->size + move + SIZE_TEST; while (move) { deltax = ob->x - player->x; deltay = ob->y - player->y; if (deltax <= size && deltax >= -size && deltay <= size && deltay >= -size) { CalcBounds (ob); return true; } if (move < ob->distance) { MoveObj (ob,move); break; } actorat[ob->tilex][ob->tiley] = 0; // pick up marker from goal if (ob->dir == nodir) ob->dir = north; ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2; ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2; move -= ob->distance; ChaseThink (ob,diagonal); if (!ob->distance) break; // no possible move actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); // set down a new goal marker //actorat[ob->tilex][ob->tiley] = ob; // set down a new goal marker } CalcBounds (ob); return false; }
/* =================== = = Internal_SpawnNewObj = =================== */ void Internal_SpawnNewObj (id0_unsigned_t x, id0_unsigned_t y, statetype *state, id0_unsigned_t size,id0_boolean_t UseDummy) { extern objtype dummyobj; GetNewObj(UseDummy); newobj->size = size; newobj->state = state; newobj->ticcount = BE_Cross_Brandom (state->tictime)+1; newobj->tilex = x; newobj->tiley = y; newobj->x = ((id0_long_t)x<<TILESHIFT)+TILEGLOBAL/2; newobj->y = ((id0_long_t)y<<TILESHIFT)+TILEGLOBAL/2; CalcBounds(newobj); newobj->dir = nodir; newobj->active = noalways; if (newobj != &dummyobj) actorat[newobj->tilex][newobj->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(newobj); //actorat[newobj->tilex][newobj->tiley] = newobj; }
id0_boolean_t LoadTheGame(BE_FILE_T file) { id0_unsigned_t i,x,y; objtype /**obj,*/*prev,*next,*followed; id0_unsigned_t compressed,expanded; id0_unsigned_t id0_far *map,tile; memptr bigbuffer; // (REFKEEN) Reading fields one-by-one in a cross-platform manner if (!LoadGameState(file, &gamestate)) //if (!CA_FarRead(file,(void id0_far *)&gamestate,sizeof(gamestate))) return(false); SetupGameLevel (); // load in and cache the base old level expanded = mapwidth * mapheight * 2; MM_GetPtr (&bigbuffer,expanded); for (i = 0;i < 3;i+=2) // Read planes 0 and 2 { if (BE_Cross_readInt16LE(file, &compressed) != 2) //if (!CA_FarRead(file,(id0_byte_t id0_far *)&compressed,sizeof(compressed)) ) { MM_FreePtr (&bigbuffer); return(false); } if (BE_Cross_readInt16LEBuffer(file, bigbuffer, compressed) != compressed) //if (!CA_FarRead(file,(id0_byte_t id0_far *)bigbuffer,compressed) ) { MM_FreePtr (&bigbuffer); return(false); } CA_RLEWexpand ((id0_unsigned_t id0_huge *)bigbuffer, (id0_unsigned_t id0_huge *)mapsegs[i],expanded,RLETAG); } MM_FreePtr (&bigbuffer); // // copy the wall data to a data segment array again, to handle doors and // bomb walls that are allready opened // memset (tilemap,0,sizeof(tilemap)); memset (actorat,0,sizeof(actorat)); map = mapsegs[0]; for (y=0;y<mapheight;y++) for (x=0;x<mapwidth;x++) { tile = *map++; if (tile<NUMFLOORS) { tilemap[x][y] = tile; if (tile>0) actorat[x][y] = tile; //(id0_unsigned_t)actorat[x][y] = tile; } } // Read the object list back in - assumes at least one object in list InitObjList (); newobj = player; while (true) { prev = newobj->prev; next = newobj->next; // (REFKEEN) Reading fields one-by-one in a cross-platform manner if (!LoadObject(file, newobj)) //if (!CA_FarRead(file,(void id0_far *)newobj,sizeof(objtype))) return(false); followed = newobj->next; newobj->prev = prev; newobj->next = next; actorat[newobj->tilex][newobj->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(newobj); // drop a new marker //actorat[newobj->tilex][newobj->tiley] = newobj; // drop a new marker if (followed) GetNewObj (false); else break; } return(true); }
void T_Bounce (objtype *ob) { id0_long_t move; id0_long_t deltax,deltay,size; move = SPDBOUNCE*tics; size = (id0_long_t)ob->size + player->size + move; while (move) { deltax = ob->x - player->x; deltay = ob->y - player->y; if (deltax <= size && deltax >= -size && deltay <= size && deltay >= -size && !ob->temp2) { ob->temp2 = 1; TakeDamage (DMGBOUNCE); } if (move < ob->distance) { MoveObj (ob,move); break; } actorat[ob->tilex][ob->tiley] = 0; // pick up marker from goal ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2; ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2; move -= ob->distance; // // bounce if hit wall // switch (ob->dir) { case north: if (tilemap[ob->tilex][--ob->tiley]) { ob->dir = south; ob->tiley+=2; ob->temp2 = 0; } break; case east: if (tilemap[++ob->tilex][ob->tiley]) { ob->dir = west; ob->tilex-=2; ob->temp2 = 0; } break; case south: if (tilemap[ob->tilex][++ob->tiley]) { ob->dir = north; ob->tiley-=2; ob->temp2 = 0; } break; case west: if (tilemap[--ob->tilex][ob->tiley]) { ob->dir = east; ob->tilex+=2; ob->temp2 = 0; } break; } ob->distance = TILEGLOBAL; actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); // set down a new goal marker //actorat[ob->tilex][ob->tiley] = ob; // set down a new goal marker } CalcBounds (ob); }
id0_boolean_t LoadTheGame(BE_FILE_T file) { id0_unsigned_t i,x,y; objtype /**obj,*/*prev,*next,*followed; id0_unsigned_t compressed,expanded; id0_unsigned_t id0_far *map,tile; memptr bigbuffer; screenpage = 0; FreeUpMemory(); playstate = ex_loadedgame; // load the sky and ground colors // REFKEEN - But not before converting from original 16-bit pointers (reusing i variable) if (BE_Cross_readInt16LE(file, &i) != 2) //if (!CA_FarRead(file,(void id0_far *)&skycolor,sizeof(skycolor))) return(false); skycolor = GetSkyGndColorPtrFromDOSPointer(i); if (BE_Cross_readInt16LE(file, &i) != 2) //if (!CA_FarRead(file,(void id0_far *)&groundcolor,sizeof(groundcolor))) return(false); groundcolor = GetSkyGndColorPtrFromDOSPointer(i); if (BE_Cross_readInt16LE(file, &FreezeTime) != 2) //if (!CA_FarRead(file,(void id0_far *)&FreezeTime,sizeof(FreezeTime))) return(false); // (REFKEEN) Reading fields one-by-one in a cross-platform manner if (!LoadGameState(file, &gamestate)) //if (!CA_FarRead(file,(void id0_far *)&gamestate,sizeof(gamestate))) return(false); if (BE_Cross_read_boolean_From16LE(file, &EASYMODEON) != 2) //if (!CA_FarRead(file,(void id0_far *)&EASYMODEON,sizeof(EASYMODEON))) return(false); SetupGameLevel (); // load in and cache the base old level // (REFKEEN) DIFFERENCE FROM VANILLA CATACOMB ADVENTURES: // Don't do this check, we've already opened the file anyway // and this can lead to unexpected behaviors! #if 0 if (!FindRewritableFile(Filename,"SAVE GAME",-1)) Quit("Error: Can't find saved game file!"); #endif expanded = mapwidth * mapheight * 2; MM_GetPtr (&bigbuffer,expanded); for (i = 0;i < 3;i+=2) // Read planes 0 and 2 { if (BE_Cross_readInt16LE(file, &compressed) != 2) //if (!CA_FarRead(file,(id0_byte_t id0_far *)&compressed,sizeof(compressed)) ) { MM_FreePtr (&bigbuffer); return(false); } if (BE_Cross_readInt16LEBuffer(file, bigbuffer, compressed) != compressed) //if (!CA_FarRead(file,(id0_byte_t id0_far *)bigbuffer,compressed) ) { MM_FreePtr (&bigbuffer); return(false); } CA_RLEWexpand ((id0_unsigned_t id0_huge *)bigbuffer, (id0_unsigned_t id0_huge *)mapsegs[i],expanded,RLETAG); } MM_FreePtr (&bigbuffer); // // copy the wall data to a data segment array again, to handle doors and // bomb walls that are allready opened // memset (tilemap,0,sizeof(tilemap)); memset (actorat,0,sizeof(actorat)); map = mapsegs[0]; for (y=0;y<mapheight;y++) for (x=0;x<mapwidth;x++) { tile = *map++; if (tile<NUMFLOORS) { if (tile != INVISIBLEWALL) tilemap[x][y] = tile; if (tile>0) actorat[x][y] = tile; //(id0_unsigned_t)actorat[x][y] = tile; } } // Read the object list back in - assumes at least one object in list InitObjList (); newobj = player; while (true) { prev = newobj->prev; next = newobj->next; // (REFKEEN) Reading fields one-by-one in a cross-platform manner if (!LoadObject(file, newobj)) //if (!CA_FarRead(file,(void id0_far *)newobj,sizeof(objtype))) return(false); followed = newobj->next; newobj->prev = prev; newobj->next = next; actorat[newobj->tilex][newobj->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(newobj); // drop a new marker //actorat[newobj->tilex][newobj->tiley] = newobj; // drop a new marker if (followed) GetNewObj (false); else break; } return(true); }
/* ==================== = = T_RunningEye = ==================== */ void T_RunningEye(objtype *ob) { id0_int_t /*x, y, */dir_num, switch_num; fixed tempx,tempy; id0_unsigned_t temp_tilex,temp_tiley; dir_num = *(mapsegs[2]+farmapylookup[ob->tiley]+ob->tilex); dir_num = dir_num>>8; if (!dir_num) dir_num = ob->temp2; if (dir_num == 5) { if (ob->temp1) { ob->temp1--; } else { ob->temp1 = 2; actorat[ob->tilex][ob->tiley] = 0; switch (ob->temp2) { case 1: ob->tiley = ob->tiley-1; ob->y = ((id0_long_t)(ob->tiley)<<TILESHIFT)+TILEGLOBAL/2; break; case 2: ob->tilex = ob->tilex+1; ob->x = ((id0_long_t)(ob->tilex)<<TILESHIFT)+TILEGLOBAL/2; break; case 3: ob->tiley = ob->tiley+1; ob->y = ((id0_long_t)(ob->tiley)<<TILESHIFT)+TILEGLOBAL/2; break; case 0: case 4: ob->tilex = ob->tilex-1; ob->x = ((id0_long_t)(ob->tilex)<<TILESHIFT)+TILEGLOBAL/2; break; } CalcBounds (ob); ChaseThink(ob,false); actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); //actorat[ob->tilex][ob->tiley] = ob; return; } } tempx = player->x; tempy = player->y; temp_tilex = player->tilex; temp_tiley = player->tiley; if (dir_num == 5) switch_num = ob->temp2; else switch_num = dir_num; switch (switch_num) { case 1: player->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)(ob->tiley-2)<<TILESHIFT)+TILEGLOBAL/2; player->tilex = ob->tilex; player->tiley = ob->tiley-2; break; case 2: player->x = ((id0_long_t)(ob->tilex+2)<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2; player->tilex = ob->tilex+2; player->tiley = ob->tiley; break; case 3: player->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)(ob->tiley+2)<<TILESHIFT)+TILEGLOBAL/2; player->tilex = ob->tilex; player->tiley = ob->tiley+2; break; case 0: case 4: player->x = ((id0_long_t)(ob->tilex-2)<<TILESHIFT)+TILEGLOBAL/2; player->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2; player->tilex = ob->tilex-2; player->tiley = ob->tiley; break; } Chase(ob, false); player->x = tempx; player->y = tempy; player->tilex = temp_tilex; player->tiley = temp_tiley; if (dir_num != 5) ob->temp2 = dir_num; }