Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Lash

Pages: 1 [2] 3
16
Bug Central / Possible bug in bonus object
« on: December 12, 2014, 07:21:11 PM »
In my experience the bonuses conferred by potions were being added to the player character but not removed after the "Duration" timer had timed out as specified in the /lib/bonus.c file. The bonus object was not being destructed as it should have been.

I believe the following piece of code starting at line 30 is the culprit in bonus.c:

Code: [Select]
void heart_beat(){
    if(Duration) Duration--;
    else eventDestruct();
}

When changed to the following:

Code: [Select]
void heart_beat(){
    if(Duration > 0 ) Duration--;
    else this_object()->eventDestruct();
}

the bonus object was destructed and the bonuses to the player were removed.

17
Bug Central / Re: Solving ticktock headaches
« on: December 01, 2014, 06:14:44 PM »
Well, I bunged that up a little bit!  :-[

In the if statement in the first post, the value '24' should be set to the max hours of your MUD. In Dead Souls default that value should be '20', otherwise the hour length of the day as indicated in your
/lib/include/config.h file.

And "minutes" should be struck from the help file addendum I put up. I don't know what the units are. Number of heartbeats maybe?





18
Bug Central / Re: Solving ticktock headaches
« on: November 29, 2014, 08:08:44 AM »
Following code added to ticktock help function for clarification:

Code: [Select]
string GetHelp(){
    return ("Syntax: ticktock <seconds>\n\n"
            "Changes in-game mud time by the number of seconds "
            "specified. This is useful for changing night to "
            "day and vice versa, when testing ambient light and "
            "variable room descriptions. The timeshift does not "
            "persist between reboots. In this MUD the day length is "
             +DAY_LENGTH+" hrs and the hour length is "+HOUR_LENGTH+" minutes.");
}

19
Bug Central / Solving ticktock headaches
« on: November 25, 2014, 01:23:02 PM »
Default Dead Souls hours in a day is 20 as defined in /lib/include/config.h

The ticktock command is set up for reporting as if the day length is 24 hrs with noon and midnight occurring at 12 pm and 12 am as exemplified by the following code starting at line 32:

Code: [Select]
if(hours >= 12  && hours != 24) {
        if(hours != 12) hours -= 12;
        meridiem = " pm";
    }

    if(!hours || hours == 0) hours = 12;

Change all the 12's to 10's since 10 is mid day and midnight.
Depending on your mud day length you would have to change the 12's to the mid day numbers (for example a 30 hour day mud would be 15).
The weirdness is that mid day is 10am and the time jumps to 1pm. But is that any weirder than going from 12 to 1?

So, change the default day time in config.h or change ticktock and be aware of the mid day times when using the ticktock command.

20
General / Re: So I decide to jump on the GitHub bandwagon
« on: November 06, 2014, 09:48:06 PM »
Technically, yes. I mean, I'm not trying to build DikuMud from scratch under FluffOS.

I just took the tinyworld files from Diku and reformatted them to work with Dead Souls. Along the way I added functionality to objects that required them. In short, I created a domain that contains the Diku "world" in Dead Souls.

However, it was not, nor was it intended to be, a robust and playable mud area. For me, it is an exercise to familiarize myself with the LPC language.

21
General / So I decide to jump on the GitHub bandwagon
« on: November 03, 2014, 04:14:03 PM »
Uploaded my DikuMud to Dead Souls areas port project at GitHub:

https://github.com/LashMUD/DikuMud-to-Dead-Souls-Port

Suggestions welcome.

22
Dead Souls Support / Bonuses and output of skills.c
« on: November 19, 2011, 03:53:54 PM »
Not really a bug per se, but I was using AddStatBonus() and AddSkillBonus() in a file I was creating - while the stat bonus was seen in the output for the players' stats command the skill bonus was not when using the players' skills command.

The skills command reported the skill level regardless of bonus points. I changed a line in skills.c so that the current skill level will be displayed.
This was bugging the crap out of me because I could see the bonus was being added using call <player>->GetSkillLevel() but the change wasn't being displayed when using the skills command.

Anyway, a minor change but may be useful to other newbies like myself.

diff file:

Code: [Select]
23c23
<             (/*mp["level"]*/this_player()->GetSkillLevel(skill) + "/" + max), x); //changed by Lash so current skill level is shown with skill bonuses
---
>             (mp["level"] + "/" + max), x);

