Difference between revisions of "GiveOrDrop(Script)"

From CoffeeMud Wiki
Jump to navigation Jump to search
(Created page with "{{CoffeeMUDWikiBuilderTOC}} = Give or Drop = This script function can be used in any script to allow a mob to properly award quest rewards, give out specific items or properly...")
 
Line 1: Line 1:
 
{{CoffeeMUDWikiBuilderTOC}}
 
{{CoffeeMUDWikiBuilderTOC}}
 
= Give or Drop =
 
= Give or Drop =
This script function can be used in any script to allow a mob to properly award quest rewards, give out specific items or properly transfer money to mobs that are not normally detectable by the scripted mob. If the mob can't see the person they are trying to give the item to, they will drop the item instead.
+
This script function can be used in any script to allow a mob to properly award quest rewards, give out specific items or properly transfer money to mobs that are not normally detectable by the scripted mob. If the mob can't see the person they are trying to give the item to, or if the mob can't accept the item for another reason, such as over-encumbered or inappropriate zappermask, they will drop the item instead.
 
* You must call this function instead of a using a GIVE command. For example, instead of a give 200 "$n", you would issue an mpcallfunc GiveOrDrop 200 "$n" to give $n 200 coins (as long as this function is in the script)
 
* You must call this function instead of a using a GIVE command. For example, instead of a give 200 "$n", you would issue an mpcallfunc GiveOrDrop 200 "$n" to give $n 200 coins (as long as this function is in the script)
 
<pre>
 
<pre>

Revision as of 13:59, 16 August 2024

CoffeeMUD
Administrator                                                  Builder                                                              Player
=CoffeeMUD Builder Information=
Basics Praetor     Player Support     Commands     Zapper Masks Advanced Races     Classes     Abilities     Socials     Scripting    
Building Behaviors     Properties     Areas     Rooms     Exits     Items     Mobs Systems Achievements     Crafting     Help Info     Ships     Planes of Existence     Quests     Triumphs    

Give or Drop

This script function can be used in any script to allow a mob to properly award quest rewards, give out specific items or properly transfer money to mobs that are not normally detectable by the scripted mob. If the mob can't see the person they are trying to give the item to, or if the mob can't accept the item for another reason, such as over-encumbered or inappropriate zappermask, they will drop the item instead.

  • You must call this function instead of a using a GIVE command. For example, instead of a give 200 "$n", you would issue an mpcallfunc GiveOrDrop 200 "$n" to give $n 200 coins (as long as this function is in the script)
#give 200 "$n"
mpcallfunc GiveOrDrop 200 "$n"

GiveOrDrop

#expect parm0=object to give and parm1=who to give to
#parms should be passed in in double quotes to handle if name has spaces
function_prog GiveOrDrop
  #below is for actual items or quest points.  It handles when the mob has more than one of them.
  if has($i $g.0)
    MPSETVAR $i VAR_INVCOUNT1 $%NUMITEMSMOB($i)%
    give $g.0 $g.1
    if numitemsmob($i == $<$i VAR_INVCOUNT1>)
      mpecho ^T$i says, 'I'll set this on the ground for you.^?
      drop $g.0
    endif
  endif

  #below is for money (i.e. use 200 for 200 gold coins or local currency)
  if number($g.0)
    MPSETVAR $i VAR_MONEYCOUNT1 $%GSTAT($i money)%
    give $g.0 $g.1
    MPSETVAR $i VAR_MONEYCOUNT2 $%GSTAT($i money)%
    if eval('$<$i VAR_MONEYCOUNT1>' == '$<$i VAR_MONEYCOUNT2>')
      mpecho ^T$i says, 'I'll set this on the ground for you.^?
      drop $g.0
    endif
  endif
~


Notes

.