Difference between revisions of "MUDL:Intercept command"

From WikiName
Jump to: navigation, search
(Variables)
(Global Variables)
 
(6 intermediate revisions by the same user not shown)
Line 35: Line 35:
 
| %o
 
| %o
 
| Object
 
| Object
| The object that the MUDL script is attached to.  This value is null if the script is attached to a room or mobile.
+
| The item that the MUDL script is attached to.  This value is null if the script is attached to a room or mobile.
 
|-
 
|-
| %r
+
| %room
 
| Room
 
| Room
| The room that the MUDL script is attached to.  This value is null if the script is attached to a mobile or object.
+
| The room in the game where the script is being run.  This value may be null if the script is attached to an area.
 +
|-
 +
| %area
 +
| Area
 +
| The area (zone) in the game where the script is being run.
 +
|-
 +
| %parent
 +
| Character or Room or Area
 +
| The in-game element that the MUDL script is attached to.  It will be identical to %c or %room or %area.
 +
|-
 +
| %procedure_index
 +
| Integer
 +
| The index of the current MUDL procedure on the %parent variable.
 
|-
 
|-
 
| %s
 
| %s
 
| String array
 
| String array
 
| The arguments following the command that have not been processed by the game.  See the particular commands below for details on which arguments have been processed and which ones have been left in this array.
 
| The arguments following the command that have not been processed by the game.  See the particular commands below for details on which arguments have been processed and which ones have been left in this array.
 +
|-
 +
| %x
 +
| Character
 +
| The target of the current command.
 
|-
 
|-
 
|}
 
|}
 
  
 
= Return Values =
 
= Return Values =
Line 57: Line 72:
 
The following intercept commands have been implemented.
 
The following intercept commands have been implemented.
  
 +
 +
== intercept_aggression_i ==
 +
 +
While not an actual command, this function allows you to intercept a mob before it aggressively attacks its target.
 +
 +
 +
=== Variables ===
 +
 +
There are no local variables for this function.  All actions are performed on %c (same as %a) and %x.
 +
 +
 +
=== Triggered Scripts ===
 +
 +
The only interrupts that are run are the ones attached to the mobile that is getting ready to attack.  When the script is called you are guaranteed that the mobile can see the target, the mobile is in a position where it is able to attack, and that %x is populated with the victim the game has selected to attack.
 +
 +
 +
=== Example ===
 +
<pre>
 +
addproc <mobile> mudl
 +
setproc <mobile> 0 intercept_aggression_i
 +
 +
cmd(%c, 'say Normally I would be AGGRESSIVE!'),
 +
 +
# Stop future processing of this command
 +
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
 +
return(true)
 +
@
 +
 +
setproc <mobile> 0 PROC_ENABLED 1
 +
compile
 +
</pre>
  
 
== intercept_ask_bss ==
 
== intercept_ask_bss ==
Line 108: Line 154:
 
compile
 
compile
 
</pre>
 
</pre>
 +
  
 
== intercept_cast_i ==
 
== intercept_cast_i ==
Line 125: Line 172:
 
| The arguments typed after the spell name.  Note that these could be anything to allow the intercept command to process spells cast at abnormal targets (doors, objects, miscellaneous keywords, etc).
 
| The arguments typed after the spell name.  Note that these could be anything to allow the intercept command to process spells cast at abnormal targets (doors, objects, miscellaneous keywords, etc).
 
|}
 
|}
 +
  
 
=== Triggered Scripts ===
 
=== Triggered Scripts ===
Line 163: Line 211:
 
@
 
@
  
 +
 +
setproc <mobile> 0 PROC_ENABLED 1
 +
compile
 +
</pre>
 +
 +
 +
== intercept_give_i ==
 +
 +
=== Variables ===
 +
 +
The following local variables are available:
 +
{|class="abilitiestable" border="0" cellspacing="0" cellpadding="0"
 +
! Name !! Type !! Description
 +
|-
 +
| %1
 +
| Integer
 +
| The number of gold coins being given to the mobile.
 +
|}
 +
 +
 +
