Jump to content

Refine Bonus


Cydh

Recommended Posts


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

I deleted some sentences here, and I forgot what they were. /hmm

so this mod, will gives script bonus for specified armor or weapon level at specified refine.
Example,

0,10,{ bonus bVit,5; }

it will makes all armors that +10, player will get VIT +5.

4,10,{ bonus bStr,5; bonus bInt,5; }

all +10 level 4 weapons, will give bonus stat +5 STR and INT

 

 
// =============================================
// [Cydh/PServeRO]
// =============================================
// Structure:
//     Type,RefineNumber,{ Script }
// ---------------------------------------------
// Type:
//     - 0 : Armor
//     - 1 : Weapon Level 1
//     - 2 : Weapon Level 2
//     - 3 : Weapon Level 3
//     - 4 : Weapon Level 4
//     - 5 : Shadow Weapon (Level 1)
//     - 6 : Shadow Weapon (Level 2)
//     - 7 : Shadow Weapon (Level 3)
//     - 8 : Shadow Weapon (Level 4)
//     - 9 : Shadow Armor
//
// ---------------------------------------------
// RefineNumber:
//     - 0 ~ MAX_REFINE
// ---------------------------------------------
// { Script }
//     - Works like { Script } on item_db.txt Look at doc/item_bonus.txt
// =============================================
// NOTES:
//     - Every line must be written completely!
// =============================================
// Examples:
//     0,1,{ bonus bVit,5; }     - Add 5 Vit for +0 Armor
//     4,10,{ bonus bStr,5; }    - Add 10 Str for +10 Weapon level 4
// ---------------------------------------------

Download:

refine-bonus-rA-20150913-f6964717.diff

[spoiler=old releases]

refine_bonus-rA-20140125.diff (Tested on latest Git)


 
How if

  • I want to make different bonus for each weapon type?

    you can make a function and place it on { Script } of weapon bonus and make a little switch-case

    switch(getiteminfo(getequipid(EQI_HAND_R)),14)
    {
        case 0:
            /* Script for Bare Fist */
            break;
        case 1:
            /* Script for Daggers */
            break;
        case 2:
            /* Script for One-handed swords */
            break;
        case 3:
            /* Script for Two-handed swords */
            break;
        case 4:
            /* Script for One-handed spears */
            break;
        case 5:
            /* Script for Two-handed spears */
            break;
        case 6:
            /* Script for One-handed axes */
            break;
        case 7:
            /* Script for Two-handed axes */
            break;
        case 8:
            /* Script for Maces */
            break;
        case 9:
            /* Script for Unused */
            break;
        case 10:
            /* Script for Staves */
            break;
        case 11:
            /* Script for Bows */
            break;
        case 12:
            /* Script for Knuckles */
            break;
        case 13:
            /* Script for Musical Instruments */
            break;
        case 14:
            /* Script for Whips */
            break;
        case 15:
            /* Script for Books */
            break;
        case 16:
            /* Script for Katars */
            break;
        case 17:
            /* Script for Revolvers */
            break;
        case 18:
            /* Script for Rifles */
            break;
        case 19:
            /* Script for Gatling guns */
            break;
        case 20:
            /* Script for Shotguns */
            break;
        case 21:
            /* Script for Grenade launchers */
            break;
        case 22:
            /* Script for Fuuma Shurikens */
            break;
    }
  • I want to make different bonus for each armor type?

    you can make a function and place it on { Script } of armor bonus and make a little switch-case

    if(getequipisequiped(EQI_HEAD_TOP))
    {
        /* Script for Upper Headgear */
    }
    if(getequipisequiped(EQI_ARMOR))
    {
        /* Script for Armor (Body) */
    }
    if(getequipisequiped(EQI_GARMENT))
    {
        /* Script for Garment */
    }
    if(getequipisequiped(EQI_SHOES))
    {
        /* Script for Footgear */
    }
    if(getequipisequiped(EQI_ACC_L))
    {
        /* Script for Left Accessory */
    }
    if(getequipisequiped(EQI_ACC_R))
    {
        /* Script for Right Accessory */
    }
    if(getequipisequiped(EQI_HEAD_MID))
    {
        /* Script for Middle Headgear */
    }
    if(getequipisequiped(EQI_HEAD_LOW))
    {
        /* Script for Lower Headgear */
    }

**Please report any bug found, and if there is suggestion too**

Edited by Cydh
  • Upvote 8
  • Love 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

good job  /no1

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  353
  • Reputation:   70
  • Joined:  07/14/12
  • Last Seen:  

