• 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] JASS newb need some help ^^

Status
Not open for further replies.
Level 1
Joined
Sep 12, 2006
Messages
5
hey. Im new to JASS, and i'm pretty confused about the whole thing... anyway - i've been trying to make a spell which damages a target unit over time, but it just wont work. Here it is:

function Trig_PoisonSting_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A017'
endfunction

//===========================================================================
function InitTrig_PoisonSting takes nothing returns nothing
set gg_trg_PoisonSting = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PoisonSting, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_PoisonSting, Condition( function Trig_PoisonSting_Conditions ) )
endfunction

function PoisonSting takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local integer dam = 25
local integer dur = 20
local integer seconds = 0
loop
exitwhen seconds==dur
if(IsUnitAliveBJ(target)!=true) then
endif
call UnitDamageTargetBJ(caster,target,dam,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED)
set seconds=seconds+1
call TriggerSleepAction(1)
endloop
set seconds=0
set dam=0
set dur=0
set caster=null
set target=null
endfunction


(dont laugh, it might be full of bugs & leaks :oops: )

Can anyone help me with this??
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
first, use JASS tags plz, they make things so much easier to read ^^

anyways, the main problem was you didnt add an action to your trigger, but i also cleaned up a few other things. most of those locals were ( and are ) not needed, but i suppose they make it easier to mod :?

JASS:
function Trig_PoisonSting_Conditions takes nothing returns boolean 
    return GetSpellAbilityId() == 'A017' 
endfunction

function PoisonSting takes nothing returns nothing 
    local unit caster = GetTriggerUnit() 
    local unit target = GetSpellTargetUnit() 
    local integer dam = 25 
    local integer dur = 20 
    local integer seconds = 0 
    loop 
        exitwhen seconds==dur or GetUnitState( target, UNIT_STATE_LIFE ) >= 0
        call UnitDamageTarget(caster,target,dam, true, false, ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED, null)
        set seconds=seconds+1 
        call TriggerSleepAction(.75) 
    endloop 
    set seconds=0 
    set dam=0 
    set dur=0 
    set caster=null 
    set target=null 
endfunction

function InitTrig_PoisonSting takes nothing returns nothing
    set gg_trg_PoisonSting = CreateTrigger( ) 
    call TriggerRegisterAnyUnitEventBJ( gg_trg_PoisonSting, EVENT_PLAYER_UNIT_SPELL_EFFECT ) 
    call TriggerAddCondition( gg_trg_PoisonSting, Condition( function Trig_PoisonSting_Conditions ) )
    call TriggerAddAction( gg_trg_PoisonSting, function PoisonSting )
endfunction
 
Level 1
Joined
Sep 12, 2006
Messages
5
Hi again. Somehow, my ability still doesnt work... :eek:
I have based my ability on Curse (don't know if this could affect the function...?) Anyway, please take a look on the trigger again (as it looks at the moement), thx :)

JASS:
function Trig_PoisonSting_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A017'
endfunction
 
function PoisonSting takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local integer dam = 25
    local integer dur = 20
    local integer seconds = 0
    loop
        exitwhen seconds==dur or GetUnitState( target, UNIT_STATE_LIFE ) >= 0
        call UnitDamageTarget(caster,target,dam, true, false, ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED, null)
        set seconds=seconds+1
        call TriggerSleepAction(.75)
    endloop
    set seconds=0
    set caster=null
    set target=null
endfunction
 
function InitTrig_PoisonSting takes nothing returns nothing
    set gg_trg_PoisonSting = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_PoisonSting, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_PoisonSting, Condition( function Trig_PoisonSting_Conditions ) )
    call TriggerAddAction( gg_trg_PoisonSting, function PoisonSting )
endfunction
hope you can make it work ^^
(btw, the trigger is named "PoisonSting")
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
OH lol

its cuz i acc made it NOT work unless they were dead rofl

---fixed, and removed the last int that was hanging on---

JASS:
function Trig_PoisonSting_Conditions takes nothing returns boolean 
    return GetSpellAbilityId() == 'A017' 
endfunction 

function PoisonSting takes nothing returns nothing 
    local unit caster = GetTriggerUnit() 
    local unit target = GetSpellTargetUnit() 
    local integer dam = 25 
    local integer dur = 20 
    local integer seconds = 0 
    loop 
        exitwhen seconds==dur or GetUnitState( target, UNIT_STATE_LIFE ) <= 0 
        call UnitDamageTarget(caster,target,dam, true, false, ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED, null) 
        set seconds=seconds+1 
        call TriggerSleepAction(.75) 
    endloop
    set caster=null 
    set target=null 
endfunction 

function InitTrig_PoisonSting takes nothing returns nothing 
    set gg_trg_PoisonSting = CreateTrigger( ) 
    call TriggerRegisterAnyUnitEventBJ( gg_trg_PoisonSting, EVENT_PLAYER_UNIT_SPELL_EFFECT ) 
    call TriggerAddCondition( gg_trg_PoisonSting, Condition( function Trig_PoisonSting_Conditions ) ) 
    call TriggerAddAction( gg_trg_PoisonSting, function PoisonSting ) 
endfunction
 
Level 1
Joined
Sep 12, 2006
Messages
5
lol :D
all right, thx a lot for the help! :D

EDIT: Oh damn... there's one more thing: I wan't the damage to be based on the intelligence of the caster, but when i change the "dam" (like this below), i get the error message "type missmatch in assignment" in the line below (dur)... please help :?

JASS:
function Trig_PoisonSting_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A017'
endfunction

function PoisonSting takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local integer dam = ( I2R(GetHeroStatBJ(bj_HEROSTAT_INT, GetSpellAbilityUnit(), true)) * ( 0.20 + ( I2R(GetUnitAbilityLevelSwapped('A017', GetSpellAbilityUnit())) * 0.10 ) ) )
    local integer dur = 20
    local integer seconds = 0
    loop
        exitwhen seconds==dur or GetUnitState( target, UNIT_STATE_LIFE ) <= 0
        call UnitDamageTarget(caster,target,dam, true, false, ATTACK_TYPE_CHAOS,DAMAGE_TYPE_ENHANCED, null)
        set seconds=seconds+1
        call TriggerSleepAction(.75)
    endloop
    set caster=null
    set target=null
endfunction
 
function InitTrig_PoisonSting takes nothing returns nothing
    set gg_trg_PoisonSting = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_PoisonSting, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_PoisonSting, Condition( function Trig_PoisonSting_Conditions ) )
    call TriggerAddAction( gg_trg_PoisonSting, function PoisonSting )
endfunction
 
Status
Not open for further replies.
Top