OSP Code Combat [WSE] Flail

Users who are viewing this thread

K700

Master Knight
WSE now allows you to realize the unusual weapon in warband such as flails, whips, nunchaks by using vertex animation to agent weapon body mesh.

Animated only flail swing, any other animation can be made similarly.

Requires WSE >= 4.2.4! http://forums.taleworlds.com/index.php/topic,324890.0.html

Creators
K700 - WSE, scripting
Votsukan - mesh, animation



Download
https://www.dropbox.com/s/gp7m6hyst8wnoc1/flail.rar?dl=0
 
That is...wow, really impessive.

One of the missing feature in warband.
 
I absolutely need this in my submod.
Do we have to use WSE?
What is the best explanation for merging an old mod with WSE?
Thanks!
GDW
 
I finally spent several hours trying to implement this in Brytenwalda for single player campaigns.
1) I installed WSE, but could not get WSELoader to run because it says I'm not on MB Warband 1.166. I actually am on Steam's latest version: 1.168 (or higher).
2) I installed all components of your OSP.
Note that your sound files are ogg and need to be in WAV format.
3) Error on compile:
The game can't find the definition for  "action_react_to_flail_attack"
Traceback (most recent call last):
  File "process_init.py", line 2, in <module>
    from process_operations import *
  File "D:\MountBlade Warband\_modsextra90615\MODULESYSTEM1157GDWBWWORKINGLATEST
!\process_operations.py", line 13, in <module>
    from module_items import *
  File "D:\MountBlade Warband\_modsextra90615\MODULESYSTEM1157GDWBWWORKINGLATEST
!\module_items.py", line 2262, in <module>
    (multiplayer_send_int_to_player, ":current_player_no", action_react_to_flail
_attack, ":attacker_agent_no"),
NameError: name 'action_react_to_flail_attack' is not defined
Traceback (most recent call last):
  File "process_global_variables.py", line 8, in <module>
    from module_presentations import *
  File "D:\MountBlade Warband\_modsextra90615\MODULESYSTEM1157GDWBWWORKINGLATEST
!\module_presentations.py", line 12, in <module>
    from module_my_mod_set import *
  File "D:\MountBlade Warband\_modsextra90615\MODULESYSTEM1157GDWBWWORKINGLATEST
!\module_my_mod_set.py", line 6, in <module>
    from module_items import *
  File "D:\MountBlade Warband\_modsextra90615\MODULESYSTEM1157GDWBWWORKINGLATEST
!\module_items.py", line 2262, in <module>
    (multiplayer_send_int_to_player, ":current_player_no", action_react_to_flail
_attack, ":attacker_agent_no"),
NameError: name 'action_react_to_flail_attack' is not defined
3) I removed this trigger from the items and just added a sound trigger.
Why didn't you have a sound trigger?
4) Now I get this error message:
So then I removed the action_react in module_items and now I get this message:
Loading module... FAILED.
MODULE `scripts` ERROR:
Traceback (most recent call last):
  File "compile.py", line 129, in <module>
    from module_scripts import *
  File "D:\MountBlade Warband\_modsextra90615\MODULESYSTEM1157GDWBWWORKINGLATEST
!\module_scripts.py", line 22926, in <module>
    (eq,":event_type", action_react_to_flail_attack),
NameError: name 'action_react_to_flail_attack' is not defined
COMPILATION FAILED.

This message is still being tested with fixes.
 
  gdwitt Do as instructed, then everything will work

simple add action_react_to_flail_attack to  free client events in header_common.py
 
gdwitt said:
Note that your sound files are ogg and need to be in WAV format.

Why? Warband can use both. If you do not like to use ogg, download old goldwave, install ogg plugin and convert sounds to wav. Problem solved.
 
So I added that action_react_to_flail_attack to header_common.
However, I then uncommented the broken code and it all compiles!
No error messages.
However, in-game the flails don't have that swing.
The chain is still attached to the handle as with the item.
The players would like it to be able to swing like in your youtube video.
Let me know if it is supposed to swing or not.

Also, the sound doesn't play, which indicates to me that the script did not get called.
I am playing this single-player, not multiplayer.

