diff --git a/src/deh_soc.c b/src/deh_soc.c index 2fc09f0ad..35b6fc9dc 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1455,6 +1455,28 @@ void readteam(MYFILE *f, INT32 num) deh_warning("readteam %d: Thing %d out of range (1 - %d)", num, i, NUMMOBJTYPES-1); } } + else if (fastcmp(word, "WEAPON")) + { + if (i == 0 && word2[0] != '0') // If word2 isn't a number + i = get_mobjtype(word2); // find a thing by name + if (i < NUMMOBJTYPES && i > 0) + team->weapon_mobj_type = i; + else + { + deh_warning("readteam %d: Thing %d out of range (1 - %d)", num, i, NUMMOBJTYPES-1); + } + } + else if (fastcmp(word, "MISSILE")) + { + if (i == 0 && word2[0] != '0') // If word2 isn't a number + i = get_mobjtype(word2); // find a thing by name + if (i < NUMMOBJTYPES && i > 0) + team->missile_mobj_type = i; + else + { + deh_warning("readteam %d: Thing %d out of range (1 - %d)", num, i, NUMMOBJTYPES-1); + } + } else if (fastcmp(word, "COLOR")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number diff --git a/src/doomstat.h b/src/doomstat.h index 5f4d0bead..5d91ebfdd 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -406,12 +406,14 @@ enum { typedef struct { char *name; + UINT16 color; + UINT32 weapon_mobj_type; + UINT32 missile_mobj_type; + UINT16 weapon_color; + UINT16 missile_color; char *flag_name; UINT16 flag; UINT32 flag_mobj_type; - UINT16 color; - UINT16 weapon_color; - UINT16 missile_color; char *icons[TEAM_ICON_MAX]; } team_t; diff --git a/src/g_game.c b/src/g_game.c index 93c462387..fe5d0adf1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3518,6 +3518,7 @@ team_t teams[MAXTEAMS] = { .color = SKINCOLOR_RED, .weapon_color = SKINCOLOR_RED, .missile_color = SKINCOLOR_SALMON, + .weapon_mobj_type = MT_BLUETEAMRING, .flag = GF_REDFLAG, .flag_mobj_type = MT_REDFLAG, }, @@ -3526,6 +3527,7 @@ team_t teams[MAXTEAMS] = { .color = SKINCOLOR_BLUE, .weapon_color = SKINCOLOR_BLUE, .missile_color = SKINCOLOR_CORNFLOWER, + .weapon_mobj_type = MT_REDTEAMRING, .flag = GF_BLUEFLAG, .flag_mobj_type = MT_BLUEFLAG, } @@ -3942,6 +3944,8 @@ void G_InitTeam(UINT8 team) memset(&teams[team], 0, sizeof(team_t)); + teams[team].weapon_mobj_type = MT_RING; + teams[team].missile_mobj_type = MT_REDRING; teams[team].flag = 1 << (team - 1); } @@ -4019,6 +4023,22 @@ const char *G_GetTeamFlagName(UINT8 team) return teams[team].flag_name; } +UINT32 G_GetTeamWeaponMobjtype(UINT8 team) +{ + if (team >= numteams || !teams[team].weapon_mobj_type) + return MT_RING; + + return teams[team].weapon_mobj_type; +} + +UINT32 G_GetTeamMissileMobjtype(UINT8 team) +{ + if (team >= numteams || !teams[team].missile_mobj_type) + return MT_REDRING; + + return teams[team].missile_mobj_type; +} + UINT16 G_GetTeamColor(UINT8 team) { if (team >= numteams) diff --git a/src/g_game.h b/src/g_game.h index 8fd7d60d8..6119645c1 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -230,6 +230,8 @@ UINT8 G_GetTeamFromTeamFlag(UINT32 flag); UINT8 G_GetTeamListFromTeamFlags(UINT8 *teamlist, UINT32 flags); const char *G_GetTeamName(UINT8 team); const char *G_GetTeamFlagName(UINT8 team); +UINT32 G_GetTeamWeaponMobjtype(UINT8 team); +UINT32 G_GetTeamMissileMobjtype(UINT8 team); UINT16 G_GetTeamColor(UINT8 team); UINT16 G_GetTeamWeaponColor(UINT8 team); UINT16 G_GetTeamMissileColor(UINT8 team); diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 0ea2440d1..d8b6c6d86 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -2101,6 +2101,8 @@ enum team_e team_flag_name, team_flag, team_flag_mobj_type, + team_weapon_mobj_type, + team_missile_mobj_type, team_color, team_weapon_color, team_missile_color, @@ -2115,6 +2117,8 @@ const char *const team_opt[] = { "flag_name", "flag", "flag_mobj_type", + "weapon_mobj_type", + "missile_mobj_type", "color", "weapon_color", "missile_color", @@ -2166,6 +2170,28 @@ static int set_team_field(lua_State *L, team_t *team, enum team_e field) team->flag_mobj_type = type; break; } + case team_weapon_mobj_type: + { + mobjtype_t type = luaL_checkinteger(L, 3); + if (type >= NUMMOBJTYPES) + { + luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); + return 0; + } + team->weapon_mobj_type = type; + break; + } + case team_missile_mobj_type: + { + mobjtype_t type = luaL_checkinteger(L, 3); + if (type >= NUMMOBJTYPES) + { + luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); + return 0; + } + team->missile_mobj_type = type; + break; + } case team_color: { UINT16 newcolor = (UINT16)luaL_checkinteger(L, 3); @@ -2295,6 +2321,12 @@ static int team_get(lua_State *L) case team_flag_mobj_type: lua_pushinteger(L, team->flag_mobj_type); break; + case team_weapon_mobj_type: + lua_pushinteger(L, team->weapon_mobj_type); + break; + case team_missile_mobj_type: + lua_pushinteger(L, team->missile_mobj_type); + break; case team_color: lua_pushinteger(L, team->color); break; diff --git a/src/p_enemy.c b/src/p_enemy.c index 8a0c0baed..a9669371a 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -824,8 +824,8 @@ static boolean P_LookForShield(mobj_t *actor) continue; // dead //When in CTF, don't pull rings that you cannot pick up. - if ((actor->type == MT_REDTEAMRING && player->ctfteam != TEAM_RED) || - (actor->type == MT_BLUETEAMRING && player->ctfteam != TEAM_BLUE)) + if ((actor->type == MT_REDTEAMRING && player->ctfteam != G_GetTeam(TEAM_RED)) || + (actor->type == MT_BLUETEAMRING && player->ctfteam != G_GetTeam(TEAM_BLUE))) continue; if ((player->powers[pw_shield] & SH_PROTECTELECTRIC) diff --git a/src/p_inter.c b/src/p_inter.c index 1fd66eaa2..d2087c5b2 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -333,6 +333,18 @@ void P_DoMatchSuper(player_t *player) } } +static void P_CollectRing(player_t *player, mobj_t *special) +{ + if (!(P_CanPickupItem(player, false)) && !(special->flags2 & MF2_NIGHTSPULL)) + return; + + special->momx = special->momy = special->momz = 0; + P_GivePlayerRings(player, 1); + + if ((maptol & TOL_NIGHTS) && special->type != MT_FLINGRING && special->type != MT_FLINGCOIN) + P_DoNightsScore(player); +} + /** Takes action based on a ::MF_SPECIAL thing touched by a player. * Actually, this just checks a few things (heights, toucher->player, no * objectplace, no dead or disappearing things) @@ -614,26 +626,21 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Rings, coins, spheres, weapon panels, etc // // ***************************************** // case MT_REDTEAMRING: - if (player->ctfteam != TEAM_RED) + if (player->ctfteam != G_GetTeam(TEAM_RED)) return; - /* FALLTHRU */ - case MT_BLUETEAMRING: // Yes, I'm lazy. Oh well, deal with it. - if (special->type == MT_BLUETEAMRING && player->ctfteam != TEAM_BLUE) + P_CollectRing(player, special); + break; + case MT_BLUETEAMRING: + if (player->ctfteam != G_GetTeam(TEAM_BLUE)) return; - /* FALLTHRU */ + P_CollectRing(player, special); + break; case MT_RING: case MT_FLINGRING: case MT_COIN: case MT_FLINGCOIN: case MT_NIGHTSSTAR: - if (!(P_CanPickupItem(player, false)) && !(special->flags2 & MF2_NIGHTSPULL)) - return; - - special->momx = special->momy = special->momz = 0; - P_GivePlayerRings(player, 1); - - if ((maptol & TOL_NIGHTS) && special->type != MT_FLINGRING && special->type != MT_FLINGCOIN) - P_DoNightsScore(player); + P_CollectRing(player, special); break; case MT_BLUESPHERE: case MT_FLINGBLUESPHERE: diff --git a/src/p_mobj.c b/src/p_mobj.c index e6d7d6276..346139535 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10889,10 +10889,10 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->lastlook = mobj->extravalue2 = -1; break; case MT_REDTEAMRING: - mobj->color = G_GetTeamWeaponColor(TEAM_RED); + mobj->color = G_GetTeamWeaponColor(G_GetTeam(TEAM_RED)); break; case MT_BLUETEAMRING: - mobj->color = G_GetTeamWeaponColor(TEAM_BLUE); + mobj->color = G_GetTeamWeaponColor(G_GetTeam(TEAM_BLUE)); break; case MT_RING: case MT_COIN: @@ -12169,7 +12169,14 @@ static mobjtype_t P_GetMobjtypeSubstitute(mapthing_t *mthing, mobjtype_t i) return teams[team].flag_mobj_type; } - if (!(gametyperules & GTR_TEAMS)) + if (gametyperules & GTR_TEAMS) + { + if (i == MT_REDTEAMRING) + i = G_GetTeamWeaponMobjtype(G_GetTeam(TEAM_RED)); + else if (i == MT_BLUETEAMRING) + i = G_GetTeamWeaponMobjtype(G_GetTeam(TEAM_BLUE)); + } + else { if (i == MT_BLUETEAMRING || i == MT_REDTEAMRING) return MT_RING; diff --git a/src/p_user.c b/src/p_user.c index c0d9e2f69..df5e2adf1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4218,7 +4218,14 @@ firenormal: return; P_SetWeaponDelay(player, TICRATE/4); - mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, 0); + mobjtype_t missile_type; + + if (G_GametypeHasTeams()) + missile_type = G_GetTeamMissileMobjtype(player->ctfteam); + else + missile_type = MT_REDRING; + + mo = P_SpawnPlayerMissile(player->mo, missile_type, 0); if (mo) P_ColorTeamMissile(mo, player);