Scripting construction & destruction of bridges

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

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

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

Scripting construction & destruction of bridges

Post by maguro »

A while back I was thinking about how to make units destroy bridges. It turns out you can script bridges to be destroyed.
Working off of a previous thread on the topic, I've come up with some that works... at least it mostly works for the campaign I'm making it for. If you read down to the bottom, you'll see there is still one issue to iron out. I hope its useful for others.

I will try to explain with the pictures I took to help me remember down the road. I had to do some wonky converting with the images being in a word doc. Sorry if it's confusing to read.
Attachments
0001.jpg
0001.jpg (530.48 KiB) Viewed 1748 times
Last edited by maguro on Mon Jan 30, 2023 5:15 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 »

Continuing on...
0002.jpg
0002.jpg (482.67 KiB) Viewed 1747 times
0003.jpg
0003.jpg (514.76 KiB) Viewed 1747 times
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 destroyed bridge is hard to see. Sorry about that.
0004.jpg
0004.jpg (601.34 KiB) Viewed 1743 times
0005.jpg
0005.jpg (462.81 KiB) Viewed 1743 times
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

And the last couple steps...
0006.jpg
0006.jpg (639.17 KiB) Viewed 1741 times
0007.jpg
0007.jpg (220.41 KiB) Viewed 1741 times
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

With some previous attempts a couple years back, this test took about an hour or so to get right. There was a couple of hiccups since I often miss details wen scripting but when everything is in the right place, the script did what I had hoped it would.

I'm am curious to know what people think about this way of doing it.
faos333
Colonel - Fallschirmjäger
Colonel - Fallschirmjäger
Posts: 1465
Joined: Sat Feb 16, 2019 9:04 pm

Re: Scripting destroyed bridges

Post by faos333 »

This is an excellent way of destroying bridges, I can not say any more, since I have never tried this
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
cw58
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 450
Joined: Thu Sep 24, 2015 9:44 pm

Re: Scripting destroyed bridges

Post by cw58 »

Hi Maguro,
I don't have much experience with scripting so a lot of what you posted is new knowledge for me. So thank you for sharing your work with us.

As I am inexperienced with scripting, I have a question regarding the "Update Hexes" in the 3rd pic. You call out hex 4,2 with a radius of 1. Why does it need a radius of 1? Wouldn't a radius of 0 be sufficient since only that hex is effected? Sorry if this is obvious to everyone but me. :oops:

Then near the end of your posts, you mention "one problem" but it seems that your scripts work as intended so I'm not sure what the problem is. I'm guessing maybe you wanted a switchable unit that would destroy the bridge only when switched to the demolition version? But both versions destroy it? If that's the case, try changing the class definition of your demo unit. For example, you have an infantry unit with the "Test Demolition" name in your "Edit Map Condition" screen. If your first switch of that unit is, let's say recon, then it shouldn't trigger the condition until you switch to the infantry version. Any combination of 2 different classes should work. If I've misunderstood the problem, my apologies. :D

At any rate, very interesting proposal and nice presentation. Again, my thanks!
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 wrote: Fri Jan 27, 2023 11:43 pm Hi Maguro,
I don't have much experience with scripting so a lot of what you posted is new knowledge for me. So thank you for sharing your work with us.

As I am inexperienced with scripting, I have a question regarding the "Update Hexes" in the 3rd pic. You call out hex 4,2 with a radius of 1. Why does it need a radius of 1? Wouldn't a radius of 0 be sufficient since only that hex is effected? Sorry if this is obvious to everyone but me. :oops:

Then near the end of your posts, you mention "one problem" but it seems that your scripts work as intended so I'm not sure what the problem is. I'm guessing maybe you wanted a switchable unit that would destroy the bridge only when switched to the demolition version? But both versions destroy it? If that's the case, try changing the class definition of your demo unit. For example, you have an infantry unit with the "Test Demolition" name in your "Edit Map Condition" screen. If your first switch of that unit is, let's say recon, then it shouldn't trigger the condition until you switch to the infantry version. Any combination of 2 different classes should work. If I've misunderstood the problem, my apologies. :D

At any rate, very interesting proposal and nice presentation. Again, my thanks!
Hi cw58,
In regard your question, I am not entirely sure why the radius needs to be 1, but I found this mentioned in a previous thread. The reason seems to be that terrain features work in connection to the neighboring hex with the same feature. Conversely, overlays (controlling the visual aspect of the hex action, AKA the broken bridge tile) function independent of the neighboring hex so 0 radius is apparently enough. Before that I was spinning my wheels with trying to get the script to work. I tested again yesterday day with a radius on 0 just make sure I wasn't misunderstanding something, but with 0 for the terrain feature hex action, it just doesn't work.

As for your idea about the unit switch, you have not misunderstood. I think you are right that the "problem" is really a non-problem. I started thinking of something similar to your suggestion after I turned off the pc yesterday. I will try it and post the results when I have more time.

