TriggerHappy
...
- Reaction score
- 341
That would move to unit away from the caster but in the direction he was facing. Unless i missed something/
function TimerCallback takes nothing returns boolean
local Knock data = TT_GetData ()
local real x = GetUnitX (data.target)
local real y = GetUnitY (data.target)
//TT_PERIOD is being used here, so that we have a single timer interval figure for any TT spells
set x = x + data.cos * TT_PERIOD * SLIDE_SPEED
set y = y + data.sin * TT_PERIOD * SLIDE_SPEED
call SetUnitPosition (data.target, x, y)
set data.distance = data.distance - TT_PERIOD * SLIDE_SPEED
if data.distance <= 0 then
call data.destroy ()
//any other cleanup
return true
endif
return false
endfunction
function SpellActions takes nothing returns nothing
local Knock data = Knock.create ()
local real x1
local real y1
local real x2
local real y2
local real angle
set data.caster = GetTriggerUnit ()
set data.target = GetSpellTargetUnit ()
set x1 = GetUnitX (data.caster)
set y1 = GetUnitY (data.caster)
set x2 = GetUnitX (data.target)
set y2 = GetUnitY (data.target)
set angle = Atan2 (y2 - y1, x2 - x1)
set data.distance = MAX_DISTANCE
set data.cos = Cos (angle)
set data.sin = Sin (angle)
call TT_Start (function TimerCallback, data)
endfunction
set angle = Atan2 (y2 - y1, x2 - x1)
call EnumDestructablesInCircleBJ(100,GetUnitLoc(data.target),KillTree)
call EnumDestructablesInCircleBJ(100,GetUnitLoc(data.target),function KillTree)
<div class="bbCodeSpoiler">
<button type="button" class="bbCodeSpoiler-button button" data-xf-click="toggle" data-xf-init="tooltip" title="Click to reveal or hide spoiler"><span class="button-text">
<span>Spoiler</span>
</span></button>
<div class="bbCodeSpoiler-content">
<div class="bbCodeBlock bbCodeBlock--spoiler">
<div class="bbCodeBlock-content">scope Stunbolt initializer Init
globals
private constant integer SPELL = 039;BOLT039; // raw code of dummy spell
private constant real MAX_DISTANCE = 700
private constant real SLIDE_SPEED = 700
private constant string EFFECT = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
private constant boolean KillTrees = true
private constant string BLOOD = "Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl"
endglobals
// do not touch below this point//
struct Knock
unit target
unit caster
real x1
real y1
real cos
real sin
real DISTANCE
real angle
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction
private function KillTree takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
private function Ally takes nothing returns boolean
return IsUnitAlly(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())) == true
endfunction
private function Damage takes nothing returns nothing
local real t1 = GetUnitX(GetEnumUnit())
local real t2 = GetUnitY(GetEnumUnit())
call UnitDamageTarget(GetEnumUnit(),GetTriggerUnit(),30,true,false,ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffect(BLOOD,t1,t2))
endfunction
private function Knockback takes nothing returns boolean
local Knock data = TT_GetData()
local real x = GetUnitX(data.target)
local real y = GetUnitY(data.target)
local location area = GetUnitLoc(data.target)
local group g = GetUnitsInRangeOfLocMatching(200,area,Condition(function Ally))
call ForGroup(g,function Damage)
//TT_PERIOD is being used here, so that we have a single timer interval figure for any TT spells
set x = x + data.cos * TT_PERIOD * SLIDE_SPEED
set y = y + data.sin * TT_PERIOD * SLIDE_SPEED
if KillTrees == true then
call EnumDestructablesInCircleBJ(200,area,function KillTree)
endif
call DestroyEffect(AddSpecialEffect(EFFECT,x,y))
call SetUnitPosition (data.target, x, y)
set data.DISTANCE = data.DISTANCE - TT_PERIOD * SLIDE_SPEED
if data.DISTANCE <= 0 then
call data.destroy ()
call RemoveLocation(area)
return true
endif
return false
endfunction
private function Actions takes nothing returns nothing
local Knock data = Knock.create ()
local real x1
local real y1
local real x2
local real y2
local real angle
set data.caster = GetTriggerUnit ()
set data.target = GetSpellTargetUnit ()
set x1 = GetUnitX (data.caster)
set y1 = GetUnitY (data.caster)
set x2 = GetUnitX (data.target)
set y2 = GetUnitY (data.target)
set angle = Atan2 (y2 - y1, x2 - x1)
set data.DISTANCE = MAX_DISTANCE
set data.cos = Cos (angle)
set data.sin = Sin (angle)
call TT_Start (function Knockback, data)
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 Conditions))
call TriggerAddAction(t, function Actions)
endfunction
endscope</div>
</div>
</div>
</div>
globals
private group G = CreateGroup ()
private boolexpr FilterFunc //In your Init func, set this variable to:
//Condition (function GroupFunc)
private Knock gdata
//You may want a different name, I just generally label global struct data with a g <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />
endglobals
private function GroupFunc takes nothing returns boolean
local Knock a = gdata
//shorter var name for struct members, it's not a requirement though
local unit u = GetEnumUnit ()
if IsUnitEnemy (u, GetOwningPlayer (data.caster)) and IsUnitType (u, UNIT_TYPE_DEAD) == false and OtherConditions then
//OtherConditions would be anything like a structure/mechanical check, ethereal check, that sorta stuff - again, can be removed
call UnitDamagetarget (a.caster, u, damage, attack, ranged, attackType, damageType, weaponType)
call DestroyEffect (AddSpecialEffect (modelPath, GetUnitX (u), GetUnitY (u)))
endif
//Then, we can just return false and keep the group empty - it's a temporary group usage, so we have no need to store them.
return false
endfunction
private function TimerCallback takes nothing returns nothing
local Knock data = TT_GetData ()
//local declarations and such
//setting the value for the global
set gdata = data
//native group enumeration function instead of that GetUnitsInRange crap <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />
call GroupEnumUnitsInRange (G, groupX, groupY, radius, FilterFunc)
//other stuff
endfunction
//
set data.DISTANCE = data.DISTANCE - TT_PERIOD * SLIDE_SPEED
if data.DISTANCE <= 0 then
call data.destroy ()
//Hmmm...
call RemoveLocation(area)
return true
endif
//
set data.DISTANCE = data.DISTANCE - TT_PERIOD * SLIDE_SPEED
call RemoveLocation (area)
if data.DISTANCE <= 0 then
call data.destroy ()
return true
endif
scope Stunbolt initializer Init
globals
private constant integer SPELL = 039;BOLT039; // raw code of dummy spell
private constant real MAX_DISTANCE = 700
private constant real SLIDE_SPEED = 700
private constant string EFFECT = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
private constant boolean KillTrees = true
private constant string BLOOD = "Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl"
private Knock GROUPDATA
private boolexpr DAMGER
endglobals
// do not touch below this point//
struct Knock
unit target
unit caster
real x1
real y1
real cos
real sin
real DISTANCE
real angle
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction
private function KillTree takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
private function Damage takes nothing returns boolean
local Knock g = GROUPDATA
local unit e = GetEnumUnit()
local real t1 = GetUnitX(e)
local real t2 = GetUnitY(e)
if IsUnitAlly(e,GetOwningPlayer(g.caster)) == false then //and IsUnitDeadBJ(e) == false then
call UnitDamageTarget(e,g.caster,30,true,false,ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffect(BLOOD,t1,t2))
endif
return false
endfunction
private function Knockback takes nothing returns boolean
local Knock data = TT_GetData()
local real x = GetUnitX(data.target)
local real y = GetUnitY(data.target)
local location area = GetUnitLoc(data.target)
local group g = CreateGroup()
set GROUPDATA = data
call GroupEnumUnitsInRange(g,GetUnitX(data.target),GetUnitY(data.target),200,DAMGER)
//TT_PERIOD is being used here, so that we have a single timer interval figure for any TT spells
set x = x + data.cos * TT_PERIOD * SLIDE_SPEED
set y = y + data.sin * TT_PERIOD * SLIDE_SPEED
if KillTrees == true then
call EnumDestructablesInCircleBJ(200,area,function KillTree)
endif
call DestroyEffect(AddSpecialEffect(EFFECT,x,y))
call SetUnitPosition (data.target, x, y)
set data.DISTANCE = data.DISTANCE - TT_PERIOD * SLIDE_SPEED
call RemoveLocation(area)
if data.DISTANCE <= 0 then
call data.destroy ()
return true
endif
return false
endfunction
private function Actions takes nothing returns nothing
local Knock data = Knock.create ()
local real x1
local real y1
local real x2
local real y2
local real angle
set data.caster = GetTriggerUnit ()
set data.target = GetSpellTargetUnit ()
set x1 = GetUnitX (data.caster)
set y1 = GetUnitY (data.caster)
set x2 = GetUnitX (data.target)
set y2 = GetUnitY (data.target)
set angle = Atan2 (y2 - y1, x2 - x1)
set data.DISTANCE = MAX_DISTANCE
set data.cos = Cos (angle)
set data.sin = Sin (angle)
call TT_Start (function Knockback, data)
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 Conditions))
call TriggerAddAction(t, function Actions)
set DAMGER = Filter(function Damage)
endfunction
endscope
Remainder of the code has yet to be looked at - don't think I really took a in-depth look at anything other than knockback yet A spellpack can't really be approved on the basis of a single component of the packWill the mods approve this?
If that's the case, you will just find some people submitting absolute rubbish (to put it nicely) because they are desperate to get some rep. People say the resource, they think "..." and either say it, or skip past it. Then, when people wonder where the rep for submission is, they do it again.Maybe you should make a system like submitting spells get a certain REP , models , icons , maps so it kind of motivate people.
If that's the case, you will just find some people submitting absolute rubbish (to put it nicely) because they are desperate to get some rep. People say the resource, they think "..." and either say it, or skip past it. Then, when people wonder where the rep for submission is, they do it again.
People currently do submit stuff which (IMO) is either sh*te with regard to material (and sometimes everything else) such as this (my post in the thread probably sums up alot of it ^_^), or just plain useless, probably because it's something that cast majority of people already (should) know
call DestroyBoolExpr(CONDITION)