Function: integer delunit( filename : string ) ;
The name of the Unit file to be deleted
Returns an integer TRUE if deleted FALSE if not
delunit is used to delete files that are used with the 'Restore' and 'store' functions.
Example:
dilbegin chest_del ("arg : string /*filename to be deleted*/);
var
ret:integer;/*to hold the return value if deleted or not*/
code
{
ret:= delstr("chest.file");
if (!ret)
{
log ("File not deleted.");
quit;
}
sendtext("Chest file deleted[&]n",self);
quit;/*dil delete routine done
}
dilend
See Also Restore a Unit from a Unit file and Store Units to a Unit file.
Function: integer isplayer( pcname : string ) ;
the name of the player being checked
Returns an integer TRUE if pcname is a player FALSE if not
This function is used to find out if a string you pass to it is a player or not. This can be used and is used to find out if a player is truly a player that an Administrator is deleting with out having that player on line.
Example:
if (not isplayer(arg))
{
sendtext (arg+" is not a character.&n",self);
quit;
}
Function: integer check_password( u : unitptr, s : string ) ;
the unit that you want to check the password of
the password you are using to check
Returns an integer TRUE if pcname is the units password FALSE if not
This function checks the string against the units password and returns TRUE if they match.
Example:
if (not check_password(pc,arg))
{
sendtext (arg+" is not "+pc.name"'s password.",self);
quit;
}
Function: set_password( u : unitptr, s : string ) ;
the unit that you want to set the password of
the password you are using to set
This function sets a unit password it only works on Players characters of corse.
Example:
dilbegin aware do_password (arg:string);
var
prmt:string;
firstpwd:string;
i:integer;
tlist:stringlist;
code
{
if(self.type != UNIT_ST_PC) quit;
arg:="";
prmt:=self.prompt;
self.prompt:="Enter new password: ";
wait (SFB_CMD,self==activator);
block;
tlist:=getwords (excmdstr);
if (length(tlist)>1){
sendtext ("Password must be only one word. Try again.&n",self);
self.prompt:=prmt;
quit;
}
if (length(excmdstr)<5){
sendtext ("Password to short. Password must be 5 characters or longer. Try again.&n",self);
self.prompt:=prmt;
quit;
}
if (length(excmdstr)>16){
sendtext ("Password to long. Try again.&n",self);
self.prompt:=prmt;
quit;
}
firstpwd:=excmdstr;
self.prompt:="Enter password again: ";
wait (SFB_CMD,self==activator);
block;
if (excmdstr!=firstpwd){
sendtext ("Passwords do not match try again.&n",self);
self.prompt:=prmt;
quit;
}
set_password(self,excmdstr);
sendtext("Changed your Password to '"+excmdstr+"' Please write it down!&n",self);
self.prompt:=prmt;
quit;
}
dilend
Function: checkdelete_player( s : string ) ;
the player name you want to delete
This function deletes a player but it doesn't check to see if it was deleted or if it even existed you will have to do that with 'isplayer'.
Example:
dilbegin aware do_delete (arg:string);
var
temp:string;
err:integer;
code
{
if(self.type != UNIT_ST_PC) quit;
if (self.level>200)
goto admin_delete;
:char_delete:
if (arg!="self forever")
{
sendtext ("To delete your char type: 'delete self forever'&n",self);
quit;
}
err:=loadstr("delete.txt",temp);
if (err<1)
goto no_insure;
sendtext (temp,self);
sendtext ("If your sure you still want to delete your character, 'say delete me'&n",self);
sendtext ("Doing anything else will abort the deletion.&n",self);
wait (SFB_CMD, self==activator);
if (command ("say"))
if (argument=="delete me")
if (self.extra.[CLAN_RANK]!=null)
exec ("cdefect",self);
delete_player(self.name);
sendtext("Deletion aborted&n",self);
quit;
:no_insure:
if (self.extra.[CLAN_RANK]!=null)
exec ("cdefect",self);
delete_player(self.name);
quit;
:admin_delete:
if (arg=="self forever")
goto char_delete;
if (arg==""){
sendtext("You must supply a characters name to delete one.&n",self);
quit;
}
if (arg==self.name){
sendtext ("To delete self you need to type 'delete self forever'&n",self);
quit;
}
if (not isplayer(arg))
{
sendtext (arg+" is not a character.&n",self);
quit;
}
dilcopy ("god_delete@clans("+arg+")",self);
sendtext (arg+" has been deleted.&n",self);
quit;
}
dilend
Function: stringlist unitdir( match : string ) ;
The wild card file you want to match or '*' for all.
a Stringlist with all the filenames that match the 'match' argument.
The 'match' argument uses the same wild cards as the Linux 'ls' command so the following will work.
Match any character or group of characters
Match one of any character
Match one of a set of characters
Example:
"corpse*" matches: corpse.10938 corpse.whistler corpseofwhistler ...
"corpse?" matches corpse1 corpses corpse5 ...
"[abc]*" matches ability about cost back ...
"[a-z]*" about zoo man father ...
"start[nm]end" matches startnend startmend
Example DIL:
dilbegin aware reload_corpse();
var
corpselist:stringlist;
u:unitptr;
ln:integer;
i:integer;
x:extraptr;
code
{
corpselist:=unitdir("corpse*");
ln:=length(corpselist);
i:=0;
while (i<ln)
{
u:=restore(corpselist.[i],null);
x:=CORPSE_EXTRA in u.extra;
if (u!=null)
if (x!=null)
link (u,findroom(x.descr));
else
link (u,findroom("temple@udgaard"));
i:=i+1;
}
quit;
}
dilend
The previous DIL example is the DIL used in restoring corpses to the game in case of a crash. For more information you can see how the death DIL'S work by reading through the file death.zon in the vme2.0/zone. directory.
Function: destroy ( u : unitptr );
:Unit to remove from game
The destroy function works in two ways depending on the Unit being acted on. If the Unit being acted on is a PC the player is saved and ejected from the game. If the Unit being acted on is a NPC, or an Object. the purge function destroys the Unit. Currently destroy will not destroy rooms. This is different from the old destroy function in that it removes the player out of the game instead of leaving the player in the menu.
Example
dilbegin purge_all_pc();
var
u:unitptr/*Unit used to purge each player*/
n:unitptr;/*used to keep track of next player*/
code
{
u:=ghead();/*get first pc in game list*/
n:=u;
while (n.type==UNIT_ST_PC)/*while unit is a pc*/
{
n:=u.gnext;
purge(u);
}
quit;/*done whiping out the players*/
}
dilend
Function: unitptr restore( filename : string , u : unitptr );
The name of the Unit file
The Unit you want to restore into or null if none
if 'u' null returns a pointer to the Unit loaded, if 'u' not null returns null and loads Units from the specified file into the unit 'u'
restore loads a copy of a unit or units which were previously saved with the 'store' command. Just as with "load", the unit is put inside the unit which executes the restore command unless the 'u' argument is not null. If the 'u' argument is an unitptr like room, object, npc, or pc the items restored will be placed inside the 'u' Unit..
Note, It is only possible to restore items as long as the main-database contains a reference for the unit 'name@zone'. Use 'Store' and 'Restore' sparingly - remember that items saved in player's inventories are automatically saved in their instance.
The 'store' and 'restore' are perfect for operations such as mud mailing objects from player to player, storage devices for players that will keep inventory through a reboot. Even the ability to save a players inventory while they fight in an arena and restore it to them undamaged when finished. finally it could be used to save a donation room through reboots since it can be used on a room to store the contents of a room any NPC or objects in the room would be saved through reboot.
Disk access is always slow. If you use 'Restore' on a continuous basis always attempt to keep file sizes to a minimum for quick loading. Otherwise you might cause serious delays on the server. If the Dil that uses Restore saves at certain times try to make it so the saves are spread out over as large amounts of time as possible.
Example 1:
dilbegin chest_load ();
var
waist:unitptr;/*to hold the null returned in this example*/
chest:unitptr;/*pointer to the storage chest*/
code
{
chest:=load ("chest@myzone");/*get the container*/
if (chest==null)
{
log ("Error");/*log an error*/
quit;
}
waist:=restore("chest."+self.zoneidx,chest);
/*
restore given filename into chest
waist can be ignored in this dil since it is not used.
*/
link (chest, self);/*link chest into room*/
quit;/*dil load routine done destroy self.*/
}
dilend
Example 2:
dilbegin chest_load ();
var
chest:unitptr;/*item to be loaded*/
code
{
chest:=restore("chest."+self.zoneidx,null);/*restore into chest*/
if (chest== null)/*see if something was restored*/
chest:=load("donate_chest@"+self.zoneidx);
/*load a new one if there is nothing restored*/
link (chest, self);/*link item into room*/
quit;/*destroy the load dil.*/
}
dilend
Note: Example 1 is to be used if 'storall' was used not storing a container. Example 2 is for items stored with 'store' with the container saved as well.
See Also Restore a Unit from a Unit file and Delete a Unit file.
Function:/send_PRE( c : string, a :unitptr, m : unitptr, t :unitptr, p : integer, arg : string, o : unitptr);
the command string that is sending the message
the unitptr (activator) that activated the message
the unitptr (medium) that the Dil is acting through
the unitptr (target) the Dil is acting on
the power of the message
the argument sent with the message
the unitptr (other) you also want the message to go to
This sends the 'SFB_DONE' message to any dils that are waiting for it in the surrounding area and to the other pointer if not null. The following is just one example you can find many more in commands.zon
Example:
dilbegin do_read (arg:string);
var
brdname : string;
i : integer;
u : unitptr;
x : extraptr;
ln : integer;
temp : string;
templist: stringlist;
buff : string;
f_name : string;
act_str : string;
code
{
i:=atoi (arg);
if (i<0)
{
exec ("look "+arg,self);
goto read_quit;
}
if (itoa (i)!=arg)
{
exec ("look "+arg,self);
goto read_quit;
}
u:=self.outside.inside;
while (u!=null)
{
if ((u.type==UNIT_ST_OBJ) and (u.objecttype==ITEM_BOARD))
break;
u:=u.next;
}
if (u==null)
{
act ("You do not see that here.",A_ALWAYS,self,null,null,TO_CHAR);
quit;
}
if (u.extra.["$BOARD_L_RES"].descr!="")
{
act_str:=u.extra.["$BOARD_L_RES"].descr(self,u);
if (act_str!="")
{
act(act_str,
A_ALWAYS,self,null,null,TO_CHAR);
quit;
}
}
brdname:=u.names.[length (u.names)-1];
i:=loadstr (brdname+".idx",temp);
if (i<=0)
{
act ("But the board is empty!",
A_ALWAYS,self,null,null,TO_CHAR);
goto read_quit;
}
templist:=split(temp,"&x");
ln:=length (templist);
x:="$BOARD_MAX" in self.extra;
if ((atoi(arg)>atoi(x.descr)) or
(atoi(arg)>ln))
{
act("That message exists only within the boundaries of your mind.",
A_ALWAYS,self,null,null,TO_CHAR);
goto read_quit;
}
i:=atoi(arg);
temp:=templist.[i-1];
f_name:=getword(temp);
i:=loadstr (brdname+"."+f_name,buff);
if (i==0)
{
sendtext("You have to let the poster finish the post before reading it.",self);
quit;
}
if (i<1)
{
log("05: Error when loading board info.");
act ("This board is not working report to an Adminstrator",
A_ALWAYS,self,null,null,TO_CHAR);
quit;
}
templist:=split(f_name,".");
if (length(templist)<2)
act ("Message "+arg+": "+temp,
A_ALWAYS,self,null,null,TO_CHAR);
else
act ("Message "+arg+": Re: "+temp,
A_ALWAYS,self,null,null,TO_CHAR);
pagestring(buff,self);
:read_quit:
send_done("read",self,null,u,0,arg,null);
quit;
}
dilend
Function:/send_PRE( c : string, a :unitptr, m : unitptr, t :unitptr, p : integer, arg : string, o : unitptr);
the command string that is sending the message
the unitptr (activator) that activated the message
the unitptr (medium) that the Dil is acting through
the unitptr (target) the Dil is acting on
the power of the message
the argument sent with the message
the unitptr (other) you also want the message to go to
takes same arguments as send_done but returns either SFR_SHARE or SFR_BLOCK.
If the command is blocked by another special or dil, then SFB_BLOCK will be returned, and you should quit your dil.
Example:
dilbegin cmdtst(arg : string);
var
i : integer;
code
{
i:=send_pre("cmdtest",self,null,null,0,argument,null);
if (i == SFR_BLOCK)
quit;
sendtext ("No one blocked me!&n",self);
quit;
}
dilend
dilbegin pretest();
code
{
:loop:
wait(SFB_PRE, command("cmdtest"));
block;
act("hahahaha I blocked your cmdtest command",
A_SOMEONE, activator, medium, null, TO_ALL);
goto loop;
}
dilend
Function: stop_fighting( ch: unitptr, vict : unitptr ) ;
unitptr - person you are stoping the fighting for
unitptr - person you are removing from the fighting or null for everyone
This function can be used to cancel combat in a room or with two people. The following example copied to a player will stop any fight the player is in.
Example:
dilbegin stop_combat();
code
{
stop_fighting(self,null);
quit;
}
dilend
Function: store( u : unitptr , filename : string , container : integer );
The Unit that has the contents to be stored or is to be stored
The name of the file you want to store the Units to
Do you want to save the container 'TRUE' for yes, 'False' for no
Store saves a copy of a unit or units. if the container value is 'TRUE' everything inside including the container itself will be saved. If the container argument is 'FALS' only the contents of the object will be saved. You will want to use the 'TRUE' value when saving something like a Clan chest that has items inside to store and has extras on the chest that you also wish to keep. The 'FALSE' value for container would be good for temporary storage of PC inventory or for storing room contents.
The 'store' and 'restore' are perfect for operations such as mud mailing objects from player to player, storage devices for players that will keep inventory through a reboot. Even the ability to save a players inventory while they fight in an arena and restore it to them undamaged when finished. finally it could be used to save a donation room through reboots since it can be used on a room to store the contents of a room any NPC or objects in the room would be saved through reboot.
Disk access is always slow. If you use store on a continues basis, it is essential that you do so ONLY if it is needed and even then, only at amply spaced intervals. Otherwise you might cause serious delays on the server. Remember that items saved in player's inventories are automatically saved in their instance.
Example 1:
dilbegin save_contents ();
code
{
:start:
wait (SFB_CMD,command ("store")); wait for the store command*/
block;
store("chest."+self.zoneidx,self,FALSE);/*store everything inside self.*/
goto start;
}
dilend
Example 2:
dilbegin save_container_n_contents ();
code
{
:start:
wait (SFB_CMD,command ("store")); wait for the store command*/
block;
store("chest."+self.zoneidx,self,TRUE);/*store everything inside self and self.*/
goto start;
}
dilend
See Also Store a Unit to a Unit file and Delete a Unit file.
Function: reset_level( u : unitptr ) ;
player your resetting
This function simply resets a players level. Can be used in functions like reroll where you set the players back to the way he first logged on.
Example: reset_level (u);
See Also
reset a players virtual level and
reset a players race information
Function: reset_vlevel( u : unitptr ) ;
player your resetting
This function simply resets a players virtual level. Can be used in functions like reroll where you set the players back to the way he first logged on.
Example: reset_vlevel (u);
See Also
reset a players level and
reset a players race information
Function: reset_race( u : unitptr ) ;
player your resetting
Reset a characters race, weight, height, age, lifespan, and costs for training. As if you first log on the character. Great for reroll along with 'reset_level' and 'reset_vlevel'.
Example: reset_race (u);
See Also
reset a players level and
reset a players virtual level
Function: meleedamage ( c : unitptr, v : unitptr, b : integer, wt : integer );
the character that should make an additional attack
the character being attacked
any penalty or bonus added to the attack.
the weapon type of the attack, if a valid type then that is used for the attack purpose, otherwise the default weapon/hand attack is used.
The amount of damage done or -1 for failed
ch' performs an attack (using whatever weapon is wielded or his bare hands) against 'vict'.
If wtype is within a valid weapon range (WPN_XXX) any weapon will be bypassed, and the value will be used as the attacktype. Good for things like "meleeattack(ch, vict, bonus, WPN_CIRCLE_KICK)" if you want person to be able to perform an extra attack even though wielding a weapon or something. Note that this will require BOTH a weapon type WPN_CIRCLE_KICK and a skill "kick" in order for it to work.
Example:
dilbegin kick(arg : string);
external
provoked_attack (victim : unitptr, ch : unitptr);
var
bonus : integer;
targ : unitptr;
code
{
if ((self.type == UNIT_ST_PC) and (self.weapons[WPN_KICK] <= 0))
{
act("You must practice first.", A_ALWAYS, self, null, null, TO_CHAR);
quit;
}
if (arg == "")
{
if (self.fighting)
{
targ := self.fighting;
goto kick;
}
act("Kick who?", A_SOMEONE, self, null, null, TO_CHAR);
quit;
}
targ := findunit(self, arg, FIND_UNIT_SURRO, null);
if ((targ == null) or not visible(self, targ))
{
act("That person is not here!", A_SOMEONE, self, null, null, TO_CHAR);
quit;
}
if (not (targ.type & (UNIT_ST_PC | UNIT_ST_NPC)))
{
act("You can't kick that, silly!", A_SOMEONE, self, null, null,
TO_CHAR);
quit;
}
if (targ == self)
{
act("You kick yourself.", A_HIDEINV, self, null, null,
TO_CHAR);
act("$1n kicks $1mself.", A_HIDEINV, self, null, null,
TO_ROOM);
quit;
}
if ((targ.type==UNIT_ST_PC) and
(self.type==UNIT_ST_PC))
{
if (not(isset (self.pcflags, PC_PK_RELAXED)))
{
act ("You are not allowed to do this unless you sign the book of blood.",
A_ALWAYS,self,null,null,TO_CHAR);
quit;
}
if (not(isset (targ.pcflags, PC_PK_RELAXED)))
{
act ("You are not allowed to do this unless $2e signs the book of blood.",
A_ALWAYS,self,targ,null,TO_CHAR);
quit;
}
}
:kick:
/* Penalty for wielding a weapon while kicking! */
if (equipment(self, WEAR_WIELD))
bonus := -25;
else
bonus := +25;
if (self.endurance < 2)
act("You are too exhausted to attempt that.", A_ALWAYS, self, null,
null, TO_CHAR);
else self.endurance := self.endurance - 2;
provoked_attack (targ, self);
bonus := meleeattack(self, targ, (bonus+self.level), WPN_KICK);
quit;
}
dilend
Function: unitptr getopponent( ch : unitptr, i : integer ) ;
NPC or PC you are checking
The number opponent you want to check.
Returns the (I)th NPC or PC in ch's list or null if there isn't one.an integer TRUE if deleted FALSE if not
This function allows you to spin through a NPC or PC's combat list so that you can deal with characters that are distance attacking and so you could attack people that you are not yet in full melee with
Example: Dil command to list people you are fighting with
dilbegin ch_combat (arg:string);
var
oppo:unitptr;
i:integer;
code
{
sendtext ("You are fighting the following:&n&n",self);
if (self.opponentcount==0){
sendtext ("NONE!",self);
quit;
}
oppo:=getopponent(self,0);
i:=1;
while (oppo!=null){
sendtext (oppo.name+"&n",self);
oppo:=getopponent(self,i);
i:=i+1;
}
quit;
}
dilend