B Tutorial Other Adding things such as overhead stab, crouching, extra formations options.

Users who are viewing this thread

At the M&B Modding Discord cokjan showed two months ago some tests which he did to prevent the facehugging. His idea was to (copy pasting his words)
"controll[...] agent footwork so they don't facehug like a dumb person via animations (didn't use set scripted destination because i think it would require 2 try_for_agents?)
After being asked "So the spear animation forces a leg animation with displace position or whatever that flag was?" he responded with.
nope, it still uses a mission trigger to set the animations. but that could be an alternate solution for removing the need for try_for_agent by adding a displace pos flag for blocked/parried animation. albeit making it kinda janky for player and ai movement
😂

To summarise it for you: It's not done via an animation (seems not to be possible that way) but a trigger within a mission template which requires scripting.
 
You would need to add an if-clause such way that items with that property are getting that flag.
Thank you, Seems easy to add. :grin:

To someone who need it, too. Only add the part between #.
Code:
      (else_try),
        (is_between, ":item_no", reference_books_begin, reference_books_end),
        (try_begin),
          (eq, ":extra_text_id", 0),
          (try_begin),
            (eq, ":item_no", "itm_book_wound_treatment_reference"),
            (str_store_string, s1, "@wound treament"),
          (else_try),
            (eq, ":item_no", "itm_book_training_reference"),
            (str_store_string, s1, "@trainer"),
          (else_try),
            (eq, ":item_no", "itm_book_surgery_reference"),
            (str_store_string, s1, "@surgery"),
          (try_end),
          (set_result_string, "@+1 to {s1} while in inventory"),
          (set_trigger_result, 0xFFEEDD),
        (try_end),
########## This part ##########
      (else_try),
        (item_has_property, ":item_no", itp_is_pike),
        (try_begin),
          (eq, ":extra_text_id", 0),
          (set_result_string, "@can brace"),
          (set_trigger_result, 0xFFEEDD),
        (try_end),
########## This part ##########
      (try_end),
  ]),
 
Last edited:
I’ve a question. Is it possible to use a different mesh in an ALT weapons mode? Because I’ve tried by just editing the files of a throwing weapon. All that happens is once the ALT mode is engaged, character is left holding an empty fist. I can equip the ALT mode weapon mesh and it’s as it should be, but it is only an empty fist when toggled from the primary weapon.
 
Ahh, I had saved a draft with a very thoughtful and very thorough explanation. You'll have to live with this one:

As Earendil said, you will need to swap the weapon manually. Similar to how you can equip the alt mode and the mesh is correct, we are basically watching for the keypress and equipping the alternate mode directly.

Here is the exact trigger I use for a player swapping to an alt mode.
Link to it inside the context of the MT file.
Code:
fate_item_swap = (0, 0, 1, [(game_key_clicked, gk_toggle_weapon_mode),  (neg|conversation_screen_is_active),], [

    # So we're going to store the player agent number, and see what they are holding:
    (get_player_agent_no, ":player"),
    (agent_get_wielded_item, ":item", ":player", 0),
   
    # This checks to see if the item is valid, as a way of preventing error messages
    (gt, ":item", 0),

    # And we also want to know what the previous item in the list is, because we check if ~either~ have the
    # itp_next_item_as_melee, we now know which item we are holding.
    (store_sub, ":previous_item", ":item", 1),
   
    # It's good practice to contain can fail checks within a block.  
    (try_begin),

        # This checks if either the weapon we are holding, or the weapon after it is the one
        # that is swapped, or is swapped to.
        (this_or_next|item_has_property, ":item", itp_next_item_as_melee),
        (item_has_property, ":previous_item", itp_next_item_as_melee),
       
        # We need to know which one we are swapping to.
        # Since we know one of them is valid, and only one ~can~ be, so we can make an assumption.
        (try_begin),
            (item_has_property, ":item", itp_next_item_as_melee),
            (store_add, ":swap_item", ":item", 1),
        (else_try),
            (assign, ":swap_item", ":previous_item"),
        (try_end),
       
        # This block goes through all the equipment slots, and if we find the item, it removes it, swapping it for the
        # alternate version and breaking the loop. By swapping it this way, the mesh can be changed.
        # It keeps the modifier, and ammo stacks, but loses the load status.
        (assign, ":total_ammo", 0),
        (assign, ":swapped", 0),
        (try_for_range, ":slot", 0, 4),
            (agent_get_item_slot, ":cur_weapon", ":player", ":slot"),
            (eq, ":cur_weapon", ":item"),
            (agent_get_ammo_for_slot, ":add", ":player", ":slot),
            (val_add, ":total_ammo", ":add"),
            (eq, ":swapped", 0),
            (val_add, ":swapped", 1),
            (troop_get_inventory_slot_modifier, ":imod", "trp_player", ":slot"),    
            (agent_unequip_item, ":player", ":item", ":slot"),
            (agent_equip_item, ":player", ":swap_item", ":slot", ":imod"),
            (agent_set_wielded_item, ":player", ":swap_item"),
           (agent_set_ammo, ":player", "item", ":total_ammo),
        (try_end),
    (try_end),
])

It's not perfect. I added some nonsense for sorting the swap from recharging their ammo, but I wrote that just now on the fly without testing it, so, I dunno if it works.

Feel free to ask any questions you may have
 
Thanks for the code! Correct me if I’m wrong, but does this only work for player? And if not, will it lag? I’m looking for the code that the CRPG guy did with alt mode weapon repositioning. Example: huskarl axe visual rotation from a cut to a pierce.
 
Back
Top Bottom