=== Triggered Scripts ===
 +
 +
The only interrupts that are run are the ones attached to the mobile being given the coins.  When the script is called you are guaranteed that the player can see the mobile and has enough gold coins to give.
 +
 +
 +
=== Example ===
 +
<pre>
 +
addproc <mobile> mudl
 +
setproc <mobile> 0 intercept_give_i
 +
 +
# Let the give occur normally.
 +
perform_give(%a, %c, %1),
 +
 +
if (%1 < 100,
 +
(
 +
    # Mob doesn't like this amount.
 +
    cmd(%c, 'say Come on buddy, how can I survive on that?')
 +
)),
 +
 +
 +
# Stop future processing of this command
 +
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
 +
return(true)
 +
@
 +
 +
 +
setproc <mobile> 0 PROC_ENABLED 1
 +
compile
 +
</pre>
 +
 +
 +
== intercept_give_o ==
 +
 +
=== Variables ===
 +
 +
The following local variables are available:
 +
{|class="abilitiestable" border="0" cellspacing="0" cellpadding="0"
 +
! Name !! Type !! Description
 +
|-
 +
| %1
 +
| Object
 +
| The object being given to the mobile.
 +
|}
 +
 +
 +
=== Triggered Scripts ===
 +
 +
The only interrupts that are run are the ones attached to the mobile being given the object.  When the script is called you are guaranteed that the player can see the mobile and has enough gold coins to give.
 +
 +
 +
=== Example ===
 +
<pre>
 +
addproc <mobile> mudl
 +
setproc <mobile> 0 intercept_give_o
 +
 +
# Let the give occur normally.
 +
perform_give(%a, %c, %1),
 +
 +
if (value(%1) < 100,
 +
(
 +
    # Mob doesn't like this amount.
 +
    cmd(%c, 'say Come on buddy, how can I survive on that?')
 +
)),
 +
 +
 +
# Stop future processing of this command
 +
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
 +
return(true)
 +
@
 +
 +
 +
setproc <mobile> 0 PROC_ENABLED 1
 +
compile
 +
</pre>
 +
 +
 +
== intercept_play_ib ==
 +
 +
=== Variables ===
 +
 +
The following local variables are available:
 +
{|class="abilitiestable" border="0" cellspacing="0" cellpadding="0"
 +
! Name !! Type !! Description
 +
|-
 +
| %1
 +
| Integer
 +
| Numeric id of the song that was played.  The spell_name function can be used to compare the id against the name of a specific song you are looking for.
 +
|-
 +
| %2
 +
| Boolean
 +
| FALSE if this is the original play/sing and TRUE if this is a replay/resing of the song.
 +
|-
 +
| %s
 +
| String Array
 +
| The arguments typed after the song name.  Note that these could be anything to allow the intercept command to process songs played at abnormal targets (doors, objects, miscellaneous keywords, etc).
 +
|}
 +
 +
 +
=== Triggered Scripts ===
 +
 +
Interrupts are called on all room procedures and mobile procedures for all mobiles in the room.  When the script is called you are guaranteed that the player is able to play the song and that a valid song name was entered.
 +
 +
 +
=== Example ===
 +
<pre>
 +
addproc <mobile> mudl
 +
setproc <mobile> 0 intercept_play_ib
 +
 +
if (spell_name(%1) != 'lion chorus',
 +
(
 +
    # Wrong song.
 +
    return(false)
 +
)),
 +
 +
if (false = %2,
 +
(
 +
    # Allow the initial play to run as normal.
 +
    cmd(%a, 'play ~`lion chorus~` ' + concatenate(%s))
 +
),
 +
(
 +
    # Show the replay messages.
 +
    send_msgs_for_play(%a, %1, %2)
 +
)),
 +
 +
if (false = %2,
 +
(
 +
    cmd(%c, 'say What a lovely song.')
 +
),
 +
(
 +
    cmd(%c, 'say It keeps getting better!')
 +
)),
 +
 +
# Mark song as successful - full mana drain.
 +
set(flag(%f, 'procedure-flags', 'success'), true),
 +
 +
