Author Topic: Advance.c - Advances target's level, max HP, MP, SP  (Read 3339 times)

Offline amylase

  • Friend
  • **
  • Posts: 75
    • View Profile
    • gpLand
Advance.c - Advances target's level, max HP, MP, SP
« on: December 12, 2006, 05:34:51 PM »
Here's my very first command Advance.c which will upgrade your target's level by 1 and other attributes such as max MP, max HP, max SP by increments of 10. You can also advance yourself by typing "Advance me" or "Advance myself". My initial intent aimed at increasing max HP only. After looking around it appears max HP is calculated from something else (from memory it's something like level times ten plus fifty). To save time and satisfy my laziness, I just pulled a whole chunk out of good old dirk and advanced a bunch of things all in one hit. They pretty much all fall under "the more the merrier" category, so that seemed a pretty good outcome in the end. If anyone knows how to specifically increase max HP (and only max HP), I'd love to learn about it.

Mudlib: DeadSouls 2.1 on Windows XP
Driver: MudOS v22.2b14
Filename: /ds/lib/secure/cmds/creators/advance.c

Code: [Select]
/*
/ds/lib/secure/cmds/creators/advance.c
Extracted from the original dirk.c of Adventurers' Guild.

Allows you to advance a player's (living and NPC) level and thereby also increase
its other attributes such as level of maximum HP, MP, SP by increments of 10.

Syntax: Advance <Player>
*/

#include <lib.h>

inherit LIB_DAEMON;

int eventRegenerate(object who){
    int i;
    string *stumps;
    stumps=who->GetMissingLimbs();
    if(sizeof(stumps)) {
for(i=0;i<sizeof(stumps);i++){
    who->RestoreLimb(stumps[i]);
}
    }
    return 1;
}

mixed cmd(string args) {
    string cmd = args;
    object who;
    mapping stumps;
    string *limb_arr = ({});
    mixed *statlist;
    int i, mhp, msp, mmp, self;
    mapping this_stat;
    int desired_level, statclass, statlevel;
 

    if( !cmd || cmd == "" ) {
return "Syntax: <advance LIVING>";
    }

    if(member_array(args,({"me","myself"})) != -1 ) self = 1;
    else self = 0;

    if( !self && !who = find_living(args) ) {
write("That being is unavailable.");
return 1;
    }
    if(!self){
previous_object()->eventPrint("You advance " + who->GetName() + ".");
who->eventPrint(previous_object()->GetCapName() + " advances you.");
say(this_player()->GetCapName() + " advances "+ who->GetName() + ".");
    }
    else {
who = this_player();
previous_object()->eventPrint("You advance thyself.");
say(this_player()->GetCapName() + " advances "+
  objective(this_player())+"self.");
    }

       statlist = who->GetStats();

who->SetLevel(desired_level);
who->AddTrainingPoints(desired_level);

for(i=0;i<sizeof(statlist);i++){
    this_stat = who->GetStat(statlist[i]);
    statclass = this_stat["class"];
    statlevel = this_stat["level"];
    who->SetStat(statlist[i],statlevel + 1,statclass);
}
who->save_player((string)this_player()->GetKeyName());
    return 1;
}

string GetHelp(string topic) {
    return ("Syntax: <advancel LIVING>\n\n"
      "Allows you to advance a living being level and thereby also increase"
      "other attributes such as level of maximum HP, MP, SP by increments of 10.");
}
« Last Edit: December 19, 2006, 08:12:23 PM by amylase »

Offline argus

  • Acquaintance
  • *
  • Posts: 24
    • View Profile
Re: Advance.c - Advances target's level, max HP, MP, SP
« Reply #1 on: January 30, 2007, 04:04:24 AM »
oi!  heya. umm. havin a slight complication with the command. get in touch with me. i am argus    @ mystiquemud.altrealm.com

Offline argus

  • Acquaintance
  • *
  • Posts: 24
    • View Profile
Re: Advance.c - Advances target's level, max HP, MP, SP
« Reply #2 on: January 30, 2007, 05:25:15 AM »
amylase. the problem i was having with your code. loaded fine etc. problem was when used it gave all messages and what not...but advanced player to level 0

ie argus at level 1
advance me

stats
level =0    and from there would do nothing else but give messages. below is the fix. courtesy of myself and Logras@Ascension....mostly logras  after
statlist = who->GetStats();   added two lines

             desired_level=who->GetLevel();
             desired_level+=1;


Code: [Select]
/*
/ds/lib/secure/cmds/creators/advance.c
Extracted from the original dirk.c of Adventurers' Guild.

Allows you to advance a player's (living and NPC) level and thereby also increase
its other attributes such as level of maximum HP, MP, SP by increments of 10.

Syntax: Advance <Player>
*/

#include <lib.h>

inherit LIB_DAEMON;

int eventRegenerate(object who){
    int i;
    string *stumps;
    stumps=who->GetMissingLimbs();
    if(sizeof(stumps)) {
for(i=0;i<sizeof(stumps);i++){
    who->RestoreLimb(stumps[i]);
}
    }
    return 1;
}

mixed cmd(string args) {
    string cmd = args;
    object who;
    mapping stumps;
    string *limb_arr = ({});
    mixed *statlist;
    int i, mhp, msp, mmp, self;
    mapping this_stat;
    int desired_level, statclass, statlevel;
 

    if( !cmd || cmd == "" ) {
return "Syntax: <advance LIVING>";
    }

    if(member_array(args,({"me","myself"})) != -1 ) self = 1;
    else self = 0;

    if( !self && !who = find_living(args) ) {
write("That being is unavailable.");
return 1;
    }
    if(!self){
previous_object()->eventPrint("You advance " + who->GetName() + ".");
who->eventPrint(previous_object()->GetCapName() + " advances you.");
say(this_player()->GetCapName() + " advances "+ who->GetName() + ".");
    }
    else {
who = this_player();
previous_object()->eventPrint("You advance thyself.");
say(this_player()->GetCapName() + " advances "+
  objective(this_player())+"self.");
    }

       statlist = who->GetStats();
desired_level=who->GetLevel();
desired_level+=1;
who->SetLevel(desired_level);
who->AddTrainingPoints(desired_level);

for(i=0;i<sizeof(statlist);i++){
    this_stat = who->GetStat(statlist[i]);
    statclass = this_stat["class"];
    statlevel = this_stat["level"];
    who->SetStat(statlist[i],statlevel + 1,statclass);
}
who->save_player((string)this_player()->GetKeyName());
    return 1;
}

string GetHelp(string topic) {
    return ("Syntax: <advancel LIVING>\n\n"
      "Allows you to advance a living being level and thereby also increase"
      "other attributes such as level of maximum HP, MP, SP by increments of 10.");
}

Offline detah

  • BFF
  • ***
  • Posts: 190
  • Ruler of 2D
    • View Profile
Re: Advance.c - Advances target's level, max HP, MP, SP
« Reply #3 on: January 30, 2007, 07:58:17 AM »
There seems to be some confusion about how MaxHP are calculated.

See /lib/race.c L153

Durability determines MaxHP, not level. Race.c is called at least once per tick (sometimes more than once per heartbeat), so unless you rewrite race.c and body.c and combat.c and a few others, you are stuck with the durability -> MaxHP relationship.  Also, you will probably need to add a MaxHP variable to the player object.

This is not a big deal for modifying NPC traits, but there may be other considerations why you dont want to automatically give a Player more Durability in addition to the higher level. FYI Durability affects other functions in the game, sobriety/intoxication to name one.

Offline amylase

  • Friend
  • **
  • Posts: 75
    • View Profile
    • gpLand
Re: Advance.c - Advances target's level, max HP, MP, SP
« Reply #4 on: May 10, 2007, 08:27:21 AM »
Thanks for the modification argus. Thanks for the information detah. I guess I had only one specific goal at the time, and that was to have a command which will allow manual, force extension of maximum HP at all cost. To my first surprise there was not such a command readily available which I would have thought to be in high demand. Also possibly as a result of my long history from playing RPG games on Playstation which typically extend MaxHP based on level, to my second surprise MaxHP in Dead Souls 2 is not a direct function of level. When I searched across the entire DS2 library, like detah pointed out, several places are involved and to some extent interdependent. The coding for MaxHP in Dead Souls 2 turns out to be almost like a phenotype expressed as a combined result of various different genes here and there (race.c, body.c, combat.c etc). Anyway, until someone who has the time, expertise and interest to implement anything different in this regard, hopefully in the meantime average users find advance.c enjoyable and effective in extending maximum HP.