<< Back to Programming Forum   Search

Posts 1 - 6 of 6   
can't skip a played reinf card played by AI?: 2021-10-11 15:18:05


Just_A_Dutchman_ 
Level 60
Report
function Server_AdvanceTurn_Order(game, order, result, skipThisOrder, addNewOrder)
	if(order.proxyType == "GameOrderPlayCardReinforcement")then
		if(game.ServerGame.Game.Players[order.PlayerID].IsAIOrHumanTurnedIntoAI == true)then
			skipThisOrder(WL.ModOrderControl.SkipAndSupressSkippedMessage);
		end
	end
end


I only just started modding and mostly copied the code from the AI's don't deploy mod, but I get some interesting results. For some reason the AI gets the bonus armies from the reinforcement card, but it gets even better the turns after. I had the settings that if you succeeded in a attack you would get a reinforcement card for sure, but only 1 a turn. But the AI had 2 reinforcement cards on turn 2 and 3 on turn 3...? When I set
if(game.ServerGame.Game.Players[order.PlayerID].IsAIOrHumanTurnedIntoAI == true)then

to
if(game.ServerGame.Game.Players[order.PlayerID].IsAIOrHumanTurnedIntoAI == false)then

I have the exact same thing. The card gets cancelled in such a way that I keep the card and the effect still goes through.

I know you're able to skip played cards, so my guess is I'm making a mistake somewhere. can someone help? xD

Edited 10/11/2021 15:18:22
can't skip a played reinf card played by AI?: 2021-10-11 19:20:24


TBest 
Level 60
Report
With mods, deployed armies don't have to match income. So maybe you manually have to change the deployed armies too.

Perhaps, the proper fix would be to not give the AI any cards in the first place.
can't skip a played reinf card played by AI?: 2021-10-12 14:25:29


Just_A_Dutchman_ 
Level 60
Report
With mods, deployed armies don't have to match income.

I tested this mod without any other mods and with a 0 base income start. The AI's still got the reinforcement card effect while the order got skipped.

The main problem I want to tackle is players that turned into an AI playing cards, not the AI's you add when you create the game. So if I do make a mod that prevents the AI's from getting card pieces they will still be able to play those they have collected when they were not an AI. I always encourage players to return to games where they got booted, not letting their AI collect card pieces migth be disencouraging them and will put them behind. Besides, for now I only want to make it so the AI's won't be able to play any cards, but I might expand this to give the option to prevent certain cards from being played by AI's and other cards not for example the diplomacy card.

I did some testing and finished the mod except for the reinforcement card. Can you tell me how I'm able to change the deployed armies? Only thing I can think of right now is to modify the amount of armies deployed until the value of the played reinforcement card has been reached
can't skip a played reinf card played by AI?: 2021-10-12 15:21:50


TBest 
Level 60
Report
Not sure if the most readable code, nor bugfree or finished, but I did something similar here :
https://github.com/TBestLittleHelper/WarLightMods/blob/de78a2b070d47235c8c93e2e69c01b93adba924f/TBest_Mods/City_Features/Server_AdvanceTurn.lua#L177

You can change the armies on a territory like this. *

local terrMod = WL.TerritoryModification.Create(order.DeployOn);	
terrMod.SetArmiesTo  = game.ServerGame.LatestTurnStanding.Territories[order.DeployOn].NumArmies.NumArmies + order.NumArmies - [reinforcement card value];


Still, the AI will assume it has the armies when making orders ofc. So the orders will be pretty bad sometimes (ie, attack with too few armies)


I think there is a mod out in the wild, that solves the similar problem, in a more drastic way. It skips all AI orders. Thus, in a diplomacy game, the AI can't do stupid stuff. EDIT: Guess you maybe saw it already given , "mostly copied the code from the AI's don't deploy mod"


*Pretty sure my first attempt was skipping the original order, and making a new deploy order, which can give a nice infinite loop :P So just using SetArmiesTo and WL.GameOrderEvent.Create was what I ended up with.

Edited 10/12/2021 15:25:17
can't skip a played reinf card played by AI?: 2021-10-12 23:24:13


Just_A_Dutchman_ 
Level 60
Report
I've put the reinforcement card on a hold for now, I'll try to include it into the next version of the mod. For now this will be perfect for the games I'll be creating.

I'm now almost ready with the mod, I only have 1 question... How can I make it a github mod? Do I have to paste the URL into the local directory?
can't skip a played reinf card played by AI?: 2021-10-13 09:44:15


TBest 
Level 60
Report
I'm now almost ready with the mod, I only have 1 question... How can I make it a github mod? Do I have to paste the URL into the local directory?

Uncheck the development box.
Posts 1 - 6 of 6