Old patch from 1997

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago #5928 by JTP
Old patch from 1997 was created by JTP
This patch dont save and/or load in tba, if someone wanna update this patch for tbamud, i will be glad.
        This is how I went about implementing death/kill/deathtrap
counters for player characters.  It's meaningless in terms of characters
having view of the underlying engine, yet still satisfies their hunger for
numbers in do_score.  Shame to let all that extra space in the playerfile
go to waste :)

        I also have a 'victories in the arena' counter, but left it out
considering my arena being scratch code.  Should be simple enough to add.
jacobin@bellatlantic.net if you have any problems.

-Jac
A ButterMud Production - Telnet://betterbox.net:4000

Edit the follow spares in structs.h (player specials)

__structs.h__

 int spells_to_learn;         /* How many can you learn yet this level*/
   int rip_cnt;
   int kill_cnt;
   int dt_cnt;;
   int spare10;

__

Add the following macros to utils.h

__utils.h__


#define GET_RIP_CNT(ch)         ((ch)->player_specials->saved.rip_cnt)
#define GET_KILL_CNT(ch)        ((ch)->player_specials->saved.kill_cnt)
#define GET_DT_CNT(ch)          ((ch)->player_specials->saved.dt_cnt)

__

Add the following right before die(victim) is called.

__fight.c__

 if (!IS_NPC(victim))
     GET_RIP_CNT(victim) += 1;
    if (!IS_NPC(ch))
     GET_KILL_CNT(ch) += 1;

__

Add the following right before the character is extracted when walking
into a deathtrap.

__act.movement.c__

GET_DT_CNT(ch) += 1;

__

Report it within do_score

__do.score__

 sprintf(buf, "%sYou have died %d times and killed %d opponents.\r\n",
          buf, GET_RIP_CNT(ch), GET_KILL_CNT(ch));
    sprintf(buf, "%sYou have walked into a deathtrap %d times.\r\n",
          buf, GET_DT_CNT(ch));

__

Now for the nosey wizards in stat_char

__act.wizard.c__