23
Design Lab / Re: Lib Port
« on: November 19, 2011, 03:37:15 PM »
Sorry about this, but I was doing some further mucking about with combat.c and realized that I had commented out a section in my modified file.

The int x in the diff file I posted won't work because my commented out section used an int x.

So, I changed MY int x to int deltaM so the diff file should read:

Code: [Select]
942a943
>     
992a994
>     int deltaM;
998a1001,1007
>     /*added by Lash for delta morality based on killed NPC's morality*/
>     deltaM = ob->GetMorality();
>     SetMorality(GetMorality()-deltaM);
>     if (GetMorality()>2500) SetMorality(2500);
>     if (GetMorality()<-2500) SetMorality(-2500);
>     

24
Design Lab / Re: Lib Port
« on: November 19, 2011, 10:36:57 AM »
Hello All,

I'm about ready for a new release of this project after quite some time. Right now I'm doing "clean up" and editing Docs.

Just to clarify, this is a port of the DikuMud-ALFA (released after Gamma) game world to Dead Souls. This is NOT a true porting in the sense of altering
Dead Souls to be DikuMud. Just a port of the areas, their associated NPC's and items into the Dead Souls MudLib. In other words, this is a port of a DOMAIN.
The DikuMud game world files are stored in a directory called "lib",  hence my orginal post calling this a Lib Port.   

What's not in the release:

Guildmasters
Player Magic Spells
A few Magic Items

What IS in the release (about 95% of the total conversion process is finished):

All rooms
Just about all of the in game NPC's and items (armor, weapons, meals, etc)
All included objects have their DikuMud code functionality equivalents
All files have been reformatted to better fit coding standards
All files include a commented output using the DikuMud STAT command  so one can compare and contrast the LPC file with the DikuMUD file information
All but two areas have been mapped . A complete overland map of the whole domain is included
Rewriten Docs, including a doc with my explanation and comparison of the DikuMud code I used and translated into LPC

I have altered some base Dead Souls 3.6 Mudlib files in order to make this work. These files need to be inherited by only a handful of objects.

I wanted to get an opinion as to how much of a pain in the ass it would be for users to overwrite the base Dead Souls 3.6 mudlib files with my modified
files. They are as follows:

/lib/combat.c
/lib/genetics.c
/lib/lead.c
/lib/npc.c

The diff files are as follows:

