• 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.

[JASS] new to JASS, need help

Status
Not open for further replies.
Level 2
Joined
Oct 4, 2006
Messages
7
This is my first atempt to a JASS spell. But the problem is that it doesnt do any damage, why?

JASS:
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
 
Level 11
Joined
Jul 12, 2005
Messages
764
you have to type 'call' before a function:

JASS:
call UnitDamageTarget()

you forgot it...
but also i don't know but maybe the WEAPON_TYPE_WHONKOWS is required here, like:
JASS:
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:
JASS:
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:
JASS:
function GlavieTossCond takes nothing returns boolean 
return GetSpellAbilityId() == 'A01M' and GetSpellAbilityLevel() == 1
endfunction
see...
 
Level 2
Joined
Oct 4, 2006
Messages
7
Still doesn`t work. Here`s the code:

JASS:
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
 
Level 6
Joined
Feb 18, 2005
Messages
263
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)

JASS:
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
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
here the corrected code (it compiles - haven't checked, wether it works)

maybe try this?

JASS:
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
 
Level 2
Joined
Oct 4, 2006
Messages
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?
 
Status
Not open for further replies.
Top