Scripting construction & destruction of bridges

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

Moderators: Slitherine Core, Panzer Corps Moderators, Panzer Corps Design

maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

Here's an image for reference. You can see this an attempt that worked on hex 13,10.
Bridge_hex_action.png
Bridge_hex_action.png (528.63 KiB) Viewed 1722 times
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5939
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Scripting destroyed bridges

Post by terminator »

I found this link https://www.slitherine.com/forum/viewto ... 07#p411807 but there is a link inside I can't access :(
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

fsx posted a scenario on this thread showing some of the actions possible. Play as the allies and you will have a bridge made for you to cross. Maybe it can be "reverse engineered".
https://www.slitherine.com/forum/viewto ... 47&t=43040
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

The script he made has 3 separate terrain feature actions within the script. I have absolutely no clue how that works. I feel like a remember that bit map mentioned in the thread, but I don't find it in my PzC materials. At least not yet.
faos333
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1465
Joined: Sat Feb 16, 2019 9:04 pm

Re: Scripting destroyed bridges

Post by faos333 »

hey, this turns to be a fantastic topic, I was hoping to find out.
I am inexperienced to scripting and all this info is amazing.
Keep it up.
Battlefield Europe get the most from Panzer Corps 8)
Download the new 2.4 Mod here http://www.slitherine.com/forum/viewtopic.php?f=147&t=47985
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

Hi faos333,

I agree, it is interesting, and there are a lot of possibilities. I am still working on it. If you or anyone else try some scripts out and find something that works (or does not work), it's certainly worth posting. The more knowledge the better as scripting seems to be not well documented.

Cheers!
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

Ok, so I have been able to get fsx's script to work on my scenario. I consider it a pretty big breakthrough (at least for me), because now I understand (I think) the basic mechanics of how scripting roads works :idea: I funny thing is, I actually knew how this worked a few years ago, but didn't pursue it because I was so focused on trying to destroy a bridge that I didn't really notice I could make one.

I will try to explain, but there are still some things I don't know :| . The bit map would be really helpful if anyone still has it stashed away somewhere...

The first thing to know is that the "radius 1" thing I was talking about before seems to be flat out wrong for adding roads (and destroying them). It just happened to work in my demolition test. I suggest anyone interested check out fsx's test scenario in the previous link.
The second is that you need to make a radius 0 hex action for the 3 hexes that the bridge continue through as listed in the test below:
In_game_broken.png
In_game_broken.png (663.54 KiB) Viewed 1662 times
Last edited by maguro on Mon Jan 30, 2023 5:04 am, edited 1 time in total.
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

Now, this is where detailed documentation would help us. I have no clue what the values should be for 1 hex let alone to connect 3 in a row, so I have used the exact same road direction/orientation as in fsx's example. I used the broken bridge tile as well as a visual since it is the best I have for this purpose at present.

For the 3 hexes listed in the image above I used these 3 hex actions in the same script:

The middle hex (11,9)
Update_hex_1.png
Update_hex_1.png (29.07 KiB) Viewed 1661 times
The lower-left hex (10-10)
Update_hex_2.png
Update_hex_2.png (21.78 KiB) Viewed 1661 times
The upper-right hex (12-9)
Update_hex_3.png
Update_hex_3.png (29.56 KiB) Viewed 1661 times
Last edited by maguro on Mon Jan 30, 2023 1:28 am, edited 1 time in total.
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

I used a time condition as the trigger, but again, the trigger can be anything. On turn 2, the bridge is made. It looks and works as it should.
In_game_bridged.png
In_game_bridged.png (526.53 KiB) Viewed 1660 times


Before, it was a case of not knowing what I don't know. Now, if we know what to put for each road terrain value in the 3-hex line, then making a bridge in any direction and in any hex shouldn't be a problem. Sleeping on it really does work!

One other thing, I am not sure why the 3rd terrain box is used and not the 4th. I thought the 3rd is for rail (also useful for constructing bridges though). Any ideas??
cw58
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 487
Joined: Thu Sep 24, 2015 9:44 pm

Re: Scripting destroyed bridges

Post by cw58 »

I've been playing around with this a bit too, including fsx's scenario. I can confirm your work thus far and maybe add a bit to it.
I think fsx using the 3rd terrain feature box was an error; that is indeed the rail terrain though a person could mistake the editor icon for paved roads. I've been using the 4th terrain box and it works fine using the same values that he used.

The bit map is indeed the key. I've worked out some of it and will try to explain though I can't say it is definitive. Sometimes I think I know how something works only to discover later that there are flaws in my reasoning. :oops:

