Warband Script Enhancer 2 (v1.1.2.1)

Users who are viewing this thread

universal_animations_on = (
ti_on_item_wielded, 0, 0, [],
[
(store_trigger_param_1, ":agent_id"),

(agent_get_wielded_item, reg6, ":agent_id", 1),
(try_begin),
(gt, reg6, 0),
(item_has_property, reg6, itp_type_shield),
(agent_cancel_current_animation, ":agent_id", 0),
(agent_set_personal_animation, ":agent_id", "anim_stand_single", "anim_stand_shield_sword"),
(try_end),
],
)
image.png

seems this might be a compiler error or wse2 bug, gives an error message when it should not, works when reg6 is changed to a local
 
what compiler are you using? Does this issue occur in vanilla Warband?
I added your code to the standard Native with the default compiler and did not notice problem on latest WSE2.
 
Last edited:
what compiler are you using? Does this issue occur in vanilla Warband?
I added your code to the standard Native with the default compiler and did not notice problem on latest WSE2.
He sent it over to me to test with the original engine and I reversed the code from locals back to registers and even compiled with the same WRECK 1.0.0 compiler he used and I couldn't replicate the issue on either engine.

His version of Python might be interacting with WRECK 1.0.0 in a weird way.
 
@K700, can you show how troop_add_merchandise_with_faction works? I am making a replacer without limit of 16 factions.
Code:
void mbGame::addMerchandiseToTroop(int type, int amount, int troopNo, int factionNo)
{
    mbTroop *troop = getTroop(troopNo);
    rglVector<int> itemKindNos;
    rglVector<float> thresholds;
    float totalThreshold = 0.0f;

    for (int i = 0; i < g_numItemKinds; ++i)
    {
        mbItemKind *itemKind = &g_itemKinds[i];

        if (itemKind->getType() == type && !itemKind->isUnique() && itemKind->isMerchandise() && (factionNo < 0 || itemKind->isAvailableForFaction(factionNo)))
        {
            itemKindNos.push(i);
            thresholds.push(totalThreshold);
            totalThreshold += itemKind->m_abundance * itemKind->m_probability * 0.01f;
        }
    }

    if (!itemKindNos.empty())
    {
        for (int i = 0; i < amount; ++i)
        {
            float randomThreshold = rglRandf() * totalThreshold;
            int itemKindIndex = 0;

            for (size_t j = 1; j < thresholds.size() && thresholds[j] <= randomThreshold; ++j)
            {
                itemKindIndex++;
            }

            int firstFreeInventorySlot = troop->getFirstFreeInventorySlot();

            if (firstFreeInventorySlot >= 0)
            {
                troop->m_inventory[firstFreeInventorySlot].setItemKind(itemKindNos[itemKindIndex]);
                troop->m_inventory[firstFreeInventorySlot].setModifierQuality(m_merchandiseModifierQuality);
            }
        }
    }

    troop->m_inventory.compactSort(troop->getNumInventorySlots());
}
 
Code:
void mbGame::addMerchandiseToTroop(int type, int amount, int troopNo, int factionNo)
{
    mbTroop *troop = getTroop(troopNo);
    rglVector<int> itemKindNos;
    rglVector<float> thresholds;
    float totalThreshold = 0.0f;

    for (int i = 0; i < g_numItemKinds; ++i)
    {
        mbItemKind *itemKind = &g_itemKinds[i];

        if (itemKind->getType() == type && !itemKind->isUnique() && itemKind->isMerchandise() && (factionNo < 0 || itemKind->isAvailableForFaction(factionNo)))
        {
            itemKindNos.push(i);
            thresholds.push(totalThreshold);
            totalThreshold += itemKind->m_abundance * itemKind->m_probability * 0.01f;
        }
    }

    if (!itemKindNos.empty())
    {
        for (int i = 0; i < amount; ++i)
        {
            float randomThreshold = rglRandf() * totalThreshold;
            int itemKindIndex = 0;

            for (size_t j = 1; j < thresholds.size() && thresholds[j] <= randomThreshold; ++j)
            {
                itemKindIndex++;
            }

            int firstFreeInventorySlot = troop->getFirstFreeInventorySlot();

            if (firstFreeInventorySlot >= 0)
            {
                troop->m_inventory[firstFreeInventorySlot].setItemKind(itemKindNos[itemKindIndex]);
                troop->m_inventory[firstFreeInventorySlot].setModifierQuality(m_merchandiseModifierQuality);
            }
        }
    }

    troop->m_inventory.compactSort(troop->getNumInventorySlots());
}
Thanks. Where is m_merchandiseModifierQuality defined?
 
