Difference between revisions of "Manual:DIL Changes"

From DikuMUD Wiki
Jump to navigation Jump to search
Line 14: Line 14:
 
Let's look at a Midgaard town guard, a quick wstat guard func shows:     
 
Let's look at a Midgaard town guard, a quick wstat guard func shows:     
  
dilcopy rescue@function("guard/captain/mayor");      
+
#dilcopy rescue@function("guard/captain/mayor");     dilcopy #arrest_check@midgaard("accus_room@midgaard");       
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();       
 
  
 
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.  
 
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.  

Revision as of 03:20, 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"); 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.

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 gargabe 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.