~GaLs~
† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
- Reaction score
- 180
Shiva Faeries Complete Version
View attachment [Contest] Shiva Faerie v1.2.w3x
View attachment [Contest] Shiva Faerie v1.2.w3x
//===========================================================================
//================================ SPELL ====================================
//============================ Instructions =================================
//===========================================================================
// MUI; requires vJASS; uses ABC and CSSafety
//===========================================================================
// 1. Go to the Object Editor, and copy + paste the following:
// Units
// * Dummy Caster
// * Whip Segment
// Abilities
// * Cool Whip: Add this ability to the Hero; make sure the "Base Order ID"
// does not conflict with any other spell on the Hero.
// * Silence (for Dummy): make sure that the buff is set to the custom
// "Cool Whip (Caster)" buff. This is the buff that will show on the Hero.
// * Permanent Immolation (for Whip Segment): make sure that the buff is set
// to the custom "Permanent Immolation (Target)" buff.
// * Slow Aura (for Whip Segment)
// Buffs
// * Cool Whip (Caster)
// * Permanent Immolation (Target): This buff applies the snowflakes-looking
// effects on targets that are hit by the whip.
// 2. Copy the following triggers:
// * ABC: this is Cohadar's ABC Struct Attachment system
// * This trigger
// 3. Other options:
// * Hero: Note that you may want to change "Stats - Can Flee" to False to
// make this skill a little easier to use. Otherwise, while the Hero is
// silenced, it will tend to run away from enemies since it can't attack.
// 4. To adjust the balance of the skill, you can change some of the following
// values:
// Abilities
// * Cool Whip: Cooldown, Mana Cost
// * Permanent Immolation (for Whip Segment): Damage, damage interval, AoE
// * Slow Aura (for Whip Segment): Attack Speed Factor, Movement Speed Factor, AoE
// 5. Make sure that the rawcodes specified below reference the proper units,
// abilities, or buffs.
scope CWScope
globals
constant integer ab_Hero = 039;A000039; //Ability ID of "Cool Whip"
constant integer un_Dmmy = 039;h000039; //Unit ID of "Dummy Caster"
constant integer ab_Slnc = 039;A001039; //Ability ID of "Silence (for Dummy)"
// constant integer bf_Cool = 'B000' //Buff ID of "Cool Whip (Caster)"
constant integer un_Whip = 039;h001039; //Unit ID of "Whip Segment"
constant integer ab_Immo = 039;A002039; //Ability ID of "Permanent Immolation (for Whip Segment)"
constant integer ab_Slow = 039;A003039; //Ability ID of "Slow Aura (for Whip Segment)"
group tempgroup = CreateGroup()
endglobals
//###########################################################################
//############## This is the CSSafety system by Vexorian ####################
globals
private timer array T
private integer N = 0
endglobals
private function NewTimer takes nothing returns timer
if (N==0) then
return CreateTimer()
endif
set N=N-1
return T[N]
endfunction
private function ReleaseTimer takes timer t returns nothing
call PauseTimer(t)
if (N==8191) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
set T[N]=t
set N=N+1
endif
endfunction
//####################### end of the CSSafety system ########################
//###########################################################################
//===========================================================================
struct CWstruct
unit hero
integer c1
integer c2
group cwgroup
endstruct
//===========================================================================
function CW_Cond takes nothing returns boolean
return GetSpellAbilityId() == ab_Hero
endfunction
function CW_TimerActions takes nothing returns nothing
local CWstruct data
local timer t = GetExpiredTimer()
local real heroX
local real heroY
local real face_rad
local unit u
local integer cv
local real dX
local real dY
local real dist
local real ang_rad
local real X
local real Y
//Retrieve values from struct "data" that is attached to the timer "t"
set data = GetTimerStructA(t)
set heroX = GetUnitX(data.hero)
set heroY = GetUnitY(data.hero)
set face_rad = GetUnitFacing(data.hero) * 0.01745
call SetUnitAnimation(data.hero, "spell")
call GroupAddGroup(data.cwgroup, tempgroup)
loop
set u = FirstOfGroup(tempgroup)
exitwhen u == null
set cv = GetUnitUserData(u)
set dX = cv * 30.00
set dY = Sin(cv * 0.52360) * cv * (IAbsBJ(ModuloInteger((data.c1 + 10), 40) - 20) - 10)
set dist = SquareRoot(dX * dX + dY * dY)
set ang_rad = Atan2(dY, dX) + face_rad
set X = heroX + dist * Cos(ang_rad)
set Y = heroY + dist * Sin(ang_rad)
call SetUnitPosition(u, X, Y)
call GroupRemoveUnit(tempgroup, u)
endloop
set data.c1 = data.c1 + 1
//If Hero is dead, set value of data.c1 to data.c2 and kill whip segments
if GetUnitState(data.hero, UNIT_STATE_LIFE) <= 0 then
set data.c1 = data.c2
call GroupAddGroup(data.cwgroup, tempgroup)
loop
set u = FirstOfGroup(tempgroup)
exitwhen u == null
call KillUnit(u)
call GroupRemoveUnit(tempgroup, u)
endloop
endif
//If data.c1 has reached the value of data.c2, stop repeating timer and reset Hero's animation
if data.c1 >= data.c2 then
if GetUnitState(data.hero, UNIT_STATE_LIFE) <= 0 then
call SetUnitAnimation(data.hero, "death")
else
call SetUnitAnimation(data.hero, "stand")
endif
call ClearTimerStructA(t)
call data.destroy()
call ReleaseTimer(t)
endif
endfunction
function CW_Actions takes nothing returns nothing
local CWstruct data = CWstruct.create()
local real heroX
local real heroY
local real face_rad
local real X
local real Y
local integer i = 1
local integer whipcount
local real dur
local unit u
local timer t = NewTimer()
local group cwgroup
//Set struct values for use in other functions
set data.hero = GetTriggerUnit()
set data.cwgroup = CreateGroup()
set data.c1 = 0
set heroX = GetUnitX(data.hero)
set heroY = GetUnitY(data.hero)
set face_rad = GetUnitFacing(data.hero) * 0.01745
set whipcount = GetUnitAbilityLevel(data.hero, ab_Hero) * 6 + 15
set dur = GetUnitAbilityLevel(data.hero, ab_Hero) * 2.00 + 4.00
set u = CreateUnit(GetOwningPlayer(data.hero), un_Dmmy, heroX, heroY, 0)
call UnitApplyTimedLife(u, 039;BTLF039;, 1.00)
call UnitAddAbility(u, ab_Slnc)
call SetUnitAbilityLevel(u, ab_Slnc, GetUnitAbilityLevel(data.hero, ab_Hero))
call IssuePointOrder(u, "silence", heroX, heroY)
call SetUnitAnimation(data.hero, "spell")
set u = null
loop
exitwhen i > whipcount
set X = heroX + i * 30.00 * Cos(face_rad)
set Y = heroY + i * 30.00 * Sin(face_rad)
set u = CreateUnit(GetOwningPlayer(data.hero), un_Whip, X, Y, 0)
call UnitApplyTimedLife(u, 039;BTLF039;, dur)
call SetUnitTimeScale(u, 0.20)
call UnitAddAbility(u, ab_Immo)
call UnitAddAbility(u, ab_Slow)
call SetUnitUserData(u, i)
call GroupAddUnit(data.cwgroup, u)
set u = null
set i = i + 1
endloop
//Set one more struct value for use in other functions
set data.c2 = R2I(dur / 0.03)
//Assign struct values "data" to the timer "t"
call SetTimerStructA(t, data)
call TimerStart(t, 0.03, true, function CW_TimerActions)
//Null local variables
set t = null
endfunction
//===========================================================================
function InitTrig_CoolWhip takes nothing returns nothing
set gg_trg_CoolWhip = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_CoolWhip, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_CoolWhip, Condition(function CW_Cond))
call TriggerAddAction(gg_trg_CoolWhip, function CW_Actions)
endfunction
endscope
The deadline is 2 weeks from now, December 26th, 2007 at midnight.
scope ShivaFaerie
//===================================================================================
// Shiva Faerie
// by kentchow75/~GaLs
//===================================================================================
//
// Implemention Instruction
//
//--------------------------------------------------------------------------------
// -Object Needed to be copied from Object Editor to your map.
// [ Ability ]
// 1. Shiva Faerie [R]
// 2. Frozening [F] [Shiva Faerie]
//
// [ Buff ]
// 1. Frozen [Shiva Faerie]
//
// [ Unit ]
// 1. Dummy Frozer [Shiva Faerie]
// 2. Shiva Faerie [Shiva Faerie]
//--------------------------------------------------------------------------------
// -Trigger
// 1. Copy this whole trigger to your map.
// 2. Copy the HSAS trigger to your map if you don't have 1 in your map. (HSAS v3.30 or above required)
// 3. CSSafety
//--------------------------------------------------------------------------------
// -Requirements
// 1. Jass NewGen WorldEditor from <a href="http://www.wc3campaigns.net" target="_blank" class="link link--external" rel="nofollow ugc noopener">www.wc3campaigns.net</a>. ( v4b and above )
//--------------------------------------------------------------------------------
// -Credits
// 1. Thanks to PandaMine for his brilliant HSAS system.
//--------------------------------------------------------------------------------
//===================================================================================
// Implementation End
//===================================================================================
globals
//*******************************************************************************************
// Configuration (This is where you need to edit to make the spell works in your map)
//*******************************************************************************************
//=================================================================
// <- Rawcode -> //
private constant integer SF_ID = 039;A000039;
//Rawcode of the Shiva Faerie [R]. (Ability)
private constant integer SF_FROZENING = 039;A001039;
//Rawcode of the Frozening [F] [Shiva Faerie]. (Ability)
private constant integer SF_FAERIE = 039;h000039;
//Rawcode of Shiva Faerie. (Unit)
private constant integer SF_FROZER = 039;h001039;
//Rawcode of Dummy Frozer [Shiva Faerie]. (Unit)
private constant integer SF_FROZENID = 039;B000039;
//Rawcode of the Frozen [Shiva Faerie]. (Buff)
// <- Rawcode End ->//
//=================================================================
// <- Speed -> //
private constant real SF_FLYSPEED = .04
// Flying speed of those faeries. (The lower the number is, the faster it flies.)
//<- Speed End ->//
//=================================================================
endglobals
//=================================================================
// <- Faerie Number -> //
private constant function FaerieNum takes integer lvl returns integer
return lvl * 3 //The formula for calculating how many faerie to be created. (Level x 3)
endfunction
//=================================================================
//=================================================================
// <- Maximun Radius -> //
private constant function MaxRadius takes integer lvl returns real
return lvl * 300. //The max radius of how far the faerie will fly around you. (Level x 300)
endfunction
//=================================================================
//=================================================================
// <- Duration -> //
private constant function Duration takes integer lvl returns real
return lvl * 10. //How long will the spell effect last. (Level x 10 second)
endfunction
//=================================================================
//*******************************************************************************************
// Configuration End
//*******************************************************************************************
// -----------------------> Do not edit anything below this line. <-----------------------//
// -----------------------> Do not edit anything below this line. <-----------------------//
// -----------------------> Do not edit anything below this line. <-----------------------//
private struct ShiFae
unit caster
unit array Faerie[300]
integer level
integer MaxFaerie
real MaxRad
real Dura
real cx
real cy
real array fnx[300]
real array fny[300]
trigger froze
timer Fmove
timer DS
//---------------------------------------------------------------------------------------
method offsetX takes real source, real dist, real angle returns real
return source + dist * Cos(angle * bj_DEGTORAD)
endmethod
method offsetY takes real source, real dist, real angle returns real
return source + dist * Sin(angle * bj_DEGTORAD)
endmethod
method AngBtwReal takes real x1, real y1, real x2, real y2 returns real
return bj_RADTODEG * Atan2(y2 - y1, x2 - x1)
endmethod
method DistBtwReal takes real x1, real y1, real x2, real y2 returns real
local real dx = x2 - x1
local real dy = y2 - y1
return SquareRoot(dx * dx + dy * dy)
endmethod
//---------------------------------------------------------------------------------------
static method create takes unit cas returns ShiFae
local ShiFae sf = ShiFae.allocate()
set sf.caster = cas
set sf.level = GetUnitAbilityLevel(cas,SF_ID)
set sf.cx = GetWidgetX(cas)
set sf.cy = GetWidgetY(cas)
set sf.froze = CreateTrigger()
set sf.Fmove = CreateTimer()
set sf.DS = CreateTimer()
set sf.MaxFaerie = FaerieNum(sf.level)
set sf.MaxRad = MaxRadius(sf.level)
set sf.Dura = Duration(sf.level)
call AttachStruct1(sf.froze,sf)
return sf
endmethod
method onDestroy takes nothing returns nothing
call DestroyTrigger(.froze)
call PauseTimer(.Fmove)
call DestroyTimer(.Fmove)
call DestroyTimer(.DS)
endmethod
static method frozeAct takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local ShiFae sf = GetAttachedStruct1(t)
local unit u
if GetUnitAbilityLevel(GetTriggerUnit(),SF_FROZENID) == 0 then
set u = CreateUnit(GetOwningPlayer(sf.caster),SF_FROZER,GetWidgetX(GetTriggerUnit()),GetWidgetY(GetTriggerUnit()),GetUnitFacing(GetTriggerUnit()))
call UnitAddAbility(u,SF_FROZENING)
call SetUnitAbilityLevel(u,SF_FROZENING,sf.level)
call UnitApplyTimedLife(u,039;BTLF039;,1)
call IssueTargetOrder(u,"entanglingroots",GetTriggerUnit())
endif
set u = null
set t = null
endmethod
static method DSAct takes nothing returns nothing
local timer t = GetExpiredTimer()
local ShiFae sf = GetAttachedStruct1(t)
call sf.destroy()
set t = null
endmethod
endstruct
//-----------------------------------------------------------------------
private function FmoveAct takes nothing returns nothing
local timer t = GetExpiredTimer()
local ShiFae sf = GetAttachedStruct1(t)
local integer start = 1
local real fx
local real fy
local real randomAngle
local real randomRadius
local real DBR //(Distance Between Real)
local real ABR //(Angle Between Real)
loop
exitwhen start>sf.MaxFaerie
set fx = GetWidgetX(sf.Faerie[start])
set fy = GetWidgetY(sf.Faerie[start])
set DBR = sf.DistBtwReal(fx,fy,sf.fnx[start],sf.fny[start])
if DBR <= 50 then
set randomAngle = GetRandomReal(0,360)
set randomRadius = GetRandomReal(0,sf.MaxRad)
set sf.fnx[start] = sf.offsetX(GetUnitX(sf.caster),randomRadius,randomAngle)
set sf.fny[start] = sf.offsetY(GetUnitY(sf.caster),randomRadius,randomAngle)
set ABR = sf.AngBtwReal(fx,fy,sf.fnx[start],sf.fny[start])
if fx != sf.fnx[start] then
call SetUnitX(sf.Faerie[start],sf.offsetX(fx,12,ABR))
endif
if fy != sf.fny[start] then
call SetUnitY(sf.Faerie[start],sf.offsetY(fy,12,ABR))
endif
endif
if DBR !=0 then
set ABR = sf.AngBtwReal(fx,fy,sf.fnx[start],sf.fny[start])
if fx != sf.fnx[start] then
call SetUnitX(sf.Faerie[start],sf.offsetX(fx,12,ABR))
endif
if fy != sf.fny[start] then
call SetUnitY(sf.Faerie[start],sf.offsetY(fy,12,ABR))
endif
endif
set start = start+1
endloop
set t = null
endfunction
private function SFCond takes nothing returns boolean
return GetSpellAbilityId() == SF_ID
endfunction
private function SFAct takes nothing returns nothing
local ShiFae sf = ShiFae.create(GetSpellAbilityUnit())
local integer start = 1
local real randomAngle
local real randomRadius
//<- Create Faerie ->//
loop
exitwhen start>sf.MaxFaerie
set sf.Faerie[start] = CreateUnit(GetOwningPlayer(sf.caster),SF_FAERIE,sf.cx,sf.cy,GetRandomReal(0,360))
call UnitApplyTimedLife(sf.Faerie[start],039;BTLF039;,sf.Dura)
call TriggerRegisterUnitInRange(sf.froze,sf.Faerie[start],100,null)
set randomAngle = GetRandomReal(0,360)
set randomRadius = GetRandomReal(0,sf.MaxRad)
set sf.fnx[start] = sf.offsetX(GetUnitX(sf.Faerie[start]),randomRadius,randomAngle)
set sf.fny[start] = sf.offsetY(GetUnitY(sf.Faerie[start]),randomRadius,randomAngle)
set start = start+1
endloop
//<- Create Faerie End ->//
call TriggerAddAction(sf.froze,function ShiFae.frozeAct)
call AttachStruct1(sf.Fmove,sf)
call AttachStruct1(sf.DS,sf)
call TimerStart(sf.Fmove,SF_FLYSPEED,true,function FmoveAct)
call TimerStart(sf.DS,sf.Dura,false,function ShiFae.DSAct)
endfunction
//===========================================================================
function InitTrig_Shiva_Faerie takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function SFCond))
call TriggerAddAction(t, function SFAct)
set t = null
endfunction
endscope