sprintf(buf, "Rip: [%d], Kills: [%d], DeaathTraps:
[%d]\r\n",GET_RIP_CNT(k), GET_KILL_CNT(k), GET_DT_CNT(k));  
    send_to_char(buf, ch);

__

Reboot!

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago #5929 by thomas
Replied by thomas on topic Old patch from 1997
Actually it is quite easy to save/load from ascii pfiles.

Have a look here: github.com/tbamud/tbamud/blob/2f12752373...4/src/players.c#L239

All values are treated the same in load_char:
1. first, they are set to some predefined value (think of it as "zero", even if it sometimes is something else)
2. then, depending on the first letter, then the full code in the file, the values are set.

The same goes for save_char(), here: github.com/tbamud/tbamud/blob/2f12752373...4/src/players.c#L503

Every value is written, one at a time, with a code to help read it again.

So, to make it save and load:
1. add a line for each value to save_char, like this:
 if (GET_RIP_CNT(ch)  != 0)		fprintf(fl, "RipC: %d\n", GET_RIP_CNT(ch));
2. add these lines in load_char (so they match the existing pattern):
  GET_RIP_CNT(ch) = 0;
..
..

 case 'R':
	     if (!strcmp(tag, "Room"))	GET_LOADROOM(ch)	= atoi(line);
+       else if (!strcmp(tag, "RipC"))  GET_RIP_CNT(ch)         = atoi(line);
	break;


Repeat for the other three values.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago - 6 years 8 months ago #5930 by JTP
Replied by JTP on topic Old patch from 1997
Add the following right before die(victim) is called.

__fight.c__

if (!IS_NPC(victim))
GET_RIP_CNT(victim) += 1;
if (!IS_NPC(ch))
GET_KILL_CNT(ch) += 1;

added this in fight.c just before die(victim, ch); that it seems to be called in tbamud, but its located two Places in fight.c ?


tryed to kill a mob...counter didnt add 1. tryed dying counter didnt add 1 :(
So im still at 0 and 0

i then tryed walking into a DT, that added +1. But when i quit and came back it was back to 0
This is what i added to save:
load_char
    GET_RIP_CNT(ch) = 0;
    GET_KILL_CNT(ch) = 0;
    GET_DT_CNT(ch) = 0;

      case 'K':
        if (!strcmp(tag, "KillC"))      GET_KILL_CNT(ch)         = atoi(line);
        break;

in case D
        else if (!strcmp(tag, "DtC"))   GET_DT_CNT(ch)          = atoi(line);

in case R
        else if(!strcmp(tag, "RipC"))   GET_RIP_CNT(ch)  = atoi(line);



save_char:

  if (GET_RIP_CNT(ch)      != 0)                fprintf(fl, "RipC: %d\n", GET_RIP_CNT(ch));
  if (GET_KILL_CNT(ch)     != 0)                fprintf(fl, "KillC: %d\n", GET_KILL_CNT(ch));
  if (GET_DT_CNT(ch)       != 0)                fprintf(fl, "DtC: %d\n", GET_DT_CNT(ch));


So why isnt it adding +1 to kill and rip.

And why isnt it saving and loading right, what am i missing ?
Last edit: 6 years 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago - 6 years 8 months ago #5931 by JTP
Replied by JTP on topic Old patch from 1997
Game seems very unstable after i added above code + save and load...im crashing every few minutes with various backtrace problems, that isnt even in the files of this code.


Program terminated with signal 11, Segmentation fault.
#0 0x080b97dd in valid_dg_target (ch=0x9482070, bitvector=1) at dg_misc.c:279
279 else if (ch->desc && (STATE(ch->desc) != CON_PLAYING))


Program terminated with signal 11, Segmentation fault.
#0 0x0032986b in strlen () from /lib/libc.so.6
(gdb)


Program terminated with signal 11, Segmentation fault.
#0 0x080b8126 in sub_write (arg=0xbfe4985f "\tG\tmKarzon Kul\tn knocks out of your hands!\tn", ch=0xa1f8ee0, find_invis=1 '\001',
targets=<value optimized out>) at dg_comm.c:180
180 if (IS_SET(targets, TO_CHAR) && SENDOK(ch))
Last edit: 6 years 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago - 6 years 8 months ago #5932 by rudeboyrave
Replied by rudeboyrave on topic Old patch from 1997
i would put this

GET_RIP_CNT(ch) = 0;
GET_KILL_CNT(ch) = 0;
GET_DT_CNT(ch) = 0;

in class.c void do_start

this is where new players are set up.

also i would put the counter ticks

if (!IS_NPC(victim))
GET_RIP_CNT(victim) += 1;
if (!IS_NPC(ch))
GET_KILL_CNT(ch) += 1;

in void die in fight.c
void die(struct char_data * ch, struct char_data * killer)
{
  gain_exp(ch, -(GET_EXP(ch) / 2));
  if (!IS_NPC(ch)) {
    GET_RIP_CNT(ch) = GET_RIP_CNT(ch) + 1;
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_KILLER);
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_THIEF);
  }
  raw_kill(ch, killer);
  if (!IS_NPC(killer))
    GET_KILL_CNT(killer) = GET_KILL_CNT(killer) + 1;
}

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.
Last edit: 6 years 8 months ago by rudeboyrave.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago - 6 years 8 months ago #5933 by JTP
Replied by JTP on topic Old patch from 1997
Ok game is still very unstable after entering this code, but now it saved how many times i died but not how many times i killed something. Didnt save DT either.

Annoying that is crashes every few minutes just because of something like this.

Program terminated with signal 11, Segmentation fault.
#0 0x0032986b in strlen () from /lib/libc.so.6
Last edit: 6 years 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago #5934 by rudeboyrave
Replied by rudeboyrave on topic Old patch from 1997
remove the code for the dt counter wherever it is and see if its not crashy anymore.

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago - 6 years 8 months ago #5935 by JTP
Replied by JTP on topic Old patch from 1997
Got it to save all 3 now :)

but yes i still crash

