NeuroToxin
New Member
- Reaction score
- 46
Basically, I get 3 errors with Cannot Convert Integer to Real, or cannot convert Real to Integer, I think its the second one. Nevertheless, code is commented, and I'll point out where the errors are.
JASS:
scope SoulMirror initializer Init
globals
//The ability ID for the spell Soul Mirror
private constant integer SPELLID = 'A001'
//The spell ID of the Dummyillusion ability
private constant integer ILLUSIONID = 'A000'
//The distance in which the SOULS_PER_DISTANCE are used. If you travel 750, it will only use one
//soul, it has to be greater than 1000 to use two +
private constant real DISTANCE = 1000
//The amount of souls used per X distance
private constant real SOULS_PER_DISTANCE = 2
//The effect to be played at the end when the damage is being dealt.
private constant string EFFECT_ON_HIT = "Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl"
//The effect that is played when the caster leaves, along with the HIDE_EFFECT
private constant string LEAVING_EFFECT = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
//The effect played where the damage occurs
private constant string AOE_EFFECT = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
//The effect to distract the eye while the caster is hid.
private constant string HIDE_EFFECT = "Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl"
//The interval at which the timing system will operate
private constant real INTERVAL = 0.03
//The offset each Interval seconds.
private constant integer OFFSET = 25
//The unimportant constants, yet they still need to be here
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
endglobals
private function AOE takes integer lvl returns real
return 100 + (lvl * 50.)
endfunction
private function DAMAGE takes integer lvl returns real
return 75 + (lvl * 75.)
endfunction
private function FilterFunc takes nothing returns boolean
local unit u = GetFilterUnit()
local boolean bool1 = IsUnitType(u, UNIT_TYPE_DEAD) == false
local boolean bool2 = IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) == false
local boolean bool3 = IsUnitType(u, UNIT_TYPE_STRUCTURE) == false
return bool1 and bool2 and bool3
endfunction
struct SoulMirror
unit Caster
real CasterX
real CasterY
real TargetX
real TargetY
unit Dummy
real DistanceToTarget
real angle
real Totalsouls
static integer structtype
endstruct
private function DamageUnits takes nothing returns nothing
local SoulMirror s = SoulMirror.structtype
local unit p = GetEnumUnit()
local real x = GetUnitX(p)
local real y = GetUnitY(p)
local integer level = GetUnitAbilityLevel(s.Caster, SPELLID)
local real damage = DAMAGE(level)
call UnitDamageTarget(s.Caster, p, damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call DestroyEffect(AddSpecialEffect(EFFECT_ON_HIT, x, y))
set p = null
endfunction
private function MoveUnit takes nothing returns boolean
local SoulMirror s = KT_GetData()
local real DX = GetUnitX(s.Dummy)
local real DY = GetUnitY(s.Dummy)
local real DNewX = DX + OFFSET * Cos(s.angle)
local real DNewY = DY + OFFSET * Sin(s.angle)
local boolean DistCheck = (s.DistanceToTarget >= 50)
local integer level = GetUnitAbilityLevel(s.Caster, SPELLID)
local real areaofeffect = AOE(level)
local group tempgroup
//Checking distance between the points.
if DistCheck then
//If it's true, then we set the dummy position closer to the targeted spot
call SetUnitX(s.Dummy, DNewX)
call SetUnitY(s.Dummy, DNewY)
call DestroyEffect(AddSpecialEffect(LEAVING_EFFECT, DNewX, DNewY))
call SetUnitFacing(s.Dummy, s.angle)
set s.DistanceToTarget = s.DistanceToTarget - OFFSET
else
//If it's not true, then we create the effects and initialize the group.
//First, we make the group to check around the casters initial casting to damage them.
set tempgroup = CreateGroup()
call GroupEnumUnitsInRange(tempgroup, s.CasterX, s.CasterY, areaofeffect, Condition(function FilterFunc))
if CountUnitsInGroup(tempgroup) > 0 then
//If there are any units around the initial spot, then we damage them, else we destroy the instance
//We also unhide the caster now, and create an effect to show the unhiding.
set SoulMirror.structtype = s
call ForGroup(tempgroup, function DamageUnits)
endif
call SetUnitX(s.Caster, s.TargetX)
call SetUnitY(s.Caster, s.TargetY)
call DestroyEffect(AddSpecialEffect(HIDE_EFFECT, GetUnitX(s.Caster), GetUnitY(s.Caster)))
//Then we check the target coordinates to damage the units there too. Nifty huh.
call DestroyGroup(tempgroup)
set tempgroup = CreateGroup()
call GroupEnumUnitsInRange(tempgroup, s.TargetX, s.TargetY, areaofeffect, Condition(function FilterFunc))
call ShowUnit(s.Caster, true)
if CountUnitsInGroup(tempgroup) > 0 then
//If there are any units around the initial spot, then we damage them, else we destroy the instance
//We also unhide the caster now, and create an effect to show the unhiding.
set SoulMirror.structtype = s
call ForGroup(tempgroup, function DamageUnits)
endif
call DestroyGroup(tempgroup)
call s.destroy()
endif
return false
endfunction
private function RemoveUnits takes nothing returns nothing
local unit p = GetEnumUnit()
call GroupRemoveUnit(CirclingUnits[GetUnitUserData(GetTriggerUnit())], p)
call RemoveUnit(p)
set p = null
endfunction
private function OnCast takes nothing returns boolean
local SoulMirror s
local boolean cond = (CountUnitsInGroup(CirclingUnits[GetUnitUserData(GetTriggerUnit())]) > 0)
local real X
local real Y
local integer count
local real DistX
local real DistY
local real Tempreal
local group tempgroup
if GetSpellAbilityId() == SPELLID and cond then
set s = SoulMirror.create()
set s.Caster = GetTriggerUnit()
set s.TargetX = GetSpellTargetX()
set s.TargetY = GetSpellTargetY()
set DistX = s.TargetX - X
set DistY = s.TargetY - Y
set Tempreal = SquareRoot(DistX * DistX + DistY * DistY)
set s.DistanceToTarget = Tempreal
set count = CountUnitsInGroup(CirclingUnits[GetUnitUserData(GetTriggerUnit())])
set s.Totalsouls = ((s.DistanceToTarget / DISTANCE) / SOULS_PER_DISTANCE)
//Setting the spell target coordinates and souls needed.
set s.Dummy = GroupPickRandomUnit(CirclingUnits[GetUnitUserData(s.Caster)])
//HERE is an error! Dddddddddddddddddddddddddddddddddddddddd
set Count[GetUnitUserData(s.Caster)] = Count[GetUnitUserData(s.Caster)] - 1
call GroupRemoveUnit(CirclingUnits[GetUnitUserData(s.Caster)], s.Dummy)
set Y = GetUnitY(s.Dummy)
set X = GetUnitX(s.Dummy)
set s.CasterX = GetUnitX(s.Caster)
set s.CasterY = GetUnitY(s.Caster)
set s.angle = bj_RADTODEG * Atan2(s.CasterY - s.TargetY, s.CasterX - s.TargetX)
//Hide the caster and create an effect to make it look cool and trick the eye
//We also are making the illusion here
call UnitAddAbility(s.Caster, ILLUSIONID)
call SetUnitAbilityLevel(s.Caster, ILLUSIONID, GetUnitAbilityLevel(s.Caster, SPELLID))
call IssueTargetOrderById(s.Caster, 852274, GetTriggerUnit())
call UnitRemoveAbility(s.Caster, ILLUSIONID)
call ShowUnit(s.Caster, false)
call DestroyEffect(AddSpecialEffect(LEAVING_EFFECT, GetUnitX(s.Caster), GetUnitY(s.Caster)))
call DestroyEffect(AddSpecialEffect(HIDE_EFFECT, GetUnitX(s.Caster), GetUnitY(s.Caster)))
//Picking, and destroying the struct in which the unit was associated with before
call SetUnitScale(s.Dummy, 300 * 0.01, 300 * 0.01, 300 * 0.01)
//Making the unit stick out a bit.
set Souls.Circling = true
if CountUnitsInGroup(CirclingUnits[GetUnitUserData(GetTriggerUnit())]) < s.Totalsouls then
//HERE IS AN ERROR--------------------------------------------------------------
set s.DistanceToTarget = s.DistanceToTarget - ((s.Totalsouls - count) * (DISTANCE / SOULS_PER_DISTANCE))
call ForGroup(CirclingUnits[GetUnitUserData(GetTriggerUnit())], function RemoveUnits)
set Count[GetUnitUserData(GetTriggerUnit())] = 0
else
//HERE IS THE LAST ERROR---------------------------------------------
set Count[GetUnitUserData(GetTriggerUnit())] = Count[GetUnitUserData(GetTriggerUnit())] - s.Totalsouls
set tempgroup = CreateGroup()
call GetRandomSubGroup(s.Totalsouls, CirclingUnits[GetUnitUserData(GetTriggerUnit())])
endif
//Destroying the struct associated with before, the true creates a separate condition in the
//SoulAcquire trigger in the movement.
call KT_Add( function MoveUnit, INTERVAL, s)
endif
return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition( t, Condition(function OnCast) )
endfunction
endscope