Scripting construction & destruction of bridges
Moderators: Slitherine Core, Panzer Corps Moderators, Panzer Corps Design
Re: Scripting destroyed bridges
Here's an image for reference. You can see this an attempt that worked on hex 13,10.
-
- Field Marshal - Elefant
- Posts: 5939
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom
Re: Scripting destroyed bridges
I found this link https://www.slitherine.com/forum/viewto ... 07#p411807 but there is a link inside I can't access 

Re: Scripting destroyed bridges
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
https://www.slitherine.com/forum/viewto ... 47&t=43040
Re: Scripting destroyed bridges
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.
Re: Scripting destroyed bridges
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.
I am inexperienced to scripting and all this info is amazing.
Keep it up.
Battlefield Europe get the most from Panzer Corps
Download the new 2.4 Mod here http://www.slitherine.com/forum/viewtopic.php?f=147&t=47985

Download the new 2.4 Mod here http://www.slitherine.com/forum/viewtopic.php?f=147&t=47985
Re: Scripting destroyed bridges
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!
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!
Re: Scripting destroyed bridges
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
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:

I will try to explain, but there are still some things I don't know

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:
Last edited by maguro on Mon Jan 30, 2023 5:04 am, edited 1 time in total.
Re: Scripting destroyed bridges
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) The lower-left hex (10-10) The upper-right hex (12-9)
For the 3 hexes listed in the image above I used these 3 hex actions in the same script:
The middle hex (11,9) The lower-left hex (10-10) The upper-right hex (12-9)
Last edited by maguro on Mon Jan 30, 2023 1:28 am, edited 1 time in total.
Re: Scripting destroyed bridges
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.
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??
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??
Re: Scripting destroyed bridges
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.
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: 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. 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!
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.

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

Last edited by cw58 on Mon Jan 30, 2023 4:08 am, edited 1 time in total.
Re: Scripting destroyed bridges
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
I think these are right but you should test & double-check all values, just in case.
8 = down to the right
128 = up to the left
136 = bridge hex NW to SE
bridge icon = 65
I think these are right but you should test & double-check all values, just in case.

Re: Scripting destroyed bridges
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.
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.
Re: Scripting construction & destruction of bridges
Just an FYI, I modified the subject title of this thread to better reflect the topic. Hope it doesn't confuse anyone 

-
- Field Marshal - Elefant
- Posts: 5939
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom
Re: Scripting construction & destruction of bridges
Sbiba pass (U.S. Corps '42, "The Battle of the Sbiba gap")
Re: Scripting construction & destruction of bridges
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.
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.
-
- Field Marshal - Elefant
- Posts: 5939
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom
Re: Scripting construction & destruction of bridges
SPRING SALE on GOG, Panzer Corps Gold with all the DLCs :
-
- Brigadier-General - 8.8 cm Pak 43/41
- Posts: 1816
- Joined: Mon Jun 27, 2022 10:10 pm
Re: Scripting construction & destruction of bridges
https://mynickname.com/id73473


Re: Scripting construction & destruction of bridges
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 after trigger editor
In case anyone needs it here how it works
before after trigger editor
-
- Field Marshal - Elefant
- Posts: 5939
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom
Re: Scripting construction & destruction of bridges
Thanks for this elaborate script 

Re: Scripting construction & destruction of bridges
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

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


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