B Info Module System New carry-position for large axes

Users who are viewing this thread

Eärendil Ardamírë

Subforum Moderator
WBWF&SM&B
Recent work at the forum let me stumble again above this thread by mtarini:
He envisioned some new carry animation for large axes which are getting carried in the left hand close to their cutting end.
carry_axe.png

Now we have meanwhile gathered more knowledge about the effect of itp flags. Per se, it is not difficult to get an item to the left hand, just declaring it as a bow or shield (with proper setup of the mesh at the brf file) would do it but then the weapon would not be an axe anymore. One could also simply set the flag itp_force_attach_left_hand to the two-handed axe which would let it be carried at the left hand but not at the above mentioned desired position, close to the weapon head. It is still possible as can be seen in the image.
mb1.jpg
The suggested way to approach this is via the flag itp_next_item_as_melee. This way we can basically add a new carry animation, additionally to the one if the axe is not equiped. For this we need two different weapon kinds between which the player can and (more importantly) the AI agents will switch by themselves without any new required triggers or scripts, just plain Native behaviour.

BFR Organisation:
The biggest challenge is to get an alternative mesh positioning of the weapon. Using the flag itp_next_item_as_melee means that we cannot call a different mesh since it will always default to the base mesh of the initial weapon. Now the only weapon which can get carried with a different vertex animated version is the crossbow. The normal state of a crossbow is the loaded one. This means we need to arrange our long axe in OpenBRF like a crossbow. For this we copy paste the mesh four times (keeping the original one save as backup) and rename them like e.g. longaxe_a_frame0, _frame1, _frame2 and _frame3.

While the frames 0, 1 and 3 are simply again the normal mesh of the long axe, frame 2 is the important one for us since it is the frame of the loaded crossbow. This means you need to repositionate the axe now accordingly that it looks good.
  1. Right-click on the mesh abd click on 'Roto-translate-rescale...'
  2. Choose here the values to your likings. I have used Translation (Z: -0,5750, Y: 0,0050) and Rotation (Z: 180,00).
  3. Now select all four frames at once. Right-click on any of them and select 'Merge as frames in a vertex ani'. Now three entries should have disappeared, leaving you with the frame0 mesh.
  4. Click on this mesh (can be renamed to remove the _frame0): It should show now the number 4 at the field frames. Click through the 'Time of frame' to see all four frames. The third (Time of frame: 2) one should be positionated differently. If so, add at the field right next to it the value 100.
  5. At the end you should have: (Time of frame 0 : 0) (Time of frame 1 : 0) (Time of frame 2 : 100) (Time of frame 3 : 200). If so, you have finished the work at the brf file. Save it of course.
