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.


Topics - Lash

Pages: [1]
1
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);

2
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;
            }
        }
    }
}

3
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.




4
Bug Central / Default MudTime in Dead Souls
« on: January 05, 2009, 02:12:22 PM »
I was messing around with creating a set time for an npc to have an action and came across some weirdness.

The library DS2.8.4 is set with a default hours per day of 20 in config.h under lib/secure/include (#define DAY_LENGTH) .

When the mudtime goes from 19 hours and 59 minutes (9:59 pm mudtime) to 0 hours 0 minutes the mudtime comes back as 10:00 am and thus there are two 10 am's .

ticktock with no argument comes back as 12:00 am at this time.

It looks like what is happening is that mudtime is reporting time based on the number of hours and subtracting 10 based on a 20 hour day after the halfway point (as defined in mudtime.c as DAY_LENGTH/2 for determining "am" and "pm" under lib/secure/cmds/creators ).  When time goes into double digits mudtime gets screwey. The mud day looks like this:

Hour      Mudtime         Ticktock
0           10am               12am
1 -10     1am - 10am     1am-10am
11-19    1pm - 9 pm      11am-7pm

Weirdly, setting the hours per day in config.h to 24 gives the "expected normal" output. Mudtime and ticktock give the same time based on a 24 hour day. I just wanted to report on these findings in case someone else might find this useful. The relationship between mudtime and hours/day has to be played with to get a consistent output if left at the default setting of 20. I haven't found that code yet but will look into this more.

I guess this isn't a problem since mudtime is a creator command and a set time function based on hours in the mud will execute. It just got confusing waiting for my npc to do something at 11:00 am when "11:00 am" turned out to be 1:00pm instead :P

Here's the code I used for the npc I was building:

set_heart_beat(1);

heart beat function:

void heart_beat(){

    ::heart_beat();

    wander();

}

wander function:

int wander(){
int hour, minutes;       

    int *time_of_day;



    time_of_day = SEASONS_D->GetMudTime();

    hour = time_of_day[0];

    minutes = time_of_day[1];

    eventForce("say hour "+hour+"; minutes "+minutes+".");

other stuff

}

Lash

5
Dead Souls Support / Overlapping armor types and increased damage
« on: December 19, 2008, 07:49:34 PM »
This may be old hat to some, but it appears that overlapping armor types cause increase in damage from an attacker.
Here is a log from whacking the dummy  wearing a shield (armor type A_SHIELD) and bracers (armor type A_CUSTOM with restrictions on "right arm" and "left arm"). When worn separately no problem. When worn together I get this:
 
Dummy says in English, "I receive damage from fighter. Damage type is BLADE,
    raw damage is 204, body part(s) affected: right hand."
Dummy says in English, "Actual damage done: 197."
Dummy says in English, "Protection due to armor: 7."
Fighter pricks Dummy lightly in the right hand with his sharp sword.

A_SHIELD protects hands. Bracers do not.

And in the same round of fighting:

Dummy says in English, "I receive damage from fighter. Damage type is BLADE,
    raw damage is 160, body part(s) affected: left arm."
Dummy says in English, "Actual damage done: 305."
Dummy says in English, "Protection due to armor: -145."
Fighter pricks Dummy just barely in the left arm with his sharp sword.

A_SHIELD protects arms as well as A_CUSTOM with "arms" restrictions.

Interestingly, "torso" protection is negated.

Any ideas?

Lash

6
Design Lab / Genetics
« on: December 04, 2008, 06:41:05 AM »
Two concepts that really turned me on to Dead Souls are the use of genetics and infectious diseases.

I was interested in expanded these ideas. If this has been done or discussed elsewhere please point me in the right direction.

As far as genetics, I would like to get some input about the idea of inserting "code" into the player object that determines physical appearance as well as abilities. Specifically, I was thinking along the lines of having actual "genetic material" in the form of DNA that when "read" would determine the appearance of eye color, for instance.

The player object would include code for eye color such as:

ATG GCC CCT AGA GGT GAG CGC ATA CTA TTT TAG which determines the corresponding amino acid sequence:

MAPRGERILF*

One gene (33 nucleotides) coding for a ten amino acid protein that determines grey eyes.

Deviations from the nucleotide sequence could result in shades of grey. Furthermore, since the genetic code has some redundancy, changes at the DNA level may not affect grey color at all since the amino acid sequence would be identical. For example,

ATG GAC CCT AGA GGT GAG CGC ATA CTA TTT TAG would still result in the MAPRGERILF* aa sequence

however

ATG GAC C CCT AGA GGT GAG CGC ATA CTA TTT TAG would result in the MDPRGERILF* aa sequence and have an affect on the shade of grey.

The above is critical because ultimately changes in DNA sequence may result in a change to the protein or not. Functionality of the protein could be affected from minor to the point of being nonfunctional. For instance, if a stop codon in the DNA (TAG in this example) is introduced in the middle of the protein the creature may very well become blind.

These are simple examples to illustrate a point. A major omission is the role of RNA in the translation process of DNA to protein and may not be relevant in a MUD universe.

When a player develops a character at login they are able to choose phenotypic traits such that the DNA sequence defining those traits are included in their player object. Other traits would be hidden from the player, such as those that determine stats and abilities.  A drawback would be that one would have to design a gene for each trait specified and has the potential to become quite cumbersome. But the neat thing is that one could develop certain programming rules that result in phenotypic changes based on  random DNA sequence changes. That might be a pretty big database.

Now, if this is possible, imagine the use of infectious agents, such as a retrovirus, that could infect a player and alter the genetic sequence resulting in phenotypic change. Or, better yet, players developing technology to change their own, or others, DNA sequences.

Thoughts appreciated.

Lash



   

7
Design Lab / Lib Port
« on: December 02, 2008, 11:24:14 AM »
Hello,

I'm pretty new to the Dead Souls mudlib. Thanks to Cratylus for releasing Dead Souls to the community and others for being so active and helpful.

You've probably seen me running Dead Souls on the mudlist listed as WinBlows, WinBlows Portable, and LibPortTest. These three represent Dead Souls up at home on the XP box, elsewhere on an XP box booted from a flash drive (Portable), or working with Dead Souls on a Ubuntu box (LibPortTest).

My project is porting the diku library form the DIKU-ALFA release to Dead Souls. This may be stoopid and redundant,
but most of all it is kind of a sick joke :p. But, diku is a mud that I'm familiar with and makes learning Dead Souls a little easier (I think). I've coded for a diku mud in the past but LP's are so much more flexible in my opinion - thus the switch.

I plan on releasing the lib when I'm finished to anyone who is interested in taking a look at it. Questions, comments, ideas, etc. are welcome. I'll keep an update here periodically to let you know how I'm progressing with this.

So far I have 2 out of 23 zones completed.

Lash

Pages: [1]