New to JASS and need help

IAmSoDoomed

New Member
Reaction score
0
Hi, I'm new to JASS and, I tried to script something and everything works, besides one thing and I'm not sure which one it is.

I guess it's
either a problem with the Unit Group
or a problem with adding the abillity

Code:
function Trig_Fire_Burst_Conditions takes nothing returns boolean
    if (not( GetSpellAbilityId() == 'A000' ))  then
        return false
    endif
    return true
endfunction

//========================================================================================================================================================================================================================================================

function Trig_Fire_Burst_FuncCon takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

//========================================================================================================================================================================================================================================================

function Trig_Fire_Burst_FuncAct takes nothing returns nothing
    call UnitAddAbilityBJ( 'A001', GetEnumUnit() )
endfunction

//========================================================================================================================================================================================================================================================

function Trig_Fire_Burst_Actions takes nothing returns nothing
    local unit Triggering_Unit = GetTriggerUnit()
    local location Caster_Location = GetUnitLoc( Triggering_Unit )
    local integer Index = 1
    local integer IndexEnd = 10
    call TriggerSleepAction( 0.18 )
    loop
        exitwhen Index > IndexEnd
        call AddSpecialEffectLocBJ(PolarProjectionBJ(Caster_Location,(50.00 * Index),GetUnitFacing(Triggering_Unit)), "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl")
        call TriggerSleepAction( 0.01 )
        call UnitDamagePointLoc(Triggering_Unit,0,40,PolarProjectionBJ(Caster_Location,(50 * Index),GetUnitFacing(Triggering_Unit)),100,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC)
        call ForGroupBJ( GetUnitsInRangeOfLocMatching(30.00, PolarProjectionBJ(GetUnitLoc(GetTriggerUnit()), ( 50.00 * 10.00 ), GetUnitFacing(GetTriggerUnit())), Condition(function Trig_Fire_Burst_FuncCon)), function Trig_Fire_Burst_FuncAct )
        set Index = Index + 1
     endloop
    call RemoveLocation(Caster_Location)
endfunction

//========================================================================================================================================================================================================================================================
function InitTrig_Fire_Burst takes nothing returns nothing
    set gg_trg_Fire_Burst = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Fire_Burst, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition( gg_trg_Fire_Burst, Condition( function Trig_Fire_Burst_Conditions ) )
    call TriggerAddAction( gg_trg_Fire_Burst, function Trig_Fire_Burst_Actions )
endfunction

The skill itself, shoots out a wave of fire to the front and is supposed to add an ability to the units, inside of the AoE. Just that it doesn't add the Ability to the target unit.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
30.00 is small value. Basically you will pick a unit only under 30 Area.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I've helped him via MSN.

Here's my version if anyone wants to see...
JASS:
scope FireBurst initializer Init
//Almost everything goes in a scope
//Except systems, which you'll get into later on

	//We talked about globals
	globals
		private constant integer SPELLID = 'A000'
		//Rawcode of the 'Fire Burst' ability
		
		private constant integer AURAID = 'A001'
		//Rawcode of the aura ability
		
		private constant real DISTANCE = 50.
		//The distance in PolarProjection
		
		private constant string SFX = "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl"
		//The path of the SFX you want
		
		private constant integer LOOPEND = 9
		//How many loops until the loop ends?
	endglobals
	
	private function DAMAGE takes integer level returns real
		return 100.
		//The damage Fire Burst deals
	endfunction
	
	private function AOERANGE takes integer level returns real
		return 30.
		//The range units are picked in
	endfunction
	
