Company of Heroes 2

Company of Heroes 2

(6 - 8) The Oder
Brummbær  [developer] 4 Aug, 2014 @ 7:56am
Used script
----------------------------------------------------------------------------------------------------------------------
-- FightingChance™ script by --=REAPER=-- (SteamId)
-- - Saves the day for smaller teams!!!
----------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------
-- Features / Notes:
----------------------------------------------------------------------------------------------------------------------
-- The script changes the popcap and resources for both teams, big maps (using the script) can now be played as 1v1.
-- You may now even be able to win in 1v(1+n) matches
-- Resource rates remain the same for all players (I haven't found a way to change that - yet...)
-- Edited the Resource Income Rates to better fit higher PopCap (Brummbær 2014)
-- Allows using an alternative popcap as a base value (default is 100).
-- Altered resources will also work with FightingChance™ - you just need to alter them before running FightingChance™.
-- Applies a bonus or malus for resources when the popcap was changed (higher popcap - bonus, lower popcap - malus).
----------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------
-- How to use:
----------------------------------------------------------------------------------------------------------------------
-- Save your map in worldbuilder
-- Put this code into the .scar file (should be in the same directory as your custom map and also have the same name).
-- Alter the setup values
-- Save the .scar file
-- Export the map using worldbuilder - but DO NOT save it again in worldbuilder or the scar file will be cleared.
-- Enjoy!
----------------------------------------------------------------------------------------------------------------------


----------------------------------------------------------------------------------------------------------------------
-- Terms of Use:
----------------------------------------------------------------------------------------------------------------------
-- You may use this script for your own maps but not claim ownership.
-- You may only change the values within the SETUP section.
-- You may NOT change the script itself.
----------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------
-- Special thanks to Wolfie88 (SteamId) (vire river creator) for beta testing!
----------------------------------------------------------------------------------------------------------------------


----------------------------------------------------------------------------------------------------------------------
-- FightingChance™ setup - change the inner values to your liking!!! -------------------------------------------------
----------------------------------------------------------------------------------------------------------------------

FightingChanceSettings =
{
-- maximum players - 4v4 == 8, 3v3 == 6, 2v2 == 4, 1v1 == 2
MaximumPlayers = 8,

-- the default popcap each player should have when both teams are maxed out - default is 100
DefaultPlayerPopCap = 150
}

----------------------------------------------------------------------------------------------------------------------
-- end of FightingChance™ setup --------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------


----------------------------------------------------------------------------------------------------------------------
-- FightingChance™ code - do NOT modify!!! ---------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
function FightingChance(settings)

local maximumPlayers = settings.MaximumPlayers
local defaultPlayerPopCap = settings.DefaultPlayerPopCap

-- determine the team sizes
local playerCount = World_GetPlayerCount()
local team1Size = 0
local team2Size = 0

for i = 1, playerCount do
local currentPlayer = World_GetPlayerAt(i)
local currentTeamId = Player_GetTeam(currentPlayer)

if currentTeamId == 0 then
team1Size = team1Size + 1
else
team2Size = team2Size + 1
end
end

-- calculate the popcaps
local teamPopCap = (maximumPlayers * defaultPlayerPopCap) / 2.0
local team1PlayerPopCap = math.floor(teamPopCap / team1Size + 0.5)
local team2PlayerPopCap = math.floor(teamPopCap / team2Size + 0.5)

-- uses the modified default popcap for a bonus or malus
local popCapResourceFactor = defaultPlayerPopCap / 100

local team1ResourceFactor = (maximumPlayers / team1Size / 2.0) * popCapResourceFactor
local team2ResourceFactor = (maximumPlayers / team2Size / 2.0) * popCapResourceFactor

-- apply the values
for i = 1, playerCount do
local currentPlayer = World_GetPlayerAt(i)
local currentTeamId = Player_GetTeam(currentPlayer)
local currentFactor = 1.0

-- select the proper factor
if currentTeamId == 0 then
Player_SetPopCapOverride(currentPlayer, team1PlayerPopCap)
currentFactor = team1ResourceFactor
else
Player_SetPopCapOverride(currentPlayer, team2PlayerPopCap)
currentFactor = team2ResourceFactor
end

local manpower = math.floor(Player_GetResource(currentPlayer, RT_Manpower) * currentFactor + 0.5)
local munition = math.floor(Player_GetResource(currentPlayer, RT_Munition) * currentFactor + 0.5)
local fuel = math.floor(Player_GetResource(currentPlayer, RT_Fuel) * currentFactor + 0.5)

Player_SetResource(currentPlayer, RT_Manpower, manpower)
Player_SetResource(currentPlayer, RT_Munition, munition)
Player_SetResource(currentPlayer, RT_Fuel, fuel)
Modify_PlayerResourceRate(currentPlayer, RT_Manpower, ((currentFactor + 0.75) * 0.5), MUT_Multiplication)
Modify_PlayerResourceRate(currentPlayer, RT_Munition, ((currentFactor + 0.75) * 0.5), MUT_Multiplication)
Modify_PlayerResourceRate(currentPlayer, RT_Fuel, ((currentFactor + 0.75) * 0.5), MUT_Multiplication)
end
end

----------------------------------------------------------------------------------------------------------------------
-- end of FightingChance™ code ---------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------


function OnInitID()

-- run FightingChance™
FightingChance(FightingChanceSettings)

-- [[ Markers ]]

-- [[ Squad Groups ]]

-- [[ Entity Groups ]]

end
Last edited by Brummbær; 6 Aug, 2014 @ 10:27am
< >
Showing 1-6 of 6 comments
that guy u know 4 Aug, 2014 @ 2:48pm 
Thanks. I'll use this on my high resource maps, and leave a link back here to tell where I got it from.
Brummbær  [developer] 4 Aug, 2014 @ 3:09pm 
Originally posted by that guy u know:
Thanks. I'll use this on my high resource maps, and leave a link back here to tell where I got it from.

Just add a note that the script was created by --=REAPER=--. I only made small adjustments to increase the resource income rates to fit higher popcaps.
that guy u know 4 Aug, 2014 @ 5:56pm 
Got it, thanks
baddoggs 26 Mar, 2015 @ 5:07pm 
Very detailed map mate, cold be a problem for players with more marginal machines, suggest a dumbed down version for them? Not a problem for me though, i absoluly love it. its so freakin big, with high popcap mod i've had some EPIC battles. Keep up the good work!!!!
Last edited by baddoggs; 26 Mar, 2015 @ 5:07pm
Brummbær  [developer] 27 Mar, 2015 @ 3:01am 
TY :KSmiley:

Removed the deep snow on the winter version of this map, because it had a much higher impact on the performance of it than the object count. The summer versions of the map are fine for me, even if there might be people having hard times with the hardware requirements of large and detailed maps.
baddoggs 27 Mar, 2015 @ 3:56am 
Ive got an amd quad with all the fruit, so no dramas for me. I just noticed many players are not as fortunate. As far as i'm concerned pile it on, you did a great job on these:-)))
< >
Showing 1-6 of 6 comments
Per page: 1530 50