1.1.1.0
-Added agent_set_missile_items_prune_time, agent_set_action_speed_modifier, agent_get_action_speed_modifier, agent_set_left_hand_weapon_collision operations.
-Fixed crash, when start game with sound off and turn on sound ingame.
-Fixed mission_cam_set_animation operation.
-Removed item modifier's check for Warband's operations for better compatibility.


Thanks to Fallen Lord for major support.
Thanks to DetektivAro for sponsoring development a agent_set_action_speed_modifier, agent_set_action_speed_modifier, agent_set_left_hand_weapon_collision operations.
Thanks to Anoki for sponsoring development a agent_set_missile_items_prune_time operation.
 
Also setModifierQuality(), setItemKind() and operators reset_item_probabilities and set_item_probability_in_merchandise. Thanks in advance.
Code:
    case reset_item_probabilities:
        g_game->resetItemProbabilities((intValues[0] ? intValues[0] : 100) / 100.0f);
        break;
    case set_item_probability_in_merchandise:
        if (mbCheckItemKind(intValues[0]))
            g_itemKinds[intValues[0]].m_probability = values[1] / 100.0f;

        break;

void mbGame::resetItemProbabilities(float probability)
{
    for (int i = 0; i < g_numItemKinds; ++i)
    {
        g_itemKinds[i].m_probability = probability;
    }
}

void mbItem::setItemKind(int itemKindNo)
{
    m_itemKindNo = itemKindNo;
    m_itemFlags = 0;
    initializeFlags();
}

void mbItem::setModifierQuality(float quality)
{
    if (!isValid() || rglRandf() < 0.1f)
        return;

    mbItemKind *itemKind = getItemKind();
    float minimumProbability = getModifierProbability(1.0f, 1.0f, quality);
    float totalProbability = minimumProbability;

    for (int i = 0; i < MB_NUM_ITEM_MODIFIERS; ++i)
    {
        if (MAKEFLAG64(i) & itemKind->m_modifiers)
            totalProbability += getModifierProbability(g_itemModifiers[i].m_rarity, g_itemModifiers[i].m_priceFactor, quality);
    }

    float threshold = rglRandf() * totalProbability;

    if (minimumProbability < threshold)
    {
        float probability = minimumProbability;
        int modifier = -1;

        for (int i = 0; i < MB_NUM_ITEM_MODIFIERS && modifier == -1; ++i)
        {
            if (MAKEFLAG64(i) & itemKind->m_modifiers)
            {
                probability += getModifierProbability(g_itemModifiers[i].m_rarity, g_itemModifiers[i].m_priceFactor, quality);

                if (probability > threshold)
                    modifier = i;
            }
        }

        if (modifier >= 0)
            setModifier(modifier);
    }
}
 
Interesting. Show getModifierProbability(), please.
Code:
float mbItem::getModifierProbability(float rarity, float priceFactor, float quality)
{
    float v7 = rglAbs(quality - priceFactor);


    if (quality > 1.001f && priceFactor < 1.001f || quality < 0.999f && priceFactor > 0.999f)
        v7 = v7 * 5.0f + 3.0f;


    return rarity / (v7 + 1.0f);
}
 
