PDA

View Full Version : Script question.



Alarti
January 3rd, 2015, 06:22
I looked through the guide for scripts online, and I couldn't seem to figure one thing. If I per say wanted to have 3 level 5 barbarians come down on my imp claiming a certain piece of land, how could I do that? I know it involves the action point but I can't manage to figure out what the actual script command is. Thanks in advance!

Metal Gear Rex
January 3rd, 2015, 06:55
I looked through the guide for scripts online, and I couldn't seem to figure one thing. If I per say wanted to have 3 level 5 barbarians come down on my imp claiming a certain piece of land, how could I do that? I know it involves the action point but I can't manage to figure out what the actual script command is. Thanks in advance!

You need to have the action point on the map placed by a map editor, you can't do that in script. So there is the main limitation in that the location you're looking to drop Heroes (or any alignment creature) is pre-set.

With the necessary action point, you can then put in the following script.


IF_ACTION_POINT(​x,PLAYER0)
ADD_CREATURE_TO_LEVEL(​PLAYER_GOOD,BARBARIAN,x,3 ,​5,​0)
ENDIF

Where x is the action point.

Another limitation is that DK1 doesn't differentiate between creatures for APs, so any creature will set off the script.

Alarti
January 3rd, 2015, 07:11
Thankyou, this is what I was looking for. Another issue I'm seeming to have is that my first tunneler party will enter which is 2 giants, 1 witch, 1 dwarf, 1 tunneler. However, my second party of 4 archers and parties after that do not arrive? What could be causing this? Would it help for me to link the script?

YourMaster
January 3rd, 2015, 09:50
Yes, post the script.

Alarti
January 3rd, 2015, 20:27
REM ********************************************
REM
REM Script for Level 207
REM
REM ********************************************

SET_GENERATE_SPEED(500)

START_MONEY(PLAYER0,7500)

MAX_CREATURES(PLAYER0,15)

ADD_CREATURE_TO_POOL(HELL_HOUND,11)
ADD_CREATURE_TO_POOL(TENTACLE,15)
ADD_CREATURE_TO_POOL(SORCEROR,7)
ADD_CREATURE_TO_POOL(BILE_DEMON,9)
ADD_CREATURE_TO_POOL(DARK_MISTRESS,15)
ADD_CREATURE_TO_POOL(DRAGON,5)
ADD_CREATURE_TO_POOL(VAMPIRE,3)
ADD_CREATURE_TO_POOL(ORC,30)

REM Creature availability
CREATURE_AVAILABLE(PLAYER0,HELL_HOUND,1,1)
CREATURE_AVAILABLE(PLAYER0,TENTACLE,1,1)
CREATURE_AVAILABLE(PLAYER0,SORCEROR,1,1)
CREATURE_AVAILABLE(PLAYER0,BILE_DEMON,1,1)
CREATURE_AVAILABLE(PLAYER0,DARK_MISTRESS,1,1)
CREATURE_AVAILABLE(PLAYER0,DRAGON,1,1)
CREATURE_AVAILABLE(PLAYER0,VAMPIRE,1,1)
CREATURE_AVAILABLE(PLAYER0,ORC,1,1)

REM Room availability
ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
ROOM_AVAILABLE(PLAYER0,TRAINING,1,1)
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,0)
ROOM_AVAILABLE(PLAYER0,BARRACKS,1,0)
ROOM_AVAILABLE(PLAYER0,GUARD_POST,1,0)
ROOM_AVAILABLE(PLAYER0,TORTURE,1,0)
ROOM_AVAILABLE(PLAYER0,TEMPLE,1,0)


REM Spells availability
MAGIC_AVAILABLE(PLAYER0,POWER_HAND,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_CAVE_IN,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CALL_TO_ARMS,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_SPEED,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_PROTECT,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_LIGHTNING,1,0)
MAGIC_AVAILABLE(PLAYER0,POWER_CONCEAL,1,0)
MAGIC_AVAILABLE(pLAYER0,POWER_DESTROY_WALLS,1,0)

REM Doors and traps availability
TRAP_AVAILABLE(ALL_PLAYERS,ALARM,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,POISON_GAS,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LAVA,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,STEEL,1,0)
DOOR_AVAILABLE(ALL_PLAYERS,MAGIC,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,LIGHTNING,1,0)
TRAP_AVAILABLE(ALL_PLAYERS,WORD_OF_POWER,1,0)