Core was generated by `bin/circle -q 6969'.
Program terminated with signal 11, Segmentation fault.
#0 0x0032986b in strlen () from /lib/libc.so.6


got this Again, it comes out of the blue...i dont even enter a DT.
Last edit: 6 years 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago #5936 by JTP
Replied by JTP on topic Old patch from 1997
Ok testing now without dt coundter in act.movement.c

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago #5937 by rudeboyrave
Replied by rudeboyrave on topic Old patch from 1997
my guess is your counter in act.movement.c is making mobs crash the game when they move.

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago #5938 by JTP
Replied by JTP on topic Old patch from 1997
Crashed Again with something new:

Program terminated with signal 11, Segmentation fault.
#0 0x080b980d in valid_dg_target (ch=0xa921268, bitvector=1) at dg_misc.c:279
279 else if (ch->desc && (STATE(ch->desc) != CON_PLAYING))

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago #5939 by rudeboyrave
Replied by rudeboyrave on topic Old patch from 1997
are you fighting a mob with triggers? or just random crashes?

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago #5940 by JTP
Replied by JTP on topic Old patch from 1997
i can fight a mob with and without trigger or just stand still doing nothing. It will crash at some point.

Sucks that it now saves all 3 and it crashes like hell. The mud has just run for 4 days with no problems, and now all this over this Little snippet :)

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago #5941 by rudeboyrave
Replied by rudeboyrave on topic Old patch from 1997
post every line of code you edited, maybe we can find the problem. is it compiling error free?

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago - 6 years 8 months ago #5942 by JTP
Replied by JTP on topic Old patch from 1997
Compiles just fine
structs.h

after: int spells_to_learn; 
   int rip_cnt;
   int kill_cnt;
   int dt_cnt;

__

utils.h

#define GET_RIP_CNT(ch)         ((ch)->player_specials->saved.rip_cnt)
#define GET_KILL_CNT(ch)        ((ch)->player_specials->saved.kill_cnt)
#define GET_DT_CNT(ch)          ((ch)->player_specials->saved.dt_cnt)

__
players.c

load_char
    GET_RIP_CNT(ch) = 0;
    GET_KILL_CNT(ch) = 0;
    GET_DT_CNT(ch) = 0;

      case 'K':
        if (!strcmp(tag, "KilC"))      GET_KILL_CNT(ch)         = atoi(line);
        break;

in case D
        else if (!strcmp(tag, "DtC "))   GET_DT_CNT(ch)          = atoi(line);

in case R
        else if(!strcmp(tag, "RipC"))   GET_RIP_CNT(ch)  = atoi(line);



save_char:

  if (GET_RIP_CNT(ch)      != 0)                fprintf(fl, "RipC: %d\n", GET_RIP_CNT(ch));
  if (GET_KILL_CNT(ch)     != 0)                fprintf(fl, "KilC: %d\n", GET_KILL_CNT(ch));
  if (GET_DT_CNT(ch)       != 0)                fprintf(fl, "DtC : %d\n", GET_DT_CNT(ch));

__

Add the following right before the character is extracted when walking
into a deathtrap.

act.movement.c

GET_DT_CNT(ch) += 1;

__
fight.c
void die(struct char_data * ch, struct char_data * killer)
{
  gain_exp(ch, -(GET_EXP(ch) / 2));
  if (!IS_NPC(ch)) {
    GET_RIP_CNT(ch) = GET_RIP_CNT(ch) + 1;
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_KILLER);
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_THIEF);
  }
  raw_kill(ch, killer);
  if (!IS_NPC(killer))
    GET_KILL_CNT(killer) = GET_KILL_CNT(killer) + 1;
}
__
class.c
  GET_RIP_CNT(ch) = 0;
  GET_KILL_CNT(ch) = 0;
  GET_DT_CNT(ch) = 0;

__

do.score


send_to_char(ch, "You have died %d times, killed %d opponents and walked into a deathtrap %d times.\r\n", GET_RIP_CNT(ch), GET_KILL_CNT(ch), GET_DT_CNT(ch));
__
Last edit: 6 years 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago #5944 by rudeboyrave
Replied by rudeboyrave on topic Old patch from 1997
looks pretty clean to me. could you show me in context where the act.movement.c line is added? before the extract?

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago #5945 by JTP
Replied by JTP on topic Old patch from 1997
yes just before extract

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago - 6 years 8 months ago #5946 by rudeboyrave
Replied by rudeboyrave on topic Old patch from 1997
load_char
GET_RIP_CNT(ch) = 0;
GET_KILL_CNT(ch) = 0;
GET_DT_CNT(ch) = 0;

this should not be in load_char, put only in do_start because it is resetting every login maybe?

if added to do_start it would only be set to 0 when a char is made.

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.
Last edit: 6 years 8 months ago by rudeboyrave.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
6 years 8 months ago #5947 by JTP
Replied by JTP on topic Old patch from 1997
forgot to remove that from the document, that it was is now in class.c as you said.

Please Log in or Create an account to join the conversation.

More
6 years 8 months ago #5948 by rudeboyrave
Replied by rudeboyrave on topic Old patch from 1997
i guess if you could upload the .c files somewhere i could have a better look

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.

Please Log in or Create an account to join the conversation.

Time to create page: 0.255 seconds