Map Database  •  FAQ  •  RSS  •  Register  •  Login

Techdemo: building walls, building/destroying bridge, floods

<<

N3k4rk

Peasant

Posts: 2

Joined: 17 Feb 2019, 21:21

Post 18 Feb 2019, 17:35

Techdemo: building walls, building/destroying bridge, floods

Hello everyone,

I would like to share a script I made. It is a techdemo for KaM Remake version r6720 that demonstrates some possibilities of dynamic environmental changes, specifically:
1. Building walls.
2. Flooding.
3. Destroying and reconstructing a bridge.

Youtube video:
https://www.youtube.com/watch?v=LF3CBQjf-Fw

I have attached the map here and you can also download the map from here: https://we.tl/t-h6M9BO3ySb


This map is meant to showcase some possibilities of scripting, not to provide a fun/challenging/balanced experience.

Note that if this map was properly balanced, in the phase after the bridge destruction, you would have to finish the bridge repairs before you run out of food because all food production buildings are on the other side of the river.

Other possible use of the ideas in this script: Simulate high/low tide. This could be an interesting dynamic in multiplayer maps. Make the area of probable battlefield periodically flood, thus creating additional challenge for players to make sure they finish the battle quickly or they risk loosing troops caught up in a fight.

Note: to achieve nice transition between water and land during flooding, I created 6 versions of the map, each with different state of flooding. I then used a script to export tiles (type, rotation) from a rectangular block and hardcoded those tile parameters to final script. A nicer way would be to create an algorithm that creates transitions automatically, similar to how the brush tool works in map editor. During each stage of flooding, the entire block is redrawn. Possible optimization is to redraw only if new tile is different from current one.

For the bridge, I used a similar approach, but I have also exported the tile height. But I only used 2 maps: bridge intact and bridge completely destroyed. Because I dont need nice transitions between tiles, I didnt have to create 50+ maps for bridge destruction and 16 maps for bridge recontruction.

Limitations of the script:
1. The code in script is not particulary robust (despite funcions being called "Robust..." :D).
2. Wall building needs updates: You shouldnt be able to build a wall on a tile where a unit is standing. Handling of collisions with buildings is undefined at this point. Merging od adjacent walls doesnt work properly (placing walls in positions other than immediate left/right/top/bottom of existing wall tends to produce garbage). Placing the tiles with white bricks around the top of the wall needs work. These issues can be largely solved by improving the code in the script. For now, an easier solution is to only allow automatic building on predefined positions, similar to how reconstruction of the bridge is implemented. This makes it also easier to create ramps that allow soldiers to get on top of the walls. Also, currently it is possible to completely surround the village with walls, making it impossible for enemy to attack (another issue that can be easily solved by making it possible to build only on predefined places). This might be solvable within the script though.
3. It is impossible to destroy wine/fields. Thus, it is impossible to flood farms. This is a limitation of the current version of KaM Remake, not the script itself (at least I was unable to find functions to remove them). This is disappointing, because it makes it impossible to implement things like season changes: say you wanted to turn grass into snow (the kind on which you cannot build) and thus create challenge for the village to survive only on stored supplies for example. Same thing if you wanted to turn grass into desert.
4. During flooding and destroying the bridge, it is impossible to change the tile to a non-walkable (water) if a unit is currently occupying it. Therefore the unit must be killed first. However, the tile doesnt become "changable" untill the death animation finishes (setting the kill to silent doesnt seem to help). This is currently handled by trying to set the whole tile block again after around 2.5 seconds. A better solution would be to keep track of tiles that failed to change and keep tring to change only those tiles.
5. Setting the tiles should only destroy houses/kill units on that tile if that tile demands it (eg. the tile is water). This would require a list of all tiles which demand destruction. The script currently implements a simple workaround: it doesnt destroy only if the new tile is simple grass. This can be fixed by improving the script code.
6. Defeat conditions arent set and AI has only 1 basic attack specified.

If any of these limitations were removed in newer releases of KaM, please let me know.

Feel free to use this as a base for your own maps/scripts. If you'd let me know you used it though, that would be appreciated! :D
You do not have the required permissions to view the files attached to this post.
<<

grayter

Barbarian

Posts: 101

Joined: 18 Aug 2014, 12:06

Location: Poland

KaM Skill Level: Skilled

Post 19 Feb 2019, 15:54

Re: Techdemo: building walls, building/destroying bridge, fl

One of my uncompleted mission of On Foreign Lands 2 campaign has scenario with flooded terrains. This was tested many times by few players and it's a little bit unstable so I decided to not include this mission in campaign. Althougth idea is very refreshing. Maybe one day I share with my scripts :)

New dynamic scripting commands giva us possibilities to create brand new kam, it's worth to try different ideas :)

