Jump to content
  • 0

Incorporating weight into a bonus


Synel

Question


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.01
  • Content Count:  38
  • Reputation:   1
  • Joined:  01/09/17
  • Last Seen:  

I've read through the wiki here: https://github.com/rathena/rathena/wiki/Adding-New-Bonuses

Was able to follow it through for the most part, though some of the format/coding used now is different from that put forth in the wiki. What I'm trying to do is incorporate a players total equipped weight into a damage reduction of a kind.

Essentially, I'd like to take 10% of any given equipment's weight, convert that into a variable bonus to reduce damage by a percentage. I've defined the variables and created three new classifications for the bonus (I think) but I'm not actually sure how to implement the coding in battle.c. or if any other files would need to be edited. Any advice would be appreciated. The following files have been edited so far:

map.hpp

pc.hpp

status.cpp

pc.cpp

const.txt

Edit: I'm currently thinking of using the following code for grabbing equipment weight:

                short index = sd->equip_index[insert equipment piece here];

                if (index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_ARMOR)
                    skillratio += sd->inventory_data[index]->weight / 10;

Edited by Synel
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  928
  • Reputation:   169
  • Joined:  04/05/13
  • Last Seen:  

Find

bonus2 bSubClass line of code.

And look for damage reduction, Then add your new bonus here.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.01
  • Content Count:  38
  • Reputation:   1
  • Joined:  01/09/17
  • Last Seen:  

44 minutes ago, Start_ said:

Find

bonus2 bSubClass line of code.

And look for damage reduction, Then add your new bonus here.

That's in PC.CPP I think? Thank you. I'm assuming this is correct?:

    case SP_SUBEQUIPWEIGHT;
        PC_BONUS_CHK_CLASS(type2,SP_SUBEQUPWEIGHT);
        if(sd->state.lr_flag != 2)
            sd->equip_weight += val;

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  928
  • Reputation:   169
  • Joined:  04/05/13
  • Last Seen:  

Try something like this. You need to change code formula to match your new bonus.

case SP_SUBEQUIPWEIGHT: // bonus bSubEquipWeight,x; //[Synel]
		if (sd->state.lr_flag != 2)
			sd->subclass[type2] += val;
		break;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.01
  • Content Count:  38
  • Reputation:   1
  • Joined:  01/09/17
  • Last Seen:  

On 8/17/2020 at 9:05 PM, Start_ said:

Try something like this. You need to change code formula to match your new bonus.


case SP_SUBEQUIPWEIGHT: // bonus bSubEquipWeight,x; //[Synel]
		if (sd->state.lr_flag != 2)
			sd->subclass[type2] += val;
		break;

 

Cool cool. Thanks man. I think I got this part. I'm still working on how to do the battle.c if you or anyone else has any info. 

 

Edit: I'm going at this from another angle. 

 

Edit: Note sure I'm on the right track or not. Since I'd prefer this bonus be applied before all the others I made it into a new type of bonus.  Trying to get weight from player characters equipment and pass it into a variable to throw into the main damage calculation. Nothing's organized here but gather code I might need.

Alright. I got nothing. Tried multiple forms and attempts of this script and looked through script.cpp, script.hpp, script commands and a few other files. Can't figure out how to run a script with a stat calc event/equip/unequip item. There's both equip and unequip scripts that return "SCRIPT_CMD_SUCCESS" which is equal to 0 but I've not been able to incorporate that into this.

 

Quote

 

function    script    WEIGHT_INTO_RESISTANCE    {        
            bonus2 bSubClass,Class_All,getarg(0,0)/10;
            bonus bcriticaldef,getarg(0,0)/20;
    return;
    }

If(!weapon) {
            .@x = ((getiteminfo(getequipid(EQI_HEAD_TOP),weight) + getiteminfo(getequipid(EQI_HEAD_MID),weight) + getiteminfo(getequipid(EQI_HEAD_LOW),weight)  + getiteminfo(getequipid(EQI_GARMENT),weight) + getiteminfo(getequipid(EQI_ARMOR),weight) + getiteminfo(getequipid(SHOES),weight) + getiteminfo(getequipid(EQI_ACC_R),weight) + getiteminfo(getequipid(EQI_ACC_L),weight) + getiteminfo(getequipid(EQI_HAND_L),weight))/ 10)
                    WEIGHT_INTO_RESISTANCE(.@x);
                    Break;
        }
        

//if( !sd->state.pc_loaded )

 


 

 

Edited by Synel
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...