# Stop future processing of this command
 +
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
 +
return(true)
 +
@
 +
 +
 +
setproc <mobile> 0 PROC_ENABLED 1
 +
compile
 +
</pre>
 +
 +
 +
== intercept_sing_ib ==
 +
 +
=== Variables ===
 +
 +
The following local variables are available:
 +
{|class="abilitiestable" border="0" cellspacing="0" cellpadding="0"
 +
! Name !! Type !! Description
 +
|-
 +
| %1
 +
| Integer
 +
| Numeric id of the song that was sung.  The spell_name function can be used to compare the id against the name of a specific song you are looking for.
 +
|-
 +
| %2
 +
| Boolean
 +
| FALSE if this is the original play/sing and TRUE if this is a replay/resing of the song.
 +
|-
 +
| %s
 +
| String Array
 +
| The arguments typed after the song name.  Note that these could be anything to allow the intercept command to process songs sung at abnormal targets (doors, objects, miscellaneous keywords, etc).
 +
|}
 +
 +
 +
=== Triggered Scripts ===
 +
 +
Interrupts are called on all room procedures and mobile procedures for all mobiles in the room.  When the script is called you are guaranteed that the player is able to play the song and that a valid song name was entered.
 +
 +
 +
=== Example ===
 +
<pre>
 +
addproc template mudl
 +
setproc template 0 intercept_sing_ib
 +
 +
if (spell_name(%1) != 'lion chorus',
 +
(
 +
    # Wrong song.
 +
    return(false)
 +
)),
 +
 +
if (false = %2,
 +
(
 +
    # Allow the initial sing to run as normal.
 +
    cmd(%a, 'sing ~`lion chorus~` ' + concatenate(%s))
 +
),
 +
(
 +
    # Show the replay messages.
 +
    send_msgs_for_play(%a, %1, %2)
 +
)),
 +
 +
if (false = %2,
 +
(
 +
    cmd(%c, 'say What a lovely song.')
 +
),
 +
(
 +
    cmd(%c, 'say It keeps getting better!')
 +
)),
 +
 +
# Mark song as successful - full mana drain.
 +
set(flag(%f, 'procedure-flags', 'success'), true),
 +
 +
# Stop future processing of this command
 +
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
 +
return(true)
 +
@
 +
 +
 +
setproc template 0 PROC_ENABLED 1
 +
compile
 +
</pre>
 +
 +
 +
== intercept_tell_ss ==
 +
 +
=== Variables ===
 +
 +
The following local variables are available:
 +
{|class="abilitiestable" border="0" cellspacing="0" cellpadding="0"
 +
! Name !! Type !! Description
 +
|-
 +
| %1
 +
| String
 +
| Text spoken by the character.  This may be different that what the player actually typed if the character is afflicted with a disease like donkeyitis that modifies speech.
 +
|-
 +
| %2
 +
| String
 +
| Text that will be heard by the mobile.  This may be different from the %2 variable if the mobile is afflicted with a disease that modifies hearing.
 +
|-
 +
| %s
 +
| String Array
 +
| The text contained in %3 broken into individual words.
 +
|}
 +
 +
 +
=== Triggered Scripts ===
 +
 +
The only interrupts that are run are the ones attached to the mobile receiving the tell.  When the script is called you are guaranteed that the player can see the mobile, the mobile is awake, and that %2, %3, and %s contain one or more words of text.
 +
 +
 +
=== Example ===
 +
<pre>
 +
addproc <mobile> mudl
 +
setproc <mobile> 0 intercept_tell_ss
 +
 +
# Allow normal processing.
 +
send_msgs_for_tell(%a, %c, %1, %2),
 +
if (room(%c) = room(%a),
 +
(
 +
    cmd(%c, 'say What are you trying to tell me?')
 +
),
 +
(
 +
    cmd(%c, 'say Who said that?')
 +
)),
 +
 +
# Stop future processing of this command
 +
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
 +
return(true)
 +
@
 +
 +
setproc <mobile> 0 PROC_ENABLED 1
 +
compile
 +