Good job!
<<

memerion2

User avatar

Blacksmith

Posts: 28

Joined: 07 Aug 2017, 16:22

Location: Poland

KaM Skill Level: Skilled

Post 20 Feb 2019, 12:56

Re: Techdemo: building walls, building/destroying bridge, fl

N3k4rk

Try this script for building wall:
https://drive.google.com/open?id=1KhK77 ... 8KHkVESf7s

My Script for building walls is not finished.

Storehouse must have 5 or more stones and repair enabled, then you must place road plan.

Thats working for all storehouses, doesn't metter where he is.
<<

sado1

User avatar

Moorbach's Guard

Posts: 1391

Joined: 21 May 2012, 19:13

KaM Skill Level: Skilled

Post 23 Feb 2019, 11:56

Re: Techdemo: building walls, building/destroying bridge, fl

It is impossible to destroy wine/fields

Maybe it's worth trying to make the script put a road over them, then destroy the road? I got a feeling it might work.
<<

grayter

Barbarian

Posts: 101

Joined: 18 Aug 2014, 12:06

Location: Poland

KaM Skill Level: Skilled

Post 23 Feb 2019, 13:47

Re: Techdemo: building walls, building/destroying bridge, fl

sado1 wrote:
It is impossible to destroy wine/fields

Maybe it's worth trying to make the script put a road over them, then destroy the road? I got a feeling it might work.


It doesn't work. I spoke about it with Rey during my campaign testing but it seems to be complicated a little bit.
<<

cmowla

User avatar

Knight

Posts: 403

Joined: 04 Aug 2013, 19:59

Location: United States

KaM Skill Level: Expert

Post 26 Feb 2019, 05:44

Re: Techdemo: building walls, building/destroying bridge, fl

At first I thought this was a request thread. But I saw the video, and I am impressed!

The ability to build walls would make my building fence strategy unnecessary. LOL. But it would change the game too much I think.

And the flooding was very neat. Kind of reminds me of my old Sim City 3000 game where natural disasters would occasionally come and disrupt building progress of your city.
Invasion and Lava Valley with 0 losses|Invasion (without saves)|TSK 20 in 4.47 minutes|Northern Islands I Co-op in 1.71 hours
What makes me an Expert isn't my skill in of itself but my desire to win big.
<<

thunder

User avatar

Moorbach's Guard

Posts: 1020

Joined: 15 Apr 2012, 12:11

Location: In the Market

KaM Skill Level: Fair

Post 26 Feb 2019, 10:05

Re: Techdemo: building walls, building/destroying bridge, fl

Hi,

I don't like to read, mainly too much, but watched the video. Interesting script!
I could imagine the walls in the multiplayer games, but I guess should limitate the usage of them and probably would need units what could counter them. (Anyway as far as I know there is already a wall script, a bit different one. The wall is wider and can walk through at some points.)

Developing your idea a bit further- what do you think about digging trenchs? :P For example there are several opened maps where there is enough space on the battle field to dig some tiles. It has pro and cons of course. I would limit this in 5-6tiles/player, and would do it removable-using stone or wood to covering the digged tiles and of course a builder. I think 4 players already could eliminate a location together and filling up these digged tiles could be a strategical element of the game.

Anyway nice to see the dynamic scripts are still gives new things:)
<<

N3k4rk

Peasant

Posts: 2

Joined: 17 Feb 2019, 21:21

Post 27 Feb 2019, 18:08

Re: Techdemo: building walls, building/destroying bridge, fl

memerion2:
I see you went with the approach of only raising a single vertex and (like me) struggle with making the surrounding wall look nice.

sado1:
I've tried it and when I remove the road, the field comes back.

Regarding balancing walls, it still seems to me that the easiest way is to simply only allow building at predefined locations. And probably only in single-player maps. Maybe making them very expensive in multiplayer, so a player will have to decide if he wants many soldiers or few soldiers+walls.

As for trenches, making the diggers actually dig them might not be possible, because I think setting the tile height will fail if there is a unit on that tile, haven;'t tested it though (maybe it will only fail if it would cause the digger to get stuck, but what good is a trench if a unit can easily get out? :D). Same with filling them again.
<<

thunder

User avatar

Moorbach's Guard

Posts: 1020

Joined: 15 Apr 2012, 12:11

Location: In the Market

KaM Skill Level: Fair

Post 28 Feb 2019, 08:43

Re: Techdemo: building walls, building/destroying bridge, fl

Trench = negative wall.
:wink:
I'm not sure about how large steepness difference needs between the sides to can not be walkable.

Return to Dynamic Scripting

Who is online

Users browsing this forum: No registered users and 5 guests

cron