Scripting construction & destruction of bridges
Moderators: Slitherine Core, Panzer Corps Design, Panzer Corps Moderators
Scripting construction & destruction of bridges
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.
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 (530.48 KiB) Viewed 1748 times
Last edited by maguro on Mon Jan 30, 2023 5:15 am, edited 1 time in total.
Re: Scripting destroyed bridges
Continuing on...
Re: Scripting destroyed bridges
The destroyed bridge is hard to see. Sorry about that.
Re: Scripting destroyed bridges
And the last couple steps...
Re: Scripting destroyed bridges
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.
I'm am curious to know what people think about this way of doing it.
Re: Scripting destroyed bridges
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
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 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.
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.
At any rate, very interesting proposal and nice presentation. Again, my thanks!
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.
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.
At any rate, very interesting proposal and nice presentation. Again, my thanks!
Re: Scripting destroyed bridges
Hi cw58,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.
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.
At any rate, very interesting proposal and nice presentation. Again, my thanks!
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.
Re: Scripting destroyed bridges
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.
Re: Scripting destroyed bridges
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.
Re: Scripting destroyed bridges
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. 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.
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!
For some quick visual reference, below is the switchable unit in its "primary" mode moving to the bridge. 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.
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!
Re: Scripting destroyed bridges
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. If it's not too much to ask, would you mind posting those for community use?
Re: Scripting destroyed bridges
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.
Re: Scripting destroyed bridges
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.
Re: Scripting destroyed bridges
Another one just for variety.
- Attachments
-
- Demolition_pioniere_2.png (49.56 KiB) Viewed 1591 times
Re: Scripting destroyed bridges
Many thanks to you and to PHCAS!
-
- Field Marshal - Elefant
- Posts: 5865
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom
Re: Scripting destroyed bridges
And now to script a bridge construction...
Re: Scripting destroyed bridges
I'll have a go at it and post the results when I have some time.
-
- Field Marshal - Elefant
- Posts: 5865
- Joined: Mon Aug 15, 2011 12:48 pm
- Location: the land of freedom
Re: Scripting destroyed bridges
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.
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.