//==============================================================
//===============     DO NOT TOUCH PAST HERE     ===============
//===============     DO NOT TOUCH PAST HERE     ===============
//===============     DO NOT TOUCH PAST HERE     ===============
//==============================================================

	globals
		private group G = CreateGroup()
		//Declare this below the "DO NOT TOUCH" line so that people don't touch this
		//You can have as many global blocks as you want
		//We use a global group since it's filled and emptied right away for this spell
		//Remember though, do NOT do "call DestroyGroup(G)" for global groups
	endglobals
	
	//Add a 'private' prefix
	//private function Trig_Fire_Burst_Conditions takes nothing returns boolean
	//The function gets renamed because we named it differently in the initializer at the bottom
	private function Conditions takes nothing returns boolean
		//if (not( GetSpellAbilityId() == 'A000' ))  then
			//return false
		//endif
		//return true
		
		//Just return if it's the right spell directly
		return GetSpellAbilityId() == SPELLID
		//SPELLID is a global
	endfunction

	//private function Trig_Fire_Burst_FuncCon takes nothing returns boolean
	private function GroupConditions takes nothing returns boolean
	//Changed name in the Grouping function so you have to change it here
	
		//return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true )
		//You don't need the "== true"
		//If there's no "== XXX" at the end it assumes you want "== true"
		return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405
		//Added in to check if the unit is alive also
	endfunction

	//private function Trig_Fire_Burst_FuncAct takes nothing returns nothing
	private function GroupActions takes nothing returns nothing
	//Changed the name in the ForGroup() function so it's changed here also
	
		//call UnitAddAbilityBJ( 'A001', GetEnumUnit() )
		//Try to start using Natives instead of BJ's
		//BJ's call upon Natives so just using the native directly is better
		call UnitAddAbility(GetEnumUnit(), AURAID)
		//AURAID is a global
		
		//Don't forget, we have to damage the units in here now
		call UnitDamageTarget(GetTriggerUnit(), GetFilterUnit(), DAMAGE, true, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
		//DAMAGE is a function global
	endfunction

//========================================================================================================================================================================================================================================================

	//private function Trig_Fire_Burst_Actions takes nothing returns nothing
	private function Actions takes nothing returns nothing
	//Renamed to "Actions"
	
		local unit tu = GetTriggerUnit()
		//local location Caster_Location = GetUnitLoc( tu )
		//Locations are so GUI, they can also leak
		//JASS = X/Y coordinates, X/Y are reals, which do not leak
		local real tx = GetUnitX(tu)
		local real ty = GetUnitY(tu)
		
		//local integer Index = 1
		local integer index = 0
		//Changed to 0
		//Also, all locals should have no capitals in them
		
		//local integer IndexEnd = 10
		//Not needed
		
		//call TriggerSleepAction( 0.18 )
		//Why the random wait?
		
		loop
		//exitwhen Index > IndexEnd
		exitwhen index == LOOPEND
		//Now you only need one variable
		//LOOPEND is a global
		
			set tx = GetUnitX(tu) + (DISTANCE * index) * Cos(GetUnitFacing(tu) * bj_DEGTORAD)
			set ty = GetUnitY(tu) + (DISTANCE * index) * Sin(GetUnitFacing(tu) * bj_DEGTORAD)
			//Uses X/Y instead of locations
			//call AddSpecialEffectLocBJ(PolarProjectionBJ(Caster_Location,(50.00 * Index),GetUnitFacing(tu)), "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl")
			call DestroyEffect(AddSpecialEffect(SFX, tx, ty))
			//The native for SFX
			//You need DestroyEffect() to prevent an SFX leak
			//AddSpecialEffect() uses X/Y instead of locations
			
			call TriggerSleepAction( 0.01 )
			//TriggerSleepAction()'s are inaccurate.
			
			//call UnitDamagePointLoc(tu,0,40,PolarProjectionBJ(Caster_Location,(50 * Index),GetUnitFacing(tu)),100,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC)
			//This can cause Mac users to disconnect
			//Damage all the units in the ForGroup() function
			
			//call ForGroupBJ( GetUnitsInRangeOfLocMatching(30.00, PolarProjectionBJ(GetUnitLoc(GetTriggerUnit()), ( 50.00 * 10.00 ), GetUnitFacing(GetTriggerUnit())), Condition(function Trig_Fire_Burst_FuncCon)), function Trig_Fire_Burst_FuncAct )
			call GroupEnumUnitsInRange(G, tx, ty, AOERANGE, Condition(function GroupConditions))
			//AOERANGE is a global, look at the top of this trigger
			//Group the units beforehand to look neater
			call ForGroup(G, function GroupActions)
			//Again, avoiding a BJ
			
			//set Index = Index + 1
			set index = index + 1
			//"Index" was renamed to "index"
		endloop
		//call RemoveLocation(Caster_Location)
		//Don't need this anymore
		//We need to null the unit and group variable though
		set tu = null
	endfunction

//========================================================================================================================================================================================================================================================
	//private function InitTrig_Fire_Burst takes nothing returns nothing
	//"scope...initializer Init"
	//The initializer is "Init", so we name this function that
	private function Init takes nothing returns nothing
		//set gg_trg_Fire_Burst = CreateTrigger(  )
		//We make a local trigger named "t" so it's easier to use
		//"t" is easier then typing "gg_trg_Fire_Burst"
		local trigger t = CreateTrigger()
		
		//call TriggerRegisterAnyUnitEventBJ(gg_trg_Fire_Burst, EVENT_PLAYER_UNIT_SPELL_CAST)
		call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
		//Notice how it changed from "gg_trg_Fire_Burst" to "t"
		//This BJ is one of the few good ones to use... ^-- Notice how I changed it to "..._EFFECT"
		//"..._EFFECT" means "Starts the effect of an ability"
		//Always use this instead of "..._CAST"
		
		//call TriggerAddCondition( gg_trg_Fire_Burst, Condition( function Trig_Fire_Burst_Conditions ) )
		call TriggerAddCondition(t, Condition(function Conditions))
		//Not much to say here
		
		//call TriggerAddAction( gg_trg_Fire_Burst, function Trig_Fire_Burst_Actions )
		call TriggerAddAction(t, function Actions)		
	endfunction
	
endscope
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top