• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Spell not dealing damage

Status
Not open for further replies.
Level 4
Joined
Apr 7, 2012
Messages
63
I wrote this spell which is supposed to deal physical power * 0.75, I also wrote a script that shows how much my physical power is and it indicates that it is 12 in game, but when I use the spell chop it doesn't do anything Im sure of my globals, If i say + it does damage.
JASS:
scope Chop initializer Init
globals
      private constant integer CHOP_VILLAGER = 'A000'
      private constant string CHOP_EFFECT = "Abilities\\Weapons\\GlaiveMissile\\GlaiveMissileTarget.mdl"
endglobals

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

private function Actions takes nothing returns nothing
    local unit hero
    local unit target
    local integer lvl            
    local real damage
    local integer pid
    local player owner
    
    set hero = GetTriggerUnit()
    set owner = GetOwningPlayer(hero) 
    set pid = GetPlayerId(owner)
    set target = GetSpellTargetUnit()
    set lvl = GetUnitAbilityLevel(hero,CHOP_VILLAGER)
    set damage = udg_StatsPhysicalPower[pid]* 0.75     

    call  UnitDamageTarget(hero,target,damage,ATTACK_TYPE_NORMAL,true,false) 
    call DestroyEffect(AddSpecialEffectTarget(CHOP_EFFECT,target,"origin") ) 
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger ChopTrg = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( ChopTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( ChopTrg, Condition( function Chop_Conditions ) )
    call TriggerAddAction( ChopTrg, function Actions )
    call Preload(CHOP_EFFECT)
endfunction
endscope

Would appreciate any help!
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
call UnitDamageTarget(hero,target,damage,ATTACK_TYPE_NORMAL,true,false)
This would throw in an error, wouldn't it?

It should be call UnitDamageTarget(hero, target, damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)

Also, you can set variables when initializing them:
JASS:
local unit hero = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
local player owner = GetOwningPlayer(hero) 
local integer pid = GetPlayerId(owner)
local integer lvl = GetUnitAbilityLevel(hero,CHOP_VILLAGER)     
local real damage = udg_StatsPhysicalPower[pid]* 0.75
And when all is said and done, don't forget to null the handles at the end!
 
Level 4
Joined
Apr 7, 2012
Messages
63
Note that GetTriggerPlayer returns the owner of triggering unit in unit events, so owner could refer to the "triggering player".

I did not use triggering player? Oh sorry about that unitdamagetarget, i was using another command which requires less arguments.

And it is still not working when I null the handles and use the correct amount of arguments.
And also if possible, when my Villager uses Chop he just stands still but I want him to just make the usual attack animation but just dealing the chop damage. Do I set this in the object editor or is it done by triggers?
JASS:
scope Chop initializer Init
globals
      private constant integer CHOP_VILLAGER = 'A000'
      private constant string CHOP_EFFECT = "Abilities\\Weapons\\GlaiveMissile\\GlaiveMissileTarget.mdl"
endglobals

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

private function Actions takes nothing returns nothing

    local unit hero = GetTriggerUnit()
    local player owner = GetOwningPlayer(hero) 
    local integer pid = GetPlayerId(owner)
    local unit target = GetSpellTargetUnit()
    local integer lvl = GetUnitAbilityLevel(hero,CHOP_VILLAGER)
    local real damage = udg_StatsPhysicalPower[pid]* 0.75     

    call UnitDamageTarget(hero,target,damage,true,false,ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL,null)
    call DestroyEffect(AddSpecialEffectTarget(CHOP_EFFECT,target,"origin") )
    
    set hero = null
    set owner = null
    set pid = 0
    set target = null
    set lvl = 0
    set damage = 0
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger ChopTrg = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( ChopTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( ChopTrg, Condition( function Chop_Conditions ) )
    call TriggerAddAction( ChopTrg, function Actions )
    call Preload(CHOP_EFFECT)
endfunction
endscope
That's how it looks now.

I realised that when I set up the globals it was all integer arrays, now I changed it to real arrays but still not working. And I also do not know how to make that the bash buff hits the target, cause i put check dependencies to false, I removed the buff, but if I set the duration to 0 it lasts forever.
 
Last edited:
Level 16
Joined
Aug 7, 2009
Messages
1,406
I didn't say you USED GetTriggerPlayer, I said you SHOULD use it.

Yes, in the object editor, "Art - Animation", set this field to "Attack". You can't be specific, so you can't pass something like "Attack - 2", if the unit has multiple of the given animations, a random one will be played.
 
Level 4
Joined
Apr 7, 2012
Messages
63
Thanks for the anim tip, but i do not see how the triggering player will help since if i set the damage to statsphysicalpower + 15 it deals 15 damage.
:\ Dont know whats wrong.
 
Level 16
Joined
Aug 7, 2009
Messages
1,406
JASS:
local player owner = GetTriggerPlayer()

I just pointed out that it could be even this.

However, because the trigger is short, this would be more efficient:

JASS:
call UnitDamageTarget(GetTriggerUnit(),GetSpellTargetUnit(),udg_StatsPhysicalPower[GetPlayerId(GetTriggerPlayer())]* 0.75,true,false,ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL,null)
call DestroyEffect(AddSpecialEffectTarget(CHOP_EFFECT,GetSpellTargetUnit(),"origin"))

P.s: gosh, these JASS tags...
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Luorax is correct, but since I don't know if you're going to add more stuff to this spell or not, I left the variables intact (while they can easily get removed).
Map attached (not the best name, but yeah...). I just copy/pasted your code and tweaked it ever so slightly. It works for me.

(You do not need to null a player I believe, and reals/integers do not need to be set to 0 either).
 

Attachments

  • tyujik.w3x
    17.3 KB · Views: 33
Level 4
Joined
Apr 7, 2012
Messages
63
oh no, still not working for me for some reason, maybe this will help.

JASS:
scope SettingGlobals initializer Init

globals
     real array StatsBlockChance
     real array StatsEvadeChance
     real array StatsPhysicalPower
     real array StatsPhysicalCriticalPower
     real array StatsPhysicalCriticalChance
     real array StatsMentalPower
     real array StatsMentalCriticalPower
     real array StatsMentalCriticalChance
     real array Booleanstats
endglobals     

private function SettingGlobals_Conditions takes nothing returns boolean
    return ((IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) )  and GetUnitTypeId(GetTriggerUnit()) == 'H000'
endfunction

private function Actions takes nothing returns nothing
     local real int 
     local real str
     local real agi
     local unit hero
     local player owner
     local integer pid

      
      set hero = GetTriggerUnit()
      set owner = GetOwningPlayer(hero)
      set pid = GetPlayerId(owner) + 1
      set int = GetHeroInt(hero,true)
      set str = GetHeroStr(hero,true)           
      set agi = GetHeroAgi(hero,true)
      
      
      set udg_StatsPhysicalPower[pid] = (str*2.5) 
      set udg_StatsPhysicalCriticalChance[pid] = (agi*0.15) 
      set udg_StatsPhysicalCriticalPower[pid] = (agi*0.15) 
      set udg_StatsMentalPower[pid]= (int*2.5) 
      set udg_StatsMentalCriticalChance[pid] = (int*0.15) 
      set udg_StatsMentalCriticalPower[pid] = (int*0.15)  
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger SettingGlobalsTrg = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( SettingGlobalsTrg, EVENT_PLAYER_HERO_LEVEL )
    call TriggerRegisterEnterRectSimple( SettingGlobalsTrg, gg_rct_Evolution_Start_Place )
    call TriggerAddCondition( SettingGlobalsTrg, Condition( function SettingGlobals_Conditions ) )
    call TriggerAddAction( SettingGlobalsTrg, function Actions )
endfunction
endscope

Yeah the jass tag is a killer.
I just took away udg in the chop spell script aswel.
LOL guys i fixed it but thanks anyway i accidentally messed up with player id's and stuff but thanks!
 
Last edited:
Status
Not open for further replies.
Top