I think I've encountered a bug, I've tried setting personal animations for horse riding, they seem not to work, but they work when I change the original entries. I've formatted the animation the same way it was in native and used the same flags as the original animations. Only ride_0_chariot works.
My entries:
["ride_0_chariot", acf_enforce_lowerbody, amf_client_prediction,
[15.0, "stand_onhorse_chariot", 0, 456, arf_cyclic],
],
["ride_1_chariot", acf_enforce_lowerbody | acf_synch_with_horse, amf_client_prediction,
[1.0, "anim_chariot", 0, 31, arf_cyclic],
],
["ride_2_chariot", acf_enforce_lowerbody | acf_synch_with_horse, amf_client_prediction,
[0.8, "anim_chariot", 50, 69, arf_cyclic],
],
["ride_3_chariot", acf_enforce_lowerbody | acf_synch_with_horse, amf_client_prediction,
[0.6, "anim_chariot", 100, 116, arf_cyclic],
],
["ride_4_chariot", acf_enforce_lowerbody | acf_synch_with_horse, amf_client_prediction,
[0.5, "anim_chariot", 150, 165, arf_cyclic|arf_blend_in_32],
],
["ride_rear_chariot", acf_enforce_lowerbody|acf_ignore_slope, amf_priority_mount|amf_play|amf_client_prediction,
[1.7, "anim_chariot", 265, 297, arf_blend_in_8],
],
["ride_jump_chariot", acf_enforce_lowerbody, amf_client_prediction,
[1.6, "anim_chariot", 205, 222, arf_blend_in_4],#|arf_end_pos_0_25],
],
["ride_jump_end_chariot", acf_enforce_all, amf_client_prediction,
[0.1, "anim_chariot", 222, 224, arf_blend_in_16],
],
["ride_turn_right_chariot", acf_enforce_lowerbody | acf_synch_with_horse, amf_client_prediction,
[1.0, "anim_chariot", 500, 533, arf_cyclic],
],
["ride_turn_left_chariot", acf_enforce_lowerbody | acf_synch_with_horse, amf_client_prediction,
[1.0, "anim_chariot", 450, 483, arf_cyclic],
],
link to the anims used:
https://drive.google.com/file/d/1tHh82cpa4SPF4mvohEmNxIf77hp146cc/view?usp=drive_link
 
So evidently some time back i started having an issue with WSE2 where it seemingly ignored any settings in any area to only allow battles at 102 size. nothing affects this internal hardcap, No the text file edits to sliders (it accepts them in game but then entirely ignores increase or decrease in actual battles.)

To make matters worse it fails to initiate logging even if i fresh install my standalone version (which for some odd reason now auto links to the steam overlay. but i dunno if thats causing it.) so I can't even get a log file to see what its doing wrong. currently I'm only having this issue in Warsword Conquest and 12th century. but i haven't tested the couple others I have thoroughly just yet to see if they are also doing it. I've been making odd attempts to counter this through file editing the battle values but absolutely nothing has worked in months. and its such an uncommon issue I'm not sure what could be doing it. Do you have an idea if someone else has reported this issue to you yet?
 
So evidently some time back i started having an issue with WSE2 where it seemingly ignored any settings in any area to only allow battles at 102 size. nothing affects this internal hardcap, No the text file edits to sliders (it accepts them in game but then entirely ignores increase or decrease in actual battles.)

To make matters worse it fails to initiate logging even if i fresh install my standalone version (which for some odd reason now auto links to the steam overlay. but i dunno if thats causing it.) so I can't even get a log file to see what its doing wrong. currently I'm only having this issue in Warsword Conquest and 12th century. but i haven't tested the couple others I have thoroughly just yet to see if they are also doing it. I've been making odd attempts to counter this through file editing the battle values but absolutely nothing has worked in months. and its such an uncommon issue I'm not sure what could be doing it. Do you have an idea if someone else has reported this issue to you yet?
Try running game as administrator
 
I think I've encountered a bug, I've tried setting personal animations for horse riding, they seem not to work, but they work when I change the original entries. I've formatted the animation the same way it was in native and used the same flags as the original animations. Only ride_0_chariot works.
My entries:

link to the anims used:
https://drive.google.com/file/d/1tHh82cpa4SPF4mvohEmNxIf77hp146cc/view?usp=drive_link
the same thing if i just replace the original animations with yours
 
EXCEPTION_OUT_OF_MEMORY crash with WSE2 on TLD mod when entering Isengard
20:52:41 - Build: Release
20:52:41 - Mount&Blade Warband WSE2 version: 1.174 1110 Dec 12 2023 17:43:03
20:52:41 - Havok version: 2013.1.0-r1
20:52:41 - FMOD Ex version: 4.44.64
20:52:41 - WSE netcode version: 10
20:52:41 - Command line: --module TLD --no-intro
20:52:41 - Initializing timer...
20:52:41 - Collecting system info...
20:52:41 - Dumping system info...

