Area Building

· Home
· Overview
· Helps
· Mobiles
· Objects
· Rooms
· Resets

· Shops
· Specials
· Time
· Weather
· Scripts


Functions:

In addition to mob and object attributes, there are some built in functions which may prove usefull.

Functions cannot be used in normal statements. That is you cannot do:

if (@hour() == 5) {
 Say It's @hour()
}

If you want to use the value of a function in a normal mud statement. You must assign it to a variable first, the following would set the v1 slot of an object to a random number between 1 and 100.

declare $myrandom number
if ($o) {
  $myrandom = @rand(1,100);
  mpset $o v1 $myrandom
}

 

@add(int1, int2)

This simply adds two integers together.

if ($myCounter > 0) {
 $myCounter = @add($myCounter, 1)
}

@cansee(arg1, arg2)

arg1 and arg2 can be either a room, object, or character reference. Returns true if arg1 can see arg2.

if (@cansee($i, $n)) {
 Say I can see you!
} else {
 say who's that?
}

@dice(number, sides)

This simply rolls <number> dice with <sides> and sums up the results. 

$damage = @dice(4, 6)

@divide(int1, int2)

This simply divides int2 into int1. Note that this is an integer calculation.. you will not get floating point values, nor is the result currently rounded.

$xp = @divide($i.level, 2)

@hasmob($i, vnum)

This method returns whether or not room $i contains a mob of the given vnum. 

if (@hasmob($n.in_room, 11739)) {
   echoat $n You notice a green monkey hanging around.
}

@hasquest(player, questid)

This method returns whether or not the player is (or has) run a given quest. 

if (@hasquest($n, 7)) {
   say Thank you for saving my son!
}

@hasjournalentry(player, subject)

This method returns whether or not the player has an entry in their journal with a matching subject. This only checks current journal entries on the player, so if an entry is removed this function has no way of knowing that. 

if (@hasjournalentry($n, "A sample journal entry")) {
   -- do nothing
} else {
   say Hey I have a story to tell you...
   mpechoat $n You write down this person's story in your journal.
   mpjournal $n subject A sample journal entry
   mpjournal $n + This is a really basic journal entry.
   mpjournal $n post
}

@hitprct($n)

Returns the hit percentage of $n.

if (@hitprct($n) < 5) {
 Say you're about to die!
}

@hour()

This will return the current hour of day as an integer

if (@hour() == 5) {
 Say It's 5 am!
}

@isaffected($n, flag)

Returns true if $n is affected by flag. In this case 'flag' must be the letter of the flag as describe in the #MOBILES section. i.e. 'A' is blind etc.

if (@isaffected($i, A)) {
 say damn I'm blind!
} else {
 say i can see!
}

@iscarrying($n, vnum)

Returns true if $n is carrying vnum

if (@iscarrying($n, 20)) {
 Say hey you have a magic mushroom!
}

@isfighting($n)

This method returns whether or not the character is fighting or not. 

if (@isfighting($n)) {
 say Rabble Rouser!
}

@isnpc($n) (or $r, $t etc)

Works just the opposite of @ispc().

@ispc($n) (or $r, $t etc)

Returns true or false if $n is a player

if (@ispc($n)) {
 say hiya $n.name!
} else {
 say hiya $n.short_descr!
}

@isremort($n)

This method returns whether or not the character (pc) is a remort or not. 

if (@isremort($n)) {
  say Couldn't get enough the first time around eh?
}

@isrunningquest(player, questid)

A bit more detailed that @hasquest, this method returns whether or not the player is currently running a given quest.  A player is running a quest if the 'state' of the quest is less than the maximum state. i.e. if a quest has 5 states, the player will be considered to be running the quest as long as the quest state is less than 5.

if (@isrunningquest($n, 7)) {
   say Hurry, time is running out!
}

@isset(flag, bit)

This method returns whether or not the specified bit is set in the given flag. 

if (@isset($n.vuln_flags, H)) {
   mpcast fireball $n
}

-- if they're vuln fire, nail them!

@iswearing($n, vnum)

Returns true if $n has vnum equipped.

if (@iswearing($n, 6621)) {
 Say you're wearing a linen robe!
}

@multiply(int1, int2)

This simply multiplies two integers together.

if ($myMoney < 100) {
 $myMoney = @multiply($i.level, 4)
}

@rand(low,hi)

Returns a random integer between the low and hi numbers

if (@rand(1,100) < 51) {
 Say this fires 50% of the time!
}

If (@rand(1,2) < 2) {
 Say this fires 50% of the time too!
}

@subtract(int1, int2)

This simply subrtracts int2 from int1.

if ($myCounter > 10) {
 $myCounter = @subtract($myCounter, 1)
}

@systime()

This will return the number of seconds since 1970, standard unix timestamp. The following code will result in the mob saying something like "It's 1048712060".

declare $thetime number
$thetime = @systime();
Say It's $thetime!