Phase Nova v1.00 by BlackRose
Last updated: Never
Big screenie!
When you learn it, you get an ability called Angle Setter.
When you cast it you disappear, birdies go outwards, after xxx distance they disappear and become illusions of the caster unit, they move outwards to confuse enemies.
You then move instantly to some angle, based on the level of Angle Setter.
When you cast Angle Setter, it changes angle of which you will teleport.
The General
Code: vJASS
Lags: Unsure.
Leaks: Don't think so.
Requirements
Coding:
JASS:
scope PhaseNova initializer Init
//-----------------------------------------
// Phase Nova v1.00 by BlackRose
//-----------------------------------------
// Last updated: 1st June 2009
// Sends out birds, after they fly some distance, you morph into one of them. Illusions are made to confuse enemy <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" />
//-----------------------------------------
// Does this lag? Not for me?
// Is this fully MUI? You can only have up to 400 instances...
//-----------------------------------------
// How to import to your map:
// 1. Copy this trigger, and TimerUtils into your map.
// 2. Copy the objects into your map.
// 3. Find the rawcode of objects pasted and replace them here. Bird rawcodes are at the bottom in Init function.
// 4. Done, don't remove "Phase Nova v1.xx" by BlackRose if you use it.
// RESOURCE CREDITS:
// - Vexorian: TimerUtils
// - NewGen.
//-----------------------------------------
// TheHelper.net
// clanmapz.com
// wc3campaigns.net
// BJDebugMsg last for 60 seconds, hateful!
private function DEBUG takes string s returns nothing
debug call DisplayTimedTextToPlayer( Player(0), 0, 0, 1.500, s )
endfunction
// Quicker.
private function TT takes string s, location l returns nothing
debug local texttag tt = CreateTextTag()
debug call SetTextTagPermanent( tt, false )
debug call SetTextTagTextBJ( tt, s, 10.00 )
debug call SetTextTagPosBJ( tt, l, 0 )
debug call SetTextTagVelocityBJ( tt, 64.00, 90.00 )
debug call SetTextTagLifespan( tt, 3.50 )
debug call SetTextTagFadepoint( tt, 3.00 )
debug set tt = null
endfunction
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// LIST OF CONFIGURABLES
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
globals
private constant integer SPELL_ID = 039;A001039; //<-- Object rawcodes. Main spell.
private constant integer LEARN_ID = 039;A000039; //<-- Angle setter rawcode.
private integer array BIRD_ID //<-- Dummy bird's id, set in Init function.
private constant boolean SELECT_HERO = true //<-- Reselects the hero after he shifts.
private constant boolean SHIFT_CAMERA = false //<-- Shifts camera to position of hero if on.
private constant real TIMER_INTERVAL = 0.04 //<-- Timer interval.
private constant real BIRD_SPEED = 20 //<-- Move bird 20 every TIMER_INTERVAL in angle.
private constant real ANGLE_VARIATIONS = 12 //<-- How many angle variations there can be. You need to edit the
// object editor if you change this.
private constant integer BIRD_AMOUNT = 20 //<-- How many birdies <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" />
// Effect shown for angle setting.
private constant string MODEL = "Abilities\\Spells\\Human\\Polymorph\\PolyMorphDoneGround.mdl"
// (Below) Damage properties.
private constant boolean ATTACK = true
private constant boolean RANGED = false
private constant attacktype ATK_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype DMG_TYPE = DAMAGE_TYPE_MAGIC
private constant weapontype WPN_TYPE = null
endglobals
// How far birdy go and teleport distance.
private function GetDistance takes integer level returns real
return level * 200. + 400.
endfunction
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
globals
private constant real ANGLE_DIFF = 360 / BIRD_AMOUNT
private group LearnGroup = CreateGroup()
private constant real ANGLE_VAR = 360 / ANGLE_VARIATIONS
endglobals
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private struct PhaseNova
unit array Bird[BIRD_AMOUNT]
unit Caster
player Owner
real cx
real cy
integer uLevel
timer t
real DistanceTrav
real Distance = 0
static method create takes nothing returns PhaseNova
local PhaseNova d = PhaseNova.allocate()
local integer i = 0
local integer btype = 0
local real ang = 0
set d.t = NewTimer()
set d.Caster = GetTriggerUnit()
set d.Owner = GetOwningPlayer( d.Caster )
set d.cx = GetUnitX( d.Caster )
set d.cy = GetUnitY( d.Caster )
set d.uLevel = GetUnitAbilityLevel( d.Caster, SPELL_ID )
set d.DistanceTrav = GetDistance( d.uLevel )
call ShowUnit( d.Caster, false )
loop
exitwhen i == BIRD_AMOUNT
set d.Bird<i> = CreateUnit( d.Owner, BIRD_ID[btype], d.cx, d.cy, ang )
set btype = btype + 1
if btype == 4 then
set btype = 0
endif
set ang = ang + ANGLE_DIFF
set i = i + 1
endloop
return d
endmethod
static method MoveOut takes nothing returns nothing
local PhaseNova d = GetTimerData( GetExpiredTimer() )
local integer i = 0
local real newx
local real newy
local real angle
local integer level
local unit u
loop
exitwhen i == BIRD_AMOUNT
set newx = GetUnitX( d.Bird<i> ) + BIRD_SPEED * Cos( bj_DEGTORAD * GetUnitFacing( d.Bird<i> ) )
set newy = GetUnitY( d.Bird<i> ) + BIRD_SPEED * Sin( bj_DEGTORAD * GetUnitFacing( d.Bird<i> ) )
call SetUnitPosition( d.Bird<i>, newx, newy )
set i = i + 1
endloop
set d.Distance = d.Distance + BIRD_SPEED
if d.DistanceTrav < d.Distance then
call ShowUnit( d.Caster, true )
if (GetLocalPlayer() == d.Owner) and SELECT_HERO then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ClearSelection()
call SelectUnit(d.Caster, true)
endif
set level = GetUnitAbilityLevel( d.Caster, LEARN_ID )
set newx = d.cx + d.DistanceTrav * Cos( (( level * 30 ) - 30 ) * bj_DEGTORAD )
set newy = d.cy + d.DistanceTrav * Sin( (( level * 30 ) - 30 ) * bj_DEGTORAD )
call SetUnitX( d.Caster, newx )
call SetUnitY( d.Caster, newy )
if (GetLocalPlayer() == d.Owner) and SHIFT_CAMERA then
// Use only local code (no net traffic) within this block to avoid desyncs.
call PanCameraTo( GetUnitX( d.Caster ), GetUnitY( d.Caster ) )
endif
set i = 0
loop
exitwhen i == BIRD_AMOUNT
call KillUnit( d.Bird<i> )
set i = i + 1
endloop
set i = 0
loop
exitwhen i == ANGLE_VARIATIONS
set newx = d.cx + d.DistanceTrav * Cos( bj_DEGTORAD * ( i * ANGLE_VAR ) )
set newy = d.cy + d.DistanceTrav * Sin( bj_DEGTORAD * ( i * ANGLE_VAR ) )
set angle = bj_RADTODEG * Atan2( d.cy - newy, d.cx - newx )
set u = CreateUnit( d.Owner, BIRD_ID[0], newx, newy, 0 )
call SetUnitUserData( u, R2I(angle) )
call ShowUnit( u, false )
call UnitApplyTimedLife( u, 039;BTLF039;, 0.50 )
call IssueTargetOrderById( u, 852274, d.Caster )
set i = i + 1
endloop
call ReleaseTimer( d.t )
call d.destroy()
endif
set u = null
endmethod
endstruct
private function Main takes nothing returns nothing
local PhaseNova d = PhaseNova.create()
call TimerStart( d.t, TIMER_INTERVAL, true, function PhaseNova.MoveOut )
call SetTimerData( d.t, d )
endfunction
//-------------------------------------------------------------------------------
// If the learning skill is Angle Setter, level of main skill is > 0 and
// Learning unit is not in the group LearnGroup.
private function LearnCond takes nothing returns boolean
return GetLearnedSkill() == SPELL_ID and GetUnitAbilityLevel( GetTriggerUnit(), SPELL_ID ) > 0 and IsUnitInGroup( GetTriggerUnit(), LearnGroup ) == false
endfunction
// When learned the main skill, add Angle Setter to caster.
private function LearnAdd takes nothing returns nothing
local unit u = GetTriggerUnit()
call UnitAddAbility( u, LEARN_ID )
call GroupAddUnit( LearnGroup, u )
set u = null
endfunction
// Is the spell casted Angle Setter?
private function AngCond takes nothing returns boolean
return GetSpellAbilityId() == LEARN_ID
endfunction
private function AngAct takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer level = GetUnitAbilityLevel( u, LEARN_ID )
local integer mainLevel = GetUnitAbilityLevel( u, SPELL_ID )
// Reals dont take up much do they? This is for easier reading.
local real x
local real y
local real angle
// Shows the angle in which you will phase out on next cast. For caster only.
if GetLocalPlayer() == GetOwningPlayer( u ) then
set angle = bj_DEGTORAD * ( level * ANGLE_VAR )
set x = GetUnitX( u ) + GetDistance( mainLevel ) * Cos( angle )
set y = GetUnitY( u ) + GetDistance( mainLevel ) * Sin( angle )
call DestroyEffect( AddSpecialEffect( MODEL, x, y ) )
endif
// If level is 12, reset angle to 0/360.
if level == ANGLE_VARIATIONS then
call SetUnitAbilityLevel( u, LEARN_ID, 1 )
// Otherwise just set it to level + 1.
else
call SetUnitAbilityLevel( u, LEARN_ID, level + 1 )
endif
set u = null
endfunction
//-------------------------------------------------------------------------------
//...lol.
private function SummonCond takes nothing returns boolean
return GetUnitTypeId( GetSummoningUnit() ) == BIRD_ID[0]
endfunction
private function SummonAct takes nothing returns nothing
local unit imageunit = GetSummonedUnit()
local unit summer = GetSummoningUnit()
local integer angle = GetUnitUserData( summer ) + 180
local location l
local location moveLoc
// Move the image right back at its caster's foot.
call SetUnitPosition( imageunit, GetUnitX( summer ), GetUnitY( summer ) )
// Now order it to move.
// Working in angles as radians stuff up here...
set l = GetUnitLoc( imageunit )
set moveLoc = PolarProjectionBJ( l, 600., angle )
call IssuePointOrderLoc( imageunit, "move", moveLoc )
debug call TT( R2S( angle ), GetUnitLoc( summer ) )
call RemoveLocation( l )
call RemoveLocation( moveLoc )
set l = null
set moveLoc = null
set imageunit = null
set summer = null
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 Cond ) )
call TriggerAddAction( t, function Main )
//-------------------------------------------------------------------------------
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( t, Condition( function LearnCond ) )
call TriggerAddAction( t, function LearnAdd )
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function AngCond ) )
call TriggerAddAction( t, function AngAct )
//-------------------------------------------------------------------------------
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SUMMON )
call TriggerAddCondition( t, Condition( function SummonCond ) )
call TriggerAddAction( t, function SummonAct )
// Set bird raw codes here.
// Blue, red, green , purple.
set BIRD_ID[0] = 039;e000039;
set BIRD_ID[1] = 039;e001039;
set BIRD_ID[2] = 039;e002039;
set BIRD_ID[3] = 039;e003039;
endfunction
endscope</i></i></i></i></i></i></i>