Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conf/map/battle/drops.conf
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,8 @@ drops_by_luk2: 0
// 1: Only marine spheres drop items.
// 2: All alchemist summons drop items.
alchemist_summon_reward: 1

// The maximum number of full iterations that server can do when dropping an item with options.
// When picking random options for a dropped item, it does lots of iterations to choose the option to be set,
// this value limits the number of iterations to avoid making the server hang in a long loop.
option_drop_max_loop: 10
2 changes: 2 additions & 0 deletions db/mob_db2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ mob_db: (
}
Drops: {
AegisName: chance (string: int)
// or
AegisName: (chance, "Option Drop Group")
// ...
}
},
Expand Down
53 changes: 53 additions & 0 deletions db/option_drop_groups.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//================= Hercules Database =====================================
//= _ _ _
//= | | | | | |
//= | |_| | ___ _ __ ___ _ _| | ___ ___
//= | _ |/ _ \ '__/ __| | | | |/ _ \/ __|
//= | | | | __/ | | (__| |_| | | __/\__ \
//= \_| |_/\___|_| \___|\__,_|_|\___||___/
//================= License ===============================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2018 Hercules Dev Team
//=
//= Hercules is free software: you can redistribute it and/or modify
//= it under the terms of the GNU General Public License as published by
//= the Free Software Foundation, either version 3 of the License, or
//= (at your option) any later version.
//=
//= This program is distributed in the hope that it will be useful,
//= but WITHOUT ANY WARRANTY; without even the implied warranty of
//= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//= GNU General Public License for more details.
//=
//= You should have received a copy of the GNU General Public License
//= along with this program. If not, see <http://www.gnu.org/licenses/>.
//=========================================================================
//= Random Option Drop Group Database
//=========================================================================

option_drop_group_db: (
{
/**************************************************************************
************* Entry structure ********************************************
**************************************************************************
<Group Name Constant>: (
{ // Option Slot 1
Rate: (int) chance of filling option slot 1 (100 = 1%)

// Possible options for slot 1
// min/max value : int, defaults to 0
// chance : int, 100 = 1% if not set, will be 100%/number of possibiltiies
OptionName: value
// or
OptionName: [min value, max value]
// or
OptionName: [min value, max value, chance]
// ... (as many as you want)
},
// ... (up to MAX_ITEM_OPTION)
),
**************************************************************************/
}
)
2 changes: 2 additions & 0 deletions db/pre-re/mob_db.conf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ mob_db: (
}
Drops: {
AegisName: chance (string: int)
// or
AegisName: (chance, "Option Drop Group")
// ...
}
},
Expand Down
2 changes: 2 additions & 0 deletions db/re/mob_db.conf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ mob_db: (
}
Drops: {
AegisName: chance (string: int)
// or
AegisName: (chance, "Option Drop Group")
// ...
}
},
Expand Down
68 changes: 53 additions & 15 deletions doc/mob_db.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ mob_db: (
MvpExp: mvp experience (int, defaults to 0)
MvpDrops: {
AegisName: chance (string: int)
// or
AegisName: (chance, "Option Drop Group")
// ...
}
Drops: {
AegisName: chance (string: int)
AegisName: chance (string: int)
// or
AegisName: (chance, "Option Drop Group")
// ...
}
},
Expand Down Expand Up @@ -199,21 +203,55 @@ MvpExp: Base Experience given by the monster to the player who inflict more atta


MvpDrops: Sets monster mvp drops list. Requires to have MvpExp to trigger.
Accepted values are AegisName as defined on item_db.conf and a chance.
There are two ways to define a drop:
1) The first one is used for simple drops and uses the item AegisName
as defined on item_db.conf and a chance.
Format:
AegisName: chance
Chance is an integer from 1 to 10000 (10000 = 100%).
Required format:
MvpDrops: {
AegisName: chance
// ...
}
When not specified, becomes false.

2) The second way to define a drop allows setting a random option drop
group to be used by this drop.
Format:
AegisName: (chance, "Option Drop Group")

The item drop chance refers to the chance of dropping this item, same as chance in the first option.
the "Option Drop Group" parameter refers to an entry on option_drop_group database file. The specified
entry will be used when this item is dropped in order to add random options to the dropped equipment.

A monster drop list may use both format for different items.
Required Format:
Drops: {
AegisName: chance
// or
AegisName: (chance, "Option Drop Group")
}

When not specified, becomes false (no drops).

Drops: Sets monster drops list.
Accepted values are AegisName as defined on item_db.conf and a chance.
There are two ways to define a drop:
1) The first one is used for simple drops and uses the item AegisName
as defined on item_db.conf and a chance.
Format:
AegisName: chance
Chance is an integer from 1 to 10000 (10000 = 100%).
Required format:
Drops: {
AegisName: chance
// ...
}
When not specified, becomes false.

2) The second way to define a drop allows setting a random option drop
group to be used by this drop.
Format:
AegisName: (chance, "Option Drop Group")

The item drop chance refers to the chance of dropping this item, same as chance in the first option.
the "Option Drop Group" parameter refers to an entry on option_drop_group database file. The specified
entry will be used when this item is dropped in order to add random options to the dropped equipment.

A monster drop list may use both format for different items.
Required Format:
Drops: {
AegisName: chance
// or
AegisName: (chance, "Option Drop Group")
}

