PDA

View Full Version : Some scripting questions



Skarma
July 14th, 2020, 04:08
I created a level last year, nothing fancy, just something simple akin to the original Deeper Dungeons levels. It is playable from start to finish but I was never able to iron out the last few finishing touches in order to get it to play exactly how I intended. Without going into too many details, this is how the level plays out:

You're up against heroes and an enemy keeper. You play through the level in a semi-linear fashion, killing heroes and finding a few secrets until you eventually make it to the hero dungeon heart, which a few parties will then drop in to defend it. Upon destroying the heart, you can then attack and kill the enemy keeper. A short length of time after this, several parties including the Lord of the Land show up. Once you've killed them all and any remaining heroes on the map, two final really strong parties will then appear and killing these ends the level.

So my problems are:

1) Because this is my first serious attempt at making a proper map, I'm not too knowledgeable about scripting in general, let alone any new ones introduced with KeeperFX patches. The only way I was able to get everything to work exactly how I want was to use flags. The main reason I did this was a failsafe to prevent the player from sequence breaking the level, as you could in many of the official levels. The flags and map design go hand in hand. For example, it is completely impossible to reach the enemy keeper without first destroying the hero heart, which means you should not be able to trigger the Lord to show up before you've accomplished both of these. The flags make all of this possible for the most part but I now feel that there has to be a more efficient method to pull this off, the script otherwise doesn't look so great even if this doesn't matter.

2) I'm probably just doing something wrong here with the flags but, as mentioned above, the level is supposed to be completed upon the defeat of the final two parties, yet the game considers you've won the level as soon as they spawn and I can't find a way to make it not do so.

3) Is there any way I can set the enemy keeper AI or prevent it from being overly expansionist and not making a total mess of it's starting dungeon? I know the AI usually ends up doing this often in many maps, but the problem is that the moment you destroy the hero heart the walls all turn to earth and the AI immediately digs through it to start claiming territory. I want it to be the other way around, it's the player who has to go knocking on his door.

I think I had a couple of other points I thought of previously but I haven't really played the level since it was created so I've forgotten what they were, if there were any. I'll add them if I think of any more.

Any help or insight into these would be appreciated.

Cheers.

YourMaster
July 14th, 2020, 08:41
1) Flags are often the way to go

2) The victory condition spawns right before the units actually spawn, so in the split second before the heroes arrive in the level. Fix this by not setting a 'win_game' there, but a 'set_timer'. Then put the victory condition separate, under the condition that timer is above 40 or something (so you win 2 seconds after you kill all units).

3) Yes, pick a different computer player. One that fits your needs.

Skarma
July 16th, 2020, 00:29
The victory condition was already it's own thing. But I tried your suggestion and it still isn't working. I tried to make the last condition similar to how Sleepiburgh is completed, but even when a timer is added to when the party spawns, the level still completes once the value on the timer is reached and the parties are all still alive. This is now the only remaining issue with the level and it's getting a bit tiresome having to play it over and over just to get to the end and find it's not working correctly.

YourMaster
July 16th, 2020, 01:07
Share your script with me and I'll have a look.

Skarma
July 16th, 2020, 01:24
Here is the script. (https://pastebin.com/raw/pC5pfvPc)

YourMaster
July 16th, 2020, 01:38
Could you start the level that belongs to this script, then quit the game straight away, and share the keeperfx.log file?

Skarma
July 16th, 2020, 02:43
keeperfx.log (https://pastebin.com/raw/QgjnZZWu)

YourMaster
July 16th, 2020, 08:26
A, there it is. You forgot to put in 'level_version(1)', so your if_controls commands aren't recognized.

Beyond that, you've got a but too many flags, but it should work. You can also update your game, you're still at 0.4.6U, there's already many patches for the 0.4.7U version.

Skarma
July 17th, 2020, 03:53
That did the trick, thanks. I also removed the last two flags as I realised they were redundant when I could just make the defeat of the final party as the win objective. I updated to the latest patches and I've noticed that the quick objectives don't show up anymore but I'm not going to bother with that.

Now that the level is finally in fully working order, how can I go about uploading it?

YourMaster
July 17th, 2020, 08:57
The thing is, if you use KeeperFX script (which the level_version(1) indicates) some script commands work differently, most importantly the creature_available and quick_objective commands. Just take a quick look at the changed commands here (https://github.com/Loobinex/keeperfx-unofficial/wiki/New-and-Modified-Level-Script-Commands). Also, you can take a quick look at the log file yourself. Simply load the level for a few seconds, exit then look at keeperfx.log and and after 30 lines or so it says 'load_script', the lines before that display all the errors in the script, which makes it easy to fix.

For uploading, I'd start with simply making a topic here (https://keeperklan.com/forums/58-DK1-Maps).

0etelaer
May 13th, 2021, 10:41
3) Is there any way I can set the enemy keeper AI or prevent it from being overly expansionist and not making a total mess of it's starting dungeon? I know the AI usually ends up doing this often in many maps, but the problem is that the moment you destroy the hero heart the walls all turn to earth and the AI immediately digs through it to start claiming territory. I want it to be the other way around, it's the player who has to go knocking on his door.

:dig:AI Keepers will not dig anything; they only dig for rooms, to attack, and all along any rock.

If you want a player to get to a clean AI keepers wall, there are several strategies to achieve this.
Some examples:
1. Use rock instead of walls. The AI will surely dig along he edges of any rock though.
2. Use walls from another keeper, with one claimed tile of that keeper behind it. It can not dig that, and your player can dig there safely, until it claims the tiles. This trick is used in lots of custom levels.
3. Use the keepers wall around water or lava, where the AI keeper can not build a bridge. AI Keepers will not dig these walls, until a bridge is researched, or build there by another. I would do that in my map Controlled Demolition, and never saw the AI keeper dig that wall, until a bridge was build, while testing. Although there even was one tile beyond the wall to the lava. Big enough rooms would touch all off the wall there though; AI may still dig for it's own designed room, if free room is 3 or more tiles.