Decreasing attack damage upon attack

bananaHUNT

You can change this now in User CP
Reaction score
55
I have an Item "Palin's Axe" that decreases the attacked Hero's damage with 15 every hit for 6 seconds. I have this, but sometimes it works, and sometimes very wierd.
Code:
Hero Damage
    Events
        Unit - A unit Is attacked
    Conditions
        And - All (Conditions) are true
            Conditions
                ((Attacked unit) is A Hero) Equal to True
                ((Attacking unit) has an item of type Palin's Axe) Equal to True
                (Random integer number between 1 and 100) Less than or equal to 25
    Actions
        Set Palin_Hero = (Attacked unit)
        Unit - Add Palin's Axe (-15) to Palin_Hero
        Wait 6.00 seconds
        Unit - Remove Palin's Axe (-15) from Palin_Hero
When i try it with more than 1 item it starts acting wierd,,

edit; this might help (i know chances are random, but for easy understanding it's once every 4 attacks):
palinum1.png
 

Faust

You can change this now in User CP.
Reaction score
123
Your hero attacks it with the good chance again before the wait could be over, so it restarts the trigger.
 

Drunken_God

Hopes to get back into Mapmaking with SC2 :)
Reaction score
106
i dont think this would stack that way
maybe use an dummy unit which casts a spell on your hero that gives a buff and lasts 6 seconds
with another trigger check for units with that buff and reduce their damage

PS: nice icon
 
S

Sausage

Guest
Code:
Hero Damage
    Events
        Unit - A unit Is attacked
    Conditions
        And - All (Conditions) are true
            Conditions
                ((Attacked unit) is A Hero) Equal to True
                ((Attacking unit) has an item of type Palin's Axe) Equal to True
                (Random integer number between 1 and 100) Less than or equal to 25
    Actions
        Set Palin_Hero = (Attacked unit)
        [B]Trigger - Turn off this trigger[/B]
        Unit - Add Palin's Axe (-15) to Palin_Hero
        Wait 6.00 seconds
        [B]Trigger - Turn on this trigger[/B]
        Unit - Remove Palin's Axe (-15) from Palin_Hero

Just my guess :p
 

Faust

You can change this now in User CP.
Reaction score
123
Code:
Hero Damage
    Events
        Unit - A unit Is attacked
    Conditions
        And - All (Conditions) are true
            Conditions
                ((Attacked unit) is A Hero) Equal to True
                ((Attacking unit) has an item of type Palin's Axe) Equal to True
                (Random integer number between 1 and 100) Less than or equal to 25
    Actions
        Set Palin_Hero = (Attacked unit)
        [B]Trigger - Turn off this trigger[/B]
        Unit - Add Palin's Axe (-15) to Palin_Hero
        Wait 6.00 seconds
        [B]Trigger - Turn on this trigger[/B]
        Unit - Remove Palin's Axe (-15) from Palin_Hero

Just my guess :p
It will never have -30 then :\
 

Faust

You can change this now in User CP.
Reaction score
123
I got a strange idea but it should work.
Create a dummy unit, and create it on the map anywhere when the lucky hit happens. Give it 6 seconds expiration timer. Give it to a custom UnitGroup variable

Another trigger checks every second how many of those units are alive, and then calculate to level the ability given to the hero, or just remove it and add it (I think it should stack that way)
Don't forget to remove those dummies when they die
2-3 triggers :)
 

bananaHUNT

You can change this now in User CP
Reaction score
55
Thanks, i now have:
Code:
Hero Damage
    Events
        Unit - A unit Is attacked
    Conditions
        And - All (Conditions) are true
            Conditions
                ((Attacked unit) is A Hero) Equal to True
                ((Attacking unit) has an item of type Palin's Axe) Equal to True
                (Random integer number between 1 and 100) Less than or equal to 25
    Actions
        Unit - Create 1 Dummy for Player 1 (Red) at (Position of (Attacked unit)) facing Default building facing degrees
        Unit - Order (Last created unit) to Human Priest - Inner Fire (Attacked unit)

Code:
Palin Buff Detection
    Events
        Time - Every 0.10 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                ((Picked unit) is A Hero) Equal to True
                                ((Picked unit) has buff Unknown (BHfs)) Equal to True
                    Then - Actions
                        Unit - Add Palin's Axe (-15) to (Picked unit)
                    Else - Actions
                        Unit - Remove Palin's Axe (-15) from (Picked unit)
But it doesn't stack; i'm using Item Attack Bonus (-15) as ability.
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Shall it work like this:
Hero 1: Attacker with your Axe
Hero 2: Attacked Unit [with base damage of 100]

Hero 1 attacks.... Hero2 loses 15 damage ... 85left.

3 Secs later
Hero 1 attacks again. Hero2 loses 15 further damage... 70left.

3Secs later

6 seconds after the first attack are over...he regains 15 damage, 85 now.

3Secs later

6 seconds passed after the second attack, Hero 2 regains 15 damage again and is restored. 100.

If you want it like this I could easily create a trigger in JASS for you... doing this in GUI will barely work.

Edit:
Yours wouldn't work properly... that way the hero loses 150damage a second :eek:
 

bananaHUNT

You can change this now in User CP
Reaction score
55
Shall it work like this:
Hero 1: Attacker with your Axe
Hero 2: Attacked Unit [with base damage of 100]

Hero 1 attacks.... Hero2 loses 15 damage ... 85left.

3 Secs later
Hero 1 attacks again. Hero2 loses 15 further damage... 70left.

3Secs later

6 seconds after the first attack are over...he regains 15 damage, 85 now.

3Secs later

6 seconds passed after the second attack, Hero 2 regains 15 damage again and is restored. 100.

If you want it like this I could easily create a trigger in JASS for you... doing this in GUI will barely work.

Edit:
Yours wouldn't work properly... that way the hero loses 150damage a second :eek:

Yeah this is exactly what i want! :D But with a maximum of 4 stacks (so max is -60 damage, though only very high attack speed would get this).
If you could make this for me big thanks :D
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
// Edited everything...

So... create a new Trigger and convert it to custom text. Replace the script with the one below. You need a item (your axe) and a item ability which is based of item damage. Give it 5levels. 1 - 0 damage 2 - 15 damage 3 - 30 damage 4 - 45 damage 5 - 60 damage. Then look at the green text I wrote in the script and it should work fine. I made it so, that the effect appears almost on hit and not on start attack and denies abusing it.


JASS:
function Conditions takes nothing returns boolean
    return UnitHasItemOfTypeBJ(GetAttacker(),'hval') == true and IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true // exchange 'hval' with the Raw Id of your item --- don't forget the "  '  ' " though
endfunction

function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
if GetUnitAbilityLevel(u,'A000') == 0 then     // exchange 'A000' with the Raw Id of your item - damage ability
    call UnitAddAbility(u,'A000')
endif
    call DisableTrigger(GetTriggeringTrigger())  // This is against abusing it 
    call TriggerSleepAction(0.4)                    //  and to make the effect appear
    call EnableTrigger(GetTriggeringTrigger())   //  on HIT and not on ATTACK start
    call SetUnitAbilityLevel(u,'A000',GetUnitAbilityLevel(u,'A000') + 1)
    call TriggerSleepAction(6) // change the value that gives the time after which the damage is restored
    call SetUnitAbilityLevel(u,'A000',GetUnitAbilityLevel(u,'A000') - 1)
endfunction

//===========================================================================
function InitTrig_Palins_Axe takes nothing returns nothing
    set gg_trg_Palins_Axe = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Palins_Axe,EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_Palins_Axe, Condition(function Conditions))
    call TriggerAddAction( gg_trg_Palins_Axe, function Actions )
endfunction
 

bananaHUNT

You can change this now in User CP
Reaction score
55
Thank you so much! :D +rep
EDIT: Uhm it gives an error:
The trigger "blabla" must have an initialization function called "InitTrig_blabla"
Then i get a box full with errors and it closes down..?

i put in the right raw ID codes i think..
 

bananaHUNT

You can change this now in User CP
Reaction score
55
Cool thanks :D But i noticed something else with the spell.. It fires every attack, not 25% chance, how would i change this?
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Oh sorry missed that part. You didn't mentioned that aside of your trigger where it was involved.. hence I forgot it^^.

Add the two lines at the places I put them. The "// add this line" lines^^.

JASS:
function Conditions takes nothing returns boolean
    return UnitHasItemOfTypeBJ(GetAttacker(),'hval') == true and IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true // exchange 'hval' with the Raw Id of your item --- don't forget the "  '  ' " though
endfunction

function Actions takes nothing returns nothing
local unit u = GetTriggerUnit() 

if GetRandomInt(1,100) <= 25 then   //add this line

    if GetUnitAbilityLevel(u,'A000') == 0 then     // exchange 'A000' with the Raw Id of your item - damage ability
        call UnitAddAbility(u,'A000')
    endif
    
    call DisableTrigger(GetTriggeringTrigger())  // This is against abusing it 
    call TriggerSleepAction(0.4)                    //  and to make the effect appear
    call EnableTrigger(GetTriggeringTrigger())   //  on HIT and not on ATTACK start
    call SetUnitAbilityLevel(u,'A000',GetUnitAbilityLevel(u,'A000') + 1)
    call TriggerSleepAction(6) // change the value that gives the time after which the damage is restored
    call SetUnitAbilityLevel(u,'A000',GetUnitAbilityLevel(u,'A000') - 1)

endif    //add this line

endfunction

//===========================================================================
function InitTrig_Palins_Axe takes nothing returns nothing
    set gg_trg_Palins_Axe = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Palins_Axe,EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_Palins_Axe, Condition(function Conditions))
    call TriggerAddAction( gg_trg_Palins_Axe, function Actions )
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top