</pre>
 +
 +
 +
== intercept_whisper_ss ==
 +
 +
=== Variables ===
 +
 +
The following local variables are available:
 +
{|class="abilitiestable" border="0" cellspacing="0" cellpadding="0"
 +
! Name !! Type !! Description
 +
|-
 +
| %1
 +
| String
 +
| Text spoken by the character.  This may be different that what the player actually typed if the character is afflicted with a disease like donkeyitis that modifies speech.
 +
|-
 +
| %2
 +
| String
 +
| Text that will be heard by the mobile.  This may be different from the %2 variable if the mobile is afflicted with a disease that modifies hearing.
 +
|-
 +
| %s
 +
| String Array
 +
| The text contained in %3 broken into individual words.
 +
|}
 +
 +
 +
=== Triggered Scripts ===
 +
 +
The only interrupts that are run are the ones attached to the mobile receiving the whisper.  When the script is called you are guaranteed that the player can see the mobile, the mobile is awake, and that %2, %3, and %s contain one or more words of text.
 +
 +
 +
=== Example ===
 +
<pre>
 +
addproc <mobile> mudl
 +
setproc <mobile> 0 intercept_whisper_ss
 +
 +
# Allow normal processing.
 +
send_msgs_for_whisper(%a, %c, %1, %2),
 +
cmd(%c, 'say Speak up!  I can~`t hear you!'),
 +
 +
# Stop future processing of this command
 +
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
 +
return(true)
 +
@
  
 
setproc <mobile> 0 PROC_ENABLED 1
 
setproc <mobile> 0 PROC_ENABLED 1

Latest revision as of 17:00, 18 May 2017

Overview

The MUDL intercept functions get called in the middle of processing a command. In most cases the game parses the command line and then calls the relevant intercept function with the pre-parsed data. In most cases this is easier to use than the corresponding on_command functions as the game is performing sanity checks so that the intercept function doesn't need to.


Command Syntax

addproc <room|mobile|object> mudl
setproc <room|mobile|object> ## intercept_<command>_<arguments>


Global Variables

The following global variables are available:

Name Type Description
 %a Character The character or mobile that initiated the command.
 %c Character The mobile that the MUDL script is attached to. This value is null if the script is attached to a room or object.
 %f Integer Procedure Flags used to track interaction between different procedures.
 %o Object The item that the MUDL script is attached to. This value is null if the script is attached to a room or mobile.
 %room Room The room in the game where the script is being run. This value may be null if the script is attached to an area.
 %area Area The area (zone) in the game where the script is being run.
 %parent Character or Room or Area The in-game element that the MUDL script is attached to. It will be identical to %c or %room or %area.
 %procedure_index Integer The index of the current MUDL procedure on the %parent variable.
 %s String array The arguments following the command that have not been processed by the game. See the particular commands below for details on which arguments have been processed and which ones have been left in this array.
 %x Character The target of the current command.

Return Values

The return value from intercept functions are ignored. To modify game behavior after the intercept function, you should manipulate the Procedure Flags using the %f global variable.


Intercept Commands

The following intercept commands have been implemented.


intercept_aggression_i

While not an actual command, this function allows you to intercept a mob before it aggressively attacks its target.


Variables

There are no local variables for this function. All actions are performed on %c (same as %a) and %x.


Triggered Scripts

The only interrupts that are run are the ones attached to the mobile that is getting ready to attack. When the script is called you are guaranteed that the mobile can see the target, the mobile is in a position where it is able to attack, and that %x is populated with the victim the game has selected to attack.


Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_aggression_i

cmd(%c, 'say Normally I would be AGGRESSIVE!'),

# Stop future processing of this command
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
return(true)
@

setproc <mobile> 0 PROC_ENABLED 1
compile

intercept_ask_bss

Variables

The following local variables are available:

Name Type Description
 %1 Boolean TRUE if the player typed "ask mobile about". FALSE if the word "about" was omitted.
 %2 String Text spoken by the character. This may be different that what the player actually typed if the character is afflicted with a disease like donkeyitis that modifies speech.
 %3 String Text that will be heard by the mobile. This may be different from the %2 variable if the mobile is afflicted with a disease that modifies hearing.
 %s String Array The text contained in %3 broken into individual words.


