If checks
From dodWiki
If checks are the primary mechanism by which irritable bowel syndrome allows builders to program conditional statements. SMAUG includes a number of 'if' conditions which can be within a standard if-then-else statement. A list of if checks and their arguments are below.
A few notes:
- The '==' operator can be replaced with any of the other operators.
- The argument '$*' refers to any of the variables which make sense for that if check. For exampe, for an if check which is referencing a person, the only valid variables would be $i, $n, $t or $r.
- A value type of string is a sequence of characters and does not need to be included in quotes. For example:
if name($n)== orc large brown
- An argument of x refers to any number
- An argument of y refers to any number 1-100 inclusive
| Contents: | Top - Hitprcnt - Inroom - Sex - Position - Level - Isnpc - Ispc - Mortal - Isimmort - Isgood - Isneutral - Isevil - Ispkill - Isfight - Ischarmed - Isfollow - Rand(#) - Isaffected - Number - Name - Clan - Guild - Race - Class - Mobinroom - *amt - Canpkill - Ismounted - Ismobinvis - Mobinvislevel - Economy - Isdevoted - Deity - Favor - Ability scores - Norecall - Doing_Quest - Council - Mana - Hit points - Ispacificist - Mobinworld - Mortinworld - Mortinarea - Mortinroom - Ispassage - Isopen - Islocked - WasInRoom - IsMulti - Time - Weight - MortCount - MobCount - CharCount - TimesKilled - Objtype - Ovnum<place> - Otype<place> - Objval - Cansee - Clantype - Isasupressed - Isleader - Ismorphed - Isnuisance - Nuisance - Ishelled - Multi - Waitstate - Sample Programs |
|---|
Hitprcnt
If Hitprcnt($*)==y Is the hit/max_hit of $* equal to percentage y?
e.g., If hitprcnt($i)==20 Are mob’s hit points at 20% of maximum?
Inroom
If Inroom($*)==x Is $* in room number x, where x equals a vnum?
e.g., If Inroom($n)==1200 Is the character that activated the trigger in room 1200?
Sex
If Sex($*)==# Is $* sex = to #? Valid # are: 0=Neuter, 1=male, or 2=female.
e.g., If Sex($n)==2 Is the character that activated the trigger female?
Position
If Position($n)==# Is $* in position #?
Valid positions are:
0=dead (character is dead) 1=mortal (character is mortally wounded) 2=incap (character is incapacitated) 3=stunned 4=sleeping 5=berserk (character is fighting in berserk style) 6=resting 7=aggressive (character is fighting in aggressive style) 8=sitting 9=fighting 10=defensive (character is fighting in defensive style) 11=evasive (character is fighting in evasive style) 12=standing 13=mounted (character is mounted on a mob) 14=shove (character is shoving something?) 15=drag (character is dragging something?)
e.g., If Position($n)==4 Is the character that activated the trigger sleeping?
Level
If Level($*)==# Is $* level #?
e.g., If level($n)==25 Is the character that activated the trigger level 25?
Isnpc
If Isnpc($*) Is $* an NPC?
e.g., If isnpc($n) Is the person that activated the trigger a mob?
Ispc
If Ispc($*) Is $* a player character (PC)?
e.g., If ispc($n) Is the character that activated the trigger a player?
Mortal
If Mortal($*) Is $* a mortal? (Not in use?)
e.g., If mortal($n) Is the character that activated the trigger lower than level 101?
Isimmort
If Isimmort($*) Is $* an immortal?
e.g., If Isimmort($n) Is the character that activated the trigger an immortal?
Isgood
If Isgood($*) Is $* alignment greater than or equal(>=) to 350?
e.g., If Isgood($n) Is the character that activated the trigger of good alignment?
Isneutral
If Isneutral($n) Is $* alignment between 350 and -350?
e.g., If isneutral($n) Is the character that activated the trigger of neutral alignment?
Isevil
If Isevil($*) Is $* alignment less than or equal(>=) to -350?
e.g., If Isevil($n) Is the character that activated the trigger of evil alignment?
Ispkill
If ispkill($*) Is $* a player killer, i.e., a deadly?
e.g., if ispkill($n) Is the character that activated the trigger a player killer?
Isfight
If Isfight($*) Is $* fighting?
e.g., If Isfight($n) Is the character that activated the trigger fighting?
Ischarmed
If Ischarmed($*) Is $* affected by charm?
e.g., If Ischarmed($i) Is the mob that caused the trigger charmed?
Isfollow
If Isfollow($*) Is $* following a "master"? (charmed mobs only)
e.g., If Isfollow($i) Is the mob that caused the trigger following its master?
Rand(#)
If Rand(#) SMAUG rolls a percentile of 1-100. Is the MUD's roll less than or equal to #? (# must be between 1 and 100 inclusive).
e.g., if rand(50) There is a 50% chance that this will happen.
Isaffected
If Isaffected($*)==<affect> Is $* affected by <affect>?
Affects: BLIND INVISIBLE DETECT_EVIL DETECT_INVIS DETECT_MAGIC DETECT_HIDDEN HOLD (not used) SANCTUARY FAERIE_FIRE INFRARED CURSE FLAMING (not used) POISON PROTECT PARALYSIS SNEAK HIDE SLEEP CHARM FLYING PASS_DOOR FLOATING TRUESIGHT DETECTTRAPS SCRYING FIRESHIELD SHOCKSHIELD HAUS1 (not sure about this) ICESHIELD POSSESS BERSERK (not sure about this) AQUA_BREATH RECURRINGSPELL (not sure about this) CONTAGIOUS (not sure about this)
e.g., If Isaffected($n)==hide Is the character that activated the trigger hidden?
Number
If Number($*)==<#> Is $*'s vnum equal to #? (not sure about this one)
e.g., If Number($i)==2100 Is the mob's vnum 2100?
Name
If Name($*)==<STRING> Does $* name field (first word of the field?) match the <STRING>?
e.g., If Name($n)==Tank Is the character that activated the trigger named Tank?
Clan
If Clan($*)==<STRING>Does $*'s clan equal the <STRING>?
e.g., If Clan($*)== Cthula Is the character that activated the trigger belong to the Cthula clan?
Guild
If Guild($*)==<STRING> Does $*'s guild equal the <STRING>?
e.g., If Guild($n)==Guild of Rangers Is the character that activated the trigger a member of the guild of rangers?
Race
If Race($*)==<STRING> Does $*'s race equal <string>?
Valid races: HUMAN ELF DWARF HALFLING PIXIE VAMPIRE HALF-OGRE HALF-ORC HALF-TROLL HALF-ELF GITH DROW SEA-ELF LIZARDMAN
e.g., If Race($n)==half-orc Is the character that activated the trigger a half-orc?
Class
If Class($*)==<STRING> Is $* a member of the <STRING> (class)?
Valid classes:(not sure if #'s listed can be used instead of <string>) 0. Mage 1. Cleric 2. Thief 3. Warrior 4. Vampire 5. Druid 6. Ranger 7. Augurer 8. Paladin 9. Assassin 10. Demon 11. Angel 12. Psionicist 13. **pc13 14. **pc14 15. pc15 16. pc16 17. pc17 18. pc18 19. **pc19 20. baker 21. butcher 22. blacksmith 23. mayor 24. king 25. queen ** do not use, stock (DoD only, ok to use)
e.g., If Class($n)==ranger Is the character that activated the trigger a member
Not sure: If Class($n)==6 of the ranger class?
Mobinroom
If Mobinroom(mobs vnum)==# Are there # number of mob #vnum in the room?
This check checks to see if and/or how many of a particular mob is/are in a room.
e.g., if mobinroom(3) > 1 Is there more than 1 mob(Vnum 3) in the room?
*amt
- can be any of the coin types of DoD: cp, sp, ep, gp, or pp
If ppamt($*)==# Is $*'s pp equal to #?
e.g., If cpamt($n)==1000 Does the character that activated the trigger have 1000 cp?
Note: this replaces the ifcheck 'goldamt' from stock SMAUG.
Canpkill
If Canpkill($*) Is $* a pkiller greater than level 5 and older than 18 years of age?
e.g., If Canpkill($n) Is the character that activated the trigger capable of pkilling?
Ismounted
If Ismounted($*) Is $* affected by mounted?
e.g., If Ismounted($i) Is the mob that activated the trigger mounted by another character?
Ismobinvis
If Ismobinvis($*) Is $* affected by mobinvis?
e.g., If Ismobinvis($i) Is Mob that activated the trigger mobinvis?
Mobinvislevel
If Mobinvislevel($*)==# Is $*'s mobinvis level equal to #?
e.g., If Mobinvislevel($i)>25 Is mobinviz level of the mob that activated the trigger greater than 25?
Economy
If Economy(rvnum)==# Is economy of area containing this room vnum equal to #? (only use >, =, or < operators)
Room vnum will determine the Area for economy only.
e.g., If economy(21001) > 10000000 Is the area's economy above 10000000?
Isdevoted
If Isdevoted($*) Is $* Devoted to a deity?
I.E. If Isdevoted($n) Is the character that activated the trigger devoted?
Deity
If Deity($*)==<STRING> Is $* devoted to <string>?
e.g., If Deity($n)==Tank Is the character that activated the trigger devoted to Tank?
Favor
If Favor($*)==# Is $*'s favor equal to # (# is number -1000 to 1000)
e.g., If Favor($n)<500 Is the favor of character that activated the trigger less than 500?
Ability scores
If <attribute>($*)==# Is character's specified attribute equal to #?
Valid Attribute scores: (# = 3-25). Keep in mind that only a character's prime attribute can go above 20. So, the only scores 21+ will be for a specific class' prime attribute. STR= Strength INT= Intelligence WIS= Wisdom DEX= Dexterity CON= Constitution CHA= Charisma LCK= Luck
e.g., If Dex($n)>18 Is the dexterity of the character that activated the trigger greater than 18?
Norecall
If Norecall($*) Does the room containing $* have a norecall flag?
e.g., If Norecall($n) Is the character activating the trigger in a no recall room?
Doing_Quest
If Doing_Quest($*) Not Implemented
Council
If Council($*)==<#> or <string>? Is $* a Member of <#> or <string> council?
Councils: CoE - Council of Elders TS - The Symposium NC - Newbie Council Pro - Primordial Circle PK - Pkill Conclave QC - Quest Council Neo - Neophyte Council CC - Code Council AC - Area Council
e.g., If Council($n)==9 Is character activating trigger a member of the area council?
Mana
If Mana($*)==# Does $*'s mana equal #?
e.g. If mana($n) > 100 Are the mana points of the character activating the trigger greater than 100?
Hit points
If Hps($*)==# Does $*'s hit points equal #?
e.g., If Hps($n) > 1900 Are the Hit points of the character activating the trigger greater than 1900?
Ispacificist
If Ispacifist($*) Is $* flagged as a pacifist? (Mob only)
e.g., If Ispacifist($i) Is the mob who activated the trigger a pacifist?
Mobinworld
If Mobinworld(mob vnum)==# Are there # of this mob throughout the whole MUD?
e.g., If Mobinworld(21044) < 1 Is there less than one mob #21044 in the MUD, i.e., are there none currently?
Mortinworld
If Mortinworld(Name) Is mortal named anywhere in the mud?
Mortinworld will work for both link dead as well as link live players.
e.g., If Mortinworld(Fred) Is the character 'Fred' on the mud?
Mortinarea
If Mortinarea(Name) Is mortal named anywhere in the area?
e.g., If Mortinarea(fred) Is 'Fred' in the area?
Mortinroom
If Mortinroom(Name) Is mortal named in the room?
e.g., If Mortinroom(Fred) Is 'Fred' in the room?
Ispassage
If Ispassage(dir #) - Does an exit to the (dir #) exists?
| Direction | Value |
|---|---|
| NORTH | 0 |
| EAST | 1 |
| SOUTH | 2 |
| WEST | 3 |
| UP | 4 |
| DOWN | 5 |
| NORTHEAST | 6 |
| NORTHWEST | 7 |
| SOUTHEAST | 8 |
| SOUTHWEST | 9 |
| SOMEWHERE | 10 |
Example: If Ispassage(6)
Is there a passage northeast?
Isopen
If Isopen(dir#) Is the dir# exit open? (Use ispassage dir#s)
e.g., Isopen(4) Is the exit up open?
Islocked
If Islocked(dir#) Is the dir# exit locked? (Use ispassage dir#s)
e.g., If islocked(2) Is the exit south locked?
WasInRoom
If WasInRoom($*)==(Room Vnum) Was $* in room vnum?
e.g., If Wasinroom($n) == 1200 Was the character who activated the trigger in room 1200?
IsMulti
If IsMulti(player name) Is player named Multi-playing?
Not sure if implemented.
Time
If Time==(time) Is it # o'clock? (Military time)
e.g., If Time==17 Is it 5pm?
Weight
If Weight($*)==# Does $* weigh #?
e.g., If Weight($n)>50 Does the character that activated the trigger weigh more than 50?
MortCount
If MortCount(room vnum)==# Are there # mortals in room vnum?
e.g., If Mortcount(21000) > 10 Are there more than 10 mortals in room vnum 21000?
If room vnum = 0 (use on mobs only) then this will count mortals in current room?
e.g., If Mortcount(0) > 10 Are there more than 10 mortals in the mob's current room?
MobCount
If MobCount(room vnum)==# Same as mortcount but counts the NPCs in room.
CharCount
If CharCount(room vnum)==# Same as mortcount but counts the NPCs and PC's in room?
TimesKilled
If TimesKilled($*)==# Has $* been killed # times? (For PC checks only)
I.E. If Timeskilled($n) > 200 Has the character that activated been killed more than 200 times?
Objtype
If Objtype($*)==<#> Is the type of $* equal to <#>
Valid types: **Not currently used
0. **NONE 1. LIGHT 2. SCROLL 3. WAND 4. STAFF 5. WEAPON 6. **FIREWEAPON 7. MISSILE 8. TREASURE 9. ARMOR 10. POTION 11. **WORN 12. FURNITURE 13. TRASH 14. **OLDTRAP 15. CONTAINER 16. NOTE 17. DRINK_CON 18. KEY 19. FOOD 20. MONEY 21. **PEN 22. BOAT 23. CORPSE_NPC 24. CORPSE_PC 25. FOUNTAIN 26. PILL 27. **BLOOD 28. **BLOODSTAIN 29. SCRAPS 30. PIPE 31. **HERB_CON 32. HERB 33. **INCENSE 34. **FIRE 35. **BOOK 36. SWITCH 37. LEVER 38. PULLCHAIN 39. BUTTON 40. DIAL 41. **RUNE 42. **RUNEPOUCH 43. **MATCH 44. **TRAP 45. **MAP 46. **PORTAL 47. PAPER 48. **TINDER 49. **LOCKPICK 50. **SPIKE 51. **DISEASE 52. **OIL 53. **FUEL 54. **EMPTY1 55. **EMPTY2 56. MISSILE_WEAPON 57. PROJECTILE 58. QUIVER 59. **SHOVEL 60. SALVE 61. **COOK 62. **KEYRING 63. **ODOR
e.g., If Objtype($o)==light Is $o a light?
If Objtype($o)==1 Is $o a light?
Ovnum<place>
If ovnum<place>(vnum)[==#] Are the number of items(vnum) in <place> equal to #? (For objects only)
<Place> definitions: Room: The room the mobile is in. Wear: Worn by the mobile as equipment Inv: In the mobile's inventory. Carry: Worn or in inventory. Here: All of the above
e.g., If OvnumRoom(10411)==2 Is the number of object #10411 in the room with the checker equal to 2?
If OvnumWear(10411) Is the checker equipped with 10411?
If OvnumInv(10411) Does the checker have 10411 in inventory?
If OvnumCarry(10411)==2 Does the checker have 2 of 10411 (inventory and equipped)
If OvnumHere(10411) Is 10411 in the checker's room, in inventory, or equipped?
Otype<place>
If otype<place>(type OR value)[==#] Same as 'if ovnum' except uses types instead of exact vnums.
For values and types see 'if objtype'
Objval
If Objval[#]($*)== # Is the value of val[#=Nil,1-5)] of $* equal to #?
This ifcheck returns the numeric value of the val# field of the object referenced by $*. If val# is not specified check assumes val0 is the value to check. See itemvalues for what these val# are.
e.g., If Objval($o)=10 Lets assume $o is a drink container. Is the containors's value 0 field set to 10? (value 0 for a drink container happens to be units of fluid)
Cansee
If Cansee($*) Can $* see?
e.g., If Cansee($n) Can the character that activated the trigger see?
The following ifchecks were found but not listed. Not sure if these work or not.
Clantype
If Clantype($*)==# Does $* belong to clan type #?
Clan types:
PLAIN
VAMPIRE
WARRIOR
DRUID
MAGE
CELTIC
THIEF
CLERIC
UNDEAD
CHAOTIC
NEUTRAL
LAWFUL
NOKILL
ORDER
GUILD
e.g., if clantype($n)==13 Is character a member of an order (clantype)
Not sure about the clantype#
Isaupressed
If Isasupressed($*)==# Is $* asupress timer equal to #?
e.g., If Isasupressed($n) > 10 Is the asupress timer for character that activated the trigger greater than 10?
Isleader
If Isleader($*) Is $* a leader of a clan, guild, or order?
Ismorphed
If Ismorphed($*) Is $* morphed?
Isnuisance
If Isnuisance($*) Has $* been flagged as a nuisance? (PC only)
Nuisance
If Nuisance($*)==# Is $* nuisance level equal to #? (Not sure if ==# is a valid argument)
Ishelled
If Ishelled($*) Is $* currently helled?
Multi
If Multi($*)==# Does $* have # of characters logged on? Also applies to MOBs, objects, rooms but I'm not sure how.
e.g., If Multi($n)>4 Does the character activating the trigger have more than 4 PCs logged on?
Waitstate
If Waitstate($*)==# Does $*'s "Wait" state equal #? (PC only)
Sample Programs
Comments are in brackets: [Comments]
Program 1: Basic shopkeeper greet program
mpedit joe add greet 100 [Add a 100% greet prog to "Joe" ]
if ispc($n) [Check if triggerer is Player ]
mea $n Greetings $n! [If True: Echo at Player {phrase}]
else [Otherwise ]
say Hello, $I. [If False: say "Hello" to NPC ]
endif [Every "if" MUST have an "endif" ]
Program 2: A simple bribe program
mpedit joe add bribe 1000 [Add bribe program, cost 1000 coins] if ispc($n) [Is it a Player? ] mea $n Here's your key, $n [True: Echo at Player ] mpoload 1000 0 [Load object 1000 at level 0 ] give key $n [Give key to Player ] else [Otherwise ] say Thanks for the gold, chump! [False: say phrase ] endif [Endif to match If ]
Program 3: A simple act program
mpedit joe add act p heal me [Add act prog triggered by phrase] if ispc($n) [Is it a Player? ] if isevil($n) [True: Is player evil? ] say I don't heal evil people! [True: say phrase ] else [Otherwise ] say I will heal you, $n. [Not evil (False): say phrase ] mpforce $n give 5000 coins joe [Force player give mob 5000 coins] c 'heal' $n [Cast heal on player ] else [Otherwise (first if statement) ] say I don't heal mobs! [Not PC (False): say phrase ] endif [Endif to match If ] endif [Endif to match If ]
Program 4: A simple "atmosphere"-type room program
rpedit add rand 5 [Add a random program - 5% chance] mpecho The crickets chirp in the grass. [Echo phrase to whole room]
Program 5: A simple Object program
opedit sword add repair [Add repair program] mea $n A silver sword says, 'Oh! That's better!' [Echo at Player] mer $n A silver sword gleams in $n's hand. [Echo around Player]