Item entry (module_items.py)
Now take the item entry of your long axe which you probably already have at hand. I use of Native the entry of the long axe (adding exp for experiment. Make sure that you have added the name of your new mesh (long_axe_a_exp in my example) into it and name it with _alt at the end:
Code:
["long_axe_exp_alt",         "Long Axe", [("long_axe_a_exp",0)], itp_type_polearm|itp_two_handed|itp_primary|itp_bonus_against_shield|itp_wooden_parry|itp_next_item_as_melee|itp_unbalanced|itp_merchandise,itc_staff|itcf_carry_axe_back,
 390 , weight(4.75)|difficulty(10)|spd_rtng(93) | weapon_length(120)|swing_damage(46 , cut) | thrust_damage(19 ,  blunt),imodbits_axe ],
Now we need a crossbow which can switch to the regular axe. Take any crossbow entry as you like and add it before your new axe entry (I chose the one of hunting_crossbow). Replace the id name (without the _alt at the ending) and the mesh name accordingly. Make sure that the crossbow entry has the flag itp_next_item_as_melee while the axe entry must not(!) have it (it should also not have the flag itp_merchandise if you don't want the normal axe to show up at the shops or vice versa the crossbow version).

Add the flag itp_force_attach_left_hand to the crossbow entry, so that it gets carried in the left hand. Items with itp_type_crossbow are however getting carried with both hands, like a staff, except for the case that they have the flag itcf_reload_pistol. Replace the flag itcf_shoot_crossbow with itcf_reload_pistol and the carry animation switches to the one of one-handed weapons. This solves a second problem which we would have had since we don't want the agents to shoot with this crossbow. If a ranged weapon has only a reload animation assigned to it (via the itcf-flag) but no shooting animation, it can't get shot with.

At the carry position I haven't found yet a good one, they all looked bad yet. Crossbows seem to be the only weapons at which an ixmesh_carry entry has no effect. Perhaps someone finds a good solution here beside simply hidding the weapon if not drawn.

Make sure that crossbow and axe have the same difficulty setting (and that the troop wielding this weapon is strong enough to do so!) and that the stats of the crossbow entry are high enough to make the weapon an attractive choice for the AI.

You can optional remove imodbits_crossbow since it isn't needed except for the fact that you have set up alternative meshes with it.

The flag itp_two_handed at the crossbow entry is optional. If not set it is possible that an agent carries the axe (crossbow entry) and a shield both at the same time in the left hand. This can look weired of course. In this case you need to pay attention that the long axe (axe entry) has then either the flag itp_two_handed itself or that it has some one-handed-itcf flags assigned to it. Otherwise the troop switches to the alternate weapon but can't fight. They are just going close to the enemy and away again, like a little dance (while they are getting wounded and killed). They also won't switch to a sword or other melee weapons they have available (untested for specific weapon orders and actual stats of the weapon).

Your item entries should now look something like that:
Code:
["long_axe_exp_alt", "Hunting Crossbow", [("long_axe_a_exp",0)], itp_type_crossbow|itp_force_attach_left_hand|itp_merchandise|itp_primary|itp_two_handed|itp_next_item_as_melee ,itcf_reload_pistol, 
22 , weight(2.25)|difficulty(0)|spd_rtng(47) | shoot_speed(50) | thrust_damage(37 ,  pierce)|max_ammo(1),imodbits_crossbow ],
["long_axe_exp_alt",         "Long Axe", [("long_axe_a_exp",0)], itp_type_polearm|itp_two_handed|itp_primary|itp_bonus_against_shield|itp_wooden_parry|itp_unbalanced,itc_staff,
 390 , weight(4.75)|difficulty(10)|spd_rtng(93) | weapon_length(120)|swing_damage(46 , cut) | thrust_damage(19 , blunt),imodbits_axe ],

Where a crossbow is there is also a bolt. You need to give the units invisible bolts. The bolt mesh can be invalid_item for that purpose. Otherwise the crossbows get loaded by the default crossbow bolt (The default bolt at your mod is the one with the flag itp_default_ammo.) and you will have a bolt floating around in the air.

Assign the new weapon to your troops, compile your Module System twice and then check in-game how it looks like (mind that you won't see it in save-games!) Here a screenshot of my last test. You can also see that the infantry is randomly equping it while all ranged units got it.

Flag_Test.jpg

Issues:
  1. At some few moments one can see a little bit clipping between the frames of the axe, especially at the beginning of a battle when the troops spawn.
  2. AI agents only switch to the alternate weapon mode if the enemy is close by. They seem to switch quicker to the alternate weapon mode if cavalry is approaching and the alternate weapon is flaged as a polearm. Otherwise they only stare at themselves from a safe distance, they behave like ranged troops. I haven't figured out yet how to influencing that otherwise than changing the itp_type.
  3. To ensure that a troop has this weapon equiped, the troop needs to have the flag tf_guarantee_ranged. This does also mean that this troop will be set to the ranged class if you aren't setting them manually! Without the flag there is only a random chance that the troops equips this weapon, so you could give the troop the regular axe as well (which would give some variety at the battlefield with not everyone carrying the axe in the left hand) but then it could happen that a troop is equiped with both. Although, the less items a troop has in his inventory, the higher the chance that he picks that axe.
That's it. Nothing big, nothing fancy, but for not-experienced scripters easy to implement. If you want to implement such carry animation at non-combat situations, it's easier to give the guards or walkers some simple new items with a repositioned mesh and the itp_force_attach_left_hand.
 
Top Bottom