Difference between revisions of "Manual:DIL Changes"

From DikuMUD Wiki
Jump to navigation Jump to search
Line 15: Line 15:
  
 
#dilcopy rescue@function("guard/captain/mayor");
 
#dilcopy rescue@function("guard/captain/mayor");
#arrest_check@midgaard("accus_room@midgaard");       
+
distribution.
 +
 
 +
So I've just uploaded a first version of alias, triggers and variables to GitHUB.
 +
 
 +
Works like this:
 +
 
 +
Three new commands implemented (in DIL):
 +
 
 +
alias
 +
trigger
 +
variable
 +
 
 +
Works like this:
 +
alias <name> commands
 +
variable <name> text
 +
trigger <name> /<trigger>/ commands
 +
 
 +
For the trigger command you must have the / / on each side of your regexp statement.
 +
 
 +
For example:
 +
alias fido goto fido;force fido tell papi bow fido
 +
alias tw tell whistler $1
 +
 
 +
variable friends papi|palio|john|bruce|the cityguard|the janitor|the beastly fido
 +
 
 +
$trigger obey /^the Beastly Fido tells you '(.+?)'/ $1
 +
$trigger guard /^(@friends)\sleaves (.+?)\.$/ say I love $1. Especially when $1 leaves $2
 +
 
 +
It's a pita to write JavaScript RegExp :o) But we can have some examples.
 +
 
 +
 
 +
As I'm writing this I'm realizing maybe I should also implement $0 to mean the whole string. Right now $1 is the first word, $2 is the second word, and so on. Or is there a better way?
 +
 
 +
Please feel free to comment and make suggestions.
 +
 
 +
PS. The test server is up, but I've deliberately messed up the output. So it looks totally odd. It's just temporary while I try to map using cMUD.
 +
#dilcopy arrest_check@midgaard("accus_room@midgaard");       
 
#dilbegin SFUN_PROTECT_LAWFUL time PULSE_SEC*60 bits SFB_RANTIME         
 
#dilbegin SFUN_PROTECT_LAWFUL time PULSE_SEC*60 bits SFB_RANTIME         
 
#dilbegin guard2();       
 
#dilbegin guard2();       

Revision as of 03:24, 3 July 2020

===== Temp list of changes. Will reorganize once I see what all we have. =====

Priority

How does a program determine it should run and pause others? When performing a wstat <unit> func command on an object, the dil functions will display in order of priority; top to bottom with most important dils at the top. If a dil program is executing the priority command, it will block all programs below it. Many of the stock game functions call on the priority or FN_PRI to function properly. A few examples of dils that should/do take priority:

  • Death ~ dilbegin recall fnpri(FN_PRI_DEATH) death_seq();
  • Rescue
  • Under Arrest ~ (dilbegin fnpri(FN_PRI_RESCUE-1)arrest_check(office:string);

We'll refer to this concept as 'fnpri'.

Let's look at a Midgaard town guard, a quick wstat guard func shows:

  1. dilcopy rescue@function("guard/captain/mayor");

distribution.

So I've just uploaded a first version of alias, triggers and variables to GitHUB.

Works like this:

Three new commands implemented (in DIL):

alias trigger variable

Works like this: alias <name> commands variable <name> text trigger <name> /<trigger>/ commands

For the trigger command you must have the / / on each side of your regexp statement.

For example: alias fido goto fido;force fido tell papi bow fido alias tw tell whistler $1

variable friends papi|palio|john|bruce|the cityguard|the janitor|the beastly fido

$trigger obey /^the Beastly Fido tells you '(.+?)'/ $1 $trigger guard /^(@friends)\sleaves (.+?)\.$/ say I love $1. Especially when $1 leaves $2

It's a pita to write JavaScript RegExp :o) But we can have some examples.


As I'm writing this I'm realizing maybe I should also implement $0 to mean the whole string. Right now $1 is the first word, $2 is the second word, and so on. Or is there a better way?

Please feel free to comment and make suggestions.

PS. The test server is up, but I've deliberately messed up the output. So it looks totally odd. It's just temporary while I try to map using cMUD.

  1. dilcopy arrest_check@midgaard("accus_room@midgaard");
  2. dilbegin SFUN_PROTECT_LAWFUL time PULSE_SEC*60 bits SFB_RANTIME
  3. dilbegin guard2();

In this example, the priority belongs to rescue. Therefore the expected behavior is that this guard will prioritize rescuing someone they see being attacked before rushing off to enforce peace or arrest someone. Secondarily, if rescuing is not an active option, the guard will arrest someone before trying to keep the peace. If the guard is interrupted in the middle of the execution of guard2(); above, the guard2(); program will simply pause until the higher priority dils are completed. In prior DIKU versions, there was no way to determine the dil insertion point on an object and therefore no way to predictably control execution order. So we introduce the following:

vme.h#define Integer Comment
FN_PRI_RES 0 Don't use
FN_PRI_SYS 1 functions dealing with death
FN_PRI_DEATH 2 functions dealing with death
FN_PRI_BODY 5 gaining hits, etc
FN_PRI_COMBAT 10 in-combat moves
FN_PRI_RESCUE 20 Rescue someone rather than passing by
FN_PRI_BLOCK 25 Blocking things like commands
FN_PRI_MISSION 30 Sent on an important mission
FN_PRI_CHORES 40 Picking up garbage or eating rabbits.

The 'Unique' DIL Flag

In DIKU III, we introduce the unique flag in a dil program. dilbegin unique programName();

This unique flag or keyword works to ensure that a unit will never have more than one of that function available on the object at any given time. This is a great way to cut down on the length of new dils because instead of having to do an if(dilfind) every time, you can simply use the unique flag. For example, if you create an entangle spell, and want to have a DIL that can be copied onto char's affected by entanglement, then the unique flag makes sure that even if the spell was cast twice on the same char, there would be only one instance of the entangle DIL running on that char.