void BATTLE_Init ( int battlemode, int numplayers ) { int index; int index2; int team; int TeamNumber[ MAXPLAYERCOLORS ]; #if (BATTLECHECK == 1) if ( ( gamestate.teamplay ) && ( BattleMode == battle_Tag ) ) { Error( "BATTLE_Init : Cannot play Tag in team mode.\n" ); } if ( ( gamestate.teamplay ) && ( BattleMode == battle_CaptureTheTriad ) ) { Error( "BATTLE_Init : Can only play Capture the Triad in team mode.\n" ); } #endif Timer = 0; RoundOver = false; BattleRound = -1; BATTLE_It = 0; BattleMode = battlemode; BATTLEMODE = false; UpdateKills = true; gamestate.BattleOptions.Gravity = NORMAL_GRAVITY; gamestate.BattleOptions.Speed = bo_normal_speed; gamestate.BattleOptions.Ammo = bo_normal_shots; gamestate.BattleOptions.HitPoints = bo_character_hitpoints; gamestate.BattleOptions.LightLevel = bo_light_normal; gamestate.BattleOptions.Kills = bo_kills_default; gamestate.BattleOptions.DangerDamage = bo_danger_normal; gamestate.BattleOptions.TimeLimit = bo_time_infinite; gamestate.BattleOptions.RespawnTime = bo_normal_respawn_time; gamestate.BattleOptions.RandomWeapons = false; gamestate.BattleOptions.FriendlyFire = true; gamestate.BattleOptions.WeaponPersistence = false; gamestate.BattleOptions.SpawnMines = false; if ( BattleMode != battle_StandAloneGame ) { BATTLEMODE = true; if ( gamestate.Product == ROTT_SHAREWARE ) { switch( battlemode ) { case battle_Normal : case battle_Collector : case battle_Hunter : break; default : Error( "Shareware version can only play Normal, Collector, " "or Hunter in Comm-bat game." ); } } gamestate.BattleOptions.Gravity = BattleOptions.Gravity; gamestate.BattleOptions.Speed = BattleOptions.Speed; gamestate.BattleOptions.Ammo = BattleOptions.Ammo; gamestate.BattleOptions.HitPoints = BattleOptions.HitPoints; gamestate.BattleOptions.LightLevel = BattleOptions.LightLevel; gamestate.BattleOptions.Kills = BattleOptions.Kills; gamestate.BattleOptions.DangerDamage = BattleOptions.DangerDamage; gamestate.BattleOptions.TimeLimit = BattleOptions.TimeLimit; gamestate.BattleOptions.RespawnTime = BattleOptions.RespawnTime; gamestate.BattleOptions.RandomWeapons = BattleOptions.RandomWeapons; gamestate.BattleOptions.FriendlyFire = BattleOptions.FriendlyFire; gamestate.BattleOptions.SpawnMines = BattleOptions.SpawnMines; gamestate.BattleOptions.WeaponPersistence = BattleOptions.WeaponPersistence; } gamestate.ShowScores = true; gamestate.BattleOptions.SpawnHealth = true; gamestate.BattleOptions.SpawnWeapons = true; gamestate.BattleOptions.SpawnDangers = true; gamestate.SpawnCollectItems = false; gamestate.SpawnEluder = false; gamestate.SpawnDeluder = false; gamestate.BattleOptions.RespawnItems = false; NumberOfPlayers = numplayers; BATTLE_NumberOfTeams = numplayers; for( index = 0; index < MAXPLAYERS; index++ ) { BATTLE_PlayerOrder[ index ] = index; BATTLE_Points[ index ] = 0; for( index2 = 0; index2 < MAXPLAYERS; index2++ ) { WhoKilledWho[ index ][ index2 ] = 0; } BATTLE_Team[ index ] = index; BATTLE_TeamLeader[ index ] = index; } if ( gamestate.teamplay ) { for( index = 0; index < MAXPLAYERCOLORS; index++ ) { TeamNumber[ index ] = -1; } BATTLE_NumberOfTeams = 0; for( index = 0; index < numplayers; index++ ) { team = PLAYERSTATE[ index ].uniformcolor; if ( TeamNumber[ team ] == -1 ) { TeamNumber[ team ] = BATTLE_NumberOfTeams; BATTLE_TeamLeader[ BATTLE_NumberOfTeams ] = index; BATTLE_NumberOfTeams++; } BATTLE_Team[ index ] = TeamNumber[ team ]; } } PointGoal = gamestate.BattleOptions.Kills; if ( ( gamestate.BattleOptions.Kills == bo_kills_random ) || ( gamestate.BattleOptions.Kills == bo_kills_blind ) ) { // Possibility of playing from 5 to 50 kills PointGoal = ( GameRandomNumber( "BATTLE_Init", 0 ) % 46 ) + 5; } DisplayPoints = PointGoal; for( index = 0; index < MAXPLAYERS; index++ ) { gamestate.PlayerHasGun[ index ] = true; } KillsEndGame = true; KeepTrackOfKills = true; switch( BattleMode ) { case battle_StandAloneGame : KillsEndGame = false; KeepTrackOfKills = false; break; case battle_Normal : break; case battle_ScoreMore : break; case battle_Collector : for( index = 0; index < MAXPLAYERS; index++ ) { gamestate.PlayerHasGun[ index ] = false; } KillsEndGame = false; KeepTrackOfKills = false; gamestate.BattleOptions.SpawnHealth = false; gamestate.BattleOptions.SpawnWeapons = false; gamestate.SpawnCollectItems = true; break; case battle_Scavenger : KillsEndGame = false; KeepTrackOfKills = false; gamestate.BattleOptions.SpawnWeapons = true; gamestate.BattleOptions.SpawnHealth = true; gamestate.SpawnCollectItems = true; break; case battle_Hunter : PointGoal *= BATTLE_NumberOfTeams; KillsEndGame = false; KeepTrackOfKills = true; BATTLE_It = 0; for( index = 0; index < NumberOfPlayers; index++ ) { if ( BATTLE_Team[ index ] == 0 ) { gamestate.PlayerHasGun[ index ] = false; } } break; case battle_Tag : for( index = 0; index < MAXPLAYERS; index++ ) { gamestate.PlayerHasGun[ index ] = false; } gamestate.BattleOptions.SpawnHealth = false; gamestate.BattleOptions.SpawnWeapons = false; gamestate.BattleOptions.SpawnDangers = true; KeepTrackOfKills = true; KillsEndGame = true; break; case battle_Eluder : KeepTrackOfKills = false; KillsEndGame = false; for( index = 0; index < MAXPLAYERS; index++ ) { gamestate.PlayerHasGun[ index ] = false; } gamestate.BattleOptions.SpawnWeapons = false; gamestate.SpawnEluder = true; break; case battle_Deluder : KeepTrackOfKills = false; KillsEndGame = false; gamestate.SpawnDeluder = true; break; case battle_CaptureTheTriad : KillsEndGame = false; KeepTrackOfKills = false; break; } if ( BattleMode != battle_StandAloneGame ) { if ( BattleOptions.RespawnItems ) { gamestate.BattleOptions.RespawnItems = true; } if ( !BattleOptions.SpawnDangers ) { gamestate.BattleOptions.SpawnDangers = false; } if ( !BattleOptions.SpawnHealth ) { gamestate.BattleOptions.SpawnHealth = false; } if ( !BattleOptions.SpawnWeapons ) { gamestate.BattleOptions.SpawnWeapons = false; } if ( gamestate.BattleOptions.Kills == bo_kills_blind ) { gamestate.ShowScores = false; } GRAVITY = gamestate.BattleOptions.Gravity; if ( gamestate.BattleOptions.Kills == bo_kills_infinite ) { KillsEndGame = false; } } BATTLE_StartRound(); #if (BATTLEINFO == 1) SoftError( "GRAVITY = %d\n", GRAVITY ); SoftError( "BO_Gravity = %d\n", BattleOptions.Gravity ); SoftError( "BO_Speed = %d\n", BattleOptions.Speed ); SoftError( "BO_Ammo = %d\n", BattleOptions.Ammo ); SoftError( "BO_HitPoints = %d\n", BattleOptions.HitPoints ); SoftError( "BO_Dangers = %d\n", BattleOptions.SpawnDangers ); SoftError( "BO_Health = %d\n", BattleOptions.SpawnHealth ); SoftError( "BO_Weapons = %d\n", BattleOptions.SpawnWeapons ); SoftError( "BO_Respawn = %d\n", BattleOptions.RespawnItems ); SoftError( "BO_Light = %d\n", BattleOptions.LightLevel ); SoftError( "BO_Kills = %d\n", BattleOptions.Kills ); SoftError( "BO_DangerDam = %d\n", BattleOptions.DangerDamage ); SoftError( "BO_TimeLimit = %d\n", BattleOptions.TimeLimit ); #endif }
void SpawnStatic (int tilex, int tiley, int mtype, int zoffset) {statobj_t * temp; boolean onetimer; #if (SHAREWARE == 1) switch(mtype) { case stat_rlight: case stat_glight: case stat_ylight: case stat_chandelier: mtype = stat_blight; break; case stat_garb1: case stat_garb2: case stat_garb3: case stat_shit: mtype = stat_metalshards; break; case stat_lamp: mtype = stat_altbrazier2; break; } #endif if ( BATTLEMODE ) { if ( !gamestate.BattleOptions.SpawnWeapons ) { if ( stats[ mtype ].flags & FL_WEAPON ) { return; } } if (mtype == stat_pit) return; // Change lifeitems and extra lives to health switch( mtype ) { case stat_lifeitem1 : case stat_lifeitem2 : mtype = stat_monkcrystal1; break; case stat_lifeitem3 : case stat_lifeitem4 : case stat_oneup : case stat_threeup : mtype = stat_monkcrystal2; break; } switch( mtype ) { case stat_monkmeal : case stat_priestporridge : case stat_monkcrystal1 : case stat_monkcrystal2 : case stat_healingbasin : if ( ( gamestate.Product != ROTT_SHAREWARE ) && ( gamestate.BattleOptions.SpawnMines ) && ( !IsPlatform( tilex, tiley ) && ( ( zoffset & 0xff00 ) != 0xb000 ) ) && ( zoffset == -1 ) ) { mtype = stat_mine; } else if ( !gamestate.BattleOptions.SpawnHealth ) { return; } break; } } if (!firstemptystat) {temp = (statobj_t*)Z_LevelMalloc(sizeof(statobj_t),PU_LEVELSTRUCT,NULL); //SoftError("\nMalloc-ing actor"); //if (insetupgame) // SoftError("in setup"); } else {temp = lastemptystat; //SoftError("\nfree actor available"); RemoveFromFreeStaticList(lastemptystat); } // Standard pole hack if ((zoffset>=14) && (zoffset<=17)) zoffset=-1; if (temp) { memset(temp,0,sizeof(*temp)); temp->shapenum = stats[mtype].picnum; temp->whichstat = statcount ++; temp->tilex = tilex; temp->tiley = tiley; temp->x = ((long)tilex << TILESHIFT) + 0x8000; temp->y = ((long)tiley << TILESHIFT) + 0x8000; temp->areanumber = MAPSPOT(tilex,tiley,0)-AREATILE; temp->linked_to = -1; if ((temp->areanumber<=0) || (temp->areanumber>NUMAREAS)) Error ("Sprite at x=%d y=%d type=%d has an illegal areanumber\n",tilex,tiley,mtype); if ( mtype == stat_mine ) { temp->z = nominalheight; } else if (zoffset!=-1) { if ((zoffset&0xff00)==0xb000) Set_NewZ_to_MapValue(&(temp->z),zoffset,"static",tilex,tiley); else if (IsPlatform(tilex,tiley)) temp->z = PlatformHeight(tilex,tiley); else if (zoffset==11) temp->z=-65; else if (zoffset==12) temp->z=-66; else temp->z = nominalheight; // Error ("You didn't specify a valid height over the sprite at tilex=%ld tiley=%ld\n",tilex,tiley); } else if (mtype>stat_chandelier) temp->z = nominalheight; temp->visspot = &spotvis[tilex][tiley]; temp->which = SPRITE; temp->ticcount = stats[mtype].tictime; temp->hitpoints = stats[mtype].hitpoints; temp->itemnumber = stats[mtype].type; temp->flags = stats[mtype].flags; temp->ammo = stats[mtype].ammo; temp->numanims = stats[mtype].numanims; if (temp->flags & FL_BONUS) switch (stats[mtype].type) {case stat_lifeitem1: case stat_lifeitem2: case stat_lifeitem3: case stat_lifeitem4: gamestate.treasuretotal++; break; default: ; } AddStatic(temp); onetimer = ((mtype == stat_rubble) || (mtype == stat_woodfrag) || (mtype == stat_metalfrag) || (mtype == stat_missmoke) ); if (DoPanicMapping()) { if (temp->numanims && (!onetimer)) { temp->flags &= ~FL_ACTIVE; temp->numanims = 0; GameRandomNumber("SpawnStatic",mtype); } } else { if (temp->numanims) { if (!onetimer) temp->count = (int)(((int)GameRandomNumber("SpawnStatic",mtype) % stats[mtype].numanims) + 1); else temp->count = 0; } else if (temp->itemnumber == stat_standardpole) { if (MAPSPOT(temp->tilex,temp->tiley,2)) temp->count = 2*(MAPSPOT(temp->tilex,temp->tiley,2)-14); else temp->count = 0; } if ((temp->itemnumber == stat_knifestatue) || (temp->itemnumber == stat_emptystatue) || (temp->itemnumber == stat_standardpole)) temp->flags|=FL_ROTATING; } if (mtype != stat_missmoke) sprites[tilex][tiley] = temp; else temp->flags |= FL_NONMARK; //================ check special junk ==================================// if (temp->itemnumber == stat_dariantouch) {_2Dpoint *tdptr; tdptr = &(MISCVARS->ETOUCH[MISCVARS->nexttouch]); tdptr->x = tilex; tdptr->y = tiley; sprites[tilex][tiley]->linked_to = MISCVARS->nexttouch; MISCVARS->nexttouch ++; } else if ((temp->itemnumber >= stat_touch1) && (temp->itemnumber <= stat_touch4)) {touchindices[tilex][tiley] = lasttouch + 1; SD_PreCacheSoundGroup(SD_TOUCHPLATESND,SD_BADTOUCHSND); lasttouch ++; } //=====================================================================// //bna added // BaseMarkerZ used to adjust height in s_basemarker1 // in SpawnNewObj(i,j,&s_basemarker1,inertobj); BaseMarkerZ=temp->z;//bna++ BaseMarkerZ = spawnz; PreCacheStaticFrames(temp); PreCacheStaticSounds(temp->itemnumber); if (temp->flags & FL_WEAPON) MISCVARS->NUMWEAPONS ++; } else Error("Z_LevelMalloc failed in SpawnStatic!"); }