works well +1

and im really sorry for what have happened. . .

 

i dunno if its only happening to me

the rest is good except for this

i get mapcrash with +20 lvl 4 weapon

 

fixed: 

after experimenting

i replaced this status.h

 
// Refine bonus [Cydh]
static struct {
    struct {
        struct script_code *script;
    } refine[MAX_REFINE];
} refine_bonus[REFINE_TYPE_MAX];

 

with this

 

// Refine bonus [Cydh]
static struct {
    struct {
        struct script_code *script;
    } refine[MAX_REFINE+1];
} refine_bonus[REFINE_TYPE_MAX+1];
 
Edited by icabit
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

@icabit, thx. :D

didn't try until +20 yet. LOL

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  353
  • Reputation:   70
  • Joined:  07/14/12
  • Last Seen:  

thank you also for providing us this it works perfectly!

and since it reads an item script there is no need to specify per class bonus since you can do it via item script

well i its my lucky debug though xD
after i tested everything i found out that map crash only happens in +20 lvl 4 weapon 

so i guessed something is lacking so i tried putting +1 in status.h then compiled
luckily it worked :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  197
  • Reputation:   13
  • Joined:  05/14/12
  • Last Seen:  

Nice mod @Cydh hehehehehe how are you brother :) watzup icabit

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  208
  • Reputation:   1
  • Joined:  01/06/12
  • Last Seen:  

how can i add this with the specified item class like this

 

 

    For weapons, the types are:
        0: bare fist
        1: Daggers
        2: One-handed swords
        3: Two-handed swords
        4: One-handed spears
        5: Two-handed spears
        6: One-handed axes
        7: Two-handed axes
        8: Maces
        9: Unused
        10: Staves
        11: Bows
        12: Knuckles
        13: Musical Instruments
        14: Whips
        15: Books
        16: Katars
        17: Revolvers
        18: Rifles
        19: Gatling guns
        20: Shotguns
        21: Grenade launchers
        22: Fuuma Shurikens
 
Example:
before
4,1,{ item_script }
after
4,1,1,{ item_script } all dagger weapon
4,1,2,{ item_script } Two-handed swords
just like that
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

@@icabitthank's anyway

 

and since it reads an item script there is no need to specify per class bonus since you can do it via item script

it could be OK too if you want to edit it

 

@@pr3pfine bro, just busy with mid-term

 

@@Blazing Spear how if

4,1,{ switch(getiteminfo(getequipid(EQI_HAND_R)),14){
case 0: /*bonus here*/ break;
case 1: /*bonus here*/ break;
case 2: /*bonus here*/ break;
case 3: /*bonus here*/ break;
case 4: /*bonus here*/ break;
.........
case 22: /*bonus here*/ break;} }

didn't try yet. :P

or maybe later will make an option [<weapon_type>], if it's really needed

 

Type,RefineNumber,{ Script }[,<weapon type>]
Edited by Cydh
Link to comment
Share on other sites

  • 2 months later...

  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

@cydh

 

what if i want to add extra bonus to a specific weapon only? i mean if i want item 11607(sword for example) to have extra + 5 str per refine but i want item 11608(another sword) to have extra + 10 str per refine

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

@cydh

 

what if i want to add extra bonus to a specific weapon only? i mean if i want item 11607(sword for example) to have extra + 5 str per refine but i want item 11608(another sword) to have extra + 10 str per refine

 

you can use this method, put this script part on script section

//...
switch(getequipid(EQI_HAND_R))
{
case 11607: bonus bStr,5; break;
case 11608: bonus bInt,5; break;
}
//...
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

Thanks

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

updated for r17379

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

crashed my map-server after recompiling

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

crashed my map-server after recompiling

 

which file did u use? ur svn? getting any error when patching and recompiling?

 

btw, map crashed after u running it on recompile.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

crashed my map-server after recompiling

 

which file did u use? ur svn? getting any error when patching and recompiling?

 

btw, map crashed after u running it on recompile.

No errors after patching and recompiling. Map server crashes after i log in to any characters.

Im using 17300+ something.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  6
  • Reputation:   0
  • Joined:  04/28/13
  • Last Seen:  

Hey i got this problem when i add this :

 