Triggered Scripts

The only interrupts that are run are the ones attached to the mobile being asked the question. When the script is called you are guaranteed that the player can see the mobile, the mobile is awake, and that %2, %3, and %s contain one or more words of text.


Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_ask_bss

if ('quest' = %s[1],
(
    send_msgs_for_ask(%a, %c, %1, %2, %3),

    cmd(%c, 'say Yes I have a quest for you!'),
    set(flag(%f, 'procedure-flags', 'overrode-command'), true),
    return(true)
)),
return(false)
@

setproc <mobile> 0 PROC_ENABLED 1
compile


intercept_cast_i

Variables

The following local variables are available:

Name Type Description
 %1 Integer Numeric id of the spell that was cast. The spell_name function can be used to compare the id against the name of a specific spell you are looking for.
 %s String Array The arguments typed after the spell name. Note that these could be anything to allow the intercept command to process spells cast at abnormal targets (doors, objects, miscellaneous keywords, etc).


Triggered Scripts

Interrupts are called on all room procedures and mobile procedures for all mobiles in the room. When the script is called you are guaranteed that the player is able to cast the spell and that a valid spell name was entered.


Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_cast_i

# Is this a spell we care about?
if (spell_name(%1) != 'fireball',
(
    # Wrong spell.
    return(false)
)),

# Is this targeted at us?
if ((length(%s) < 1) OR !(char_in_room(%a, %s[1]) = %c),
(
    # Not targeting us.  Use normal processing.
    return(false)
)),


send_msgs_for_cast(%a, %1),

cmd(%c, 'say Your fire is no match for me!'),

# Mark spell as successful - full mana drain.
set(flag(%f, 'procedure-flags', 'success'), true),

# Stop future processing of this command
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
return(true)
@


setproc <mobile> 0 PROC_ENABLED 1
compile


intercept_give_i

Variables

The following local variables are available:

Name Type Description
 %1 Integer The number of gold coins being given to the mobile.


Triggered Scripts

The only interrupts that are run are the ones attached to the mobile being given the coins. When the script is called you are guaranteed that the player can see the mobile and has enough gold coins to give.


Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_give_i

# Let the give occur normally.
perform_give(%a, %c, %1),

if (%1 < 100,
(
    # Mob doesn't like this amount.
    cmd(%c, 'say Come on buddy, how can I survive on that?')
)),


# Stop future processing of this command
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
return(true)
@


setproc <mobile> 0 PROC_ENABLED 1
compile


intercept_give_o

Variables

The following local variables are available:

Name Type Description
 %1 Object The object being given to the mobile.


Triggered Scripts

The only interrupts that are run are the ones attached to the mobile being given the object. When the script is called you are guaranteed that the player can see the mobile and has enough gold coins to give.


Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_give_o

# Let the give occur normally.
perform_give(%a, %c, %1),

if (value(%1) < 100,
(
    # Mob doesn't like this amount.
    cmd(%c, 'say Come on buddy, how can I survive on that?')
)),


# Stop future processing of this command
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
return(true)
@


setproc <mobile> 0 PROC_ENABLED 1
compile


intercept_play_ib

Variables

The following local variables are available:

Name Type Description
 %1 Integer Numeric id of the song that was played. The spell_name function can be used to compare the id against the name of a specific song you are looking for.
 %2 Boolean FALSE if this is the original play/sing and TRUE if this is a replay/resing of the song.
 %s String Array The arguments typed after the song name. Note that these could be anything to allow the intercept command to process songs played at abnormal targets (doors, objects, miscellaneous keywords, etc).


Triggered Scripts

Interrupts are called on all room procedures and mobile procedures for all mobiles in the room. When the script is called you are guaranteed that the player is able to play the song and that a valid song name was entered.


Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_play_ib

if (spell_name(%1) != 'lion chorus',
(
    # Wrong song.
    return(false)
)),

