|
Post by shadex on Jan 7, 2017 8:50:36 GMT
Some people asked if i would share how i got Duel Wield to work. So despite being the worst coder in existence, this is my contribution to the community. For those that want to be able to duel wield and have duel wield attack animations in their game. This is a simple edit on a single file, and shouldn't cause any problems. It should work with any non defense only weapon
What it does When you exit out of the equip screen it sets the AttackID of the right hand weapon that is equipped. This simply checks if there is a weapon in both the right hand and left hand, it's not a defense only weapon (shields!) and if there is, it adds 100 to the right hands attack ID. This effectively gives a new attack ID for duel wielding. So lets say you have assigned swords as attackID 1, maces as attackID 2 and Axes as attackID 3. When you equip an axe (attackID 3) and any weapon in the off hand it adds 100 making the attackID making it 103. So all you have to do is duplicate a combo set for weak and strong attacks, add the transitions and the condition to the combo set attackID equals 103 and assign it duel wield animations and do the same for swords (101) and Maces (102) and your done. You can now duel wield axes, maces and swords.
Code: In Melee Manager line: 195 | Function GetAttackID()
public virtual int GetAttackID() { // Activate Duel Wield if (leftWeapon != null && rightWeapon != null && rightWeapon.meleeType != vMeleeType.OnlyDefense && leftWeapon.meleeType != vMeleeType.OnlyDefense && leftWeapon.gameObject.activeSelf) { // Debug.Log("Activate Duel Wield"); return rightWeapon.attackID + 100; } // Activate One Handed if (rightWeapon != null && rightWeapon.meleeType != vMeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID; }
return 0; }
A simple trick to get this to work with the default animations is to select the box that contains the animation in the animator and click "Mirror". This will mirror the entire animation, meaning if your character is swinging from the right hand it will now be the left hand. Just make sure on the V Meele Attack Control Script that you assign the correct body parts.
Hopefully i explained it well enough, if not let me know, i will clarify. If i ever get two hand to prevent off hands from equipping while holding a two handed weapon I'll add it to this.
|
|
|
Post by uberwiggett on Jan 7, 2017 11:30:51 GMT
SO this script detects an off hand weapon and assigns the player the new attack ID number, much better than having to create items that are dual wielded, VERY GOOD!
|
|
|
Post by jrackley on Jan 7, 2017 12:49:57 GMT
Sweet! Can't wait to try this when I wake up(been up all night),lol! Thanks for sharing shadex.
|
|
|
Post by shadex on Jan 7, 2017 21:48:14 GMT
SO this script detects an off hand weapon and assigns the player the new attack ID number, much better than having to create items that are dual wielded, VERY GOOD! That was the idea. You can change if you want the offhand dictating the attack ID or the primary by changing return rightWeapon.attackID + 100 to leftWeapon.attackID. I'm not a huge fan of designing duel wield as specific weapons, it destroys a lot of depth in the weapon combo's you can find. It's one of the things i really hated about the Dark Souls series. Offhand weapons were limited to parry and nearly useless attacks, which made duel wielding kinda not viable.
|
|
|
Post by Tanzanite Games on Feb 26, 2017 11:12:50 GMT
Wow, very nice. This has also helped me creating 2 handed weapons. Thank you!
|
|
|
Post by Tanzanite Games on Mar 3, 2017 22:20:10 GMT
For anyone who wants the two handed script:
Implement them in the same way as the dual-wielding
public virtual int GetAttackID() { // Activate Duel Wield if (leftWeapon != null && rightWeapon != null && rightWeapon.meleeType != MeleeType.OnlyDefense && leftWeapon.meleeType != MeleeType.OnlyDefense && leftWeapon.gameObject.activeSelf) { // Debug.Log("Activate Duel Wield"); return rightWeapon.attackID + 1000; } // Two Handed if (rightWeapon != null && leftWeapon == null && rightWeapon.meleeType != MeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf && rightWeapon.TwoHanded == true) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID + 2000; } // Activate One Handed if (rightWeapon != null && rightWeapon.meleeType != MeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID; }
return 0; } In the VMeleeWeapon add a simple bool called TwoHanded, It has to be public, or editable in the editor, it does not have to be used anywhere else.
- Joeri
|
|
|
Post by chocolatka on Mar 4, 2017 21:53:31 GMT
For anyone who wants the two handed script: Implement them in the same way as the dual-wieldingpublic virtual int GetAttackID() { // Activate Duel Wield if (leftWeapon != null && rightWeapon != null && rightWeapon.meleeType != MeleeType.OnlyDefense && leftWeapon.meleeType != MeleeType.OnlyDefense && leftWeapon.gameObject.activeSelf) { // Debug.Log("Activate Duel Wield"); return rightWeapon.attackID + 1000; } // Two Handed if (rightWeapon != null && leftWeapon == null && rightWeapon.meleeType != MeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf && rightWeapon.TwoHanded == true) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID + 2000; } // Activate One Handed if (rightWeapon != null && rightWeapon.meleeType != MeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID; }
return 0; } In the VMeleeWeapon add a simple bool called TwoHanded, It has to be public, or editable in the editor, it does not have to be used anywhere else. - Joeri You can make a video with examples ?? just wondering how it looks
|
|
|
Post by Tanzanite Games on Mar 13, 2017 13:36:51 GMT
For anyone who wants the two handed script: Implement them in the same way as the dual-wieldingpublic virtual int GetAttackID() { // Activate Duel Wield if (leftWeapon != null && rightWeapon != null && rightWeapon.meleeType != MeleeType.OnlyDefense && leftWeapon.meleeType != MeleeType.OnlyDefense && leftWeapon.gameObject.activeSelf) { // Debug.Log("Activate Duel Wield"); return rightWeapon.attackID + 1000; } // Two Handed if (rightWeapon != null && leftWeapon == null && rightWeapon.meleeType != MeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf && rightWeapon.TwoHanded == true) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID + 2000; } // Activate One Handed if (rightWeapon != null && rightWeapon.meleeType != MeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID; }
return 0; } In the VMeleeWeapon add a simple bool called TwoHanded, It has to be public, or editable in the editor, it does not have to be used anywhere else. - Joeri You can make a video with examples ?? just wondering how it looks I don’t have any animations for it yet, so you’d have to get your own 2 handed animations.
|
|
|
Post by g00loum on Dec 30, 2019 10:14:37 GMT
Hello, your script works perfectly but I would like to integrate my own dual wielding animations. Can you explain how we do it in stages please. Thank
|
|
|
Post by hobbycoder on Feb 7, 2020 2:13:11 GMT
@g00luom, what you can do is to copy one of the anim state inside the weak or strong attack, replace A,B,C animations with ur own dual then change the attack id +100 of ur right weapon, lets say ur right hand weapon has an attack id of 12, so ur dual would be 112..example below
|
|
|
Post by kingceryn on Oct 5, 2020 8:13:35 GMT
Hey all! So I have this working, with a small problem- it does mirror and do the attacks on the Left hand properly, however it seems to only register the FIRST weapon equipped- i.e. if I equip a sword, or a spell in my left OR right hand, thats the "main attack" that gets used, and the SECONDARY attack on the opposite hand is always "Unarmed," or Attack ID 0/100.
So basically no matter what weapons I equip in which hand, only the attacks from the first weapon that is equipped gets used, and the other is Unarmed- even if another weapon is equipped in that hand.
Anyone else getting this?
|
|
eldv
Junior vMember
Posts: 47
|
Post by eldv on Oct 13, 2022 16:49:19 GMT
For anyone who wants the two handed script: Implement them in the same way as the dual-wieldingpublic virtual int GetAttackID() { // Activate Duel Wield if (leftWeapon != null && rightWeapon != null && rightWeapon.meleeType != MeleeType.OnlyDefense && leftWeapon.meleeType != MeleeType.OnlyDefense && leftWeapon.gameObject.activeSelf) { // Debug.Log("Activate Duel Wield"); return rightWeapon.attackID + 1000; } // Two Handed if (rightWeapon != null && leftWeapon == null && rightWeapon.meleeType != MeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf && rightWeapon.TwoHanded == true) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID + 2000; } // Activate One Handed if (rightWeapon != null && rightWeapon.meleeType != MeleeType.OnlyDefense && rightWeapon.gameObject.activeSelf) { // Debug.Log("Activate One Handed"); return rightWeapon.attackID; }
return 0; } In the VMeleeWeapon add a simple bool called TwoHanded, It has to be public, or editable in the editor, it does not have to be used anywhere else. - Joeri Just an update for this code: change the capitalized MeleeType to vMeleeType in the code to make the code compatible with the current Invector TPC. ie "MeleeType.OnlyDefense" should now be "vMeleeType.OnlyDefense".
|
|