Warcraft III resources & community, 2003–2006 · archived

new to JASS, need help

8 posts
#1

new to JASS, need help

This is my first atempt to a JASS spell. But the problem is that it doesnt do any damage, why?

function GlavieTossCond takes nothing returns boolean
  if ( not ( GetSpellAbilityId() == 'A01M' ) ) then
        return false
    endif
    return true
endfunction 

function GlavieToss takes nothing returns nothing

local unit glavietoss_targ = GetSpellTargetUnit ()
local unit glavietoss_cast = GetTriggerUnit ()
local integer glavietoss_dmg = GetHeroAgi(glavietoss_cast,true)* (1 + (0.4 * GetUnitAbilityLevel (glavietoss_cast,'A01M')))

UnitDamageTarget( glavietoss_cast,glavietoss_targ,glavietoss_dmg,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED,null)

set glavietoss_targ = null    
set glavietoss_cast = null

endfunction

function InitTrig_glavietoss takes nothing returns nothing  
set gg_trg_GLavieToss = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_GLavieToss, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_GLavieToss, Condition(function GlavieTossCond))
call TriggerAddAction(gg_trg_GLavieToss, function GlavieToss) 
endfunction
#2
you have to type 'call' before a function:

call UnitDamageTarget()


you forgot it...
but also i don't know but maybe the WEAPON_TYPE_WHONKOWS is required here, like:
call UnitDamageTarget(glavietoss_cast,glavietoss_targ,glavietoss_dmg,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED,WEAPON_TYPE_WHONKOWS)


just a hint:
you don't need those long variable names, you can use the same variable names in different functions. so you can use a simple 'trg' instead of 'glavietoss_targ'. you know what i mean...

ah and also, these are the same, but the second is much simpler:
function GlavieTossCond takes nothing returns boolean 
if ( not ( GetSpellAbilityId() == 'A01M' ) ) then 
return false 
endif 
return true 
endfunction

function GlavieTossCond takes nothing returns boolean 
return GetSpellAbilityId() == 'A01M'
endfunction


If you have more conditions, use an 'and' between them. F. ex:
function GlavieTossCond takes nothing returns boolean 
return GetSpellAbilityId() == 'A01M' and GetSpellAbilityLevel() == 1
endfunction

see...
#3
Thank you very much, going to change it and se if it works :D
#4
Still doesn`t work. Here`s the code:

function GlavieTossCond takes nothing returns boolean
return GetSpellAbilityId() == 'A01M' 
endfunction

function GlavieToss takes nothing returns nothing

local unit glavietoss_targ = GetSpellTargetUnit ()
local unit glavietoss_cast = GetTriggerUnit ()
local integer glavietoss_dmg = GetHeroAgi(glavietoss_cast,true) * (1 + (0.4 * GetUnitAbilityLevel (glavietoss_cast,'A01M')))

call UnitDamageTarget ( glavietoss_cast,glavietoss_targ,glavietoss_dmg,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED,WEAPON_TYPE_WHONKOWS)

set glavietoss_targ = null    
set glavietoss_cast = null

endfunction

function InitTrig_glavietoss takes nothing returns nothing  
set gg_trg_GlavieToss = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_GlavieToss, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_GlavieToss, Condition(function GlavieTossCond))
call TriggerAddAction(gg_trg_GlavieToss, function GlavieToss) 
endfunction
#5
I have looked through your code.

you had several typos, but no true errors.

1. you wrote "WEAPON_TYPE_WHONKOWS" instead of "WEAPON_TYPE_WHOKNOWS"
2. you mistyped the triggername at least once - you wrote "GlavieToss" as well as "glavietoss" - warcraft III-Jass is casesensitiv
3. you used an integer for the damage. damage is a real.

here the corrected code (it compiles - haven't checked, wether it works)


function GlavieTossCond takes nothing returns boolean
  return ( GetSpellAbilityId() == 'A01M' )
endfunction

function GlavieToss takes nothing returns nothing
  local unit glavietoss_targ = GetSpellTargetUnit()
  local unit glavietoss_cast = GetTriggerUnit()
  local real glavietoss_dmg = GetHeroAgi(glavietoss_cast,true) * (1 + (0.4 * GetUnitAbilityLevel(glavietoss_cast,'A01M')))

  call UnitDamageTarget( glavietoss_cast, glavietoss_targ, glavietoss_dmg, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)

  set glavietoss_targ = null
  set glavietoss_cast = null
endfunction

//===========================================================================
function InitTrig_glavietoss takes nothing returns nothing
  set gg_trg_glavietoss = CreateTrigger(  )
  call TriggerRegisterAnyUnitEventBJ( gg_trg_glavietoss, EVENT_PLAYER_UNIT_SPELL_EFFECT)
  call TriggerAddCondition(gg_trg_glavietoss, Condition(function GlavieTossCond))
  call TriggerAddAction(gg_trg_glavietoss, function GlavieToss)
endfunction
#6
here the corrected code (it compiles - haven't checked, wether it works)


maybe try this?

function GlavieTossCond takes nothing returns boolean
return GetSpellAbilityId() == 'A01M'
endfunction

function GlavieToss takes nothing returns nothing
local unit glavietoss_cast = GetTriggerUnit()
call UnitDamageTarget( glaivetoss_cast, GetSpellTargetUnit(), GetHeroAgi(glavietoss_cast,true) * (1 + 0.4 * GetUnitAbilityLevel(glavietoss_cast,'A01M')), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_ENHANCED, null)
set glavietoss_cast = null
endfunction

//===========================================================================
function InitTrig_glavietoss takes nothing returns nothing
set gg_trg_glavietoss = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_glavietoss, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_glavietoss, Condition(function GlavieTossCond))
call TriggerAddAction(gg_trg_glavietoss, function GlavieToss)
endfunction


EDIT: optimized a bit
#7
It works now :)
Thank you very much Lord Raszul and PurpelPoot.

Now Im going to see if i can make a chain spell out of it ^^

And btw, why should damage be real and not an integer?
#8
so you can do decimal numbers, for example if you want to do .1 damage every 0.01 seconds, thus doing 10 damage a second, though doing it smoothly instead of choppily.