• 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] Taunt Spell

Status
Not open for further replies.
Level 5
Joined
Feb 22, 2013
Messages
161
So I am having the worst time ever with my programming or something but I've been asking for help a lot more than I should.. But yet another problem has occured:

JASS:
scope Taunt initializer TauntInit

	globals
		integer random
		timer tauntTimer = CreateTimer()
		unit caster
        group tauntGroup = CreateGroup()
		unit array unitIndex
		integer unitCount
		effect array sfx
	endglobals
	
	function TauntGroupFilter takes nothing returns boolean
		return (GetFilterUnit() != caster) and (IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(caster)) == true) and (not (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == true) )
	endfunction
	
	function TauntExecute takes unit u returns nothing
		
		set sfx[unitCount] = AddSpecialEffectTarget("Abilities\\Spells\\Other\\HowlOfTerror\\HowlTarget.mdl", u, "overhead")
		call IssueTargetOrder(u, "attack", caster)
	endfunction
	
	function TauntCast takes nothing returns boolean
    
		set caster = GetSpellAbilityUnit()
		call DisplayTimedTextToPlayer(Player(0), 0, 0, 3.00, GetUnitName(caster))
		if GetSpellAbilityId() == 'TA00' then
			call GroupEnumUnitsInRange(tauntGroup, GetUnitX(caster), GetUnitY(caster), 256.00, Condition(function TauntGroupFilter))
            call DestroyBoolExpr(Condition(function TauntGroupFilter))
			call DisplayTimedTextToPlayer(Player(0), 0, 0, 3.00, "FirstOfGroup = " + GetUnitName(FirstOfGroup(tauntGroup)))
			loop
				set unitCount = unitCount + 1
				set unitIndex[unitCount] = FirstOfGroup(tauntGroup)
				exitwhen unitIndex[unitCount] == null
                
				call TauntExecute(unitIndex[unitCount])
				call GroupRemoveUnit(tauntGroup, unitIndex[unitCount])
			endloop
		endif
			
		set caster = null
		return false
	endfunction
	
	private function TauntInit takes nothing returns nothing
		local trigger t = CreateTrigger()
		
		call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
		call TriggerAddCondition(t, Condition(function TauntCast))
		
		set t = null
	endfunction
	
endscope

For some reason FirstOfGroup is returning a null unit, why is that?
 
Level 5
Joined
Feb 22, 2013
Messages
161
It's not supposed to be, I put it there to determine whether the group is formed but it's not because it's saying FirstOfGroup = 'blank' signifying a null unit return for FirstOfGroup.. But I'm not exactly sure...
 
Level 5
Joined
Feb 22, 2013
Messages
161
......... I figured it out... the global variable unitCount wasn't set to 0 for the loop to begin what is necessary.. I hate obvious but somehow hidden errors SOOO much...
 
Level 5
Joined
Feb 22, 2013
Messages
161
EDIT: Nevermind that last question.. What does it mean when a syntax error pops up saying " Identifier redeclared: 'this' "
 
Last edited:
EDIT: Nevermind that last question.. What does it mean when a syntax error pops up saying " Identifier redeclared: 'this' "

that means that you are redeclaring something. basically you set something twice or more like this.

JASS:
local integer i
local integer i
local unit u
local unit u

both the integer i and the unit u have been redeclared. this also happens with functions and anything else.
 
Level 5
Joined
Feb 22, 2013
Messages
161
JASS:
scope Taunt
	
//***************************************************************
//*				Taunt_AoE
//*
//*		Created by RupTure_QS
//*
//***************************************************************

//***************************************************************
//*
//*		Configurables
//*
//***************************************************************

	globals
		
	
