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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top