There is also the string that should be changed, to show the updated name of the hex. For a destroyed bridge, this may not be so important as the tile shows everything the player needs to know. At any rate, I expect the string change to be similar to the tile hex action.

I hope that helps. I'm a bit of a pea brain when it comes to this stuff, so my explanations might not make sense.
cw58
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 450
Joined: Thu Sep 24, 2015 9:44 pm

Re: Scripting destroyed bridges

Post by cw58 »

Thanks for the clarification. It's always good to see game-play theories tested and results posted. It helps to build a pool of knowledge about the game's mechanics. :)
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

No worries, I'm happy to share it. Scripting has been witchcraft for me at times, but in case it just worked. To me, it seems like the scenario editor has a lot of possibilities, but not a lot of explanation on how to use it once you get passed the more basic applications.
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 is an update, picking up on where I was struggling previously. cw58, you're idea worked perfectly, and really makes perfect sense. By changing the demolition version to a recon unit, the original Bruckenpioniere unit no longer destroys the bridge. It's only destroyed when the switch is made to the demolition version.

For some quick visual reference, below is the switchable unit in its "primary" mode moving to the bridge.
Switch_1.png
Switch_1.png (571.92 KiB) Viewed 1662 times
The unit must wait until the next turn, but then when switched, the message I scripted appears after deselecting the unit. After clicking out of the msg, the bridge can be seen as destroyed.
Switch_2.png
Switch_2.png (499.7 KiB) Viewed 1662 times


Cw58, Thank you for your input. I'm really excited that we now have a way for a neutral bridge to be destroyed by either side, all be it with a bit of extra script work.

Cheers!
cw58
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 450
Joined: Thu Sep 24, 2015 9:44 pm

Re: Scripting destroyed bridges

Post by cw58 »

I'm glad to hear that it worked. Obviously, the 2nd switch can be any class that you think is most appropriate; the recon class was just the first to come to mind. And I really like your demolition icons, the soldier on the plunger & the exploding bridge; nicely done. :D If it's not too much to ask, would you mind posting those for community use?
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 is the icon. It's modified from PHCAS's goliath icon, so credit goes to him. I just added the destroyed bridge symbol and some tweaks.
Demolition_pioniere.png
Demolition_pioniere.png (38.86 KiB) Viewed 1596 times
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 is the symbol to destroy the bridge. This may be obvious, but when I am editing using gimp, I copy the entire image including all the blank area, and paste it to the icon I want it be used with. That way I always know it's positioned in the same place.
Destroy_bridge_icon.png
Destroy_bridge_icon.png (24.46 KiB) Viewed 1597 times
maguro
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 305
Joined: Thu Oct 23, 2014 3:14 pm

Re: Scripting destroyed bridges

Post by maguro »

Another one just for variety.
Attachments
Demolition_pioniere_2.png
Demolition_pioniere_2.png (49.56 KiB) Viewed 1591 times
cw58
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 450
Joined: Thu Sep 24, 2015 9:44 pm

Re: Scripting destroyed bridges

Post by cw58 »

Many thanks to you and to PHCAS!
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5865
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Scripting destroyed bridges

Post by terminator »

And now to script a bridge construction...
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'll have a go at it and post the results when I have some time.
terminator
Field Marshal - Elefant
Field Marshal - Elefant
Posts: 5865
Joined: Mon Aug 15, 2011 12:48 pm
Location: the land of freedom

Re: Scripting destroyed bridges

Post by terminator »

Thanks in advance :)

The bridge design that helped win World War II: https://youtu.be/vaNOuVgwPos
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 Terminator,

So far, adding a bridge is proving to be more challenging. The good news is I have added roads across a major river. The bad news is that the positioning is pretty much out of my control. For now, I am not worrying about the road tile, since others have already demonstrated that works, and others have . Here is what I know:

(a) Radius of 1 seems to connect the road feature in a way that allows some values to create a road.
(b) Values in the road terrain box between 1-9 have given no results. 10-26 (have not tried all in this range) about half the numbers seem to do something.
(c) My attempts was were focused on hex 11,9. Every time I was able to create a road, it was across hex 12,11 or hex 13,10. In the image below, you can see the result after one of the attempts. I thought that this offset could be caused by the maps hexes extending off the playable surface by 1 hex in each direction, but there was no issue making the road go away when making the bridge demolition script.
(d) Since the first two or so pathways were made across hex on 12,11, I expected to make one on 11,9 by moving the hex action to 10,8. This did nothing - no pathway was created. I plan to try this again with some different values in the road terrain box.

What I don't know:
(a) What each number does in the road terrain box.
(b) If a larger radius is making a longer road or moving the pathway to an unintended location.
(c) Probably a bunch of other things.

I'm sure it will work, but there is too much I don't know.
Last edited by maguro on Sun Jan 29, 2023 1:49 pm, edited 1 time in total.
Post Reply

Return to “Panzer Corps : Scenario Design”