A new version of the mod framework is now live! This one adds hooks that allow mods to hook into the advance-turn algorithm.
This the big update we've all been waiting for that enables mods to do all sorts of fancy things with the game as it plays out. Mods now have full control over which players own what territories and how many armies are on them throughout the entire game. They can also modify or skip player's orders as the turn plays out, like modify how many attackers/defenders died in each attack, or whether not or each attack was successful, etc.
Some examples of what you can do:
- Limited multi-attack
- One way connections
- Attacking/Defending from territory A to B deals more damage than the other way around.
- Different kill rates in different regions on the map
- The list is endless! But this list ends here.
To kick it off, I've made a mod I call the Safe Start mod that prevents players from attacking each other at the start of the game (10 turns is the default but it's configurable.) Here's the juicy bits, with comments:
function Server_AdvanceTurn_Order(game, order, result, skipThisOrder, addNewOrder)
if (game.Game.NumberOfTurns < Mod.Settings.NumTurns -- are we at the start of the game, within our defined range? (without this check, we'd affect the entire game, not just the start)
and order.proxyType == 'GameOrderAttackTransfer' --is this an attack/transfer order? (without this check, we'd stop deployments or cards)
and result.IsAttack --is it an attack? (without this check, transfers wouldn't be allowed within your own territory or to teammates)
and not IsDestinationNeutral(game, order)) --is the destination owned by neutral? (without this check we'd stop people from attacking neutrals)
then
skipThisOrder(WL.ModOrderControl.Skip); --skip it
end
end
function IsDestinationNeutral(game, order)
local terrID = order.To; --The order has "To" and "From" which are territory IDs
local terrOwner = game.ServerGame.LatestTurnStanding.Territories[terrID].OwnerPlayerID; --LatestTurnStanding always shows the current state of the game.
return terrOwner == WL.PlayerID.Neutral;
end
Full code is here:
https://github.com/FizzerWL/ExampleMods/tree/master/SafeStartModDocumentation for new hooks:
https://www.warlight.net/wiki/Mod_HooksDocumentation for mods, if you haven't been following their development:
https://www.warlight.net/wiki/ModsLet me know if you try it out!