When not specified, becomes false (no drops).
97 changes: 97 additions & 0 deletions doc/option_drop_group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Option Drop Group Database

## Description
Explanation of the `db/option_drop_groups.conf` file and structure.

This database file allows the creation of groups of random options
that will be added to certain equipments when dropped. After creating
a group in this database file, you may set up drops in `mob_db` to use
it in order to get items with these options. For more information on
adding option drop groups to `mob_db`, check `doc/mob_db.txt` documentation file.

Each item may have up to `MAX_ITEM_OPTION` options at the same time,
in this document, each of these independent options will be called
`option slot`. One drop group will define the possibilities of random
options for each of these slots.

## Entries Format

```
<Group Name Constant>: (
{ // Option Slot 1
Rate: (int) chance of filling option slot 1 (100 = 1%)

// Possible options for slot 1
// min/max value : int, defaults to 0
// chance : int, 100 = 1% if not set, will be 100%/number of possibiltiies
OptionName: value
// or
OptionName: [min value, max value]
// or
OptionName: [min value, max value, chance]
// ... (as many as you want)
},
// ... (up to MAX_ITEM_OPTION)
),
```

### `Group Name Constant`
This is the group name, it is how this group is referenced in other files
(e.g. mob_db). It must be globally unique, as it is a server constant, and
must contain only letters, numbers and " _ ".

### `Rate`
This is the chance of this option slot to drop. In other words, this is the
chance of getting this slot filled with something, where something is given
by the list of `OptionName` that follows.

Rate is an integer value where 100 means 1%.

### `OptionName`
Adds `OptionName` as one option that may fill this slot when it drops.

The details of this option may be specified in one of 3 ways:

#### `OptionName: value`
The chance of this option being picked is auto calculated (see below),
and if this option is chosen, its value will be `value`.

#### `OptionName: [min, max]`
The chance of this option being picked is auto calculated (see below),
and if this option is chosen, its value will be a random integer between
`min` and `max` (both included).

#### `OptionName: [min, max, chance]`
The chance of this option being picked is `chance`, and if this option is chosen,
its value will be a random integer between `min` and `max` (both included).

#### Auto calculated chances
When chance is not specified in an option, it will be auto calculated by
the server as being `100%/num`, when `num` is the number of possibilities
in this option slot.

For example, if you specify 3 possible options, all of them without
a `chance` defined, all of them will have 33.33% chance of being
picked (100%/3). If you set the chance of one of them to 50%, you
will have one option with 50% chance, and each of the others with
33.33% chance.

## Example
```
MYITEM: (
{ // Option Slot 1
Rate: 10000 // It has 100% of chance of being filled

// This slot may have one of the following options:
WEAPON_ATTR_WIND: 5, // WEAPON_ATTR_WIND Lv5 (33.33%)
WEAPON_ATTR_GROUND: [2, 4] // WEAPON_ATTR_GROUND Lv 2~4 (33.33%)
WEAPON_ATTR_POISON: [1, 4, 8000] // WEAPON_ATTR_POISON Lv 1~4 (80%)
},
{ // Option Slot 2
Rate: 5000 // It has 50% of chance of being filled

// If filled, may have one of the following options:
WEAPON_ATTR_WATER: 4 // WEAPON_ATTR_WATER Lv4 (100%)
}
)
```
4 changes: 4 additions & 0 deletions src/common/HPMDataCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,12 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
{ "mob_chat", sizeof(struct mob_chat), SERVER_TYPE_MAP },
{ "mob_data", sizeof(struct mob_data), SERVER_TYPE_MAP },
{ "mob_db", sizeof(struct mob_db), SERVER_TYPE_MAP },
{ "mob_drop", sizeof(struct mob_drop), SERVER_TYPE_MAP },
{ "mob_interface", sizeof(struct mob_interface), SERVER_TYPE_MAP },
{ "mob_skill", sizeof(struct mob_skill), SERVER_TYPE_MAP },
{ "optdrop_group", sizeof(struct optdrop_group), SERVER_TYPE_MAP },
{ "optdrop_group_option", sizeof(struct optdrop_group_option), SERVER_TYPE_MAP },
{ "optdrop_group_optslot", sizeof(struct optdrop_group_optslot), SERVER_TYPE_MAP },
{ "spawn_info", sizeof(struct spawn_info), SERVER_TYPE_MAP },
#else
#define MAP_MOB_H
Expand Down
1 change: 1 addition & 0 deletions src/map/battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -7417,6 +7417,7 @@ static const struct battle_data {
{ "features/enable_achievement_system", &battle_config.feature_enable_achievement, 1, 0, 1, },
{ "ping_timer_inverval", &battle_config.ping_timer_interval, 30, 0, 99999999, },
{ "ping_time", &battle_config.ping_time, 20, 0, 99999999, },
{ "option_drop_max_loop", &battle_config.option_drop_max_loop, 10, 1, 100000, },
};

static bool battle_set_value_sub(int index, int value)
Expand Down
2 changes: 2 additions & 0 deletions src/map/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ struct Battle_Config {

int ping_timer_interval;
int ping_time;

int option_drop_max_loop;
};

/* criteria for battle_config.idletime_critera */
Expand Down
Loading