Jump to content
  • 0

Wrong calculating atk with setunitdata


nguyenhuy123

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   1
  • Joined:  08/24/19
  • Last Seen:  

I'm currently use setunitdata to change str,min attk and max attk of a mob like this:

// Save current mob data
getunitdata .GID, .@por_arr;
        
// Cache origin value of mob for the first time to calculate anger later
if (!.origin_sch_data) {
	copyarray .origin_sch_data[0], .@por_arr[0], getarraysize(.@por_arr);
}

set .@newminatk, .origin_sch_data[UMOB_ATKMIN] + .anger_arr[1] * 2;
set .@newmaxatk, .origin_sch_data[UMOB_ATKMAX] + .anger_arr[1] * 2;

setunitdata .GID,UMOB_STR,.origin_sch_data[UMOB_STR] + .anger_arr[1];
setunitdata .GID,UMOB_ATKMIN,.@newminatk;
setunitdata .GID,UMOB_ATKMAX,.@newmaxatk;

But as i log through the command line, i can see that the atk of mob is decreasing instead of increasing:

image.thumb.png.6b996a4d7c0c7ba5e7cb24a60b016b4b.png

This is small piece of code i put into setunitdata source code to log:

if (calc_status) {
	status_calc_bl(&md->bl, SCB_BATTLE);
	ShowDebug("log current min-maxatk: %d %d\n", md->status.rhw.atk, md->status.rhw.atk2);
}

Also this is the stat of the mob i spawn:

image.thumb.png.47da820a2d957ab241b4cf299248889c.png

Is there any wrong with command "setunitdata" for atk calculating?

Another try:  When i increase int, the matk is increase too.

Edited by nguyenhuy123
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

Get/setunitdata works incorrectly and gets/sets from wrong variables because it doesn't implement renewal changes to stat mechanics properly.

This is what I had to do to make it work for the matk stats : https://github.com/rathena/rathena/pull/3968

I haven't investigated the atk stat yet. However, like matk, the min and max values are calculated. Setting them makes no sense because they are not the base values so they'll be replaced as soon as the unit is recalculated. Monsters only have one base atk value, and it's atk1. atk2 is their base matk stat.

It's really disappointing such basic functionality was remaning broken for this long.

  • Like 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  21
  • Reputation:   1
  • Joined:  08/24/19
  • Last Seen:  

On 12/1/2019 at 3:01 AM, Seravy said:

Get/setunitdata works incorrectly and gets/sets from wrong variables because it doesn't implement renewal changes to stat mechanics properly.

This is what I had to do to make it work for the matk stats : https://github.com/rathena/rathena/pull/3968

I haven't investigated the atk stat yet. However, like matk, the min and max values are calculated. Setting them makes no sense because they are not the base values so they'll be replaced as soon as the unit is recalculated. Monsters only have one base atk value, and it's atk1. atk2 is their base matk stat.

It's really disappointing such basic functionality was remaning broken for this long.

Thanks @Seravy, i will take a look on the source.

I don't know why we do this( in status_calc_bl_main function in status.cpp), but this block of code make the str modifier not affect batk anymore( just like +1 then -1):

image.png.75f7f9da2d6f956b84d9028c0ee7bb92.png

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