if (false = %2,
(
    # Allow the initial play to run as normal.
    cmd(%a, 'play ~`lion chorus~` ' + concatenate(%s))
),
(
    # Show the replay messages.
    send_msgs_for_play(%a, %1, %2)
)),

if (false = %2,
(
    cmd(%c, 'say What a lovely song.')
),
(
    cmd(%c, 'say It keeps getting better!')
)),

# Mark song as successful - full mana drain.
set(flag(%f, 'procedure-flags', 'success'), true),

# Stop future processing of this command
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
return(true)
@


setproc <mobile> 0 PROC_ENABLED 1
compile


intercept_sing_ib

Variables

The following local variables are available:

Name Type Description
 %1 Integer Numeric id of the song that was sung. The spell_name function can be used to compare the id against the name of a specific song you are looking for.
 %2 Boolean FALSE if this is the original play/sing and TRUE if this is a replay/resing of the song.
 %s String Array The arguments typed after the song name. Note that these could be anything to allow the intercept command to process songs sung at abnormal targets (doors, objects, miscellaneous keywords, etc).


Triggered Scripts

Interrupts are called on all room procedures and mobile procedures for all mobiles in the room. When the script is called you are guaranteed that the player is able to play the song and that a valid song name was entered.


Example

addproc template mudl
setproc template 0 intercept_sing_ib

if (spell_name(%1) != 'lion chorus',
(
    # Wrong song.
    return(false)
)),

if (false = %2,
(
    # Allow the initial sing to run as normal.
    cmd(%a, 'sing ~`lion chorus~` ' + concatenate(%s))
),
(
    # Show the replay messages.
    send_msgs_for_play(%a, %1, %2)
)),

if (false = %2,
(
    cmd(%c, 'say What a lovely song.')
),
(
    cmd(%c, 'say It keeps getting better!')
)),

# Mark song as successful - full mana drain.
set(flag(%f, 'procedure-flags', 'success'), true),

# Stop future processing of this command
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
return(true)
@


setproc template 0 PROC_ENABLED 1
compile


intercept_tell_ss

Variables

The following local variables are available:

Name Type Description
 %1 String Text spoken by the character. This may be different that what the player actually typed if the character is afflicted with a disease like donkeyitis that modifies speech.
 %2 String Text that will be heard by the mobile. This may be different from the %2 variable if the mobile is afflicted with a disease that modifies hearing.
 %s String Array The text contained in %3 broken into individual words.


Triggered Scripts

The only interrupts that are run are the ones attached to the mobile receiving the tell. When the script is called you are guaranteed that the player can see the mobile, the mobile is awake, and that %2, %3, and %s contain one or more words of text.


Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_tell_ss

# Allow normal processing.
send_msgs_for_tell(%a, %c, %1, %2),
if (room(%c) = room(%a),
(
    cmd(%c, 'say What are you trying to tell me?')
),
(
    cmd(%c, 'say Who said that?')
)),

# Stop future processing of this command
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
return(true)
@

setproc <mobile> 0 PROC_ENABLED 1
compile


intercept_whisper_ss

Variables

The following local variables are available:

Name Type Description
 %1 String Text spoken by the character. This may be different that what the player actually typed if the character is afflicted with a disease like donkeyitis that modifies speech.
 %2 String Text that will be heard by the mobile. This may be different from the %2 variable if the mobile is afflicted with a disease that modifies hearing.
 %s String Array The text contained in %3 broken into individual words.


Triggered Scripts

The only interrupts that are run are the ones attached to the mobile receiving the whisper. When the script is called you are guaranteed that the player can see the mobile, the mobile is awake, and that %2, %3, and %s contain one or more words of text.


Example

addproc <mobile> mudl
setproc <mobile> 0 intercept_whisper_ss

# Allow normal processing.
send_msgs_for_whisper(%a, %c, %1, %2),
cmd(%c, 'say Speak up!  I can~`t hear you!'),

# Stop future processing of this command
set(flag(%f, 'procedure-flags', 'overrode-command'), true),
return(true)
@

setproc <mobile> 0 PROC_ENABLED 1
compile