//***************************************************************
//*
//*		End of Configurables
//*
//***************************************************************

		private integer newestInstance = 0
		private integer array currentInstance
		private constant GROUP_INIT = CreateGroup()
        private unit caster
        private effect casterTargetEffect
	endglobals
	
	private struct TA_Data
		unit enumTargetUnit
		effect enumTargetEffect
		timer tauntExitTimer = CreateTimer()
		
		static method create takes unit u returns thistype
			local thistype this = thistype.allocate()
			
			set newestInstance = newestInstance + 1
			set this.enumTargetUnit = u
			set this.enumTargetEffect = AddSpecialEffectTarget(targetUnitSFXStringModel(), this.enumTargetUnit, targetUnitSFXStringPlacement())
			
			return this
		endmethod
		
		private method tauntGroupFilter takes nothing returns boolean
			return (GetFilterUnit() != caster) and (IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(caster)) == true) and (not (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == true) )
		endmethod
		
		private method tauntCast takes nothing returns boolean
			local thistype this
			local real x = GetUnitX(caster)
			local real y = GetUnitY(caster)
			local unit u
			
			if GetSpellAbilityId() == ABILITY_ID() then
				set caster = GetSpellAbilityUnit
				set casterTargetEffect = AddSpecialEffectTarget(casterSFXStringModel(), caster, casterSFXStringPlacement())
				
				call GroupEnumUnitsInRange(GROUP_INIT, x, y, tauntRadius(), Condition(function thistype.tauntGroupFilter)
				call DestroyBoolExpr(Condition(function thistype.tauntGroupFilter))
				
				loop
					exitwhen u == null
					set u = FirstOfGroup(GROUP_INIT)
					set this = thistype.create(u)
					set currentInstance[newestInstance] = this
					call GroupRemoveUnit(GROUP_INIT, u)
				endloop
				
			endif
            
			return false
		endmethod
		
		static method onInit takes nothing returns nothing
			local trigger trigTaunt = CreateTrigger()
			
			call TriggerRegisterAnyUnitEventBJ(trigTaunt, EVENT_PLAYER_UNIT_SPELL_EFFECT)
			call TriggerAddCondition(trigTaunt, Condition(function thistype.tauntCast))
			
			set trigTaunt = null
		endmethod
	endstruct
	
endscope

it's giving the error on the local thistype this in the tauntCast method, saying its been redeclared. Nevermind the undelcared functions, re-did constant functions and am turning them into globals instead.
 
Level 5
Joined
Feb 22, 2013
Messages
161
Oh ok, so I fixed it by setting the other methods to static as well... Here is the updated version:

JASS:
scope Taunt
	
//***************************************************************
//*				Taunt_AoE
//*
//*		Created by RupTure_QS
//*
//***************************************************************

//***************************************************************
//*
//*		Configurables
//*
//***************************************************************

	globals
		// How long taunt lasts until the unit taunted has a chance to attack something else.
		private real timerInterval = 5.00
		// The area of affect radius
        private real tauntRadius = 256.00
		// The special effect model string for the affected unit
        private string targetUnitSFXStringModel = "Abilities\\Spells\\Other\\HowlOfTerror\\HowlTarget.mdl"
		// Where the special effect for the affected unit is put
		private string targetUnitSFXStringPlacement = "overhead"
		// The special effect model string for the caster
		private string casterSFXStringModel = "Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl"
		// Where the special effect for the caster is put
		private string casterSFXStringPlacement = "origin"
//***************************************************************
//*
//*		End of Configurables
//*
//***************************************************************

        private constant integer ABILITY_ID = 'TA00'
		private integer newestInstance = 0
		private integer array currentInstance
		private constant group GROUP_INIT = CreateGroup()
        private unit caster
        private effect casterTargetEffect
	endglobals
	
	private struct TA_Data
		unit enumTargetUnit
		effect enumTargetEffect
		timer tauntExitTimer = CreateTimer()
		
		static method create takes unit u returns thistype
			local thistype this = thistype.allocate()
			
			set newestInstance = newestInstance + 1
			set this.enumTargetUnit = u
			set this.enumTargetEffect = AddSpecialEffectTarget(targetUnitSFXStringModel, this.enumTargetUnit, targetUnitSFXStringPlacement)
			
			return this
		endmethod
		
		private static method tauntGroupFilter takes nothing returns boolean
			return (GetFilterUnit() != caster) and (IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(caster)) == true) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false)
		endmethod
		
		private static method tauntCast takes nothing returns nothing
            local thistype this
			local real x = GetUnitX(caster)
			local real y = GetUnitY(caster)
			local unit u
			
            call DisplayTimedTextToPlayer(Player(0), 0, 0, 3.00, "tauntCast running.")
			set caster = GetSpellAbilityUnit()
			set casterTargetEffect = AddSpecialEffectTarget(casterSFXStringModel, caster, casterSFXStringPlacement)
				
			call GroupEnumUnitsInRange(GROUP_INIT, x, y, tauntRadius, Condition(function thistype.tauntGroupFilter))
			call DestroyBoolExpr(Condition(function thistype.tauntGroupFilter))
				
			loop
                set u = FirstOfGroup(GROUP_INIT)
				exitwhen u == null
				set this = thistype.create(u)
				set currentInstance[newestInstance] = this
				call GroupRemoveUnit(GROUP_INIT, u)
			endloop
				
		endmethod
        
        private static method tauntConditions takes nothing returns boolean
            if GetSpellAbilityId() == ABILITY_ID then
                call DisplayTimedTextToPlayer(Player(0), 0, 0, 3.00, "Conditions registered.")
                call thistype.tauntCast()
            endif
            return false
        endmethod
		
		static method onInit takes nothing returns nothing
			local trigger trigTaunt = CreateTrigger()
			
            call DisplayTimedTextToPlayer(Player(0), 0, 0, 3.00, "Initiated.")
			call TriggerRegisterAnyUnitEventBJ(trigTaunt, EVENT_PLAYER_UNIT_SPELL_EFFECT)
			call TriggerAddCondition(trigTaunt, Condition(function thistype.tauntConditions))
			
			set trigTaunt = null
		endmethod
	endstruct
	
endscope

Now it works but wont go past the tauntConditions method it will run the DisplayTimedTextToPlayer saying Conditions registered. But it wont run the tauntCast method... I've even gotten rid of the 'private' setting for the methods but still wouldn't work
 
The problem is that you try to get the x and y of the caster before you assign the variable "caster" to a value. This will cause the thread to stop (which is why the message isn't running). It is actually running tauntCast(), but it isn't going very far because of that.

You should change it:
JASS:
local real x 
local real y 
local unit u 

set caster = GetTriggerUnit()
set x = GetUnitX(caster)
set y = GetUnitY(caster)
 
Level 5
Joined
Feb 22, 2013
Messages
161
-__- yea.... tauntCast wasn't running at all then because the loop ends when it gets a null unit, so it never calls tauntCast... Just another stupid mistake..
 
Status
Not open for further replies.
Top