Setting up Victory Conditions
Moderator: Panzer Corps 2 Moderators
Setting up Victory Conditions
I want 1 Victory Hex set to hold for 3 turns to win the game.
Not eable to do it.
If i set Objectives to a Hex and ad count 0 - 3 turns it only has to be captured.
I tried different values.. but either coming up the game wins/loose imidiatly or after turn 3 (not holding it for 3) or right after capturing that hex.
Also setting up optional victory conditions only shows up normal not as optional. Having it enabled or "optional" checked, dechecked makes no difference.
Anyone can help on the scripting?
Thanks in advance.
Not eable to do it.
If i set Objectives to a Hex and ad count 0 - 3 turns it only has to be captured.
I tried different values.. but either coming up the game wins/loose imidiatly or after turn 3 (not holding it for 3) or right after capturing that hex.
Also setting up optional victory conditions only shows up normal not as optional. Having it enabled or "optional" checked, dechecked makes no difference.
Anyone can help on the scripting?
Thanks in advance.
Re: Setting up Victory Conditions
Let's say you are using Hold victory hexes objective. Under "Hexes" text field click on the map to get desired hex coordinates. For turn count you are not using "Count" field but "Turns" field instead. Just write 3. "Count" field is used if you have several hexes defined, like let's say 5 and you define how many of them you need to hold for victoy through "Count" field, let's say 3. So in "Hexes" field you will have 5 hex coordinates and in "Count" field you will have single numeric value 3. This means you need to hold 3 hexes out of 5.
Optional objective makes sense only if you have some other objective which is mandatory. To inform player which objective is optional use "Custom header" field. Whatever you write there will be displayd in UI.
Optional objective makes sense only if you have some other objective which is mandatory. To inform player which objective is optional use "Custom header" field. Whatever you write there will be displayd in UI.
Re: Setting up Victory Conditions
I think what he is asking for is more complicated.
I could be wrong, but he seems to want to.
1. Put a hex on the board, not owned by the player. King of the Hill style.
2. Player fights towards that hex and captures it.
3. Player must control it for 3 consecutive turns (meaning it will be counterattacked) instead of winning the scenario instantly upon capture.
While this is certainly possible, it's not one of the default options.
You'll need to dive into custom victory conditions, and have a Lua script to define everything.
It's not horribly scary, if I have some extra time I will try to help. Assuming I understood what you described correctly.
Need a script file, need to set up a counter, need the counter to increment up at start of player turn for when player owns hex X. Need game to check value of counter. Award victory when counter reaches 3.
I could be wrong, but he seems to want to.
1. Put a hex on the board, not owned by the player. King of the Hill style.
2. Player fights towards that hex and captures it.
3. Player must control it for 3 consecutive turns (meaning it will be counterattacked) instead of winning the scenario instantly upon capture.
While this is certainly possible, it's not one of the default options.
You'll need to dive into custom victory conditions, and have a Lua script to define everything.
It's not horribly scary, if I have some extra time I will try to help. Assuming I understood what you described correctly.
Need a script file, need to set up a counter, need the counter to increment up at start of player turn for when player owns hex X. Need game to check value of counter. Award victory when counter reaches 3.
Re: Setting up Victory Conditions
Thanks for helping both of you.
Exactly like Kerensky said. One simple HEX need to be hold for 3 Turns to win the game.
If i set it up with empty "Count" and 3 Turns - if you move a unit on that HEX you immediately win the game.
Also the condition window show it up 1/1 from Start.
Optional works now thanks

@ Kerensky - Yes thats how i did it in PZ1 .. a kind scriptloop that checks every turn conditions.
Help will be appreciate - ill mention your name on the Map. =)
Exactly like Kerensky said. One simple HEX need to be hold for 3 Turns to win the game.
If i set it up with empty "Count" and 3 Turns - if you move a unit on that HEX you immediately win the game.
Also the condition window show it up 1/1 from Start.
Optional works now thanks

