viewing paste Unknown #49535 | Diff | Private

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
conf\battle\player.conf
@@ -164,6 +164,12 @@ character_size: 0
// items from Autoloot (0: disabled).
idle_no_autoloot: 0
 
+// Extra Bonuses [Lilith]
+// Enable [1-2] or disable[0] player's Extra Bonuses?
+// 1 = enable for all players any bonuses from db/extra_bonuses.txt
+// 2 = enable only for players which have a specific variable "EXTRA_BONUS"
+enable_extra_bonus: 2
+
// Minimum distance a vending/chat room must be from a NPC in order to be placed.
// Default: 3 (0: disabled).
min_npc_vendchat_distance: 3
 
 
db\extra_bonuses.txt
@@ -0,0 +1,12 @@
+// Extra Bonuses [Lilith]
+// Skorm addition 2 to the power of the bonus should be the extra bonus variable.
+// EX: 2^2 = 4 so 4 is the variable of the second bonus this way multiple bonus can be added to one player.
+// If enable_extra_bonus is 1 this and below Extra bonuses will be received by all players 
+// If enable_extra_bonus is 2 this Extra bonus will be received by players which have variable EXTRA_BONUS = 1
+{ bonus bStr,15; bonus bSpeedAddRate,50;} //1
+// If enable_extra_bonus is 2 this Extra bonus will be received by players which have variable EXTRA_BONUS = 2
+{ bonus bAgi,10; bonus bMdef,30;} //2
+// More bonuses...
+{ bonus bAgi,100;} //4
+{}
+{}
\ No newline at end of file
 
 
src\map\battle.c
@@ -8384,6 +8384,10 @@ static const struct _battle_data {
    { "tarotcard_equal_chance",             &battle_config.tarotcard_equal_chance,          0,      0,      1,              },
    { "change_party_leader_samemap",        &battle_config.change_party_leader_samemap,     1,      0,      1,              },
    { "dispel_song",                        &battle_config.dispel_song,                     0,      0,      1,              },
+       /**
+       * Extra Bonuses [Lilith]
+       **/
+   { "enable_extra_bonus",                 &battle_config.enable_extra_bonus,              1,      0,      2,              },
 
#include "../custom/battle_config_init.inc"
};
 
 
src\map\battle.h
@@ -616,6 +616,11 @@ extern struct Battle_Config
    int change_party_leader_samemap;
    int dispel_song; //Can songs be dispelled?
 
+   /**
+    * Extra Bonuses [Lilith]
+    **/
+   int enable_extra_bonus;
+
#include "../custom/battle_config_struct.inc"
} battle_config;
 
 
 
src\map\itemdb.c
@@ -570,6 +570,59 @@ static bool itemdb_read_itemavail(char* str[], int columns, int current) {
    return true;
}
 
+/**
+* Extra Bonuses [Lilith]
+**/
+static int itemdb_readbonus(void)
+{
+   char* filename = "extra_bonuses.txt";
+   uint32 lines = 0, count = 1;
+   char line[1024], path[256];
+   FILE* fp;
+
+   sprintf(path, "%s/%s", db_path, filename);
+   fp = fopen(path, "r");
+   if (fp == NULL)
+   {
+       ShowWarning("itemdb_readbonus: File not found \"%s\", skipping.\n", path);
+       return 0;
+   }
+
+   while (fgets(line, sizeof(line), fp))
+   {
+       char *str, *p;
+       lines++;
+       if (line[0] == '/' && line[1] == '/')
+           continue;
+       str = 0;
+       p = line;
+       while (ISSPACE(*p))
+           ++p;
+       if (*p == '\0')
+           continue;
+       if (*p != '{')
+       {
+           ShowError("itemdb_readbonus: Invalid format in line %d of \"%s\", skipping.\n", lines, path);
+           continue;
+       }
+       str = p;
+       p = strstr(p + 1, "}");
+       if (strchr(p, ',') != NULL)
+       {
+           ShowError("itemdb_readbonus: Extra columns in line %d of \"%s\", skipping.\n", lines, path);
+           continue;
+       }
+       extra_bonus[count].script = parse_script(str, path, lines, 0);
+       count++;
+   }
+
+   fclose(fp);
+
+   ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count - 1, filename);
+
+   return 0;
+}
+
static int itemdb_group_free(DBKey key, DBData *data, va_list ap);
 
static bool itemdb_read_group(char* str[], int columns, int current) {
@@ -1684,6 +1737,8 @@ static void itemdb_read(void) {
        itemdb_read_sqldb();
    else
        itemdb_readdb();
+
+   itemdb_readbonus(); //Extra Bonuses [Lilith]
    
    for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
        uint8 n1 = (uint8)(strlen(db_path)+strlen(dbsubpath[i])+1);
        
 
src\map\itemdb.h
@@ -12,6 +12,19 @@
#define MAX_ITEMID USHRT_MAX
///Use apple for unknown items.
#define UNKNOWN_ITEM_ID 512
+
+/**
+ * Extra Bonuses [Lilith]
+ **/
+
+//#define MAX_ITEMDB 500
+
+   struct s_bonus_data {
+   struct script_code *script;
+   
+};
+struct s_bonus_data extra_bonus[MAX_ITEMID];
+
/// The maximum number of item delays
#define MAX_ITEMDELAYS  10
///Designed for search functions, species max number of matches to display.
 
 
src\map\status.c
@@ -3389,6 +3389,33 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
    pc_delautobonus(sd,sd->autobonus2,ARRAYLENGTH(sd->autobonus2),true);
    pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),true);
 
+   /**
+   * Extra Bonuses [Lilith]
+   **/
+   if (battle_config.enable_extra_bonus) {
+       if (battle_config.enable_extra_bonus == 2) {
+           for (i = 1; i<ARRAYLENGTH(extra_bonus); i++) {
+               if (!extra_bonus[i].script)
+                   break;
+               if ( pc_readglobalreg(sd, add_str("EXTRA_BONUS")) & (int)pow(2,i-1) )
+                   run_script(extra_bonus[i].script, 0, sd->bl.id, 0);
+               if (!calculating)
+                   return 1;
+           }
+       }
+       else {
+           for (i = 1; i<ARRAYLENGTH(extra_bonus); i++) {
+               if (!extra_bonus[i].script)
+                   break;
+               run_script(extra_bonus[i].script, 0, sd->bl.id, 0);
+               if (!calculating)
+                   return 1;
+           }
+       }
+   }
+
+
    pc_itemgrouphealrate_clear(sd);
 
    running_npc_stat_calc_event = true;
Viewed 391 times, submitted by suezosilver.