As you've already figured out, the values designate direction. It's kind of like drawing an arrow from one hex to the next. The values in the Terrain Features box of the 2 hexes on either side of the bridge, point the arrow towards the bridge. The value for the bridge hex is the sum of those 2 arrows. Hopefully this pic will explain:
bridge1.jpg
bridge1.jpg (115.77 KiB) Viewed 1647 times
If you wanted a north-south bridge to the left, you would use the values 1, 16 & 17 for the Terrain Features boxes and 66 in the Tile box for the bridge icon.
bridge2.jpg
bridge2.jpg (112 KiB) Viewed 1647 times
I still haven't worked out the values for northwest-southeast bridges but I'm working on it. I have some confidence in my testing so far but not complete confidence. I'm really only posting this now to maybe save you some work. Use with caution! :wink:
Last edited by cw58 on Mon Jan 30, 2023 4:08 am, edited 1 time in total.
cw58
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 487
Joined: Thu Sep 24, 2015 9:44 pm

Re: Scripting destroyed bridges

Post by cw58 »

Here's the last set of numbers:
8 = down to the right
128 = up to the left
136 = bridge hex NW to SE
bridge icon = 65
bridge3.jpg
bridge3.jpg (302.3 KiB) Viewed 1626 times
I think these are right but you should test & double-check all values, just in case. :roll:
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

cw58,

This is excellent work, and indeed you're saving us a lot of time. I, and I'm sure some others, have wanted to demystify I'll give this a try when I have some time and let you know it goes.

I'd like to see how destroying a bridge goes using this same method. There I go, back to destroying. Just can't help myself!

I think also I'll have a go at making road tiles with two opposing road endings so before a bridge is constructed, it will look like dead end roads and not just cut off. That should be fairly straightforward.

Thank you for all your effort. I plan to put these new findings to good use. Hopefully others as well.
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting construction & destruction of bridges

Post by maguro »

Just an FYI, I modified the subject title of this thread to better reflect the topic. Hope it doesn't confuse anyone :wink:
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5939
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Scripting construction & destruction of bridges

Post by terminator »

Sbiba pass (U.S. Corps '42, "The Battle of the Sbiba gap")


Sbiba pass (1).jpg
Sbiba pass (1).jpg (393.06 KiB) Viewed 1451 times

Sbiba pass (2).jpg
Sbiba pass (2).jpg (358.45 KiB) Viewed 1454 times
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting construction & destruction of bridges

Post by maguro »

I was away from the forums for a while. Thanks for sharing, Terminator.

Too bad I never picked up the US Corps DLC. I'd like to have a look under the hood, and see if the scripting is similar to what we tried here.
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5939
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Scripting construction & destruction of bridges

Post by terminator »

maguro wrote: Sat Apr 01, 2023 4:48 am I was away from the forums for a while. Thanks for sharing, Terminator.

Too bad I never picked up the US Corps DLC. I'd like to have a look under the hood, and see if the scripting is similar to what we tried here.
SPRING SALE on GOG, Panzer Corps Gold with all the DLCs :

Capture d’écran (65).png
Capture d’écran (65).png (130.5 KiB) Viewed 1302 times
bondjamesbond
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1816
Joined: Mon Jun 27, 2022 10:10 pm

Re: Scripting construction & destruction of bridges

Post by bondjamesbond »

Image
Steam also offers discounts up to 80 %
Image
https://store.steampowered.com/app/2684 ... orps_Gold/
https://mynickname.com/id73473
Image
Japoivvb
Senior Corporal - Ju 87G
Senior Corporal - Ju 87G
Posts: 95
Joined: Sun Jan 16, 2011 6:15 pm

Re: Scripting construction & destruction of bridges

Post by Japoivvb »

Thanks for detailed explanation, it helps me a lot to define my trigger, "destroy a dam to flood a river in order to make a defense line"

In case anyone needs it here how it works
before
before.jpg
before.jpg (355.78 KiB) Viewed 1121 times
after
after.jpg
after.jpg (328.99 KiB) Viewed 1121 times
trigger editor
addSwampDestroyBridge.png
addSwampDestroyBridge.png (49.18 KiB) Viewed 1121 times
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5939
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Scripting construction & destruction of bridges

Post by terminator »

Thanks for this elaborate script :)
Intenso82
Most Successful Mod 2017
Most Successful Mod 2017
Posts: 1175
Joined: Mon May 04, 2015 8:48 am

Re: Scripting construction & destruction of bridges

Post by Intenso82 »

Bravo for this research!

Summarize,
for the action of terrain features,
each hex indicates the direction of its way.
Like the sum of directions.

Usually these are two directions, incoming and outgoing, but maybe three or four.
Then for example it will be 1+8+32=41

This allows you to remove terrain features (destructing bridges)
and add it when building new roads, for example :wink:

Image
[MOD] RUSSIA AT WAR:1941 - http://www.slitherine.com/forum/viewtopic.php?f=147&t=75743
Post Reply

Return to “Panzer Corps : Scenario Design”