• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Bonus dmg vs unit group

Status
Not open for further replies.
Level 3
Joined
Jul 27, 2010
Messages
35
Hello! im working on my map, its kinda like age of empire with units. my question is, how do i make for example: a Pikeman are stronger vs Knight and a Spear thrower to be strong against archers.

I tried to change unit damage type but then it will effect more units like footman (heavy armor) which is supposed to counter pikemans.

To be 100% clear what i want to achieve here:

Pikemans beats knights.
Footman beats pikeman.
Knight beats footman.
Spear thrower beats archer.

problem : footmans and knight both use heavy armor.

can i make this with a trigger or a passive ability ,that makes a unit stronger vs another unit?



Help me out here please!
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
There is a Unit takes damage along with event responses for damager, victim and amount dealt. Also Unit - Damage Target as action. Remember to turn off the trigger while dealing bonus damage in order to not recursively fire the trigger again. And remember that other Unit takes damage events now run twice/still have the prior amount of damage taken.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
You could always use this
http://www.hiveworkshop.com/forums/submissions-414/system-damage-modification-effect-213608/

It allows you to create custom damage/armor types really easily =). You could even give a unit multiple weapons for multiple attacks ;o.

This resource allows you to use the above in a much better fashion
http://www.hiveworkshop.com/forums/submissions-414/system-damage-queue-213752/

The thread also contains some really awesome examples
JASS:
library HandDamageCreator uses DamageQueue, DamageSourceTypes, DamageSourceInstance
    struct HandDamageCreator extends array
        readonly DamageSource leftHand
        readonly DamageSource rightHand
        
        readonly thistype leftHandModifier
        readonly thistype rightHandModifier
        
        readonly DamageSource source
        
        private static method PRIORITY takes nothing returns integer
            return DAMAGE_PRIORITY_CREATOR
        endmethod

        private method onDamageOutgoing takes nothing returns nothing
            if (DamageSource(damageId).type == DamageSourceTypes.NULL) then
                call DamageQueue.add(sourceId, targetId, amount/2, DamageTypes.PHYSICAL, source, DamageSourceInstance.create(targetId, source))
            endif
        endmethod

        implement DamageModificationEffect
        
        private method index takes nothing returns nothing
            set leftHand = DamageSource.create(DamageSourceTypes.HANDS)
            set rightHand = DamageSource.create(DamageSourceTypes.HANDS)
            
            set leftHandModifier = apply(false)
            set leftHandModifier.source = leftHand
            
            set rightHandModifier = apply(false)
            set rightHandModifier.source = rightHand
        endmethod
        
        private method deindex takes nothing returns nothing
            call leftHand.destroy()
            call rightHand.destroy()
        endmethod
        
        implement UnitIndexStruct
    endstruct
endlibrary

Instead of thinking of Damage resulting from attacks, it thinks of modifiers and creators. You have damage sources, which would be your weapons, and then you have modifiers on them, which create or modify damage ^_-.

Keep in mind that using DamageQueue will disable regular wc3 damage.
 
Level 3
Joined
Jul 27, 2010
Messages
35
Hello and thank you for answering!

i solved my problem by rebalance armor type and attack type:


spearman damage type = magic Defense type = light
knight damage type = normal Defense type = heavy
footman damage type = normal Defense type = medium
archer damage type = pierce Defense type = medium
spearthrower damage type = normal Defense type = medium



spearman wins against knight
knight wins against archer, spearthrower och footman
footman wins against spearman
spearthrower wins against footman and archer
archer wins against spearman
 
Status
Not open for further replies.
Top