Prog Appendix 6

From Immwiki
Jump to: navigation, search

Appendix 6: Generic Prog Skeletons

In this section, we will include generic versions of whole progs, to be cannibalized and adapted for future use. Make the parts that need to be changed obvious!

Object Decay

Prevent useless items that might otherwise pile up as useless clutter from doing so. Other uses are to keep particular items from stashing/vault hording (though there would need to be a good reason for such), or having a "Stone of Power"-like random placement/movement effect.

Requirements:

  • an object
rand_prog 1
if isheld($o)
  opvalueset 0 0
else
  opvalueup 0
  if value(0) == 3
    opecho $I crumbles to dust.
    oppurge self
   endif
endif

Player-owned Shop

With profit-sharing and optional comped goods

Requirements:

  • 1 shopkeeper mobile (requires act keepgold),
  • 1 room flagged save, nowhere, nosum_to, nosum_from, and nogate,
  • and 1 free bit.

Progs go on the mob.

>load_prog 100
 speak common

This mob talks, so include this if it's not a human.

>verb_prog p collect
if isbitset($n) == shopOwnerBit
       mpset mob self copper 0
       mpset mob self platinum 0
       mpset mob self gold 0
       mpset mob self silver 0
       mpat shopStorageVnum get all
       mpget mob $i platinum 0
       mpget mob $i gold 1
       mpget mob $i silver 2
       mpget mob $i copper 3
       if value(0) > 0
       or value(1) > 0
       or value(2) > 0
       or value(3) > 0
               say Your portion of the profits, sir.
               emote passes a small bag to $N.
//above is the flavour section of the cash handoff-- you will want to write your own.                
               mpmath 4 \$3 + 10*\$2 + 100*\$1 + 1000*\$0
               mpmath 5 (\$4*2)/5
//the above line is the one where owner return rate is determined.
//do decimals via fractions. Example shown gives a 40% return--
//use that number as-is unless you have a reason to do otherwise.
               mpmath 6 \$5/1000
               mpmath 5 \$5 - \$6*1000
               mpmath 7 \$5/100
               mpmath 5 \$5 - \$7*100
               mpmath 8 \$5/10
               mpmath 5 \$5 - \$8*10
               mpset mob self copper \$5
               mpset mob self platinum \$6
               mpset mob self gold \$7
               mpset mob self silver \$8
               give \$5 copper $n
               give \$8 silver $n
               give \$7 gold $n
               give \$6 platinum $n
               note to immortal
               note subject $N collected $s filthy, filthy lucre.
               note + I passed off \$6 platinum, \$7 gold, \$8 silver, and \$5 copper.
               note send
               
       else
               say I apologize, sir, but there hasn't been enough business, since you were by last.
 //flavour for no money in the storage room; again, write your own.                
       endif
else
       emote pointedly ignores $N.
//you ain't the boss of me-- and the same.        
endif
>verb_prog p buy
if isbitset($n) == shopOwnerBit
       mpinterpret $n $x
       mpget mob $i platinum 0
       mpget mob $i gold 1
       mpget mob $i silver 2
       mpget mob $i copper 3
       give \$0 platinum $n
       give \$1 gold $n
       give \$2 silver $n
       give \$3 copper $n
       tell $n Your money is no good here, sir.
else
//the above section can be removed for a shop that doesn't comp purchases, or math can be done to provide
//a discount rather than comping, if you study the math in 'collect' above.
       mpinterpret $n $x
       mpget mob $i platinum 0
       mpget mob $i gold 1
       mpget mob $i silver 2
       mpget mob $i copper 3
       mpat shopStorageVnum drop \$0 platinum
       mpat shopStorageVnum drop \$1 gold
       mpat shopStorageVnum drop \$2 silver
       mpat shopStorageVnum drop \$3 copper
endif


Dreams

Gives a dream one or more times to any number of particular, sleeping PCs

Resources needed:

  • A dream manager bot added as a standard reset.
  • A dream handler bot which is loaded by the manager.
  • A bit number, if you want to have the complete dream given only once.
  • The content of the dream, to be added in the data prog.

Manager bot progs

>rand_prog 100
// Periodically runs the dream sequence
// This could also easily work as a time prog, a verb_prog, etc.
// For a rand prog, the 0 value check can vary for a less or more 
// frequent/likely dream, but it must be higher than the number 
// of lines in dream data_progs.
//
mpvalueup 0
if value(0) == 250
  mpvalueset 0 0
  mpmasstrigger
endif
>trigger_prog 100
if position($n) == 4
  // Stops if the PC has already dreamed the complete dream.
  if isbitset($n) == StopDreamBit
    break
  endif
  // Conditions for the dream. Could use a "name($n) == Jolinn" to target only 1 PC.
  if class($n) == 4
  or ischaotic($n)
  or israce($n) == kankoran
    mpmload DreamHandlerVnum
    mpforce DreamHandlerName mpfocus $n
    mpforce DreamHandlerName mpsetdata dream_time
    mpstring mob DreamHandlerName long $I is giving $N a dream.
    // Notifications that a dream is starting.
    tell ImmName $N is dreaming.
  endif
endif

Handler bot progs

>rand_prog 100
// Deliver the dream lines if the PC is sleeping. Go away, if not.
//
if position($f) == 4
  $d
  mpnextdata
else
  mppurge self
endif
>data_prog dream_time
// You can add more // lines in the data_prog to slow the pace of the dream echoes.
mpechoat $f Your normal dreams are disturbed by strange, vague images and sensations.
// 
mpechoat $f You dream that you gaze up into the night sky, and it is black, devoid of stars. 
[[//]]
mpechoat $f In the dream, three brilliant, blazing stars appear on the eastern horizon.
[[//]]
mpechoat $f You see that the three bright stars are flanked by two other lesser stars. 
[[//]]
mpechoat $f On the western horizon, as if in response or challenge, three faint stars appear. 
//
mpechoat $f The strange images fade away, and you return to normal slumber.
mpat 1210 prog_enddream
>verb_prog prog_enddream
// Set a bit if you want the dream to be delivered one time only.
mpbitset $f StopDreamBit 1
//
// Send a note if you want to be notified that the PC had the dream.
note to RECIPIENT(S)
note subject $F had the dream
note send
//
mppurge self