C:\george\work\PseudoMUD>tree /F
Folder PATH listing for volume IBM_PRELOAD
Volume serial number is 3428-03C0
C:.
? INSTALL.md
? LICENSE.md
? README.md
?
????data
? ? config.p
? ?
? ????areas
? ? ????DeadlyDungeon
? ????help
? help.md
?
????src
????driver
? ????net
????game
? main.p
?
????abilities
????combat
????commands
? go.p
? help.p
? kill.p
? say.p
?
????effects
????things
#include <lib.h>
inherit LIB_ROOM;
int maxnoob = MAX_NEWBIE_LEVEL;
int PreExit(){
object guard = present("gate guard",this_object());
if(!MAX_NEWBIE_LEVEL) maxnoob = 3;
if(((MAX_NEWBIE_LEVEL && !newbiep(this_player())) ||
this_player()->GetLevel() > maxnoob) &&
(!this_player()->GetInvis() && !creatorp(this_player()) &&
!present("testchar badge",this_player()))){
if(guard && living(guard)){
present("gate guard",this_object())->eventForce("say You're too big to slip by me now. You're not going to the mansion any more.");
return 0;
}
}
if((newbiep(this_player()) || this_player()->GetLevel() <= maxnoob)
&& guard && living(guard)){
tell_object(this_player(),"You are such a newbie that the gate guard doesn't even notice you slip by him.");
tell_room(this_object(),this_player()->GetName()+" sneaks past the gate guard.",({ this_player() }) );
}
return 1;
}
static void create() {
room::create();
SetClimate("outdoors");
SetAmbientLight(30);
SetShort("Mansion Gate");
SetLong("You are standing just north of the gate to a large, "+
"beautiful mansion, which stands to the south. The "+
"Corinthian capitals on the front pillars bespeak "+
"of the wealth and importance of the person who "+
"lives here. Lush ivy wraps around the gate and the "+
"brick wall surrounding the estate.");
SetItems( ([
"gate" : "A handsome, wrought-iron entry control point.",
({"estate", "mansion"}) : "The grounds of a mansion are to the south.",
({"capital","capitals","corinthian capital","corinthian capitals"}) :
"These are the headpieces of the pillars supporting the "
"mansion's front overhang. The beautifully detailed "
"carvings of encanthus leaves distinguish them as "
"Corinthian.",
({"overhang","front overhang"}) : "A fancy and unnecessary "
"structure in front of the mansion supported by "
"columns.",
({"pillar","pillars","column","columns"}) : "Load-bearing "
"structures supporting the mansion's front overhang.",
({"ivy","lush ivy"}) : "Vines of the ivy plant run "
"over and along the walls and gate, so thickly that "
"they nearly obscure them.",
({"wall","walls"}) : "Architectural features which prevent "
"casual entry. They are made of brick and appear old "
"and strong.",
]) );
SetExits( ([
"north" : "/domains/town/room/road2.c",
]) );
SetFlyRoom("/domains/town/virtual/sky/26,99999,1");
SetInventory(([
"/domains/town/npc/mp" : ({ 3600, 1 }),
]));
AddExit("south", "/domains/town/room/mansion_ext", (: PreExit :));
AddItem(new("/domains/town/obj/lamp"));
SetProperty("no attack", 1);
}
void init(){
::init();
}
#include <lib.h>
inherit LIB_STORAGE;
static int maxlevel = 5;
string ReadSign(){
string ret = "Only players of level "+cardinal(maxlevel)+" and below "+
"may take from this bin with impunity.";
return ret;
}
void create() {
::create();
SetKeyName("charity bin");
SetId(({"bin"}));
SetAdjectives(({"large","charity"}));
SetShort("a large bin");
SetLong("This a very large bin for holding donations to the "
"needy. Since it is in a church, and for charity, it is "
"reasonable to guess that folks above a certain level will "
"receive a minor bonus for donating valuable things, and a "
"severe penalty for taking them. There is a sign on "
"the charity bin that you can read.");
SetItems( ([
({ "sign" }) : "A sign on the bin you can read.",
]) );
SetReads( ([
"default" : "Try 'read label on bin'",
({"sign"}) : (: ReadSign :),
]) );
SetPreventGet("It's bolted down you filthy scum.");
SetMass(5000);
SetBaseCost("silver",500);
SetMaxCarry(15000);
SetCanClose(0);
SetClosed(0);
SetPersistent(1);
RestoreObject();
}
void init(){
::init();
}
varargs int eventCalculateBonus(object ob, int take){
int value, cls, sum, bonus, duration;
object thingy, who = this_player();
if(!ob || !this_player()) return 0;
if(this_player()->GetLevel() <= maxlevel) return 0;
value = ob->GetBaseCost();
cls = (ob->GetClass() || 1);
sum = (value + (cls * 1000) || 1);
bonus = (sum/10000 || 1);
duration = bonus * 10;
if(bonus > 10) bonus = 10;
if(duration > 1000) duration = 1000;
if(take && bonus > 0) bonus = -bonus - (to_float(bonus) * 0.1);
if(bonus > 0 && take) duration = -duration - (to_float(duration) * 0.1);
if(sum >= 10000 || take){
thingy = present_bonus("charity_bonus", who);
if(thingy){
bonus += thingy->GetStats()["luck"];
duration += thingy->GetDuration();
if(bonus > 33) bonus = 33;
if(duration > 5000) duration = 5000;
}
else thingy = new(LIB_BONUS);
thingy->SetBonusName("charity_bonus");
thingy->SetStats( ([
"luck" : bonus,
]) );
thingy->SetBonusDuration(duration);
if(present(thingy, who) || thingy->eventMove(who)){
object env = environment(this_object());
object wenv = environment(who);
if(env && wenv && env == wenv){
if(!take){
write("You experience a pleasant sense of kinship "+
" with the rest of the world.");
}
else {
write("You feel cheap and petty.");
}
}
}
}
return 1;
}
int eventReceiveObject(object ob){
int ret = ::eventReceiveObject(ob);
if(ret) eventCalculateBonus(ob);
return ret;
}
int eventReleaseObject(object ob){
int ret = ::eventReleaseObject(ob);
if(ret) eventCalculateBonus(ob, 1);
return ret;
}
#/domains/town/obj/charity.c
MaxCarry 5000
Opacity 100
Keys ({})
MaxRecurseDepth 3
RecurseDepth 1
MaxDamagePoints 20000
PreventGet "It's bolted down you filthy scum."
DisableChance 50
Mass 5000
PersistentInventory ({})
PersistentInventoryEnabled 1
Modify 1
Short "a large bin"
CapName "Charity bin"
ExternalDesc "This a very large bin for holding donations to the needy. Since it is in a church, and for charity, it is reasonable to guess that folks above a certain level will receive a minor bonus for donating valuable things, and a severe penalty for taking them. There is a sign on the charity bin that you can read."
Items (["sign":"A sign on the bin you can read.",])
Properties ([])
SaveRecurse 1
Saved ({"Closed", "CanClose","CanLock", "RecurseDepth", "MaxRecurseDepth", "Properties", "Locked", "Keys", "LockStrength", "Properties", "Persist", "Properties", "Class", "Worn", "Poison", "Wielded", "Value", "Cost", "Mass", "Broken", "Deterioration", "Properties",})
Cost 50000
VendorType 2
Class 1
DamageType 2
MaxClass 1
ArmorType 32768
Hands 1
WeaponType "blunt"
Money ([])
QuestId ""
While we're talking about pseudocode, it still makes sense to describe which environment you're drawing up. If you look at an LPMUD driver, you'll see it has almost no game-related code at all, passing all that off to the mudlib itself, while dealing with sockets, file access, and ensuring softcode objects have resource limits.
OTOH, even a DikuMUD with scripting still has the majority of code in the driver, with scripts only acting on very game-specific hooks that can't be expanded without driver hacking.