PDA

View Full Version : need help with script



Edwin
March 17th, 2014, 19:13
when i use this code in the script, i do get the :warlock:
but the library becomes available a lot later, instead of giving it when the :warlock: enters the dungeon.
the :warlock: comes in the level through a hero gate, at a timed event.
the code below is the Original code from the original Dungeon keeper maps as used in Wishvale.
just changed :orc: for :warlock:


IF(PLAYER0,SORCEROR > 0)
ROOM_AVAILABLE(PLAYER0,RESEARCH,1,1)
QUICK_INFORMATION(0,"A Sorceror joins you and brings with him the plans for building a Library. In this room you can research more spells and rooms.",PLAYER0)
ENDIF

mefistotelis
March 17th, 2014, 20:01
when i use this code in the script, i do get the :warlock:
but the library becomes available a lot later, instead of giving it when the :warlock: enters the dungeon.


DK checks one script line per game turn. If you're unlucky, it may take a few seconds for this particular part of script to be executed. But it may take seconds, not a lot later.

Ie. if there are 20 turns per second and script has 200 lines, the maximum time of waiting is less than 10 seconds (only some lines are added to the per-turn checklist, so it will be more like up to 6 seconds).

Edwin
March 17th, 2014, 20:31
i just timed the time it takes for the library to appear in the rooms section of the menu, 2 minutes after the sorceror appeared i got the library.

1386

mefistotelis
March 17th, 2014, 23:16
i just timed the time it takes for the library to appear in the rooms section of the menu, 2 minutes after the sorceror appeared i got the library.

With script written the way it is, it may take long before the condition is met.

Note that the DK script doesn't really work like typical programming language - it isn't sequential in the same manner.
You could even say it resembled hardware design languages is the area of sequencing instructions.

When the condition:

IF(all_players,TIMER0 > 2500)
is met, the lines inside it are not neccessarily executed in sequence - they may, for example, start with your line:

SET_TIMER(all_players,TIMER0)
If this will happen, no other instructions from IF block will be executed - because the condition will no longer be met.
The condition isn't checked once at the beginning of the block - it is checked for each instruction inside.

There is no reason for your condition:

IF(PLAYER0,SORCEROR > 0)
to be nested in TIMER0 check conditional. Close the conditional earlier and this will work better.

DragonsLover
March 18th, 2014, 02:40
Setting a timer for ALL_PLAYERS is kind of weird. Better use a normal player instead.

And yup, like Mefisto said, close the conditional earlier. You have a huge IF condition with all of the other IFs inside. Better separate them in many different small IFs.

Also, why setting the TIMER0 another time for no reason? If you want to do a loop, you know what command to do.

And I don't catch this:

IF(PLAYER3,DUNGEON_DESTROYED == 0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,0,0)
ENDIF

Just to mention: if you set a timer from the beginning and you don't plan to reset the timer, use IF(PLAYER0,GAME_TURN >= X) instead.

Edwin
March 18th, 2014, 08:52
Setting a timer for ALL_PLAYERS is kind of weird. Better use a normal player instead.

And I don't catch this:

IF(PLAYER3,DUNGEON_DESTROYED == 0)
MAGIC_AVAILABLE(ALL_PLAYERS,POWER_DISEASE,0,0)
ENDIF


the thing with the power_disease is that only player3 should be able to use it. so no other player can get the spell if player3's library is taken, after the dungeon is destroyed.

just removed the
set_timer(all_players,timer0) and placed and ENDIF, now it works.