Here's a snippet of the part at the bottom of client events side of "game_receive_network_message"
(else_try),
  (eq, ":event_type", multiplayer_event_player_play_sound),
  #(display_message,"@Bang!"),
  (store_script_param, ":sound", 3),
  (store_script_param, ":player", 4),
  #(gt,":player",0),
  (player_get_agent_id,":agent",":player"),
  (try_begin),
  (neq,":agent",-1),
  (agent_is_alive,":agent"),
  (agent_play_sound,":agent",":sound"),
  (try_end),
     
    (else_try),
        (eq, ":event_type", multiplayer_event_player_play_animation),
  (store_script_param, ":animation", 3),
  (store_script_param, ":player", 4),
  (player_get_agent_id,":agent",":player"),
  (try_begin),
  (neq,":agent",-1),
  (agent_is_alive,":agent"),
  (agent_set_animation,":agent",":animation"),
  (try_end),
        ##gdw script below from flail osp cause fatal compilation error because "action_react_to_flail_attack" is not defined.

    (else_try),#########gdw Flail osp
      (eq,":event_type", action_react_to_flail_attack),
      (store_script_param,":attacker_agent_no",4),
      (try_begin),
          (agent_is_active, ":attacker_agent_no"),
          (agent_is_alive, ":attacker_agent_no"),
          (agent_get_wielded_item_slot_no, ":slot_no", ":attacker_agent_no"),
          (val_add, ":slot_no", bmm_item_1),
          (agent_body_meta_mesh_set_vertex_keys_time_point, ":attacker_agent_no", ":slot_no", 10),
          (agent_set_slot, ":agent_no", slot_agent_flail_using, 1),
          (agent_get_bone_position,pos1,":attacker_agent_no",hb_item_r, 1),
          (play_sound_at_position, "snd_chain", pos1),
      (try_end),

####multiplayer chief acaba
    (try_end),
(try_end),#gdw from error in compilation "mission tryend"
    ]),
 
  # script_cf_multiplayer_evaluate_poll
  # Input: none
  # Output: none (can fail)
  ("cf_multiplayer_evaluate_poll",

thank you for the wonderful work so far.

Here's a link to my complete source code if you question my implementation.
http://www.nexusmods.com/mbwarband/mods/5997/?
 
Ahh.
So is Scripts the only place where I would need to move something?
What script would you move it to?
Thank you and happy thanks-giving day.
GDW
 
First, thank you for working on this for us.
I downloaded and carefully matched all my files to your files.
It still doesn't work for single player. In fact, it causes opcode errors.
One new thing is that now I hear a consistently new sound at each swing: "snd_draw_flail".
Here is my item trigger:
Code:
[(ti_on_weapon_attack,
  [(store_trigger_param_1, ":attacker_agent_no"),
    (try_begin),
            (multiplayer_is_server),
      (get_max_players, ":num_players"),
            (try_for_range, ":current_player_no", 1, ":num_players"),
                (player_is_active, ":current_player_no"),
        (multiplayer_send_int_to_player, ":current_player_no", action_react_to_flail_attack, ":attacker_agent_no"),
            (try_end),
     (else_try),
          (agent_get_wielded_item_slot_no, ":slot_no", ":attacker_agent_no"),
          (val_add, ":slot_no", bmm_item_1),
          (agent_body_meta_mesh_set_vertex_keys_time_point, ":attacker_agent_no", ":slot_no", 10),
          (agent_set_slot, ":attacker_agent_no", slot_agent_flail_using, 1),
          (agent_play_sound, ":attacker_agent_no", "snd_draw_flail"),
     (try_end),
  ])]],

Here is the error log:
Code:
At Item itm_flailsteel_blunt trigger no: 0. At Item itm_flailsteel_blunt trigger no: 0. Unrecognized opcode 3317.; LINE NO: 11: 
 At Item itm_flailsteel_blunt trigger no: 0. At Item itm_flailsteel_blunt trigger no: 0. Unrecognized opcode 3308.; LINE NO: 9: 
 At Item itm_flailsteel_blunt trigger no: 0. At Item itm_flailsteel_blunt trigger no: 0. Unrecognized opcode 3317.; LINE NO: 11: 
 At Item itm_flailsteel_blunt trigger no: 0. At Item itm_flailsteel_blunt trigger no: 0. Unrecognized opcode 3308.; LINE NO: 9: 
 At Item itm_flailsteel_blunt trigger no: 0. At Item itm_flailsteel_blunt trigger no: 0. Unrecognized opcode 3317.; LINE NO: 11: 
 At Item itm_flailsteel_blunt trigger no: 0. At Item itm_flailsteel_blunt trigger no: 0. Unrecognized opcode 3308.; LINE NO: 9: 