combat.c (for having a players' morality change based on killing an NPC):
Code: [Select]
942a943
>     
992a994
>     int x;
998a1001,1007
>     /*added by Lash for delta morality based on killed NPC's morality*/
>     x = ob->GetMorality();
>     SetMorality(GetMorality()-x);
>     if (GetMorality()>2500) SetMorality(2500);
>     if (GetMorality()<-2500) SetMorality(-2500);
>     

genetics.c (for use with an NPC "curse" spell I wrote):
Code: [Select]
14d13
< inherit "/domains/diku-alfa/etc/curse.c";
359,365d357
<         }
<     }
<     /* added by Lash */
<     if(Cursed){
<         Cursed->duration--;
<         if(Cursed->duration < 1){
<             RemoveCurse();

lead.c (for having an animal follower (companion) that a player won't "evade" and lose):
Code: [Select]
117,122d116
<
<         /* added by lash */
<         if(this_player()->GetProperty(ob) && (ob->GetSleeping() || ob->GetParalyzed() || pos & badpos)){
<             return 0;
<         }
<

npc.c (for adding SetActionsMap() in NPC's)
Code: [Select]
45,46d44
< private mapping ActionsMap = ([]); /* added by Lash */
< private int tick_resolution = 5; /* added by Lash */
121,125d118
<     /* added by Lash */
<     if((Action && (sizeof(Action) || functionp(Action)))
<             || sizeof(ActionsMap)){
<         set_heart_beat(tick_resolution);
<     }
146,156d138
<
<     /* added by lash */
<     if( !GetInCombat() && sizeof(ActionsMap)){
<         foreach(mixed key, mixed val in ActionsMap){
<             if( val > random(100) ){
<                 if(functionp(key)) evaluate(key);
<                 else eventPrint(key);
<             }
<         }
<     }
<
650,659d631
<
< /* added by Lash */
< mapping SetActionsMap(mapping ActMap){
<     if(ActMap && sizeof(ActMap)) ActionsMap = ActMap;
<     return copy(ActionsMap);
< }
<
< mapping GetActionsMap(){
<     return copy(ActionsMap);
< }

25
Dead Souls Support / Re: Adding SetActionsMap to npc.c
« on: October 16, 2011, 01:19:35 PM »
@ Quixadhal:

First, thanks for taking the time to comment. I appreciate it.

Right. some data:

Scavenge set to 90 and NpcSteal set to 5:
Heart Beats: 100
Total calls to NpcSteal() and Scavenge(): 91
NpcSteal() calls: 3
Scavenge() calls: 88


Scavenge set to 5 and NpcSteal set to 90:
Heart Beats: 100
Total calls to NpcSteal() and Scavenge(): 91
NpcSteal() calls: 84
Scavenge() calls: 7


Scavenge set to 50 and NpcSteal set to 50:
Heart Beats: 100
Total calls to NpcSteal() and Scavenge(): 95
NpcSteal() calls: 47
Scavenge() calls: 48


Scavenge set to 10 and NpcSteal set to 5:
Heart Beats: 100
Total calls to NpcSteal() and Scavenge(): 16
NpcSteal() calls: 3
Scavenge() calls: 13

Heart Beats: 1000
Total calls to NpcSteal() and Scavenge(): 148
NpcSteal() calls: 46
Scavenge() calls: 102

So, the chance is set per heart beat to call each function. Note that this also works independently of SetAction(). In fact, I used a SetAction(100, (:count:)); function call to measure the object's heart beats.

As an aside, I haven't figured out how to use the heart_beat function to count heart_beats in an object. The way I tried didn't work - the heart_beat function took precedence over the other function calls.

Anyway, for this project the SetActionsMap() function is working as wanted.
 
Thanks again for commenting. I really like your array suggestion and am eager to try to get that working.

And the revised code to generate the data: (NpcCheck() has also been removed as this NPC is actually not supposed to be aggressive - a work still in progress :sigh:)
Code: [Select]
// Based on Diku MUD Alfa.  Program and Concept created by
// Sebastian Hammer, Michael Seifert, Hans Henrik Staerfeldt,
// Tom Madsen, and Katja Nyboe.
// http://www.dikumud.com
//
// Modified by Lash (Christopher Coker) for use with:
//
// The Dead Souls Mud Library version 2
// developed by Cratylus
// http://www.dead-souls.net

#include <lib.h>

inherit LIB_SENTIENT;

void NpcSteal(object ob);
void Scavenge();
int count();

iint ntimes = 0;
int stimes = 0;
int tot = 0;
int hb = 0;

static void create() {
    sentient::create();

    SetKeyName("the thief");
    SetId( ({"thief"}) );
    SetAdjectives(({"non-player", "evil", "tricky"}));
    SetShort("A thief, all dressed in black");
    SetLong("Well, COUNT your money..!");
    SetRace("human");
    SetClass("thief");
    SetLevel(8);
    SetMelee(1);
    SetCanBite(0);
    SetGender("male");
    SetMorality(250); //?
    AddCurrency("gold", 100);
    SetAction(100, (:count:));
    SetActionsMap( ([
                     ( :Scavenge: ) : 50,
                     ( :NpcSteal: ) : 50,
                 ]) );
    //SetWander(5);
    SetInventory( ([
         "/domains/diku-alfa/room/41.zon/meals/4103_slime" :1,
         "/domains/diku-alfa/room/41.zon/meals/4104_slime_poison" :1,
       ]) );
    SetProperty("STAY_ZONE", 1);
}

void init(){
    ::init();
}

int count(){
   
    hb++;

    tell_room(environment(this_object()), "Heart Beats: "+hb+"\nTotal calls to NpcSteal() and Scavenge(): "+tot+"\nNpcSteal() calls: "+ntimes+"\nScavenge() calls: "+stimes+"\n");
    return hb;
}

void NpcSteal(object ob){

    object env = environment(this_object());
    object *potvictims;
    int n1, n2, gold, level;
    level = this_object()->GetLevel();
   
    tot++;
    ntimes++;

    potvictims = filter(get_livings(env), ( :living($1) && $1 != this_object() && playerp($1):) );

    foreach(object target in potvictims){
        if(playerp(target)){
            n1 = random(level);
            if(n1 ==0){
                tell_object(target, "You notice " + capitalize(this_object()->GetKeyName()) + " trying to steal from you!");
                break;
            }

            if(n1 > 0){
                n2 = random(level)+1;
                gold = target->GetCurrency("gold") * n2 /100;
                this_object()->AddCurrency("gold", gold);
                target->AddCurrency("gold", -gold);
            }
        }
    }
}

void Scavenge(){

    object env = environment(this_object());
    object *item, *cost;
    int s;

    tot++;
    stimes++;
         
    item = filter(all_inventory(env), (: !living($1) && (inherits(LIB_ITEM, $1) || inherits(LIB_ARMOR, $1)):) );
    cost = sort_array(item->GetBaseCost(), -1);
    s = sizeof(cost);
    if(s>0){
        foreach(object thing in item){
            if(thing->GetBaseCost() == cost[0]){
                eventForce("get "+thing->GetKeyName());
                break;
            }
        }
    }
}

26
Dead Souls Support / Re: Adding SetActionsMap to npc.c
« on: October 15, 2011, 12:41:02 PM »
Still editing and missed this - CheckNpc() is usually called in "aggressive" npc files with the following function:

Code: [Select]
SetEncounter( (:CheckNPC:) ); //aggressive
All aggressive NPC's in the domain I'm making kill non-npc's on sight.

Lash

27
Dead Souls Support / Adding SetActionsMap to npc.c
« on: October 15, 2011, 12:21:22 PM »
For having an npc that can perform more than one action each at different chances per heartbeat. Having more than one SetAction() function in an NPC or SENTIENT doesn't seem to work or, of course, I'm missing something. Nothing really special here - more or less copying and pasting code from room.c.

Modified file: ds3.6/lib/lib/npc.c

At line 45 added function prototypes:

Code: [Select]
private mapping ActionsMap = ([]);
private int tick_resolution = 5;

Inserted at line 119 in static void init()

Code: [Select]
if((Action && (sizeof(Action) || functionp(Action)))
            || sizeof(ActionsMap)){
        set_heart_beat(tick_resolution);
    }

Inserted at line 139 in static void heartbeat()

Code: [Select]
if( !GetInCombat() && sizeof(ActionsMap)){
        foreach(mixed key, mixed val in ActionsMap){
            if( val > random(100) ){
                if(functionp(key)) evaluate(key);
                else eventPrint(key);
            }
        }
    }

Inserted at line 632 in /lib/npc.c data functions section

Code: [Select]
mapping SetActionsMap(mapping ActMap){
    if(ActMap && sizeof(ActMap)) ActionsMap = ActMap;
    return copy(ActionsMap);
}

mapping GetActionsMap(){
    return copy(ActionsMap);
}

Example npc - a thief that has a chance to steal and pick up stuff as it goes along. I varied the values in SetActionsMap and the functions were called as expected for the SetActionsMap() value. Included is the function CheckNpc() to make sure this guy doesn't bash on other loaded npc's.

Code: [Select]
// Based on Diku MUD Alfa.  Program and Concept created by
// Sebastian Hammer, Michael Seifert, Hans Henrik Staerfeldt,
// Tom Madsen, and Katja Nyboe.
// http://www.dikumud.com
//
// Modified by Lash (Christopher Coker) for use with:
//
// The Dead Souls Mud Library version 2
// developed by Cratylus
// http://www.dead-souls.net

#include <lib.h>

inherit LIB_SENTIENT;

void CheckNPC();
void NpcSteal(object ob);
void Scavenge();

static void create() {
    sentient::create();

    SetKeyName("the thief");
    SetId( ({"thief"}) );
    SetAdjectives(({"non-player", "evil", "tricky"}));
    SetShort("A thief, all dressed in black");
    SetLong("Well, COUNT your money..!");
    SetRace("human");
    SetClass("thief");
    SetLevel(8);
    SetMelee(1);
    SetCanBite(0);
    SetGender("male");
    SetMorality(250); //?
    AddCurrency("gold", 100);
    SetActionsMap( ([
                     ( :Scavenge: ) : 10,
                     ( :NpcSteal: ) : 5,
                   ]) );
    SetWander(5);
    SetInventory( ([
         "/domains/diku-alfa/room/41.zon/meals/4103_slime" :1,
         "/domains/diku-alfa/room/41.zon/meals/4104_slime_poison" :1,
       ]) );
}

void init(){
    ::init();
}

/*Do not attack other NPC's*/
void CheckNPC(object ob){
 
    object env=environment(this_object());
    if(ob && !inherits(LIB_NPC, ob)){
        eventForce("kill " +ob->GetKeyName());
 }
}

void NpcSteal(object ob){

    object env = environment(this_object());
    object *potvictims;
    int n1, n2, gold, level;
    level = this_object()->GetLevel();

    potvictims = filter(get_livings(env), ( :living($1) && $1 != this_object() && playerp($1):) );
   
    foreach(object target in potvictims){
        if(playerp(target)){
            n1 = random(level);
            if(n1 ==0){
                tell_object(target, "You notice " + capitalize(this_object()->GetKeyName()) + " trying to steal from you!");
                break;
            }
       
            if(n1 > 0){
                n2 = random(level)+1;
                gold = target->GetCurrency("gold") * n2 /100;
                this_object()->AddCurrency("gold", gold);
                target->AddCurrency("gold", -gold);
            }
        }
    }
}

void Scavenge(){

    object env = environment(this_object());
    object *item, *cost;
    int s;
   
    item = filter(all_inventory(env), (: !living($1) && (inherits(LIB_ITEM, $1) || inherits(LIB_ARMOR, $1)):) );
    cost = sort_array(item->GetBaseCost(), -1);
    s = sizeof(cost);
    if(s>0){
        foreach(object thing in item){
            if(thing->GetBaseCost() == cost[0]){
                eventForce("get "+thing->GetKeyName());
                break;
            }
        }
    }
}

28
Thanks for looking at my question  :)

I got around it by getting rid of LIB_BONUS and modifying the code by directly adding the bonus to the skill and removing it after un-equiping the object.

Here's the code if anyone is interested:

Code: [Select]
varargs int check_morality(object who){
    int x, y, morality;
    
    object env = environment(who);

    morality = who->GetMorality();

  
    x=who->GetSkillLevel("melee attack");
    who->eventPrint("Melee attack before skill bonus = "+x+".");
      
    //only less than 'good' chars can use

    if( morality <=200 ){
    
    who->eventPrint("You can feel an increase in your fighting "+
           "prowess as you put on the gloves.");
        if(env) tell_room(env, who->GetName()+" wears "+
          GetShort()+".", ({who}));
        
        who->AddSkillBonus("melee attack", 2);
        x=who->GetSkillLevel("melee attack");
        who->eventPrint("Melee attack after skill bonus = "+x+".");  
      
        return 1;
    

    }

    else {
        who->eventPrint("You cannot seem to get your hands in "+

            "the gloves.");
        x=who->GetSkillLevel("melee attack");
        who->eventPrint("Melee attack not wearing gloves = "+x+".");  
        return 0;

    }
    
      
}

mixed eventUnequip(){
   int x;
   this_player()->RemoveSkillBonus("melee attack");
   armor::eventUnequip(this_player());
   x=this_player()->GetSkillLevel("melee attack");
   this_player()->eventPrint("Melee attack bonus is now "+x+".");

}

Essentially, this tells the player what his melee attack value is before and after wearing the gloves and after removing them. There's no stacking and no delay in bonus removal.

29
I was trying to implement an armor item that enabled a bonus of +2 to "melee attack" using SetSkills with the LIB_BONUS feature.

When the item was equipped the bonus applied. However, when quickly equipping and unequipping the item the bonus started stacking. Initially melee attack was set at a value of 1 then after wearing the item melee attack was set to 3 as expected. If I removed and re-wore the item quickly the bonus started stacking - so 1 to 3, 3 to5, 5 to 7 , etc.

Interestingly, if I waited a few seconds after observing this stacking phenomenon then removed and rewore the item the skill and bonus went back to baseline. It seems that the mud needs some time to reset the bonus after unequipping the item. Here's the relevant code after SetWear( (:check_morality:) ) in the armor item file

Code: [Select]

varargs int check_morality(object who, string where){
    int x, y, morality;
    object env = environment(who);

    morality = who->GetMorality();
   
    x=who->GetSkillLevel("melee attack");
    who->eventPrint("Melee attack before skill bonus = "+x+".");
             
    //only less than 'good' chars can use

    if( morality <=200 ){
    object ob=new(LIB_BONUS);
    ob->SetSkills( (["melee attack" : 2]) );
    ob->eventMove(who);
   
    x=who->GetSkillLevel("melee attack");
    who->eventPrint("Melee attack after skill bonus = "+x+".");
   
    who->eventPrint("You can feel an increase in your fighting "+
           "prowess as you put on the gloves.");
        if(env) tell_room(env, who->GetName()+" wears "+
          GetShort()+".", ({who})); 
     
    return 1; 

    }

    else {
       who->eventPrint("You cannot seem to get your hands in "+
            "the gloves.");
       
        x=who->GetSkillLevel("melee attack");
        who->eventPrint("Melee attack not wearing gloves = "+x+"."); 
    return 0;

    }
       
}


Here's the output I received - wearing and removing is in quick succesion:

(Morality is too high)

wear gloves
Melee attack before skill bonus = 1.
You cannot seem to get your hands in the gloves.
Melee attack not wearing gloves = 1.

(Reset morality)

call me->SetMorality(200)
OBJ(lash /secure/save/creators/l/lash) -> SetMorality( 200 ) = 200
wear gloves
Melee attack before skill bonus = 1.
Melee attack after skill bonus = 3.
You can feel an increase in your fighting prowess as you put on the gloves.
remove gloves
You remove a pair of swordsman gloves.

wear gloves
Melee attack before skill bonus = 3.
Melee attack after skill bonus = 5.
You can feel an increase in your fighting prowess as you put on the gloves.
remove gloves
You remove a pair of swordsman gloves.

wear gloves
Melee attack before skill bonus = 5.
Melee attack after skill bonus = 7.
You can feel an increase in your fighting prowess as you put on the gloves.
remove gloves
You remove a pair of swordsman gloves.

(After waiting about 5 seconds after removing the gloves)

wear gloves
Melee attack before skill bonus = 1.
Melee attack after skill bonus = 3.
You can feel an increase in your fighting prowess as you put on the gloves.

I was wondering if having a check for "if not worn" every heartbeat to do something like:

Code: [Select]

int check_gloves(string skill) {
    write("Check gloves called");
    if( !GetWorn() ) {
        previous_object()->RemoveSkillBonus("melee attack", this_object());
        return 0;
    }


I had the above function called before checking for the morality condition but it did not make a difference in the stacking behaviour.




30
Bug Central / Re: Default MudTime in Dead Souls
« on: January 05, 2009, 04:16:46 PM »
Basically, the way it works is hours /2 with 0 hour equivalent to half the DAY_LENGTH value in am.

A 30 hour day:
Hour      Mudtime         
0           15am             
1 -14     1am - 14am
15          15pm (in my first post this should have been hour 10 and 10 pm)
16-29    1pm - 14pm

So, not really a bug per se just something to be aware of when fooling with mudtime, ticktock, and time from SEASONS_D->GetMudTime(); where the hours are based on 0 to x; x being the hours defined by DAY_LENGTH in config.h.

It was just kind of weird thinking of 10 pm or 15 pm as being the middle of the day and then going straight to 1 pm.

In order to be consistent ticktock and mudtime have to be coded to take in the DAY_LENGTH value.

Lash

Pages: 1 [2] 3