- Joined
- Jan 14, 2017
- Messages
- 75
I looked at the example spell in the Jass tutorial and copied it (In order to familiarize myself with JASS), but my trigger has been disabled due to a truckload of errors (37!). Here is the code (Ignore comments in the code):
If you're wondering why I put the code in JavaScript, it was because I don't have the option to put it in JASS code.
Please explain what I did wrong briefly (Don't explain every single error, for convenience).
Thank you! I'm sorry that I post so many questions.
JASS:
function Trig_Slash_Actions takes nothing returns nothing
endfunction
//===========================================================================
function InitTrig_Slash takes nothing returns nothing
set gg_trg_Slash = CreateTrigger( )
call TriggerAddAction( gg_trg_Slash, function Trig_Slash_Actions )
endfunction
function Trig_Jass_Spell_Actions takes nothing returns nothing
endfunction
//===========================================================================
function InitTrig_Jass_Spell takes nothing returns nothing
set gg_trg_Jass_Spell = CreateTrigger( )
call TriggerAddAction( gg_trg_Jass_Spell, function Trig_Jass_Spell_Actions )
endfunction
function Slash_Condition takes nothing returns boolean
return GetSpellAbilityId() == 'A001' //Compares the ability Id of the ability being cast to this ability Id
endfunction
function Slash_Actions takes nothing returns nothing
local unit caster
local location start_position
local group enemies //It's like a trigger. It's empty initially, and you add stuff to it :)
local unit temp //Position of enemies when they are hit
local integer count = 5 // local means create or set. In this case, local integer count is the maximum number of enemies that can be hit
endfunction
endfunction
function InitTrig_Slash takes nothing returns nothing
set gg_trg_Slash = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Jass_Spell, EVENT_PLAYER_UNIT_SPELL_EFFECT) //Or, whenever a unit starts the effect of the ability, an event registers
call TriggerAddCondition (gg_trg_Jass_Spell, Condition(function Slash_Condition)
call TriggerAddAction(gg_trg_Jass_Spell, function Slash_Actions)
endfunction
call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 500.0, null)
// GroupEnumUnitsInRangeOfLoc takes a group, a location, a radius, and a boolexpr (a condition, kind of) and then gets units within that radius and adds them to our group
loop
set temp = FirstOfGroup(enemies)
exitwhen temp = null or count = 0
if IsUnitEnemy(temp, GetOwningPlayer(caster)) then
set temp_loc = GetUnitLoc(temp)
call SetUnitPositionLoc(caster,temp_loc)
call UnitDamageTarget (caster, temp, 50, true, false ,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, null)
set count = count - 1
call RemoveLocation(temp_loc)
endif
call GroupRemoveUnit(enemies, temp)
endloop
call RemoveLocation (start_position)
call DestroyGroup(enemies)
set caster = null
set start_position = null
set enemies = null
set temp=null
local start_position = GetUnitLoc(caster)
endfunction
function InitTrig_Jass_Spell takes nothing returns nothing
set gg_trg_Jass_Spell = CreateTrigger()
call TriggerRegisterAnyUnitEvenBJ (gg_trg_Jass_Spell, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition (gg_trg_Jass_Spell, Condition (function Slash_Condition)
call TriggerAddAction (gg_trg_Slash, function Slash_Actions)
endloop
endfunction
Please explain what I did wrong briefly (Don't explain every single error, for convenience).
Thank you! I'm sorry that I post so many questions.

Last edited: