• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

[JASS] Simple(?) Spell help

Status
Not open for further replies.
Level 1
Joined
Jan 19, 2008
Messages
4
Hi everyone, this is my first real attempt at making anything at all with JASS and therefore I'm still not 100% clear on what I'm doing. Anywho, me and my buddy are trying to make a skill that does (Agility*4 damage).

So far i have:
function Attack_Condition takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Attack_Actions takes nothing returns nothing
endfunction
function InitTrig_AttackA000 takes nothing returns nothing
call UnitDamageTargetBJ(GetSpellAbilityUnit(),GetEnumUnit(),(I2R(GetHeroStatBJ(0,GetSpellAbilityUnit(),true))*3.),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
call PolledWait(2.)
endfunction


Please help
 
Level 11
Joined
Feb 22, 2006
Messages
752
First of all, you have your code in the wrong place. The stuff that's supposed to run when the trigger fires goes in the Actions function, not the trigger initialization function. The trigger initialization function is automatically called at map initialization and it basically sets up the trigger.

Secondly, use GetTriggerUnit() whenever you can instead of the other functions that return the same unit, like GetSpellAbilityUnit(), or GetDyingUnit(). GetTriggerUnit() is faster and won't screw up after waits.

Thirdly, GetEnumUnit() only works in ForGroup() callback functions and refers to the "picked unit" when the function loops through every unit in the group. Targeted unit of a spell is returned by GetSpellTargetUnit().

Fourthly, if you're going to use Jass, use natives, not BJ functions, whenever possible. Natives are faster than BJ functions since BJ functions just call natives and more function calls = more memory usage. So, get a function list somewhere (JassCraft or JassNewGen Pack) and get to know which native functions do what.

Fifthly, I don't know why you have a polled wait at the end of the function. It does nothing, so get rid of it.

So you WANT to have something like this:

JASS:
function Trig_Attack_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A000' )
endfunction

function Trig_Attack_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real damage = 4.00 * GetHeroAgi( caster, true )
    call UnitDamageTarget( caster, target, damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
    set caster = null
    set target = null
endfunction 

function InitTrig_Attack takes nothing returns nothing
    set gg_trg_Attack = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Attack, Condition ( function Trig_Attack_Conditions ) )
    call TriggerAddAction( gg_trg_Attack, function Trig_Attack_Actions )
endfunction
 
Level 1
Joined
Jan 19, 2008
Messages
4
Thanks for the input but neither jasscraft or world edit accept

set gg_trg_Attack = CreateTrigger()

:S Do you happen to know why?
 
Level 1
Joined
Jan 19, 2008
Messages
4
That wouldn't explain why jasscraft detects an error,
and I just rechecked and there is no trigger called attack :S
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
repleace this set gg_trg_Attack = CreateTrigger() with this local trigger gg_trg_Attack = CreateTrigger()

OR

Make your triggers name "Attack"

man my avatar really looks annoying... changed*
 
Level 1
Joined
Jan 19, 2008
Messages
4
Okay, so just to clarify
1. Make a trigger named Attack that (unsure about this part: activates the other trigger when a spell is activated)
2. Create a SEPERATE trigger and paste in the above trigger
3. Pray?
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Tell ya what
your trigger variable is gg_trg_<triggername> ("_" for spaces ex "Golbin Bomb" -> gg_trg_Goblin_Bomb)

so when you create a trigger named Attack its variable will bi gg_trg_Attack
so you can use that variable

STILL

JassCraft wont accept it because it doesnt know about trigger you created (you cant expect it to know what is your trigger)

OR

like I said you can use a local variable instead of global (that repleace part in my post)
but you wont be able to disable-modify that trigger with anyother triggers
 
Status
Not open for further replies.
Top