NeuroToxin
New Member
- Reaction score
- 46
Okay, so I'm making my spell, and I have some unknown errors that I don't know whats wrong, one is on my Polar offset, I use this.
And it says, "Bad type for binary operator."
Also, I have a group tempgroup thats a local, and it gives me this, "Cannot convert nothing to group." Heres the code for it
I have four of these, so it gives me four errors, out of the 7 I have. Heres the rest of the code.
JASS:
set offsetx = targetloc + 10 * Cos(V.Tfacing)
And it says, "Bad type for binary operator."
Also, I have a group tempgroup thats a local, and it gives me this, "Cannot convert nothing to group." Heres the code for it
JASS:
set tempgroup=GroupEnumUnitsInRange(s__Vampiric_Targets[V], offsetx, offsety, 200, Filter(function VampiricStrike___Boolexpr))
I have four of these, so it gives me four errors, out of the 7 I have. Heres the rest of the code.
JASS:
scope VampiricStrike
//==========================SETUP=============================================
globals
//The Special Effect of the Blink
string BLINK_SFX = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"
//The Special Effect of each Attack
string ATTACK_SFX = "Abilities\\Spells\\Undead\\CarrionSwarm\\CarrionSwarmDamage.mdl"
//The Special Effect of the Final Attack
string FINAL_ATTACK_SFX = "Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl"
//If true, then the target that you first targeted will be targeted last for the blink attacks.
boolean ALWAYS_ATTACK_FIRST = true
//Ability ID of the Vampiric Strike ability
integer ABILITY_CODE = 039;A000039;
//This is the animation string (Name) of the animation you want to play when the unit is attacked.
string ATTACK_ANIMATION = "attack"
//If this boolean is set to true, instead of always finding units in BACK of the attacked, it will find them depending on the units
//facing. EX. If a unit is attacking you and this triggers, it will be behind, (If you're attacking it) however, if you're attacking a unit
//from behind, then it blinks you behind you, it won't be of much use, however, if its true it will do that.
boolean ALWAYS_BACK = false
//This one is the rate at which you teleport to targets, attack, then find a new target. Higher values can be set for longer visual.
real KEY_TIMERS_RATE = .25
//This is the attack type for the damage
attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
//This is the damage type for the damage
damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
//This is the weapon type for the damage
weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
endglobals
private function DAMAGE takes integer lvl returns real
return 25 + (lvl * 25.)
endfunction
private function RANGE_PER_LEVEL takes integer lvl returns real
return 400 + (lvl * 100.)
endfunction
private function Boolexpr takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true and IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) != true
endfunction
//=======================ENDSETUP=============================================
struct Vampiric
unit Caster
unit Targeted
group Targets
real Cfacing
real Tfacing
real Maxangle
real Leastangle
real Castertoattacked
real AngleDif
static integer Structtype
endstruct
private function Move takes nothing returns nothing
local Vampiric V = Vampiric.Structtype
local real damage = DAMAGE(GetUnitAbilityLevel(V.Caster, ABILITY_CODE))
local real casterx = GetUnitX(V.Caster)
local real castery = GetUnitY(V.Caster)
local real targetx = GetUnitX(GetEnumUnit())
local real targety = GetUnitY(GetEnumUnit())
local real angle = GetUnitFacing(GetEnumUnit())
local real offsetx = casterx + 20 * Cos(angle)
local real offsety = castery + 20 * Sin(angle)
if GetEnumUnit() != V.Targeted then
call SetUnitX(V.Caster, offsetx)
call SetUnitY(V.Caster, offsety)
call DestroyEffect(AddSpecialEffect(BLINK_SFX, offsetx, offsety))
call SetUnitAnimation(V.Caster, ATTACK_ANIMATION)
call UnitDamageTarget(V.Caster, GetEnumUnit(), damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call DestroyEffect(AddSpecialEffect(ATTACK_SFX, targetx, targety))
call GroupRemoveUnit(V.Targets, GetEnumUnit())
elseif CountUnitsInGroup(V.Targets) == 1 and ALWAYS_ATTACK_FIRST != true then
call SetUnitX(V.Caster, offsetx)
call SetUnitY(V.Caster, offsety)
call DestroyEffect(AddSpecialEffect(BLINK_SFX, offsetx, offsety))
call SetUnitAnimation(V.Caster, ATTACK_ANIMATION)
call UnitDamageTarget(V.Caster, GetEnumUnit(), damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call DestroyEffect(AddSpecialEffect(FINAL_ATTACK_SFX, targetx, targety))
call GroupRemoveUnit(V.Targets, GetEnumUnit())
elseif GetEnumUnit() == V.Targeted and ALWAYS_ATTACK_FIRST == true and CountUnitsInGroup(V.Targets) == 1 then
call SetUnitX(V.Caster, offsetx)
call SetUnitY(V.Caster, offsety)
call DestroyEffect(AddSpecialEffect(BLINK_SFX, offsetx, offsety))
call SetUnitAnimation(V.Caster, ATTACK_ANIMATION)
call UnitDamageTarget(V.Caster, GetEnumUnit(), damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call DestroyEffect(AddSpecialEffect(FINAL_ATTACK_SFX, targetx, targety))
call GroupRemoveUnit(V.Targets, GetEnumUnit())
endif
endfunction
private function userFunc takes nothing returns boolean
local Vampiric V = KT_GetData()
set Vampiric.Structtype = V
call ForGroup(V.Targets, function Move)
if CountUnitsInGroup(V.Targets) < 1 then
call V.destroy()
return true
endif
return false
endfunction
private function Oncast takes nothing returns nothing
local Vampiric V = Vampiric.create()
local real maxrange = RANGE_PER_LEVEL(GetUnitAbilityLevel(GetAttacker(), ABILITY_CODE))
local real angle
local real offsetx
local real offsety
local location casterloc
local location targetloc
local integer p = 0
local integer i = GetRandomInt(0, 100)
local group tempgroup
if i < 50 then
call V.destroy()
elseif GetUnitAbilityLevel(GetAttacker(), ABILITY_CODE) > 0 then
set V.Cfacing = GetUnitFacing(GetAttacker())
set V.Targeted = GetTriggerUnit()
set V.Tfacing = GetUnitFacing(GetTriggerUnit())
set angle = V.Cfacing - V.Tfacing
if angle < 0 then
set angle = (-angle)
elseif angle <= 75 or ALWAYS_BACK != false then
set casterloc = GetUnitLoc(GetAttacker())
set targetloc = GetUnitLoc(GetTriggerUnit())
set V.Tfacing = V.Tfacing + 180
loop
exitwhen i >= maxrange
set offsetx = targetloc + 10 * Cos(V.Tfacing)
set offsety = targetloc + 10 * Sin(V.Tfacing)
set tempgroup = GroupEnumUnitsInRange(V.Targets, offsetx, offsety, 200, Filter(function Boolexpr))
call DestroyBoolExpr(Filter(function Boolexpr))
call GroupAddGroup(tempgroup, V.Targets)
call DestroyGroup(tempgroup)
set i = i + 10
endloop
else
if angle >= 76 then
set targetloc = GetUnitLoc(GetTriggerUnit())
loop
exitwhen i >= maxrange
set offsetx = targetloc + 10 * Cos(V.Tfacing)
set offsety = targetloc + 10 * Sin(V.Tfacing)
set tempgroup = GroupEnumUnitsInRange(V.Targets, offsetx, offsety, 200, Filter(function Boolexpr))
call DestroyBoolExpr(Filter(function Boolexpr))
call GroupAddGroup(tempgroup, V.Targets)
call DestroyGroup(tempgroup)
set i = i + 10
endloop
endif
endif
endif
if CountUnitsInGroup(V.Targets) <= 0 then
call V.destroy()
call RemoveLocation(casterloc)
call RemoveLocation(targetloc)
else
call RemoveLocation(casterloc)
call RemoveLocation(targetloc)
call KT_Add(userFunc, V, KEY_TIMERS_RATE)
endif
endfunction
//===========================================================================
private function InitTrig_Vampiric_Strike takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerAddAction( t, function Oncast)
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED)
endfunction
endscope