Skip to content

Commit

Permalink
dev ongoing features and fixes (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlthelama authored Apr 2, 2023
2 parents 535589b + fcf410d commit 9744b09
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 71 deletions.
24 changes: 24 additions & 0 deletions mcm/Config/LamasTinyHUD/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,19 @@
"sourceType": "ModSettingFloat"
}
},
{
"id": "fItemNameTextFontSize:GraphicSetting",
"text": "$LamasTinyHUD_GraphicSetting_ItemNameTextFontSize_OptionText",
"type": "slider",
"help": "$LamasTinyHUD_GraphicSetting_ItemNameTextFontSize_InfoText",
"valueOptions": {
"min": 10.0,
"max": 35.0,
"step": 1.0,
"formatString": "{0}",
"sourceType": "ModSettingFloat"
}
},
{
"text": "$LamasTinyHUD_GraphicSetting_Color",
"type": "header",
Expand Down Expand Up @@ -1217,6 +1230,17 @@
"valueOptions": {
"sourceType": "ModSettingBool"
}
},
{
"id": "bDrawPageId:GraphicSetting",
"text": "$LamasTinyHUD_GraphicSetting_DrawPageId_OptionText",
"type": "toggle",
"help": "$LamasTinyHUD_GraphicSetting_DrawPageId_InfoText",
"groupCondition": 5,
"groupBehavior": "disable",
"valueOptions": {
"sourceType": "ModSettingBool"
}
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions mcm/Config/LamasTinyHUD/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ bDrawItemNameText = 1
bDrawToggleButton = 1
bDrawCurrentShoutText = 0
fCurrentShoutFontSize = 20
fItemNameTextFontSize = 20
bDrawPageId = 0

[MiscSetting]
bActionCheck = 0
Expand Down
Binary file modified mcm/Interface/Translations/LamasTinyHUD_english.txt
Binary file not shown.
96 changes: 54 additions & 42 deletions src/equip/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,48 +197,7 @@ namespace equip {

auto alchemy_item = obj->As<RE::AlchemyItem>();
if (alchemy_item->IsPoison()) {
logger::trace("try to apply poison to weapon, count left {}"sv, left);
uint32_t potion_doses = 1;
/* it works for vanilla and adamant
* vanilla does a basic set value to 3
* adamant does 2 times a add value 2
* ordinator we could handle it "dirty" because the Information we need needs to be RE, but if perk xy Is set
we could calculate it ourself. It is basically AV multiply base + "alchemy level" * 0.1 * 3 = dose count
* vokrii should be fine as well
* other add av multiply implementations need to be handled by getting the data from the game
* the MCM setting will be left for overwrite handling */
if (config::mcm_setting::get_overwrite_poison_dose()) {
potion_doses = config::mcm_setting::get_apply_poison_dose();
} else {
if (a_player->HasPerkEntries(RE::BGSEntryPoint::ENTRY_POINTS::kModPoisonDoseCount)) {
auto perk_visit = util::perk_visitor(a_player, static_cast<float>(potion_doses));
a_player->ForEachPerkEntry(RE::BGSEntryPoint::ENTRY_POINTS::kModPoisonDoseCount, perk_visit);
potion_doses = static_cast<int>(perk_visit.get_result());
}
}
logger::trace("Poison dose set value is {}"sv, potion_doses);

//check if there is a weapon to apply it to
//check count here as well, since we need max 2
auto equipped_object = a_player->GetEquippedEntryData(false);
if (equipped_object && equipped_object->object->IsWeapon() && !equipped_object->IsPoisoned()) {
logger::trace("try to add poison {} to right {}"sv,
alchemy_item->GetName(),
equipped_object->GetDisplayName());
equipped_object->PoisonObject(alchemy_item, potion_doses);
a_player->RemoveItem(alchemy_item, 1, RE::ITEM_REMOVE_REASON::kRemove, nullptr, nullptr);
left--;
}

auto equipped_object_left = a_player->GetEquippedEntryData(true);
if (equipped_object_left && equipped_object_left->object->IsWeapon() &&
!equipped_object_left->IsPoisoned() && left > 0) {
logger::trace("try to add poison {} to left {}"sv,
alchemy_item->GetName(),
equipped_object_left->GetDisplayName());
equipped_object_left->PoisonObject(alchemy_item, potion_doses);
a_player->RemoveItem(alchemy_item, 1, RE::ITEM_REMOVE_REASON::kRemove, nullptr, nullptr);
}
poison_weapon(a_player, alchemy_item, left);
logger::trace("Is a poison, I am done here. return.");
return;
}
Expand Down Expand Up @@ -370,4 +329,57 @@ namespace equip {
logger::warn("No suitable potion found. return.");
}
}

void item::poison_weapon(RE::PlayerCharacter*& a_player, RE::AlchemyItem*& a_poison, uint32_t a_count) {
logger::trace("try to apply poison to weapon, count left {}"sv, a_count);
uint32_t potion_doses = 1;
/* it works for vanilla and adamant
* vanilla does a basic set value to 3
* adamant does 2 times add value 2
* ordinator we could handle it "dirty" because the Information we need needs to be RE, but if perk xy Is set
we could calculate it ourselves. It is basically AV multiply base + "alchemy level" * 0.1 * 3 = dose count
* vokrii should be fine as well
* other add av multiply implementations need to be handled by getting the data from the game
* the MCM setting will be left for overwrite handling */
if (config::mcm_setting::get_overwrite_poison_dose()) {
potion_doses = config::mcm_setting::get_apply_poison_dose();
} else {
if (a_player->HasPerkEntries(RE::BGSEntryPoint::ENTRY_POINTS::kModPoisonDoseCount)) {
auto perk_visit = util::perk_visitor(a_player, static_cast<float>(potion_doses));
a_player->ForEachPerkEntry(RE::BGSEntryPoint::ENTRY_POINTS::kModPoisonDoseCount, perk_visit);
potion_doses = static_cast<int>(perk_visit.get_result());
}
}
logger::trace("Poison dose set value is {}"sv, potion_doses);

RE::BGSSoundDescriptor* sound_descriptor;
if (a_poison->data.consumptionSound) {
sound_descriptor = a_poison->data.consumptionSound->soundDescriptor;
} else {
sound_descriptor = RE::TESForm::LookupByID(0x00106614)->As<RE::BGSSoundDescriptorForm>()->soundDescriptor;
}

//check if there is a weapon to apply it to
//check count here as well, since we need max 2
auto equipped_object = a_player->GetEquippedEntryData(false);
if (equipped_object && equipped_object->object->IsWeapon() && !equipped_object->IsPoisoned()) {
logger::trace("try to add poison {} to right {}"sv, a_poison->GetName(), equipped_object->GetDisplayName());
equipped_object->PoisonObject(a_poison, potion_doses);
util::player::play_sound(sound_descriptor, a_player);
a_player->RemoveItem(a_poison, 1, RE::ITEM_REMOVE_REASON::kRemove, nullptr, nullptr);
a_count--;
}

auto equipped_object_left = a_player->GetEquippedEntryData(true);
if (equipped_object_left && equipped_object_left->object->IsWeapon() && !equipped_object_left->IsPoisoned() &&
a_count > 0) {
logger::trace("try to add poison {} to left {}"sv,
a_poison->GetName(),
equipped_object_left->GetDisplayName());
equipped_object_left->PoisonObject(a_poison, potion_doses);
a_player->RemoveItem(a_poison, 1, RE::ITEM_REMOVE_REASON::kRemove, nullptr, nullptr);
a_count--;
}
//
}
}
3 changes: 3 additions & 0 deletions src/equip/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ namespace equip {
static void equip_ammo(const RE::TESForm* a_form, RE::PlayerCharacter*& a_player);
static void un_equip_ammo();
static void find_and_consume_fitting_option(RE::ActorValue a_actor_value, RE::PlayerCharacter*& a_player);

private:
static void poison_weapon(RE::PlayerCharacter*& a_player, RE::AlchemyItem*& a_poison, uint32_t a_count);
};
}
6 changes: 2 additions & 4 deletions src/equip/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace equip {
//could trigger an animation here
//might need to set some things
//TODO make an animation to play here
//a_player->NotifyAnimationGraph("RightCastSelf");
//a_player->NotifyAnimationGraph("IdleMagic_01"); //works
auto is_self_target = spell->GetDelivery() == RE::MagicSystem::Delivery::kSelf;
auto target = is_self_target ? actor : actor->GetActorRuntimeData().currentCombatTarget.get().get();

Expand All @@ -88,12 +88,10 @@ namespace equip {
if (auto* effect = spell->GetCostliestEffectItem()) {
magnitude = effect->GetMagnitude();
}
//auto dual_cast_scale = spell->avEffectSetting->data.dualCastScale;
logger::trace("casting spell {}, magnitude {}, effecticeness {}"sv,
logger::trace("casting spell {}, magnitude {}, effectiveness {}"sv,
spell->GetName(),
fmt::format(FMT_STRING("{:.2f}"), magnitude),
fmt::format(FMT_STRING("{:.2f}"), effectiveness));

caster->CastSpellImmediate(spell,
false,
target,
Expand Down
3 changes: 2 additions & 1 deletion src/handle/data/page/position_setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace handle {
uint32_t button_press_modify = ui::draw_full;
uint32_t key = 0;
position_draw_setting* draw_setting = nullptr;
float font_size = 0.f;
float item_name_font_size = 0.f;
float count_font_size = 0.f;
bool item_name = false;
bool highlight_slot = false;
};
Expand Down
1 change: 1 addition & 0 deletions src/handle/data/page/slot_setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace handle {
mask = 12
};


RE::TESForm* form = nullptr;
slot_type type = slot_type::empty;
action_type action = action_type::default_action;
Expand Down
7 changes: 5 additions & 2 deletions src/handle/page_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "equip/equip_slot.h"
#include "handle/data/data_helper.h"
#include "handle/data/page/position_setting.h"
#include "handle/data/page/slot_setting.h"
#include "setting/mcm_setting.h"
#include "util/constant.h"
#include "util/helper.h"
Expand Down Expand Up @@ -68,6 +69,7 @@ namespace handle {
if (slot->type == slot_type::consumable || slot->type == slot_type::scroll) {
slot->display_item_count = true;
}

slot->equip_slot = equip_slot;

slots->push_back(slot);
Expand Down Expand Up @@ -120,7 +122,7 @@ namespace handle {
draw->offset_text_x = config::mcm_setting::get_slot_count_text_offset();
draw->offset_text_y = config::mcm_setting::get_slot_count_text_offset();

if ((mcm::get_elden_demon_souls() || mcm::get_draw_item_name_text()) &&
if ((elden || mcm::get_draw_item_name_text()) &&
(a_position == position_type::bottom || a_position == position_type::top)) {
page->item_name = true;
get_offset_values(a_position,
Expand Down Expand Up @@ -156,7 +158,8 @@ namespace handle {
page->draw_setting = draw;

page->key = a_key_pos->get_key_for_position(a_position);
page->font_size = config::mcm_setting::get_slot_count_text_font_size();
page->item_name_font_size = config::mcm_setting::get_item_name_font_size();
page->count_font_size = config::mcm_setting::get_slot_count_text_font_size();

if (elden) {
if (first_slot->type != slot_type::empty || slots->size() == 2 && slots->at(1)->type != slot_type::empty) {
Expand Down
6 changes: 4 additions & 2 deletions src/processing/set_setting_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ namespace processing {
return;
}

clear_hands();
//clear_hands();

logger::trace("execute first setting for left/right/top"sv);

Expand Down Expand Up @@ -481,7 +481,9 @@ namespace processing {
for (const auto& [item, inv_data] : inv) {
const auto& [num_items, entry] = inv_data;
const auto ammo = item->As<RE::TESAmmo>();
if (!ammo->GetPlayable() || ammo->GetRuntimeData().data.flags.any(RE::AMMO_DATA::Flag::kNonPlayable)) {

if (ammo->IsBoundObject() || !ammo->GetPlayable() ||
ammo->GetRuntimeData().data.flags.any(RE::AMMO_DATA::Flag::kNonPlayable)) {
continue;
}

Expand Down
7 changes: 7 additions & 0 deletions src/setting/mcm_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ namespace config {
static bool draw_toggle_button;
static bool draw_current_shout_text;
static float current_shout_font_size;
static float item_name_font_size;
static bool draw_page_id;

static uint32_t alpha_slot_animation;
static float duration_slot_animation;
Expand Down Expand Up @@ -197,6 +199,8 @@ namespace config {
draw_current_shout_text = mcm.GetBoolValue("GraphicSetting", "bDrawCurrentShoutText", false);
current_shout_font_size =
static_cast<float>(mcm.GetDoubleValue("GraphicSetting", "fCurrentShoutFontSize", 20));
item_name_font_size = static_cast<float>(mcm.GetDoubleValue("GraphicSetting", "fItemNameTextFontSize", 20));
draw_page_id = mcm.GetBoolValue("GraphicSetting", "bDrawPageId", false);

alpha_slot_animation =
static_cast<uint32_t>(mcm.GetLongValue("AnimationSetting", "uAlphaSlotAnimation", 51));
Expand Down Expand Up @@ -315,6 +319,9 @@ namespace config {
bool mcm_setting::get_draw_toggle_button() { return draw_toggle_button; }
bool mcm_setting::get_draw_current_shout_text() { return draw_current_shout_text; }
float mcm_setting::get_current_shout_font_size() { return current_shout_font_size; }
float mcm_setting::get_item_name_font_size() { return item_name_font_size; }
bool mcm_setting::get_draw_page_id() { return draw_page_id; }


uint32_t mcm_setting::get_alpha_slot_animation() { return alpha_slot_animation; }
float mcm_setting::get_duration_slot_animation() { return duration_slot_animation; }
Expand Down
2 changes: 2 additions & 0 deletions src/setting/mcm_setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace config {
static bool get_draw_item_name_text();
static bool get_draw_current_shout_text();
static float get_current_shout_font_size();
static float get_item_name_font_size();
static bool get_draw_page_id();

static uint32_t get_alpha_slot_animation();
static float get_duration_slot_animation();
Expand Down
Loading

0 comments on commit 9744b09

Please sign in to comment.