CREATE_PARTY(DUNGEON)
ADD_TO_PARTY(DUNGEON,GIANT,2,250,ATTACK_ENEMIES,0)
ADD_TO_PARTY(DUNGEON,GIANT,2,250,ATTACK_ENEMIES,0)
ADD_TO_PARTY(DUNGEON,DWARFA,3,300,ATTACK_ENEMIES,0 )
ADD_TO_PARTY(DUNGEON,WITCH,3,500,ATTACK_ENEMIES,0)

CREATE_PARTY(ONE)
ADD_TO_PARTY(ONE,ARCHER,4,350,ATTACK_ENEMIES,0)
ADD_TO_PARTY(ONE,ARCHER,4,350,ATTACK_ENEMIES,0)
ADD_TO_PARTY(ONE,ARCHER,4,350,ATTACK_ENEMIES,0)
ADD_TO_PARTY(ONE,ARCHER,4,350,ATTACK_ENEMIES,0)

CREATE_PARTY(TWO)
ADD_TO_PARTY(TWO,FAIRY,5,400,ATTACK_ENEMIES,0)
ADD_TO_PARTY(TWO,FAIRY,5,400,ATTACK_ENEMIES,0)
ADD_TO_PARTY(TWO,FAIRY,5,400,ATTACK_ENEMIES,0)
ADD_TO_PARTY(TWO,FAIRY,5,400,ATTACK_ENEMIES,0)

CREATE_PARTY(THREE)
ADD_TO_PARTY(THREE,MONK,6,1000,ATTACK_ENEMIES,0)
ADD_TO_PARTY(THREE,MONK,6,1000,ATTACK_ENEMIES,0)
ADD_TO_PARTY(THREE,MONK,6,1000,ATTACK_ENEMIES,0)
ADD_TO_PARTY(THREE,MONK,6,1000,ATTACK_ENEMIES,0)

CREATE_PARTY(BOX)
ADD_TO_PARTY(BOX,FAIRY,6,250,ATTACK_ENEMIES,0)
ADD_TO_PARTY(BOX,BARBARIAN,5,600,ATTACK_ENEMIES,0)
ADD_TO_PARTY(BOX,BARBARIAN,5,600,ATTACK_ENEMIES,0)
ADD_TO_PARTY(BOX,BARBARIAN,5,600,ATTACK_ENEMIES,0)

CREATE_PARTY(LANDLORD)
ADD_TO_PARTY(LANDLORD,KNIGHT,10,5000,ATTACK_ENEMIE S,0)
ADD_TO_PARTY(ARCHER,10,1000,ATTACK_ENEMIES,0)
ADD_TO_PARTY(ARCHER,10,1000,ATTACK_ENEMIES,0)
ADD_TO_PARTY(MONK,10,3000,ATTACK_ENEMIES,0)
ADD_TO_PARTY(MONK,10,3000,ATTACK_ENEMIES,0)

cREATE_PARTY(SURPRISE)
ADD_TO_PARTY(SURPRISE,GIANT,7,2000,ATTACK_ENEMIES, 0)
ADD_TO_PARTY(SURPRISE,GIANT,7,2000,ATTACK_ENEMIES, 0)
ADD_TO_PARTY(SURPRISE,GIANT,7,2000,ATTACK_ENEMIES, 0)
ADD_TO_PARTY(SURPRISE,GIANT,7,2000,ATTACK_ENEMIES, 0)

REM ************************************************** **************************

REM "Your location is already known to the heroes of this land. They have moved quickly to mobilise their forces against you."
DISPLAY_OBJECTIVE(122,PLAYER0)

IF(PLAYER0,GAME_TURN >= 8500)
ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,DUNGEON,-2,DUNGEON,0,1,250)
ENDIF

IF(PLAYER0,GAME_TURN >= 9500)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,-1,DUNGEON,0,1,250)
ENDIF

IF(PLAYER0,GAME_TURN >= 11000)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,-3,DUNGEON,0,1,250)
ENDIF

IF(PLAYER0,GAME_TURN >= 14000)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,THREE,-3,DUNGEON,0,1,250)
ENDIF

IF(PLAYER0,GAME_TURN >= 16000)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,SURPRISE,-2,0,1,250)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,ONE,-1,DUNGEON,0,1,250)
ENDIF

IF(PLAYER0,GAME_TURN >= 22000)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,SURPRISE,-2,0,1,250)
REM "The enemy are upon us. I'm just telling you in case you were having a doze."
DISPLAY_INFORMATION(103)
ENDIF

IF(PLAYER0,GAME_TURN >= 23000)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,THREE,-3,DUNGEON,0,1,250)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,BOX,-1,DUNGEON,0,1,250)
ENDIF

IF(PLAYER0,GAME_TURN >= 29000)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,SURPRISE,-2,0,1,250)
ENDIF

