Jump to content
  • 0

Damage logs


gabrielfb22

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/13/14
  • Last Seen:  

Greetings everyone,

I've been trying to log damage numbers related to each character at a certain mapflag, however I've got no success at all. So I got the idea of logging the "Battle message" numbers on the chat instead of trying to mess around creating new src commands. Where would I be able to find those numbers on the server side? I gave a look at clif.c but still couldn't find out the logic behind it. Thanks in advance!

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  477
  • Reputation:   269
  • Joined:  06/13/17
  • Last Seen:  

This is all about source.. you can start looking at pc.cpp/.hpp

uint16 dmglog[DAMAGELOG_SIZE_PC]; ///target ids

EDIT : however if you just want to get the damage log of a certain mob.. it's good to look at mob_dead function around mob.cpp ?

Edited by Haruka Mayumi
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/13/14
  • Last Seen:  

On 6/4/2020 at 4:35 PM, Haruka Mayumi said:

This is all about source.. you can start looking at pc.cpp/.hpp

uint16 dmglog[DAMAGELOG_SIZE_PC]; ///target ids

EDIT : however if you just want to get the damage log of a certain mob.. it's good to look at mob_dead function around mob.cpp ?

Amazing, I'll take a look at that, thanks for the reply! 

 

On 6/4/2020 at 4:35 PM, Haruka Mayumi said:

This is all about source.. you can start looking at pc.cpp/.hpp

uint16 dmglog[DAMAGELOG_SIZE_PC]; ///target ids

EDIT : however if you just want to get the damage log of a certain mob.. it's good to look at mob_dead function around mob.cpp ?

So, i took a look at the DAMAGELOG_SIZE_PC and it seems like it only stores players' IDs. Is that right? 

Then I found the function pc_damage_log_add on pc.cpp, however I don't really get how it stores the damage and when pc_damage_log_clear is called, do you have any insight on that?

Thanks once again.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  477
  • Reputation:   269
  • Joined:  06/13/17
  • Last Seen:  

14 minutes ago, gabrielfb22 said:

So, i took a look at the DAMAGELOG_SIZE_PC and it seems like it only stores players' IDs. Is that right? 

Then I found the function pc_damage_log_add on pc.cpp, however I don't really get how it stores the damage and when pc_damage_log_clear is called, do you have any insight on that?

Thanks once again.


i dunno what you are trying to achieve. because the damage logs have their own respective code like the mob_data->dmglog

Edited by Haruka Mayumi
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/13/14
  • Last Seen:  

6 minutes ago, Haruka Mayumi said:


i dunno what you are trying to achieve. because the damage logs have their own respective code like the mob_data->dmglog

I was trying to log those on a sql table or either create a variable to be used on a script to store the damage (onto a certain mob or mapflag), but then I got lost on how to do that.

Edited by gabrielfb22
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  477
  • Reputation:   269
  • Joined:  06/13/17
  • Last Seen:  

There's a good way to log players damage to monsters. but there's also another way for logging the players damage vs players. i just really don't know which one you are aiming. if logs between pvm or pvp. if you are focusin on pvm. you can just simply get the md->dmglog however if you want to take pvp damage logs you can do things on sd->dmglog

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/13/14
  • Last Seen:  

2 minutes ago, Haruka Mayumi said:

There's a good way to log players damage to monsters. but there's also another way for logging the players damage vs players. i just really don't know which one you are aiming. if logs between pvm or pvp. if you are focusin on pvm. you can just simply get the md->dmglog however if you want to take pvp damage logs you can do things on sd->dmglog

I'm mainly trying to log the damage on a certain monster, but I'll try that!  So dmglog is a char-bound variable? Because the system I'm trying to implement is a damage rank on an instanced monster, so I was trying to get each character's damage on a certain mapflag or monster.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  477
  • Reputation:   269
  • Joined:  06/13/17
  • Last Seen:  