@ Kerensky - Yes thats how i did it in PZ1 .. a kind scriptloop that checks every turn conditions.
Help will be appreciate - ill mention your name on the Map. =)
Re: Setting up Victory Conditions
Yea as I understand it 'Hold' only works for one situation:
Defend X amount of hexes for Y duration, where turn duration is pretty universally equal to scenario turn limit. It's meant for when you have a battlefield you already control, and the objective is to not lose control of it.
No promises that I can help write that script for you, I'm very busy and also not exactly an expert script writer, but I will try.
Defend X amount of hexes for Y duration, where turn duration is pretty universally equal to scenario turn limit. It's meant for when you have a battlefield you already control, and the objective is to not lose control of it.
No promises that I can help write that script for you, I'm very busy and also not exactly an expert script writer, but I will try.
Re: Setting up Victory Conditions
It's messy, it's a frankenstein's monster of cutting up scripts from other scenarios, and I have zero clue how to decipher (most) of what exists in function Player1VH, but it does what it's supposed to do. Definite barbarian level of script work...
Capture the labeled hex. Nothing happens immediately.
Controlled captured hex for 3 consecutive turns... victory is awarded.
So this is the bare bones basic implementation of what you're looking for. How you want to adjust the values and incorporate them into your design is up to you. Good luck!
https://www.dropbox.com/s/gqbejcj2td97n ... z2scn?dl=0
https://www.dropbox.com/s/c797txhbz1xr6 ... r.map?dl=0
https://www.dropbox.com/s/004k5z9z9gp2t ... r.lua?dl=0
Download all three files. Put them all together in the same folder. Open Timer map in editor, hit play, see that it works.
Capture the labeled hex. Nothing happens immediately.
Controlled captured hex for 3 consecutive turns... victory is awarded.
So this is the bare bones basic implementation of what you're looking for. How you want to adjust the values and incorporate them into your design is up to you. Good luck!
https://www.dropbox.com/s/gqbejcj2td97n ... z2scn?dl=0
https://www.dropbox.com/s/c797txhbz1xr6 ... r.map?dl=0
https://www.dropbox.com/s/004k5z9z9gp2t ... r.lua?dl=0
Download all three files. Put them all together in the same folder. Open Timer map in editor, hit play, see that it works.
Last edited by Kerensky on Thu Apr 09, 2020 10:46 pm, edited 2 times in total.
Re: Setting up Victory Conditions
The script file basically...
defines what VH matters
creates a local variable to track turns that hex is owned by player0
functionPlayer1VH...
does something I cannot fathom
does another thing I cannot fathom
checks the owner of a hex
if the owner is player 0, increment the value of the variable by one
and the success checker is just waiting for that variable value to reach above 3
defines what VH matters
creates a local variable to track turns that hex is owned by player0
functionPlayer1VH...
does something I cannot fathom
does another thing I cannot fathom
checks the owner of a hex
if the owner is player 0, increment the value of the variable by one
and the success checker is just waiting for that variable value to reach above 3
Re: Setting up Victory Conditions
cool thanks will check out later going bed now.
Does the timer resets if the Hex is recaptured?
Does the timer resets if the Hex is recaptured?
Re: Setting up Victory Conditions
I can only assume no, because there's nothing in there that says:
Set value to 0 if ownership does not equal player0.
But you could probably add an else statement to this effect.
if hex.owner == 0 then
p1captured = p1captured + 1
else p1captured = 0
That would certainly reset the value to zero.
Re: Setting up Victory Conditions
It is not working proper. Cant find what is the current problem but i get "random" victorys.
Sometimes something triggers the victory even if you not hold it for 3 turn after recapture.
I had Player 1 move in on HEX - End Turn
2 player makes his turn not eable to get to the HEX - End turn - Game Triggers Victory - cant see for what side!
current script looks like this.
There is no count on the overview tab. Not sure if this is doeable but a turncounter for the victory hex wouldt be awsome =).
It will be a multiplayermap:
Sometimes something triggers the victory even if you not hold it for 3 turn after recapture.
I had Player 1 move in on HEX - End Turn
2 player makes his turn not eable to get to the HEX - End turn - Game Triggers Victory - cant see for what side!
current script looks like this.
There is no count on the overview tab. Not sure if this is doeable but a turncounter for the victory hex wouldt be awsome =).
It will be a multiplayermap:
Code: Select all
VHs = {{23,10}}
local p1captured = 0
local p2captured = 0
function Player1VH()
for _,vh in ipairs(VHs) do
local hex = world:GetHex(vh)
if hex.owner == 0 then
p1captured = p1captured + 1
end
end
return p1captured
end
function Player1CustomSuccess(action)
return Player1VH() > 3
end
function Player1CustomFail(action)
return action:GetActionClass() == "TurnsLimitAction" and Player1VH() < 3
end
function Player2VH()
for _,vh in ipairs(VHs) do
local hex = world:GetHex(vh)
if hex.owner == 0 then
p2captured = p2captured + 1
end
end
return p2captured
end
function Player2CustomSuccess(action)
return Player2VH() > 3
end
function Player2CustomFail(action)
return action:GetActionClass() == "TurnsLimitAction" and Player2VH() < 3
end


