Komaqtion
You can change this now in User CP.
- Reaction score
- 469
Hi !
I was just making a spell request by Avaleirra (Official thread here and though there has already been submissions, I'll make it anyway XD) and I thought I could use a rect as the "line" between the units, meaning that it would always stay the same size, just turn and move...
But I noticed that the [ljass]MoveRectTo[/ljass] native takes newCenterX and newCenterY which means that it can't "turn" in the way I wanted
And then I ran into more trouble with it, as I noticed when I tested the spell (Which might not be done yet, but I'd believe it should work up to that point at least...)
I now know that rects are always rectangular (Which I kinda new before, but was just hoping I was wrong XD)
But the spell I'm making needs to register when units pass through a "line", and this was the only way I could think of
Any ideas ofmaking this spell work as intended ? :S
I was just making a spell request by Avaleirra (Official thread here and though there has already been submissions, I'll make it anyway XD) and I thought I could use a rect as the "line" between the units, meaning that it would always stay the same size, just turn and move...
But I noticed that the [ljass]MoveRectTo[/ljass] native takes newCenterX and newCenterY which means that it can't "turn" in the way I wanted
And then I ran into more trouble with it, as I noticed when I tested the spell (Which might not be done yet, but I'd believe it should work up to that point at least...)
I now know that rects are always rectangular (Which I kinda new before, but was just hoping I was wrong XD)
But the spell I'm making needs to register when units pass through a "line", and this was the only way I could think of
Any ideas ofmaking this spell work as intended ? :S
JASS:
scope SpiritLink initializer Init// requires T32
globals
private constant integer SPELL_ID = 039;SPIR039;
private constant real DURATION = 20.0
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_UNKNOWN
private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
endglobals
private constant function Damage takes integer spellvl returns real
return spellvl * 50.0
endfunction
private constant function Heal takes integer spellvl returns real
return spellvl * 50.0
endfunction
globals
private location Z = Location( 0.0, 0.0 )
private group new = CreateGroup()
private unit c = null
private player owner = null
private integer lvl = 0
endglobals
native UnitAlive takes unit id returns boolean
private struct Link extends array
//! runtextmacro AIDS()
lightning light
unit cast
unit targ
rect r
integer tick
group check
private method AIDS_onCreate takes nothing returns nothing
set this.tick = R2I( DURATION / T32_PERIOD )
set this.check = CreateGroup()
endmethod
private static method Filters takes nothing returns boolean
return UnitAlive( GetFilterUnit() ) == true
endmethod
private static method CheckGroups takes nothing returns nothing
local unit u = GetEnumUnit()
if IsUnitInGroup( u, new ) != true then
if IsUnitEnemy( u, owner ) then
call UnitDamageTarget( c, u, Damage( lvl ), true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE )
call DisplayTextToPlayer( Player( 0 ), 0.0, 0.0, "Damage dealt: " + R2S( Damage( lvl ) ) )
else
call SetWidgetLife( u, GetWidgetLife( u ) + Heal( lvl ) )
call DisplayTextToPlayer( Player( 0 ), 0.0, 0.0, "Damage healed: " + R2S( Heal( lvl ) ) )
endif
else
call GroupRemoveUnit( new, u )
call DisplayTextToPlayer( Player( 0 ), 0.0, 0.0, "The unit hasn039;t moved..." )
endif
endmethod
private method periodic takes nothing returns nothing
local real x1 = GetUnitX( this.cast )
local real x2 = GetUnitX( this.targ )
local real y1 = GetUnitY( this.cast )
local real y2 = GetUnitY( this.targ )
local real z1
local real z2
set this.tick = this.tick - 1
call DisplayTextToPlayer( Player( 0 ), 0.0, 0.0, "Tick !" )
if this.tick >= 0 then
// ========================================================== \\
call MoveLocation( Z, x1, y1 )
set z1 = GetLocationZ( Z ) + GetUnitFlyHeight( cast )
// This is to get the height of both the caster and target <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /> \\
call MoveLocation( Z, x2, y2 )
set z2 = GetLocationZ( Z ) + GetUnitFlyHeight( targ )
// ========================================================== \\
call MoveLightningEx( this.light, true, x1, y1, z1, x2, y2, z2 )
call RemoveRect( this.r )
set this.r = Rect( x1, y1, x2, y2 )
set owner = GetOwningPlayer( this.cast )
set cast = this.cast
set lvl = GetUnitAbilityLevel( this.cast, SPELL_ID )
call GroupEnumUnitsInRect( new, this.r, Filter( function thistype.Filters ) )
call ForGroup( this.check, function thistype.CheckGroups )
else
call DestroyLightning( this.light )
call RemoveRect( this.r )
call this.stopPeriodic()
endif
endmethod
implement T32xs
method StartPeriod takes unit caster, unit target, lightning light, rect r returns nothing
set this.cast = caster
set this.targ = target
set this.light = light
set this.r = r
set owner = GetOwningPlayer( caster )
call GroupEnumUnitsInRect( this.check, this.r, Filter( function thistype.Filters ) )
call this.startPeriodic()
endmethod
endstruct
private function Actions takes nothing returns boolean
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local player p = GetOwningPlayer( u )
local real x1 = GetUnitX( u )
local real x2 = GetUnitX( t )
local real y1 = GetUnitY( u )
local real y2 = GetUnitY( t )
local real z1
local real z2
if GetSpellAbilityId() == SPELL_ID then
call MoveLocation( Z, x1, y1 )
set z1 = GetLocationZ( Z ) + GetUnitFlyHeight( u )
call MoveLocation( Z, x2, y2 )
set z2 = GetLocationZ( Z ) + GetUnitFlyHeight( t )
call Link[ u ].StartPeriod( u, t, AddLightningEx( "SPLK", false, x1, y1, z1, x2, y2, z2 ), Rect( x1, y1, x2, y2 ) )
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger() // Here we're creating the trigger <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" />
local integer i = 0 // This will be used for looping through the players
loop
call TriggerRegisterPlayerUnitEvent( t, Player( i ), EVENT_PLAYER_UNIT_SPELL_EFFECT, null ) // And here the looping goes.
// And also, registering the events to the previusly created trigger
set i = i + 1
exitwhen i >= 12
endloop
call TriggerAddCondition( t, Condition( function Actions ) ) // And here we're adding the condition/action to the trigger
endfunction
endscope