--------------------------------- game load

20:54:31 - Launching game...
20:55:15 - Loading post effect shaders (HDR: 1, DoF: 1, FXAA: 1, PP: 0)...
20:55:15 - Loaded earlyZ shaders...
20:55:16 - Loaded PostFx shaders...
20:55:21 - Saving game...
20:55:21 - Creating new savegame file...
20:55:21 - Saving header...
20:55:21 - Saving game state...
20:55:21 - Closing new save game file...
20:55:21 - Starting checksum control...
20:55:21 - Performing checksum control...
20:55:22 - Savegame checksum control succeeded!
20:55:22 - Backing up old file name...
20:55:22 - Removing old backup file...
20:55:22 - Renaming old savegame to backup file...
20:55:22 - Renaming new savegame file...
20:55:22 - Savegame succeded!
20:55:24 - Starting map isengard_center in mode town_center
20:55:24 - WARNING: Failed to change river material to mud
20:55:27 - EXCEPTION_OUT_OF_MEMORY (0xE0000006, 0x004381E0)
20:55:27 - Dumping call stack...
20:55:27 - - 0x77689392 ??+0x77689392 (RaiseException+0x62)
20:55:27 - - 0x009DBD1C ??+0x9DBD1C (NewHandler+0x1C)
20:55:27 - - 0x00B7CFB7 ??+0xB7CFB7 (_callnewh+0x1:cool:
20:55:27 - - 0x00B7884F ??+0xB7884F (malloc+0x60)
20:55:27 - - 0x00B77D71 ??+0xB77D71 (operator new+0x1D)
20:55:27 - - 0x00855A78 ??+0x855A78 (std::vector<mbFaunaRec,std::allocator<mbFaunaRec> >::_Reallocate+0x2:cool:
20:55:27 - - 0x009E78B8 ??+0x9E78B8 (rglManifold::build+0x2C:cool:
20:55:27 - - 0x008A6643 ??+0x8A6643 (mbMission::start+0x27C3)
20:55:27 - - 0x0089E5AF ??+0x89E5AF (mbMetaMission::startMission+0x1F)
20:55:27 - - 0x0089BA29 ??+0x89BA29 (mbMeetingRedirector::redirect+0xD9)
20:55:27 - - 0x0089D675 ??+0x89D675 (mbMenuWindow::frameMove+0x405)
20:55:27 - - 0x00825932 ??+0x825932 (mbCoreGame::frameMove+0xF2)
20:55:27 - - 0x008330FA ??+0x8330FA (CD3DApplication::FrameMove+0x3A)
20:55:27 - - 0x00832355 ??+0x832355 (CD3DApplication::Render3DEnvironment+0x3A5)
20:55:27 - - 0x00832D3C ??+0x832D3C (CD3DApplication::Run+0xEC)
20:55:27 - - 0x009CA7EF ??+0x9CA7EF (WinMain+0xF6F)
20:55:27 - - 0x00B7EDE1 ??+0xB7EDE1 (__tmainCRTStartup+0xF1)
20:55:27 - - 0x75C37BA9 ??+0x75C37BA9 (BaseThreadInitThunk+0x19)
20:55:27 - - 0x7783BD2B ??+0x7783BD2B (RtlInitializeExceptionChain+0x6B)
20:55:27 - - 0x7783BCAF ??+0x7783BCAF (RtlClearBits+0xBF)
20:55:27 - - 0x7783BCAF ??+0x7783BCAF (RtlClearBits+0xBF)
20:55:27 - Dumping memory status...
20:55:27 - Commit size: 3616 MB
20:55:27 - Working set size: 3495 MB
20:55:27 - Available size: 19718 MB
20:55:27 - Heap #0 (process): 3242 MB
20:55:27 - Heap #1: 3 MB
20:55:27 - Heap #2: 0 MB
20:55:27 - Heap #3: 0 MB
20:55:27 - Heap #4: 76 MB
20:55:27 - Heap #5: 0 MB
20:55:27 - Heap #6: 2 MB
20:55:27 - Heap #7: 0 MB
20:55:27 - Heap #8: 28 MB
20:55:27 - Closing log file...

I've sent the full log to discord
 
Last edited:
Back
Top Bottom