0,1,{ bonus bVit,1; }
0,2,{ bonus bVit,2; }
0,3,{ bonus bVit,3; }
0,4,{ bonus bVit,4; }
0,5,{ bonus bVit,5; }
0,6,{ bonus bVit,6; }
0,7,{ bonus bVit,7; }
0,8,{ bonus bVit,8; }
0,9,{ bonus bVit,9; }
0,10,{ bonus bVit,10; }
0,11,{ bonus bVit,11; }
0,12,{ bonus bVit,12; }
0,13,{ bonus bVit,13; }
0,14,{ bonus bVit,14; }
0,15,{ bonus bVit,15; }
0,16,{ bonus bVit,16; }
0,17,{ bonus bVit,17; }
0,18,{ bonus bVit,18; }
0,19,{ bonus bVit,19; }
0,20,{ bonus bVit,20; }

 

My armors do not give any vit.

 

I use rathena 17408.

 

Weapons work.

 

I used this on my last server and it worked perfect i love it.

 

Sorry for my bad english.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

@MrVandalBus

try re-patch it manually if ur svn is different version from patch file rev number. I tried on 1740x, there is problem there

 

@Roundness

OK, I'll check it

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  6
  • Reputation:   0
  • Joined:  04/28/13
  • Last Seen:  

I was wrong about the weapon refine working. I added str and some matk on each refine and nothing happend. I did this :

 

1,1,{ bonus bStr,1; bonus bMatk,1; }
1,2,{ bonus bStr,2; bonus bMatk,2; }
1,3,{ bonus bStr,3; bonus bMatk,3; }
1,4,{ bonus bStr,4; bonus bMatk,4; }
1,5,{ bonus bStr,5; bonus bMatk,5; }
1,6,{ bonus bStr,6; bonus bMatk,6; }
1,7,{ bonus bStr,7; bonus bMatk,7; }
1,8,{ bonus bStr,8; bonus bMatk,8; }
1,9,{ bonus bStr,9; bonus bMatk,9; }
1,10,{ bonus bStr,10; bonus bMatk,10; }
1,11,{ bonus bStr,11; bonus bMatk,11; }
1,12,{ bonus bStr,12; bonus bMatk,12; }
1,13,{ bonus bStr,13; bonus bMatk,13; }
1,14,{ bonus bStr,14; bonus bMatk,14; }
1,15,{ bonus bStr,15; bonus bMatk,15; }
1,16,{ bonus bStr,16; bonus bMatk,16; }
1,17,{ bonus bStr,17; bonus bMatk,17; }
1,18,{ bonus bStr,18; bonus bMatk,18; }
1,19,{ bonus bStr,19; bonus bMatk,19; }
1,20,{ bonus bStr,20; bonus bMatk,20; }

 

So it sadly does not work at all for me.

Link to comment
Share on other sites

  • 2 months later...

  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  145
  • Reputation:   15
  • Joined:  01/06/12
  • Last Seen:  

is this safe?

Index: src/map/status.c
===================================================================
--- src/map/status.c    (revision 17379)
+++ src/map/status.c    (working copy)
@@ -2543,6 +2543,18 @@
                 if (!calculating) //Abort, run_script retriggered this. [Skotlex]
                     return 1;
             }