for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) {
		struct map_session_data* tsd = NULL;
		if (md->dmglog[i].flag == MDLF_SELF) {
			//Self damage counts as exp tap
			count++;
			continue;
		}
		tsd = map_charid2sd(md->dmglog[i].id);
		if (tsd == NULL)
			continue; // skip empty entries
		if (tsd->bl.m != m)
			continue; // skip players not on this map
		count++; //Only logged into same map chars are counted for the total.
		if (pc_isdead(tsd))
			continue; // skip dead players
		if (md->dmglog[i].flag == MDLF_HOMUN && !hom_is_active(tsd->hd))
			continue; // skip homunc's share if inactive
		if (md->dmglog[i].flag == MDLF_PET && (!tsd->status.pet_id || !tsd->pd))
			continue; // skip pet's share if inactive

		if(md->dmglog[i].dmg > mvp_damage) {
			third_sd = second_sd;
			second_sd = mvp_sd;
			mvp_sd = tsd;
			mvp_damage = md->dmglog[i].dmg;
		}

		tmpsd[i] = tsd; // record as valid damage-log entry

		switch( md->dmglog[i].flag ) {
			case MDLF_NORMAL: dmgbltypes|= BL_PC;  break;
			case MDLF_HOMUN:  dmgbltypes|= BL_HOM; break;
			case MDLF_PET:    dmgbltypes|= BL_PET; break;
		}
	}

i'll give you a little insight on where you will edit ?
it's somewhere here.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   7
  • Joined:  07/17/18
  • Last Seen:  

12 hours ago, Haruka Mayumi said:

for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) {
		struct map_session_data* tsd = NULL;
		if (md->dmglog[i].flag == MDLF_SELF) {
			//Self damage counts as exp tap
			count++;
			continue;
		}
		tsd = map_charid2sd(md->dmglog[i].id);
		if (tsd == NULL)
			continue; // skip empty entries
		if (tsd->bl.m != m)
			continue; // skip players not on this map
		count++; //Only logged into same map chars are counted for the total.
		if (pc_isdead(tsd))
			continue; // skip dead players
		if (md->dmglog[i].flag == MDLF_HOMUN && !hom_is_active(tsd->hd))
			continue; // skip homunc's share if inactive
		if (md->dmglog[i].flag == MDLF_PET && (!tsd->status.pet_id || !tsd->pd))
			continue; // skip pet's share if inactive

		if(md->dmglog[i].dmg > mvp_damage) {
			third_sd = second_sd;
			second_sd = mvp_sd;
			mvp_sd = tsd;
			mvp_damage = md->dmglog[i].dmg;
		}

		tmpsd[i] = tsd; // record as valid damage-log entry

		switch( md->dmglog[i].flag ) {
			case MDLF_NORMAL: dmgbltypes|= BL_PC;  break;
			case MDLF_HOMUN:  dmgbltypes|= BL_HOM; break;
			case MDLF_PET:    dmgbltypes|= BL_PET; break;
		}
	}

i'll give you a little insight on where you will edit ?
it's somewhere here.

How do you save the damage as a player variable? I tried using :

 

pc_setglobalreg(sd, add_str("variable"), mvp_damage);

Or

pc_setaccountreg(sd, add_str("variable"), mvp_damage);


But the map_server crashes.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  477
  • Reputation:   269
  • Joined:  06/13/17
  • Last Seen:  

you used sd without checking if there's session data. also using sd on the loop is a no.. you should use the tsd.

here's a last insight.

	struct s_dmglog {
		int id; //char id
		unsigned int dmg;
		unsigned int flag : 2; //0: Normal. 1: Homunc exp. 2: Pet exp
	} dmglog[DAMAGELOG_SIZE];

 

  • MVP 2
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   7
  • Joined:  07/17/18
  • Last Seen:  

12 hours ago, Haruka Mayumi said:

you used sd without checking if there's session data. also using sd on the loop is a no.. you should use the tsd.

here's a last insight.


	struct s_dmglog {
		int id; //char id
		unsigned int dmg;
		unsigned int flag : 2; //0: Normal. 1: Homunc exp. 2: Pet exp
	} dmglog[DAMAGELOG_SIZE];

 

Thank you very much! it was the sd without checking, it is solved!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.01
  • Content Count:  16
  • Reputation:   0
  • Joined:  10/07/20
  • Last Seen:  

I need help and assistance with these i want to apply it on my server for my worldboss ranking script but i dont know how to apply this

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...