Prog Appendix 6

From Immwiki
Revision as of 16:48, 5 November 2011 by Dovolente (Talk | contribs) (Appendix 6: Generic Prog Skeletons: Added dream progs)

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!

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


Dream Prog

Delivers a dream to any number of 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 dream given only once.

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
  // Cancel the dream (for example, if you want it to be dreamed only once).
  // Other conditions could be added.
  if isbitset($n) == StopDreamBit
    break
  endif
  // Conditions for delivering the dream.
  if class($n) == 4
  or ischaotic($n)
  or israce($n) == kankoran
    mpmload DreamHandlerVnum
    mpforce DreamHandlerName mpfocus $n
    mpforce DreamHandlerName mpsetdata DataProgName
    mpstring mob DreamHandlerBotName long $N is being given a dream by DreamHandlerName.
    // Notifications that a dream is starting.
    tell ImmName $N is dreaming the DataProgName dream.
  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 stardream
// Use // 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 your 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.
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. Pray works too.
note to RECIPIENT
note subject $F had the dream
note send
//
mppurge self