Setting up Victory Conditions

A forum to discuss custom scenarios, campaigns and modding in general.

Moderator: Panzer Corps 2 Moderators

Post Reply
Owi
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 68
Joined: Thu Feb 25, 2010 3:06 pm

Setting up Victory Conditions

Post by Owi » Thu Apr 09, 2020 2:03 pm

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.

uran21
Panzer Corps Map Designer
Panzer Corps Map Designer
Posts: 2071
Joined: Thu Dec 02, 2010 8:34 pm

Re: Setting up Victory Conditions

Post by uran21 » Thu Apr 09, 2020 5:51 pm

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.

Kerensky
Content Designer
Content Designer
Posts: 7178
Joined: Wed Jan 12, 2011 2:12 am

Re: Setting up Victory Conditions

Post by Kerensky » Thu Apr 09, 2020 7:29 pm

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.

Owi
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 68
Joined: Thu Feb 25, 2010 3:06 pm

Re: Setting up Victory Conditions

Post by Owi » Thu Apr 09, 2020 7:56 pm

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 :D
Image


@ 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. =)

Kerensky
Content Designer
Content Designer
Posts: 7178
Joined: Wed Jan 12, 2011 2:12 am

Re: Setting up Victory Conditions

Post by Kerensky » Thu Apr 09, 2020 8:21 pm

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. :)

Kerensky
Content Designer
Content Designer
Posts: 7178
Joined: Wed Jan 12, 2011 2:12 am

Re: Setting up Victory Conditions

Post by Kerensky » Thu Apr 09, 2020 10:31 pm

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... :lol:

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.

Kerensky
Content Designer
Content Designer
Posts: 7178
Joined: Wed Jan 12, 2011 2:12 am

Re: Setting up Victory Conditions

Post by Kerensky » Thu Apr 09, 2020 10:33 pm

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

Owi
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 68
Joined: Thu Feb 25, 2010 3:06 pm

Re: Setting up Victory Conditions

Post by Owi » Thu Apr 09, 2020 11:41 pm

cool thanks will check out later going bed now.
Does the timer resets if the Hex is recaptured?

Kerensky
Content Designer
Content Designer
Posts: 7178
Joined: Wed Jan 12, 2011 2:12 am

Re: Setting up Victory Conditions

Post by Kerensky » Thu Apr 09, 2020 11:53 pm

Owi wrote:
Thu Apr 09, 2020 11:41 pm
cool thanks will check out later going bed now.
Does the timer resets if the Hex is recaptured?
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.

Owi
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 68
Joined: Thu Feb 25, 2010 3:06 pm

Re: Setting up Victory Conditions

Post by Owi » Fri Apr 10, 2020 10:50 am

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:

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

Owi
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 68
Joined: Thu Feb 25, 2010 3:06 pm

Re: Setting up Victory Conditions

Post by Owi » Thu Apr 16, 2020 1:08 pm

*bump*

Post Reply

Return to “Panzer Corps 2 Scenario Design”