Now I get an error EVERY time I swing only when I'm near the enemy.
I tested and the errors occur when I'm on a horse or on foot.
Before we meet the enemy, I can swing the flails without any opcodes appearing.
Here is my header_operations:
Code:
agent_get_wielded_item_slot_no = 3308 #(agent_get_wielded_item_slot_no, <destination>, <agent_no>, [<hand_no>]), #Stores <agent_no>'s wielded item slot for [<hand_no>] into <destination>
agent_body_meta_mesh_set_vertex_keys_time_point = 3317 #(agent_body_meta_mesh_set_vertex_keys_time_point, <agent_no>, <body_meta_mesh>, <time_point>), #Sets <agent_no>'s <body_meta_mesh> mesh vertex key

I don't understand why these are "unrecognized".
Maybe it is not successfully calling the script or mission template?

Positive: I think this is progress, because now we know that it's trying to actually use those triggers and call the script.
It just can't seem to connect.
It does use the new snd_draw_flail from the item trigger.
I set the scripts to  play snd_chain and that's not being heard
Code:
(else_try),#########gdw Flail osp
       (eq,":event_type", action_react_to_flail_attack),
       (store_script_param,":attacker_agent_no",4),
       (try_begin),
          (agent_is_active, ":attacker_agent_no"),
          (agent_is_alive, ":attacker_agent_no"),
          (agent_is_human, ":attacker_agent_no"),
          (agent_get_wielded_item_slot_no, ":slot_no", ":attacker_agent_no"),
          (val_add, ":slot_no", bmm_item_1),
          (agent_body_meta_mesh_set_vertex_keys_time_point, ":attacker_agent_no", ":slot_no", 10),
          (agent_set_slot, ":agent_no", slot_agent_flail_using, 1),
          # (agent_get_bone_position,pos1,":attacker_agent_no",hb_item_r, 1),
          # (play_sound_at_position, "snd_chain", pos1),
          (agent_play_sound, ":attacker_agent_no", "snd_chain"),
       (try_end),

Why don't we put all of the trigger into a separate script or the script into the trigger?
 