+            
+            // Refine bonus [Cydh]
+            if(refine_bonus[wlv].refine[sd->status.inventory[index].refine-1].script) {
+                if (wd == &sd->left_weapon) {
+                    sd->state.lr_flag = 1;
+                    run_script(refine_bonus[wlv].refine[sd->status.inventory[index].refine-1].script,0,sd->bl.id,0);
+                    sd->state.lr_flag = 0;
+                } else
+                    run_script(refine_bonus[wlv].refine[sd->status.inventory[index].refine-1].script,0,sd->bl.id,0);
+                if (!calculating)
+                    return 1;
+            }
 
             if(sd->status.inventory[index].card[0]==CARD0_FORGE)
             {    // Forged weapon
@@ -2559,6 +2571,9 @@
             int r;
             if ( (r = sd->status.inventory[index].refine) )
                 refinedef += refine_info[REFINE_TYPE_ARMOR].bonus[r-1];
+                // Refine bonus
+                if(refine_bonus[REFINE_TYPE_ARMOR].refine[sd->status.inventory[index].refine-1].script)
+                    run_script(refine_bonus[REFINE_TYPE_ARMOR].refine[sd->status.inventory[index].refine-1].script,0,sd->bl.id,0);
             if(sd->inventory_data[index]->script) {
                 if( i == EQI_HAND_L ) //Shield
                     sd->state.lr_flag = 3;
@@ -11445,6 +11460,97 @@
     return true;
 }
 
+// Refine bonus
+// [Cydh] [email protected]
+static int status_readdb_refine_bonus(void)
+{
+    const char* filename = "refine_bonus.txt";
+    uint32 lines = 0, count = 0;
+    char line[1024], path[256];
+    FILE* fp;
+
+    sprintf(path, "%s/%s", db_path, filename);
+    if((fp = fopen(path, "r")) == NULL )
+    {
+        ShowWarning("status_readdb_refine_bonus: File not found \"%s\", skipping.\n", path);
+        return 0;
+    }
+
+    while(fgets(line, sizeof(line), fp))
+    {
+        char *str[3], *p;
+        int i, type, refine;
+
+        lines++;
+        if(line[0] == '/' && line[1] == '/')
+            continue;
+
+        memset(str, 0, sizeof(str));
+
+        p = line;
+
+        while( ISSPACE(*p) )
+            ++p;
+        if( *p == '\0' )
+            continue;
+        for( i = 0; i < 2; ++i )
+        {
+            str[i] = p;
+            p = strchr(p,',');
+            if( p == NULL )
+                break;
+            *p = '\0';
+            ++p;
+        }
+
+        if( p == NULL )
+        {
+            ShowError("status_readdb_refine_bonus: Insufficient columns in line %d of \"%s\" (item with type %d), skipping.\n", lines, path, atoi(str[0]));
+            continue;
+        }
+
+        // Equip type
+        type = atoi(str[0]);
+        if( type < REFINE_TYPE_ARMOR || type > REFINE_TYPE_WEAPON4 ) 
+        {
+            ShowError("status_readdb_refine_bonus : Invalid item type '%s'.\n",atoi(str[0]));
+            continue;
+        }
+
+        // Refine number
+        refine = atoi(str[1])-1;
+        if( refine < 0 || refine >= MAX_REFINE ) 
+        {
+            ShowError("status_readdb_refine_bonus : Invalid item refine number '%s' (0 - %d).\n",atoi(str[1]),MAX_REFINE);
+            continue;
+        }
+
+        // Script
+        if( *p != '{' )
+        {
+            ShowError("status_readdb_refine_bonus: Invalid format (Script column-start) in line %d of \"%s\" (script with item type %d and refine number %d), skipping.\n",lines,path,atoi(str[0]),atoi(str[1]));
+            continue;
+        }
+        str[2] = p;
+        p = strstr(p+1,"}");
+        if( strchr(p,',') != NULL )
+        {
+            ShowError("status_readdb_refine_bonus: Invalid format (Script column-end) in line %d of \"%s\" (script with item type %d and refine number %d), skipping.\n",lines,path,atoi(str[0]),atoi(str[1]));
+            continue;
+        }
+
+        refine_bonus[type].refine[refine].script = parse_script(str[2],path,lines,0);
+        count++;
+    }
+
+    fclose(fp);
+    
+    ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
+
+    return 0;
+}
+
+
 /*
 * Read status db
 * job1.txt
@@ -11467,6 +11573,10 @@
     memset(aspd_base, 0, sizeof(aspd_base));
     // reset job_db2.txt data
     memset(job_bonus,0,sizeof(job_bonus)); // Job-specific stats bonus
+    
+    // Refine bonus
+    memset(refine_bonus->refine,0,sizeof(refine_bonus->refine));
+    memset(refine_bonus,0,sizeof(refine_bonus));
 
     // size_fix.txt
     for(i=0;i<ARRAYLENGTH(atkmods);i++)
@@ -11486,8 +11596,10 @@
 
     // read databases
     //
+    
+    // Refine bonus
+    status_readdb_refine_bonus();
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

updated

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  87
  • Reputation:   4
  • Joined:  08/09/12
  • Last Seen:  

error in status.h it says refine_bonus is defined but not used.

Link to comment
Share on other sites

  • 2 months later...

  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   17
  • Joined:  12/31/11
  • Last Seen:  

i got it:

status.h:1831: warning: 'refine_bonus' defined but not used
        CC      battle.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      battleground.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      intif.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      trade.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      party.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      vending.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      guild.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      pet.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      log.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      mail.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      date.c
        CC      unit.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      homunculus.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      mercenary.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      quest.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      instance.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      buyingstore.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      searchstore.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      duel.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      pc_groups.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      elemental.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      cashshop.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      channel.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      mapreg_sql.c
        CC      achievement.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      region.c
status.h:1831: warning: 'refine_bonus' defined but not used
        CC      faction.c
status.h:1831: warning: 'refine_bonus' defined but not used
        LD      map-server
Link to comment
Share on other sites

  • 3 weeks later...

  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

updated file to download.

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
Reply to this topic...

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