Warband Script Enhancer 2 (v1.0.5.9)

Users who are viewing this thread

Vetrogor

Sergeant at Arms
@K700, how goes searching the air friction formula? Also I need the formula of weapon speed animation for throwing weapons. Thanks in advance.
 

K700

Sergeant Knight
WB
C++:
void mbMissile::computePath()
{
    m_hitType = mht_none;
    m_hitHorse = false;
    m_hitMissionObjectNo = -1;
    m_hitAgentNo = -1;
    m_hitBoneNo = -1;
    m_attack.clear();
#if !defined DEDICATED_SERVER
    m_screenState = mss_none;
    m_soundChannel = -1;

    if (m_startingDirection.dot(g_mission->m_cameraTransform.o - m_curPosition) > 0.1f)
        m_screenState = mss_incoming;
#endif

    rglVector4 position = m_startingPosition;
    rglVector4 direction = m_startingDirection;
    float speed = m_speed;
    rglVector4 clientPosition = m_startingClientPosition;
    rglVector4 clientDirection = m_startingClientVelocity;
    float clientSpeed = clientDirection.normalize();
    bool noFriction = false;
    bool noGravity = false;
    float friction = rglConfig::Battle::fAirFrictionArrow;
    float timeFactor = 1.0f / 50.0f;
    float gravityFactor = 9.8f / 50.0f;

    if (m_missileItem.isValid())
    {
        mbItemKind *missileItemKind = m_missileItem.getItemKind();

        if (missileItemKind->m_properties & itp_ignore_friction)
            noFriction = true;
        else if (missileItemKind->getType() == itp_type_bullets)
            friction = rglConfig::Battle::fAirFrictionBullet;

        if (missileItemKind->m_properties & itp_ignore_gravity)
            noGravity = true;
    }

    m_path[0] = position;
    m_prevPath = 0;
    m_curPath = 1;

    for (int i = 1; i < MB_MISSILE_PATH_SIZE; ++i)
    {
        rglVector4 newDirection = direction * speed;
        rglVector4 newClientDirection = clientDirection * clientSpeed;

        if (!noGravity)
        {
            newDirection.z -= gravityFactor;
            newClientDirection.z -= gravityFactor;
        }

        position += newDirection * timeFactor;
        clientPosition += newClientDirection * timeFactor;

        if (i >= 25)
            m_path[i] = position;
        else
            m_path[i] = (position * (float)i + clientPosition * (float)(25 - i)) * 0.04f;
        
        float newSpeed = newDirection.normalize();
        float newClientSpeed = newClientDirection.normalize();

        if (!noFriction)
        {
            newSpeed = newSpeed - newSpeed * newSpeed * friction * timeFactor;
            newClientSpeed = newClientSpeed - newClientSpeed * newClientSpeed * friction * timeFactor;
        }

        if (newSpeed > 0.00001f)
            direction = newDirection;

        if (newClientSpeed > 0.00001f)
            clientDirection = newClientDirection;
        
        speed = newSpeed;
        clientSpeed = newClientSpeed;
    }
}
 

K700

Sergeant Knight
WB
1.0.5.2
-Added WFaS build.
-Added bMoreProficiencyEffectForMovingSpeedWhileReloading config option.
-Added sf_use_next_for_far sound flag.
-Fixed sf_always_send_via_network sound flag.
-Fixed sound bugs.
-Fixed backpedal speed.


Note for WFaS

All Warband features, operations, triggers, scripts, flags are available, along with all wse features. For modding don't forget to add whatever you need from warband headers to wfas module system.

Since the WFaS does not have necessary network events, for compatibility following Warband features works only when bBreakWarbandCompatibility=true:

-Separate audio channel for agent_play_sound and agent_stop_sound operations.
-Network sync for agent_set_accuracy_modifier, agent_set_speed_modifier, agent_set_reload_speed_modifier, agent_set_use_speed_modifier operations.

Thanks to DoDoCat for sponsoring development.
 
Last edited:

K700

Sergeant Knight
WB
This is flag used in WFaS and Carribean. It's hardcoded

Code:
float distance = (m_transform.o - soundChannel.m_position).length();
    float distanceFactor = 1.0f;

    for (int i = 1; i < 5 && sound->m_flags & sf_use_next_for_far && distance > 15.0f && soundNo < (m_numSounds - i); ++i)
    {
        soundNo++;
        sound = &m_sounds[soundNo];
        distance *= 0.3f;
        distanceFactor *= 0.35f;
    }

    soundChannel.m_position = m_transform.o + (soundChannel.m_position - m_transform.o) * distanceFactor;
 

Pitch

Squire
WBNWVCM&BWF&S
1.0.5.2
-Added WFaS build.
-Added bMoreProficiencyEffectForMovingSpeedWhileReloading config option.
-Added sf_use_next_for_far sound flag.
-Fixed sf_always_send_via_network sound flag.
-Fixed sound bugs.
-Fixed backpedal speed.


Note for WFaS
Since the WFaS does not have necessary network events, for compatibility following Warband features works only when bBreakWarbandCompatibility=true:

-Separate audio channel for agent_play_sound and agent_stop_sound operations.
-Network sync for agent_set_accuracy_modifier, agent_set_speed_modifier, agent_set_reload_speed_modifier, agent_set_use_speed_modifier operations.

Thanks to DoDoCat for sponsoring development.

Thank you.
 

K700

Sergeant Knight
WB
1.0.5.3
-Added warband_compatibility.ini support.
-Fixed brace rotation.
-Minor bugfixes.
 

Vetrogor

Sergeant at Arms
Currently limit for attributes like strength are limited to 63. It will be good to rase limit to 255 at least.
 

Pitch

Squire
WBNWVCM&BWF&S
@K700
WFAS WSE2

There is currently bug in WFaS WSE which causes Double-barreled pistols and muskets not work properly.
On first use, they work correctly (they shot twice) but after reloading - they take 1 bullet and shot only once.

Tested on dedicated server and on "host game". Same effect.
 

K700

Sergeant Knight
WB
1.0.5.4
-Fixed reloading bug - only one projectile was loaded, regardless of weapons max ammo.
-Fixed make_screenshot operation.
-Implemented troop viewer for edit mode.
 

Pitch

Squire
WBNWVCM&BWF&S
Fixed reloading bug - only one projectile was loaded, regardless of weapons max ammo.
Thank you for quick update.






@K700
WFaS WSE2
I noticed some inconsistency in store_agent_hit_points native operation.

Python:
(store_agent_hit_points, reg10, ":agent_id"),

In this situation, I expect reg10 to return 100 on brand new agents.
This works correctly in Native M&B, however with WFaS WSE2, it behaves a bit strange, not horribly incorrect - but still strange.

Client side
Tested on both, native server and server with WSE.

i0ciGcY.jpeg
.


EDITED


It's something oddly specific and honestly can't figure what it is.
I think you can safely ignore it.

Python:
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (call_script, "script_multiplayer_server_on_agent_spawn_common", ":agent_no"),

        (try_begin),
         (agent_is_human, ":agent_no"),
         (store_agent_hit_points, reg50, ":agent_no", 0),
         (assign, reg51, ":agent_no"),
         (display_message, "@Agent ID: {reg51 }HP: {reg50}", green),
         (try_end),

^ Here it returns always correct values.
Maybe it's mistake on my side and I am just blind.
 
Last edited:

K700

Sergeant Knight
WB
1.0.5.5
-Added bDoNotMakeHandsParallelToGround config option.

set to true to fix dead agents hands bug when scale of agents is not equal to 1.0
 
Top Bottom