I have all the file components of WSE 4.2.4 added to the module system.
However, I can't get WSELoader.exe to cooperate.
It tells me:
"Error: You are running an unsupported version of Warband (WSE only supports version 1.16:cool:. Please download the full game..."
My WSE Loader log:
WSE Loader by cmpxchg8b, K700 (Build date: Aug 29 2015 14:51:34)
OS version: 6.2.9200 SP 0.0
Command line:
WSE path: C:\Steam\steamapps\common\MountBlade Warband\Modules\MODULESYSTEM1157GDWBWWORKINGLATEST!\WSE v4.2.4\
Game executable origin: registry (Steam)
Game executable path: C:\Steam\steamapps\common\MountBlade Warband\mb_warband.exe
Game executable checksum: 69A4957B
You are running an unsupported version of Warband (WSE only supports version 1.16:cool:.
Please update or download the full game from http://www.taleworlds.com/download.aspx.

This is very frustrating because I do have the latest version installed. I have MBWarband from Steam (I'm a registered user) and my came properties tells me I have v1.168.

Do you need to set up module.ini features from WSE in a specific manner to get this to work?
# set to 0 to break network compatibilty and enable advanced WSE features like composite network messages and more skins in multiplayer
network_compatible = 1
# set to 1 to hide servers running other mods from the servers list
hide_other_mod_servers = 0
# set to 1 to enable weapon collision with ground
ground_weapon_collision = 0
# set to 1 to use missile (arrow, bolt, bullet) damage type (cut, pierce, blunt) instead of launcher item (bow, crossbow, musket, pistol) damage type
use_missile_damage_type = 0
# set to 1 to prevent showing an error when using unset script params (default value for unset params is 0)
allow_unset_script_params = 0
# set module download url
module_download_url = www.taleworlds.com/mb_warband_download_module.html
 
Yes, WSE is working now!
No, the flails still don't swing.
The good news is that I no longer get opcode warnings;
the script is working and connecting.
What do I need to do to see the flails swing in single player mod?

I have 6 flails, in alt-pairs, that are working in-game. I only hear that sound.
I use the 6 flails to test out different options.
Please give me some options to test.
["flail1_blunt", "Cavalry_Flail", [("mace_pear",0), ("flail_scab", ixmesh_carry)], itp_bln, itc_bln, 815,
Code:
weight(3.7)|difficulty(9)|spd_rtng(76)|weapon_length(102)|swing_damage(30,blunt)|thrust_damage(0,blunt), imodbits_mace, 
 [(ti_on_weapon_attack,
  #(play_sound,"snd_chain"),
  [(store_trigger_param_1, ":attacker_agent_no"),
    (try_begin),
            (multiplayer_is_server),
      (get_max_players, ":num_players"),
            (try_for_range, ":current_player_no", 1, ":num_players"),
                (player_is_active, ":current_player_no"),
        (multiplayer_send_int_to_player, ":current_player_no", action_react_to_flail_attack, ":attacker_agent_no"),
            (try_end),
     (else_try),
          (agent_get_wielded_item_slot_no, ":slot_no", ":attacker_agent_no"),
          (val_add, ":slot_no", bmm_item_1),
          (agent_body_meta_mesh_set_vertex_keys_time_point, ":attacker_agent_no", ":slot_no", 10),
          (agent_set_slot, ":attacker_agent_no", slot_agent_flail_using, 1),
          (agent_play_sound, ":attacker_agent_no", "snd_draw_flail"),
     (try_end),
  ])]],
["flail1_blunt_alt", "rcavalry_flail", [("flanged_mace",0), ("flail_scab", ixmesh_carry)], itp_ax1huqb, itc_sleg, 710, weight(3.7)|difficulty(9)|spd_rtng(78)|weapon_length(104)|swing_damage(35,blunt)|thrust_damage(0,blunt), imodbits_mace ,
 [(ti_on_weapon_attack,
  #(play_sound,"snd_chain"),(play_sound,"snd_chain"),
  [(store_trigger_param_1, ":attacker_agent_no"),
    (try_begin),
            (multiplayer_is_server),
      (get_max_players, ":num_players"),
            (try_for_range, ":current_player_no", 1, ":num_players"),
                (player_is_active, ":current_player_no"),
        (multiplayer_send_int_to_player, ":current_player_no", action_react_to_flail_attack, ":attacker_agent_no"),
            (try_end),
    (try_end)]),
  #[(ti_on_weapon_attack, [(play_sound,"snd_chain"),
 ]],
["flail2_blunt", "Cavalry Chain Flail", [("flail",0), ("flail_scab", ixmesh_carry)], itp_bln, itc_bln, 990, weight(4.1)|difficulty(10)|spd_rtng(74)|weapon_length(107)|swing_damage(33,blunt)|thrust_damage(0,blunt), imodbits_mace, 
 [(ti_on_weapon_attack,
  #(play_sound,"snd_chain"),
  [(store_trigger_param_1, ":attacker_agent_no"),
    (try_begin),
            (multiplayer_is_server),
      (get_max_players, ":num_players"),
            (try_for_range, ":current_player_no", 1, ":num_players"),
                (player_is_active, ":current_player_no"),
        (multiplayer_send_int_to_player, ":current_player_no", action_react_to_flail_attack, ":attacker_agent_no"),
            (try_end),
     (else_try),
          (agent_get_wielded_item_slot_no, ":slot_no", ":attacker_agent_no"),
          (val_add, ":slot_no", bmm_item_1),
          (agent_body_meta_mesh_set_vertex_keys_time_point, ":attacker_agent_no", ":slot_no", 10),
          (agent_set_slot, ":attacker_agent_no", slot_agent_flail_using, 1),
          (agent_play_sound, ":attacker_agent_no", "snd_draw_flail"),
     (try_end),
  ])]],
["flail2_blunt_alt", "Cavalry Chain Flail", [("flanged_mace",0), ("flail_scab", ixmesh_carry)], itp_ax1huqb, itc_sleg, 1050, weight(4.1)|difficulty(8)|spd_rtng(75)|weapon_length(107)|swing_damage(38,blunt)|thrust_damage(0,blunt), imodbits_mace ,
 [(ti_on_weapon_attack,
  #(play_sound,"snd_chain"),
  [(play_sound,"snd_chain"),(store_trigger_param_1, ":attacker_agent_no"),
    (try_begin),
            (multiplayer_is_server),
      (get_max_players, ":num_players"),
            (try_for_range, ":current_player_no", 1, ":num_players"),
                (player_is_active, ":current_player_no"),
        (multiplayer_send_int_to_player, ":current_player_no", action_react_to_flail_attack, ":attacker_agent_no"),
            (try_end),
    (try_end)]),
  #[(ti_on_weapon_attack, [(play_sound,"snd_chain"),
 ]],
 
Here's my latest mission_template if someone else wants to test this.
I added 2 flails, two new animations and 4 debug statements. The rest is identical to the latest flail pack.
The debug statements are not appearing in my rgl_log which indicates to me that something is not connecting.
I am still not seeing the flails swing.
They sound and work like flails though.

flail_trigger = (
  0, 0, 0,
[(neg|multiplayer_is_dedicated_server),],
    [
(try_for_agents, ":agent_no"),
(agent_is_active, ":agent_no"),
(agent_is_alive, ":agent_no"),
(agent_slot_eq, ":agent_no", slot_agent_flail_using, 1),
(agent_get_wielded_item, ":wielded_weapon", ":agent_no", 0),
(try_begin),
(this_or_next|eq, ":wielded_weapon", "itm_flail1_blunt"),
(this_or_next|eq, ":wielded_weapon", "itm_flail2_blunt"),
(eq, ":wielded_weapon", "itm_flailsteel_blunt"),
(agent_get_wielded_item_slot_no, ":slot_no", ":agent_no"),
(val_add, ":slot_no", bmm_item_1),
(agent_get_animation, ":upper_anim", ":agent_no", 1),
(try_begin),
(this_or_next|eq, ":upper_anim", "anim_release_slashright_onehanded"),
(this_or_next|eq, ":upper_anim", "anim_release_slashright_onehanded_continue"),
(this_or_next|eq, ":upper_anim", "anim_release_slashleft_onehanded_continue"),
(this_or_next|eq, ":upper_anim", "anim_release_slashleft_onehanded"),
(this_or_next|eq, ":upper_anim", "anim_release_overswing_onehanded"),
(this_or_next|eq, ":upper_anim", "anim_release_slash_horseback_right"),
(eq, ":upper_anim", "anim_release_slash_horseback_left"),

(agent_get_animation_progress, ":animation_progress", ":agent_no", 1),
(store_mul, ":vertex_animation_time", 55, ":animation_progress"),
(val_div, ":vertex_animation_time", 100),
(val_add, ":vertex_animation_time", 10),
(agent_body_meta_mesh_set_vertex_keys_time_point, ":agent_no", ":slot_no", ":vertex_animation_time"),
(try_begin),
                    (gt, "$cheat_mode", 0),
                    (display_message, "@{!}DEBUG flail mt1"),
            (try_end),
(else_try),
(agent_body_meta_mesh_set_vertex_keys_time_point, ":agent_no", ":slot_no", 65),
(agent_set_slot, ":agent_no", slot_agent_flail_using, 0),
(try_begin),
                    (gt, "$cheat_mode", 0),
                    (display_message, "@{!}DEBUG flail mt2"),
            (try_end),
(try_end),
(else_try),
(agent_set_slot, ":agent_no", slot_agent_flail_using, 0),
(try_begin),
                    (gt, "$cheat_mode", 0),
                    (display_message, "@{!}DEBUG flail mt3"),
            (try_end),
(try_end),
(try_end),
])

flail_wielding_trigger = (
ti_on_item_wielded, 0, 0,
[(neg|multiplayer_is_dedicated_server),],
    [
(store_trigger_param_1, ":agent_no"),
        (store_trigger_param_2, ":item_no"),
#(eq, ":item_no", "itm_flail"),
(this_or_next|eq, ":item_no", "itm_flail1_blunt"),
(this_or_next|eq, ":item_no", "itm_flail2_blunt"),
(eq, ":item_no", "itm_flailsteel_blunt"),
#(agent_get_bone_position,pos1,":agent_no",hb_item_r, 1),##this was used for 1st flail pack -multiplayer
#(play_sound_at_position, "snd_draw_flail", pos1),
(agent_play_sound, ":agent_no", "snd_draw_flail"),
(try_begin),
                    (gt, "$cheat_mode", 0),
                    (display_message, "@{!}DEBUG flail mt4"),
    (try_end),
])

Do I need to embed this into lead charge?
 
The key problem that was not pointed out was that you need to put the flail scripts in all the mission templates, not separate.
Add the MT scripts anywhere in missions templates then do this at the end of each primary mission:

]+ AI_triggers + heridas_chel + dplmc_battle_mode_triggers + formations_triggers + order_volley_triggers + rider_damage + warcry_chel + flail_trigger + flail_wielding_trigger,
  ),

Here's one sample which I put at the bottom, not actually in the mission templates.
flail_wielding_trigger =
(ti_on_item_wielded, 0, 0,
[(neg|multiplayer_is_dedicated_server),],
    [
(store_trigger_param_1, ":agent_no"),
        (store_trigger_param_2, ":item_no"),
#(eq, ":item_no", "itm_flail"),
(this_or_next|eq, ":item_no", "itm_flail1_blunt"),
(this_or_next|eq, ":item_no", "itm_flail2_blunt"),
(eq, ":item_no", "itm_flailsteel_blunt"),
#(agent_get_bone_position,pos1,":agent_no",hb_item_r, 1),##this was used for 1st flail pack -multiplayer
#(play_sound_at_position, "snd_draw_flail", pos1),
(agent_play_sound, ":agent_no", "snd_draw_flail"),
]),
 
Back
Top Bottom