Spell dealing more damage than it's supposed to do?

Immolation

Member
Reaction score
20
JASS:
scope CurseOfChar initializer Initialization
//-------------------------------------------------------------
//                        Curse of Char               
//-------------------------------------------------------------

// Description:
//---------------------------
//Curse the target enemy, dealing damage over time. The longer the enemy unit remains cursed, the faster it will receive damage.
//Cursing again an already cursed enemy renews the duration. Also reduces cursed enemies attack speed and movement speed.


//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//                             LIST OF CONFIGURABLES
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    globals
        //ID settings:
        private constant integer SPELL_ID = 'A000' //ID of the "Curse of Char" ability.
        private constant integer DUMMY_SPELL_ID = 'A002' //ID of the "Curse of Char(Buff)" ability.
        private constant integer DUMMY_UNIT_ID = 'n000' //ID of the "Dummy Unit".
        private constant integer DUMMY_BUFF_ID = 'B000' //ID of the "Curse of Char" buff.
        
        //Dummy unit/rawcode settings:
        private constant real DUMMY_DURATION = 3.00 //Duration of dummy unit.
        private constant string DUMMY_SPELL_RAWCODE = "cripple" //Rawcode of the "Curse of Char(Buff)" ability.
        
        //Time/Ticks settings:
        private constant real TIME_DECREASE_INTERVAL = 0.15 //Amount of time that is removed at every tick of the spell.
        private constant real TIME_START = 3 //Amount of time at the start.
        private constant real TIME_MINIMUM = 1 //Minimum amount of time between each tick.

        //Damage/Attack Type settings:
        private constant boolean ATTACK = true
        private constant boolean RANGED = false 
        private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
        private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
        private constant weapontype WEAPON_TYPE = null
        
        //Special effect settings:
        private constant string SFX_MODEL = "Environment\\LargeBuildingFire\\LargeBuildingFire1.mdl"

    endglobals
    
    //Damage settings:
    private constant function DamageBase takes integer Level returns real
        return (3.00 + (7.00 * Level))
    endfunction
    
    private constant function DamageIntelligence takes integer Level returns real
        return (0.3 + (0.5 * Level))
    endfunction
    
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A000'
    endfunction

    private function Actions takes nothing returns nothing
        local unit TriggeringUnit = GetTriggerUnit()
        local unit TargetUnit = GetSpellTargetUnit()
        local player OwnerTriggeringUnit = GetOwningPlayer(TriggeringUnit)
        local real x = GetUnitX(TriggeringUnit)
        local real y = GetUnitY(TriggeringUnit)
        local integer Intelligence = GetHeroInt(TriggeringUnit, true)
        local integer Level = GetUnitAbilityLevel(TriggeringUnit, SPELL_ID)
        local integer TimeInterval
        local unit DummyUnit = CreateUnit(OwnerTriggeringUnit, DUMMY_UNIT_ID, x, y, 0)
        local real TimeToWait
        call UnitApplyTimedLife(DummyUnit, 'BTLF', DUMMY_DURATION)
        call UnitAddAbility(DummyUnit, DUMMY_SPELL_ID)
        call SetUnitAbilityLevel(DummyUnit, DUMMY_SPELL_ID, Level)
        call IssueTargetOrder(DummyUnit, DUMMY_SPELL_RAWCODE, TargetUnit)
        if GetUnitAbilityLevel(TargetUnit, DUMMY_BUFF_ID) > 0 == false then
                set TimeInterval = 1
                call TriggerSleepAction(0.1)
                loop
                    exitwhen GetUnitAbilityLevel(TargetUnit, DUMMY_BUFF_ID) > 0 == false
                        call UnitDamageTarget(TriggeringUnit, TargetUnit, (DamageBase + (DamageIntelligence * Intelligence)), ATTACK, RANGED, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
                        call DestroyEffect(AddSpecialEffectTarget(SFX_MODEL, TargetUnit, "origin"))
                        call DestroyEffect(AddSpecialEffectTarget(SFX_MODEL, TargetUnit, "chest"))
                        call DestroyEffect(AddSpecialEffectTarget(SFX_MODEL, TargetUnit, "head"))
                        call DestroyEffect(AddSpecialEffectTarget(SFX_MODEL, TargetUnit, "hand, left"))
                        call DestroyEffect(AddSpecialEffectTarget(SFX_MODEL, TargetUnit, "hand, right"))
                        set TimeToWait = TIME_START - (TIME_DECREASE_INTERVAL * I2R(TimeInterval))
                        if TimeToWait <= TIME_MINIMUM then 
                            set TimeToWait = TIME_MINIMUM
                        endif
                        call TriggerSleepAction(TimeToWait)
                        set TimeInterval = TimeInterval + 1
                endloop
        endif
        set TimeInterval = 1
        set TriggeringUnit = null
        set TargetUnit = null
        set DummyUnit = null
    endfunction

//========================================================================================================
    private function Initialization takes nothing returns nothing
        local trigger Trigger = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(Trigger, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition(Trigger, Condition(function Conditions))
        call TriggerAddAction(Trigger, function Actions)
    endfunction
endscope


Curse the target enemy, dealing damage over time. The longer the enemy unit remains cursed, the faster it will receive damage.
Cursing again an already cursed enemy renews the duration. Also reduces cursed enemies attack speed and movement speed.

The spell works perfectly, but it deals an insane amount of damage:

It should 10 damage plus 0.08 for each point of Intelligence at level 1.

But it deals around 31-35 damage, even to heroes!

Help, please :(
 

_whelp

New Member
Reaction score
54
Stupid TSA's!
You also used UnitDamageTarget three times, because of the loop.
 

Immolation

Member
Reaction score
20
Mmm, care to explain what TSAs are, and if you read the code carefully, I don't run the loop three times, since the effects are fine(tested with only 1 effect, and it would create only one)
 

_whelp

New Member
Reaction score
54
TSA is TriggerSleepAction, I just took the term from some people who said it...

See what happens when you take out UnitDamageTarget from the loop and put it above.
 

Immolation

Member
Reaction score
20
Putting the UnitDamageTarget above won't change a thing, and that would ruin the spell. Gameplay Constants are default.

Any other ideas?

EDIT: I know I can fix this by dividing the damage by 3, but it smells fishy and I want to know the truth :O
 

Immolation

Member
Reaction score
20
Base Damage at level 1: 10.
Damage per Point of Intelligence at level 1: 0.08.

DamageBase(10)+(DamageIntelligence(0.08) x Intelligence)


Note that DamageIntelligence isn't already multiplied.
...

And please, if you don't know what you're saying, don't post.
 

Builder Bob

Live free or don't
Reaction score
249
JASS:
call UnitDamageTarget(TriggeringUnit, TargetUnit, (DamageBase + (DamageIntelligence * Intelligence)), ATTACK, RANGED, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)

How does that even compile?

There are no variables called DamageBase or DamageIntelligence in that trigger, only functions.

Using the functions would look like this:
JASS:
call UnitDamageTarget(TriggeringUnit, TargetUnit, (DamageBase(Level) + (DamageIntelligence(Level) * Intelligence)), ATTACK, RANGED, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)


If this won't help solve your problem, then please use BJDebugMsg() and tell us what the following values report:

  • DamageBase(Level)
  • DamageIntelligence(Level)
  • Intelligence

Also, it could help to know what armor type you are testing against, and if you have changed any of the damage type gameplay constants in your map.
 

Immolation

Member
Reaction score
20
Thanks, it works now ;)

*Offtopic: Builder Bob, are you still working on Dungeon Crawler? That map rocks, don't abandon it please :D*
 

Builder Bob

Live free or don't
Reaction score
249
Thanks, it works now ;)
Great :)

*Offtopic: Builder Bob, are you still working on Dungeon Crawler? That map rocks, don't abandon it please :D*
If I am, it's not in an efficient manner. I'm working on something. What it is, and where it is going, not even I know. It's something of a branch of what I put into Dungeon Crawler. I am sorry to disappoint you...
 
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