Page 2 of 3
Re: Scripting destroyed bridges
Posted: Sun Jan 29, 2023 1:55 pm
by maguro
Here's an image for reference. You can see this an attempt that worked on hex 13,10.

- Bridge_hex_action.png (528.63 KiB) Viewed 1727 times
Re: Scripting destroyed bridges
Posted: Sun Jan 29, 2023 2:25 pm
by terminator
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
Posted: Sun Jan 29, 2023 3:19 pm
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
Re: Scripting destroyed bridges
Posted: Sun Jan 29, 2023 3:24 pm
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.
Re: Scripting destroyed bridges
Posted: Sun Jan 29, 2023 7:48 pm
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.
Re: Scripting destroyed bridges
Posted: Mon Jan 30, 2023 1:06 am
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!
Re: Scripting destroyed bridges
Posted: Mon Jan 30, 2023 1:16 am
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

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 (663.54 KiB) Viewed 1667 times
Re: Scripting destroyed bridges
Posted: Mon Jan 30, 2023 1:22 am
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 (29.07 KiB) Viewed 1666 times
The lower-left hex (10-10)

- Update_hex_2.png (21.78 KiB) Viewed 1666 times
The upper-right hex (12-9)

- Update_hex_3.png (29.56 KiB) Viewed 1666 times
Re: Scripting destroyed bridges
Posted: Mon Jan 30, 2023 1:27 am
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 (526.53 KiB) Viewed 1665 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??
Re: Scripting destroyed bridges
Posted: Mon Jan 30, 2023 2:47 am
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.
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 (115.77 KiB) Viewed 1652 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 (112 KiB) Viewed 1652 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!

Re: Scripting destroyed bridges
Posted: Mon Jan 30, 2023 3:55 am
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 (302.3 KiB) Viewed 1631 times
I think these are right but you should test & double-check all values, just in case.

Re: Scripting destroyed bridges
Posted: Mon Jan 30, 2023 4:29 am
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.
Re: Scripting construction & destruction of bridges
Posted: Mon Jan 30, 2023 5:18 am
by maguro
Just an FYI, I modified the subject title of this thread to better reflect the topic. Hope it doesn't confuse anyone

Re: Scripting construction & destruction of bridges
Posted: Sun Feb 26, 2023 6:34 am
by terminator
Sbiba pass (U.S. Corps '42, "The Battle of the Sbiba gap")

- Sbiba pass (1).jpg (393.06 KiB) Viewed 1456 times

- Sbiba pass (2).jpg (358.45 KiB) Viewed 1459 times
Re: Scripting construction & destruction of bridges
Posted: Sat Apr 01, 2023 4:48 am
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.
Re: Scripting construction & destruction of bridges
Posted: Sat Apr 01, 2023 6:01 am
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 (130.5 KiB) Viewed 1307 times
Re: Scripting construction & destruction of bridges
Posted: Sat Apr 01, 2023 7:05 am
by bondjamesbond
Re: Scripting construction & destruction of bridges
Posted: Thu Apr 27, 2023 9:15 pm
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 (355.78 KiB) Viewed 1126 times
after

- after.jpg (328.99 KiB) Viewed 1126 times
trigger editor

- addSwampDestroyBridge.png (49.18 KiB) Viewed 1126 times
Re: Scripting construction & destruction of bridges
Posted: Sun Apr 30, 2023 8:18 am
by terminator
Thanks for this elaborate script

Re: Scripting construction & destruction of bridges
Posted: Sat Feb 03, 2024 11:02 am
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