IF(PLAYER0,GAME_TURN >= 35000)
ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,BOX,-2,DUNGEON,0,1,250)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,TWO,-1,DUNGEON,0,1,250)
ADD_TUNNELER_PARTY_TO_LEVEL(PLAYER_GOOD,LANDLORD,-3,DUNGEON,0,1,250)
REM "You've upset the local Lord. He's on his way right now. Shall I alert the media?"
DISPLAY_OBJECTIVE(123,PLAYER0)
ENDIF

IF_ACTION_POINT(1,PLAYER0)
ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,FAIRY,1,3,5,0)
ENDIF

IF_ACTION_POINT(2,PLAYER0)
ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WIZARD,2,2,7,0)
ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,DWARFA,2,2,7,0)
ENDIF

IF_ACTION_POINT(3,PLAYER0)
ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,BARBARIAN,3,3,5, 0)
ENDIF

IF_ACTION_POINT(4,PLAYER0)
ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,SAMURAI,4,2,10,0 )
ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,GIANT,4,2,10,0)
ADD_CREATURE_TO_LEVEL(PLAYER_GOOD,WITCH,4,1,10,0)
ENDIF

IF(PLAYER_GOOD,DUNGEON_DESTROYED ==1)
WIN_GAME
ENDIF

Mind you that this script is not necessarily "finished". I'm just curious as to why my hero parties to not respond. The first one arrives just fine, but the second and others after that do not arrive.

YourMaster
January 3rd, 2015, 22:40
Well, that is a very easy question to answer: you keep writing 'TUNNELLER' wrong in the ADD_TUNNELLER_PARTY_TO_LEVEL command. You are writing TUNNELER.
After that, you will also have several issues with the 'LANDLORD' party.

To work with scripts, try the notepad++ plugin I shared here ('https://keeperklan.com/threads/4802-DK-Level-script-plugin-for-Notepad') or use one of these ('http://keeper.lubiki.pl/html/dk1_tools_script.php') scripting tools.

Additional tip: If you post your script here on the forum, put it between [code] tags so it doesn't take up the entire screen.

Alarti
January 3rd, 2015, 22:50
Doh >.<. Have to admit that i am just a noob when it comes to map making and writing these scripts in general so thank you for correcting a simple mistake! :).

Edit: What scripting tool would you suggest would best suit a new scripter?

YourMaster
January 3rd, 2015, 23:05
Well, the scripting guide (http://keeper.lubiki.pl/dk1_docs/dk_scripting_ref.htm) is good to have, and if you want to use the additional KeeperFX commands this wiki page (https://code.google.com/p/keeperfx/wiki/NewLevelScriptCommands) as well.

As for what tool to use, it doesn't really matter much, the script language is quite simple but almost all of the problems people have are caused by typo's. If you use the adikted editor you might as well use that to verify your scripts, it is the most powerful one.
I use Notepad++ myself as I just like that as a text-editor, and with the syntax highlighter and type-ahead functionality it is hard to make mistakes.

Alarti
January 3rd, 2015, 23:28
Odd. It would seem my "Surprise" party is not coming in when it's supposed to. Other parties thus far have come in when they're supposed to but not this one. Any idea why?

YourMaster
January 3rd, 2015, 23:39
Yes, you are missing the 'head for' parameter on the command you use to spawn the surprise party..

So two more hints:
* If a command isn't working, compare it to the scripting guide to see if it matches
* When you run the map in KeeperFX and it has an error, the keeperfx.log file will tell you what it is. Open that with a text editor and search for 'error'.

Alarti
January 3rd, 2015, 23:54
Okay, so I fixed the simple mistakes and reviewed the guide you gave me (thankyou) and played through the map. The one remaining problem is that the Lord of the land's party spawns, but it does not spawn with the monks or archers. any idea as to why this happens?

YourMaster
January 4th, 2015, 00:00
Well yes, I already said you would get problems with this,.... You have forgotten the party name when adding the monks and archers to that party. Also, you have an additional space in 'ATTACK_ENEMIE S'

Alarti
January 4th, 2015, 00:04
Corrected and map finished. Thanks a ton for the help you've given me recently. Pardon my ignorance when it comes to the map editor as I'm just a beginner :). Will be making more maps and planning to compile them in some sort of campaign. Will also post any additional questions or discoveries I have here. Thanks again.

YourMaster
January 4th, 2015, 00:12
You're welcome, and no problem. All those questions so far have been easy enough to fix, they were commands you knew how to do as you did them right a couple of times, but simply made typo's or forgotten parameters.

Here (https://keeperklan.com/threads/4914-Guide-to-fun-DK1-maps) I have some tips on making fun maps, perhaps useful for you as well.