- Joined
- Mar 16, 2008
- Messages
- 941
Well, is the titel correct english grammar? I don't know, just want to know it 
I tried to do some stuff again and started a vJass spell with table, the first time in my life (*glorious moment*).
It's pretty simple: The spell creates a ward that ticks in a random amount of seconds and deals aoe damage, with limited tick-times and a live-duration.
But the spell keeps prohibiting warcraft from correct starting.
It always enters the warcraft menu instead of starting, but I dind't get any errors while compiling and RtC is disabled:
The spell is based on channel, the unit is a healtotem without the aura.
mfg Justify
PS: Table, TimerUtils, GroupUtils and BoolExprUtils required
I love standarts 
I tried to do some stuff again and started a vJass spell with table, the first time in my life (*glorious moment*).
It's pretty simple: The spell creates a ward that ticks in a random amount of seconds and deals aoe damage, with limited tick-times and a live-duration.
But the spell keeps prohibiting warcraft from correct starting.
It always enters the warcraft menu instead of starting, but I dind't get any errors while compiling and RtC is disabled:
JASS:
scope SoilTotem initializer InitTotem
globals
private constant string TotemSFX = "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl"
private constant string HitSFX = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"
private constant integer ABILITY_ID = 'A000'
private constant integer TOTEM_ID = 'o000'
private HandleTable TotemTable
private integer TotemCount = 0
private player TempPlayer
endglobals
//Feel free to change to formulas below this comment (just the stuff behind the "return")
//How long the totem will live
private function GetTotemDuration takes integer level returns real
return 5.*I2R(level)
endfunction
//How many ticks a totem can do at maximum
private function GetTotemTicks takes integer level returns integer
return 2*level
endfunction
//Time until the next tick, GetRandomReal(4.,8.) is a random value between 4 and 8
private function GetNextTick takes integer level returns real
return GetRandomReal(4., 8.)/I2R(level)
endfunction
//The damage done per tick
private function GetSpellDamage takes integer level returns real
return 100.*I2R(level)
endfunction
//The radius of the totem ticks
private function GetTotemRadius takes integer level returns real
return 500.+50*I2R(level)
endfunction
//Don't touch the stuff below THIS comment ;) it is the spell core and you can't change any values
//here. Only change things if you want to change the way the spell works and you have enough knowledge of vJass.
private struct TotemStruct
unit caster
unit totem
real totemx
real totemy
player owner
integer abillevel
real damage
real radius
real maxtime
integer maxcount
real acttime
integer actcount
timer tim
private static method Enemys takes nothing returns boolean
return IsUnitEnemy(GetEnumUnit(), TempPlayer) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.405 and not IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)
endmethod
private static method RunAbility takes nothing returns nothing
local timer t = GetExpiredTimer()
local TotemStruct dat = TotemTable[t]
local real tick
local unit u
local group g
if GetUnitState(dat.totem, UNIT_STATE_LIFE) > 0.405 then
call DestroyEffect(AddSpecialEffect(TotemSFX, dat.totemx, dat.totemy))
set g = NewGroup()
set TempPlayer = dat.owner
call GroupEnumUnitsInRange(g, dat.totemx, dat.totemy, dat.radius, Condition(function TotemStruct.Enemys))
loop
set u = FirstOfGroup(g)
exitwhen u == null
call UnitDamageTarget(dat.caster, u, dat.damage, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffect(HitSFX, GetUnitX(u), GetUnitY(u)))
call GroupRemoveUnit(g, u)
endloop
call ReleaseGroup(g)
else
call dat.destroy()
endif
if dat.acttime >= dat.maxtime or dat.actcount >= dat.maxcount then
call dat.destroy()
else
set tick = GetNextTick(dat.abillevel)
set dat.acttime = dat.acttime+tick
set dat.actcount = dat.actcount+1
call TimerStart(dat.tim, tick, false, function TotemStruct.RunAbility)
endif
endmethod
static method create takes nothing returns TotemStruct
local TotemStruct dat
local integer level
set dat = TotemStruct.allocate()
set dat.caster = GetTriggerUnit()
set dat.owner = GetOwningPlayer(dat.caster)
set dat.totemx = GetSpellTargetX()
set dat.totemy = GetSpellTargetY()
set dat.totem = CreateUnit(dat.owner, TOTEM_ID, dat.totemx, dat.totemy, GetRandomReal(0., 360.))
set dat.abillevel = GetUnitAbilityLevel(dat.caster, ABILITY_ID)
set dat.damage = GetSpellDamage(dat.abillevel)
set dat.radius = GetTotemRadius(dat.abillevel)
set dat.maxtime = GetTotemDuration(dat.abillevel)
set dat.maxcount = GetTotemTicks(dat.abillevel)
set dat.acttime = GetNextTick(dat.abillevel)
set dat.actcount = 1
set dat.tim = NewTimer()
if TotemCount == 0 then
set TotemTable = HandleTable.create()
endif
set TotemCount = TotemCount+1
set TotemTable[dat.tim] = dat
call TimerStart(dat.tim, dat.acttime, false, function TotemStruct.RunAbility)
return dat
endmethod
private method onDestroy takes nothing returns nothing
set .caster = null
call KillUnit(.totem)
set .totem = null
set TotemCount = TotemCount-1
if TotemCount == 0 then
call TotemTable.destroy()
endif
call ReleaseTimer(.tim)
endmethod
endstruct
private function StartTotem takes nothing returns boolean
if GetSpellAbilityId() == ABILITY_ID then
call TotemStruct.create()
endif
return true
endfunction
private function InitTotem takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i >= 16
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, BOOLEXPR_TRUE)
set i = i+1
endloop
call TriggerAddCondition(t, Condition(function StartTotem))
endfunction
endscope
mfg Justify
PS: Table, TimerUtils, GroupUtils and BoolExprUtils required
Last edited: