Revamped Laphine UIs (#6625)

Fixes #3302
Closes #4348

Thanks for the initial release by @Cydh in #4348 and everyone that contributed to it.

All existing data was migrated and cleaned up where necessary.
Thanks to @Everade for his help here.

Laphine UIs are now fully yamlified and not dependent on the script engine.
They make use of new item group features and of the already existing random option group feature.
This way they will be far easier to be maintained, even though they are a little less customize able.

Thanks to @limitro, @CairoLee, @dimasshotta and everyone else who contributed!

Co-authored-by: Cydh <cydh.ramdh@gmail.com>
Co-authored-by: Everade <Everade@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
This commit is contained in:
Lemongrass3110
2022-02-22 21:52:27 +01:00
committed by GitHub
parent 5227167716
commit 08192a35bc
29 changed files with 19587 additions and 468 deletions

View File

@@ -2102,17 +2102,6 @@ static TIMER_FUNC(mob_ai_hard){
return 0;
}
/**
* Assign random option values to an item
* @param item_option: Random option on the item
* @param option: Options to assign
*/
void mob_setitem_option(s_item_randomoption &item_option, const std::shared_ptr<s_random_opt_group_entry> &option) {
item_option.id = option->id;
item_option.value = rnd_value(option->min_value, option->max_value);
item_option.param = option->param;
}
/**
* Set random option for item when dropped from monster
* @param item: Item data
@@ -2126,40 +2115,7 @@ void mob_setdropitem_option(item *item, s_mob_drop *mobdrop) {
std::shared_ptr<s_random_opt_group> group = random_option_group.find(mobdrop->randomopt_group);
if (group != nullptr) {
// Apply Must options
for (size_t i = 0; i < group->slots.size(); i++) {
// Try to apply an entry
for (size_t j = 0, max = group->slots[static_cast<uint16>(i)].size() * 3; j < max; j++) {
std::shared_ptr<s_random_opt_group_entry> option = util::vector_random(group->slots[static_cast<uint16>(i)]);
if (rnd() % 10000 < option->chance) {
mob_setitem_option(item->option[i], option);
break;
}
}
// If no entry was applied, assign one
if (item->option[i].id == 0) {
std::shared_ptr<s_random_opt_group_entry> option = util::vector_random(group->slots[static_cast<uint16>(i)]);
// Apply an entry without checking the chance
mob_setitem_option(item->option[i], option);
}
}
// Apply Random options (if available)
if (group->max_random > 0) {
for (size_t i = 0; i < min(group->max_random, MAX_ITEM_RDM_OPT); i++) {
// If item already has an option in this slot, skip it
if (item->option[i].id > 0)
continue;
std::shared_ptr<s_random_opt_group_entry> option = util::vector_random(group->random_options);
if (rnd() % 10000 < option->chance)
mob_setitem_option(item->option[i], option);
}
}
group->apply( *item );
}
}