[vJASS] JonNny´s Spellpack
| |
JonNny | Date: Sunday, 2008-09-14, 4:48 PM | Message # 1 |
Lieutenant
Group: Moderators
Messages: 50
Status: Offline
| This is my Spellpack which was created for the Spell Olympics on Wc3c first Im not sure if some new Spells will Follow because i will fokus my Survival map first ! Contains : - Fire Dissipartion (Fire/Heat) "The Firelord disperses into flames moving to the target location and recomposes himself releasing an explosion." Quote (Code) // Fire Dissipation // Fire/Heat - Submission for the Spell Olympics 2008 // Created by JonNny aka WorIdEdit - Please give credits if you use this Spell in your map //What you need to implent this spell is a cache(look in the Init Trigger) + globals in the main script + these things : //1. The Ability which runs this Script (adjustable in line 18) //2. The Dummy-Unit for the Fire (adjustable line 247) //3. The Test-Position-Dummy Unit (adjustable in line 19) ////////////////////////Spell//Modifications/////////////////////////////////////////////////// globals constant real Speed = 9.00 //The Speed of the Spirits constant real TimerEvent = 0.02 //How fast the Timer runs constant real circle = 4.00 //The Speed of the Spirits circling arround the Target Location constant integer GlowID = 'h000' //The Unit ID of the FireSFX-Dummy constant integer SpellID = 'A000' //The ID of the casted Spell constant integer TestPositionID = 'h001' //The ID of the casted Spell constant integer GlowNumber = 8 // The Number of created Spirits which move constant real ExplosionRange = 450.00 // The Range of the Explosion dealing damage and pushing units away constant string Effect = "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl" //The Model of the Explosion appearing when being recomposed endglobals function height takes real maxdistance returns real return maxdistance/8 + 150 // The max. height the Spirits reach on their movement endfunction function DamageDealt takes integer level returns real return 25.00+(55.00*I2R(level)) // The max. dealt damage on explosion endfunction function PushRate takes integer level returns real return 2.50+(3.75*I2R(level)) // The rate of units being pushed away endfunction function IsUnitPushedAway takes unit u , unit uu returns boolean // change the Conditions for the affected units here (push only) return (u!= uu) and (IsUnitType(u, UNIT_TYPE_STRUCTURE) == false ) and (GetUnitState(u, UNIT_STATE_LIFE) >= 0) endfunction function IsUnitDamaged takes unit u , unit uu returns boolean // change the Conditions for the affected units here (Damage) return (IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(uu)) == true ) and (IsUnitType(u, UNIT_TYPE_STRUCTURE) == false ) and (GetUnitState(u, UNIT_STATE_LIFE) >= 0) and ( IsUnitType(u, UNIT_TYPE_MECHANICAL) == false ) and ( IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) == false ) endfunction ////////////////////////Fire//Dissipation//Spell//Script////////////////////////////////////////////////////////////////////////////////////// function H2I takes handle h returns integer return h return 0 endfunction function I2U takes integer i returns unit return i return null endfunction function FadeOut takes integer red , integer green , integer blue , unit u returns nothing local integer q = 1 local integer qq= 4 loop exitwhen q>qq call SetUnitVertexColor(u,red,green,blue,(255-(64*q))) call TriggerSleepAction(0.01) set q = q + 1 endloop call ShowUnit(u, false) endfunction function FadeIn takes integer red , integer green , integer blue , unit u returns nothing local integer q = 1 local integer qq= 4 call ShowUnit(u, true) loop exitwhen q>qq call SetUnitVertexColor(u,red,green,blue,(64*q)) call TriggerSleepAction(0.01) set q = q + 1 endloop endfunction function DestroyEffectDelayed takes real t , effect e returns nothing call TriggerSleepAction(t) call DestroyEffect(e) endfunction function CastedAbilityID takes nothing returns boolean return ( GetSpellAbilityId() == SpellID ) endfunction function Damage takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = I2U(GetStoredInteger(cache,I2S(H2I(t)),"Hero")) local location l = GetUnitLoc(u) local real move = GetStoredReal(cache,I2S(H2I(t)),"dmg") local real distance = ExplosionRange local group g = GetUnitsInRangeOfLocMatching(ExplosionRange,l,null) local unit a= null local real x = 0.00 local real y = 0.00 local real xx = GetUnitX(u) local real yy = GetUnitY(u) local real dx = 0.00 local real dy = 0.00 local real d = 0.00 local real angle = 0.00 loop set a = FirstOfGroup(g) exitwhen a==null call GroupRemoveUnit(g,a) set x = GetUnitX(a) set y = GetUnitY(a) set angle = bj_RADTODEG * Atan2(y - yy, x - xx) if (a != u) and IsUnitPushedAway(a,u) then set dx = xx - x set dy = yy - y set d = SquareRoot(dx*dx+dy*dy) call SetUnitX(a,x + move*((ExplosionRange-d)/ExplosionRange) * Cos(angle * bj_DEGTORAD)) call SetUnitY(a,y + move*((ExplosionRange-d)/ExplosionRange) * Sin(angle * bj_DEGTORAD)) else endif endloop if move > 0 then call StoreReal(cache, I2S(H2I(t)), "dmg", (move-0.25)) call TimerStart(t,TimerEvent,false,function Damage) else call FlushStoredMission(cache, I2S(H2I(t))) endif set a = null set u = null set t = null call DestroyGroup(g) set g = null endfunction function Move takes nothing returns nothing local timer t = GetExpiredTimer() local unit glow = I2U(GetStoredInteger(cache, I2S(H2I(t)), "Glow")) local location l = GetUnitLoc(glow) local real angle = GetStoredReal(cache,I2S(H2I(t)),"angle") local real distance = GetStoredReal(cache,I2S(H2I(t)),"maxd") local real moved = GetStoredReal(cache,I2S(H2I(t)),"moved") local real x = GetLocationX(l) + Speed * Cos(angle * bj_DEGTORAD) local real y = GetLocationY(l) + Speed * Sin(angle * bj_DEGTORAD) local integer Movement = GetStoredInteger(cache,I2S(H2I(t)),"Movement") local effect explosion = null local unit hero = null local real movement = 0.00 local integer level local location loc = null local group g = null local unit a = null local real d = 0.00 local real dx = 0.00 local real dy = 0.00 if Movement == 1 then call SetUnitPosition( glow , x,y ) set moved = moved + Speed call SetUnitFlyHeight (glow , (80.00 + Sin((moved/(1.75*distance))*3.1415)*height(distance)) , 400) call StoreReal(cache, I2S(H2I(t)), "maxd", distance) call StoreReal(cache, I2S(H2I(t)), "moved", moved) call StoreInteger(cache, I2S(H2I(t)), "Glow", H2I(glow)) if moved > distance then set angle = bj_RADTODEG * Atan2(y - GetStoredReal(cache,I2S(H2I(t)),"yt"), x - GetStoredReal(cache,I2S(H2I(t)),"xt")) call StoreInteger(cache, I2S(H2I(t)), "Movement", 2) call StoreReal(cache, I2S(H2I(t)), "maxd", GetUnitFlyHeight(glow)) call StoreReal(cache, I2S(H2I(t)), "moved", 0.00) call StoreReal(cache, I2S(H2I(t)), "angle", angle) else endif call TimerStart(t,TimerEvent,false,function Move) else if moved*1.5 > distance then if GetStoredInteger(cache,I2S(H2I(t)),"MoveHero") == 1 then set hero = I2U(GetStoredInteger(cache, I2S(H2I(t)), "Hero")) call SetUnitPosition( hero, GetStoredReal(cache,I2S(H2I(t)),"xt"),GetStoredReal(cache,I2S(H2I(t)),"yt")) call FadeIn.execute(255,255,255,hero) call PauseUnit(hero, false) call SetUnitPathing( hero, true ) // call SelectUnitAddForPlayer( hero, GetOwningPlayer(glow) ) if (GetLocalPlayer() == GetOwningPlayer(glow)) then // Use only local code (no net traffic) within this block to avoid desyncs. call SelectUnit(hero ,true) endif call StoreInteger(cache, I2S(H2I(t)), "MoveHero", 2) set moved = moved + 75.00 set hero = null else endif else endif if moved > distance then if GetStoredInteger(cache,I2S(H2I(t)),"MoveHero") == 2 then set level = GetStoredInteger(cache,I2S(H2I(t)),"level") set hero = I2U(GetStoredInteger(cache, I2S(H2I(t)), "Hero")) set loc = GetUnitLoc(hero) set explosion = AddSpecialEffectLoc(Effect, loc) call DestroyEffect(explosion) call StoreInteger(cache, I2S(H2I(t)), "Hero", H2I(hero)) call StoreReal(cache, I2S(H2I(t)), "dmg", PushRate(level)) set g = GetUnitsInRangeOfLocMatching(ExplosionRange,loc,null) call TimerStart(t,0.15,false,function Damage) loop set a = FirstOfGroup(g) exitwhen a==null call GroupRemoveUnit(g,a) set bj_lastCreatedEffect = AddSpecialEffectTarget("Abilities\\Spells\\Other\\BreathOfFire\\BreathOfFireDamage.mdl" , a, "chest") call DestroyEffectDelayed.execute(0.15,bj_lastCreatedEffect) set dx = GetUnitX(a) - GetUnitX(hero) set dy = GetUnitY(a) - GetUnitY(hero) set d = SquareRoot(dx*dx+dy*dy) if IsUnitDamaged(a,hero) and hero != a then call UnitDamageTarget(hero, a, DamageDealt(level)*((ExplosionRange-d)/ExplosionRange), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) else endif endloop call DestroyGroup(g) set g = null set a = null call RemoveLocation(loc) else call FlushStoredMission(cache, I2S(H2I(t))) endif call RemoveUnit(glow) else call SetUnitFlyHeight (glow , (distance-moved) , 1000) call SetUnitPosition( glow , GetStoredReal(cache,I2S(H2I(t)),"xt") + (120*(1-(moved/distance))) * Cos(angle * bj_DEGTORAD),GetStoredReal(cache,I2S(H2I(t)),"yt") + (120*(1-(moved/distance))) * Sin(angle * bj_DEGTORAD) ) set moved = moved + (0.3*Speed) set angle = angle + circle + 4*(moved/distance) call StoreReal(cache, I2S(H2I(t)), "moved", moved) call StoreReal(cache, I2S(H2I(t)), "angle", angle) call TimerStart(t,TimerEvent,false,function Move) endif call RemoveLocation(l) endif set glow = null set loc = null set t = null set hero = null set explosion = null set l = null endfunction function Dissipation takes nothing returns nothing local unit array u local timer array t local location array l local unit caster = GetTriggerUnit() local real x = GetUnitX(caster) local real y = GetUnitY(caster) local real angle =0.00 local real distancemax = 0.00 local location target2 = GetSpellTargetLoc() local location target = null local unit testposition = CreateUnitAtLoc(GetOwningPlayer(caster),TestPositionID,target2,0) local real array xt local real array yt local real size = GetRandomReal(180,300) set target = GetUnitLoc(testposition) call RemoveUnit(testposition) call FadeOut.execute(255,255,255,caster) set i = 1 set ii = GlowNumber loop exitwhen i>ii set size = GetRandomReal(275,350) set xt[i] = GetLocationX(target) + (120.00 * Cos( 360 / ii * i * bj_DEGTORAD)) set yt[i] = GetLocationY(target) + (120.00 * Sin( 360 / ii * i * bj_DEGTORAD)) set t[i] = CreateTimer() set l[i] = Location(x + GetRandomReal(50.00,125.00) * Cos(GetRandomReal(0.00,360.00) * bj_DEGTORAD),y + GetRandomReal(25.00,150.00) * Sin(GetRandomReal(0.00,360.00) * bj_DEGTORAD)) set u[i] = CreateUnit(GetOwningPlayer(caster),GlowID,x,y,0) call SetUnitScale( u[i], size*0.01, size*0.01, size*0.01) call IssuePointOrderLoc( u[i], "move", l[i] ) set distancemax = SquareRoot((GetLocationX(l[i])-xt[i])*(GetLocationX(l[i])-xt[i])+(GetLocationY(l[i])-yt[i])*(GetLocationY(l[i])-yt[i])) set angle = bj_RADTODEG * Atan2(GetLocationY(l[i]) - yt[i], GetLocationX(l[i]) - xt[i]) +180.00 call FadeIn.execute(GetRandomInt(25,200),GetRandomInt(125,255),GetRandomInt(25,200),u[i]) call StoreReal(cache, I2S(H2I(t[i])), "angle", angle) call StoreReal(cache, I2S(H2I(t[i])), "xt", GetLocationX(target)) call StoreReal(cache, I2S(H2I(t[i])), "yt", GetLocationY(target)) call StoreReal(cache, I2S(H2I(t[i])), "maxd", distancemax) call StoreReal(cache, I2S(H2I(t[i])), "moved", 0.00) call StoreInteger(cache, I2S(H2I(t[i])), "Glow", H2I(u[i])) call StoreInteger(cache, I2S(H2I(t[i])), "Movement", 1) if i == ii then call StoreInteger(cache, I2S(H2I(t[i])), "level", GetUnitAbilityLevel(GetTriggerUnit(),SpellID)) call StoreInteger(cache, I2S(H2I(t[i])), "Hero", H2I(GetTriggerUnit())) call StoreInteger(cache, I2S(H2I(t[i])), "MoveHero", 1) else endif call TimerStart(t[i],0.75,false,function Move) call RemoveLocation(l[i]) set t[i] = null set l[i]= null set u[i] = null set i = i + 1 endloop call TriggerSleepAction(0.50) call PauseUnit(GetTriggerUnit(), true) call SetUnitPathing( GetTriggerUnit(), false ) set testposition = null set caster = null call RemoveLocation(target) call RemoveLocation(target2) set target = null endfunction //=========================================================================== function InitTrig_Dissipation takes nothing returns nothing local integer index set gg_trg_Dissipation = CreateTrigger() set index = 0 loop call TriggerRegisterPlayerUnitEvent(gg_trg_Dissipation, Player(index), EVENT_PLAYER_UNIT_SPELL_CAST, null) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop call TriggerAddCondition( gg_trg_Dissipation, Condition( function CastedAbilityID ) ) call TriggerAddAction( gg_trg_Dissipation, function Dissipation ) endfunction - Tornado(Wind/Air) "The Blademaster will spin with an incredible speed creating a tonado arround him sucking in all enemys in range. Spun enemys will be woozy depending on the time they were in the tornado." Quote (Code) // Tornado // Air/Wind - Submission for the Spell Olympics 2008 // Created by JonNny aka WorIdEdit - Please give credits if you use this Spell in your map //What you need to implent this spell is a cache(look in the Init Trigger) + globals in the main script + these things : //1. The Ability which runs this Script (adjustable in line 14) //2. The SFX-Dummy-Unit for the Tornadoeffect (adjustable line 24) //3. The Dummy-Caster Unit ID (adjustable in line 25) //4. The Dummy-Spell which causes the effect (adjustable in line 27) with its used OrderID (adjustable line 29) and the used Buff (adjustable line 28) ////////////////////////Spell//Modifications/////////////////////////////////////////////////// globals constant integer TornadoSpell = 'A002' //The ID of the casted Spell constant real TornadoTimer = 0.03 //How fast the Timer runs constant string TornadoEffect = "Abilities\\Spells\\NightElf\\Cyclone\\CycloneTarget.mdl" //The effect which is created at the location of the caster constant string TornadoOrder = "channel" //The OrderID of the Channeled Spell (can be set in the constant real SuckRange = 850.00 // The range the spell will start suck units constant real EyeOfTheStormRadius = 100.00 //Defines the radius of the inner circle the units will spin arround ( 90.00° = 0 range , higher angle = bigger radius ) constant real ElevatorRange = 600.00 //The Range the Units begin beeing sucked into the air (Mind the GravityRate , this range does not mean that the Unit will being lifted constant real MaxHeight = 250.00 // The Maximal Height the unit can reach of beein sucked constant real HeightChange = 20.00 //The Rate the Units will get Sucked in the Air constant real GravityRate = 10.00 //The Rate the Unit will Fall Down after sucked into the air constant integer TornadoSFXID = 'h002' //The Unit ID of the TornadoSFX-Dummy constant integer SpellCastDummyID = 'h003' //The Unit ID of the Dummy caster constant real DamageRange = 350 // The range the Spell deals Damage / has an effect(like the one below) constant integer SpellEffectID = 'A001' // The Spell which is affects all enemys in DamageRange constant integer SpellEffectBuffID = 'B000' //The Buff of the casted ability above which has to be removed again constant string SpellAbilityOrder = "slow" //The Order of the Ability endglobals function DamageAmount takes integer level returns real return 0.20+(0.15*level) // The damage the Unit deals each "TornadoTomer" seconds endfunction function Suck takes integer level returns real return 3.8+(2.5*level) // The Speed the Units gets sucked by the Tornado endfunction function IsUnitSuckAffected takes unit u , unit uu returns boolean // change the Conditions for the affected units here (suck only) return (u!= uu) and (IsUnitType(u, UNIT_TYPE_STRUCTURE) == false ) and (GetUnitState(u, UNIT_STATE_LIFE) >= 0) endfunction function IsUnitSpellAffected takes unit u , unit uu returns boolean // change the Conditions for the affected units here (Spell Effect + Damage) return (IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(uu)) == true ) and (u!= uu) and (IsUnitType(u, UNIT_TYPE_STRUCTURE) == false ) and (GetUnitState(u, UNIT_STATE_LIFE) >= 0) and ( IsUnitType(u, UNIT_TYPE_MECHANICAL) == false ) and ( IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) == false ) endfunction function TornadoID takes nothing returns boolean return ( GetSpellAbilityId() == TornadoSpell ) //The condition this script runs (Casted spell must be your spell) endfunction //=================================================================================== ////////////////////////Tornado//Spell//Script////////////////////////////////////////////////////////////////////////////// //=================================================================================== function I2E takes integer i returns effect return i return null endfunction function RemoveEffect takes unit u returns nothing local real remaining = GetStoredReal(cache, I2S(H2I(u)), "remaining") loop exitwhen remaining < 0.00 set remaining = GetStoredReal(cache, I2S(H2I(u)), "remaining") - 0.60 call StoreReal(cache, I2S(H2I(u)), "remaining", remaining) call TriggerSleepAction(0.01) endloop call UnitRemoveAbility( u , SpellEffectBuffID ) call StoreReal(cache, I2S(H2I(u)), "remaining", 0.00) endfunction function GetDown takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = I2U(GetStoredInteger(cache, I2S(H2I(t)), "unit")) local real z = GetUnitFlyHeight(u) call UnitAddAbility(u, 'Amrf') call SetUnitFlyHeight(u, ( z - GravityRate), 500) call UnitRemoveAbility(u, 'Amrf') if z > 0.01 then call TimerStart(t,TornadoTimer,false,function GetDown) else call StoreInteger(cache, I2S(H2I(u)), "GetDown", 0) call FlushStoredMission(cache, I2S(H2I(t))) endif set t = null set u = null endfunction function SuckActions takes nothing returns nothing local timer t = GetExpiredTimer() local unit hero = I2U(GetStoredInteger(cache, I2S(H2I(t)), "hero")) local unit SFX = I2U(GetStoredInteger(cache, I2S(H2I(t)), "SFX")) local effect e = I2E(GetStoredInteger(cache, I2S(H2I(t)), "e")) local effect ee = I2E(GetStoredInteger(cache, I2S(H2I(t)), "ee")) local integer level = GetStoredInteger(cache, I2S(H2I(t)), "level") local real z = GetUnitFlyHeight(hero) local location l = GetUnitLoc(hero) local group g = GetUnitsInRangeOfLocMatching(SuckRange,l,null) local real x = 0.00 local real y = 0.00 local real xx = GetLocationX(l) local real yy = GetLocationY(l) local real dx = 0.00 local real d = 0.00 local real dy = 0.00 local unit a = null local real angle = 0.00 local timer array tt local integer Int = 1 local real remaining = 0.00 local unit dummy = null call SetUnitX(SFX,xx) call SetUnitY(SFX,yy) if OrderId2String(GetUnitCurrentOrder(hero)) == TornadoOrder then loop set a = FirstOfGroup(g) exitwhen a==null call GroupRemoveUnit(g,a) set x = GetUnitX(a) set y = GetUnitY(a) if IsUnitSuckAffected(a,hero) then set dx = xx - x set dy = yy - y set d = SquareRoot(dx*dx+dy*dy) set angle = -EyeOfTheStormRadius * (1-d/SuckRange) + (bj_RADTODEG * Atan2(yy - y, xx - x)) call SetUnitX(a,x + Suck(level)*((SuckRange-d)/SuckRange) * Cos(angle * bj_DEGTORAD)) call SetUnitY(a,y + Suck(level)*((SuckRange-d)/SuckRange) * Sin(angle * bj_DEGTORAD)) if (d < ElevatorRange) and GetUnitDefaultFlyHeight(a) < 1.00 then set z = GetUnitFlyHeight(a) if (GetStoredInteger(cache, I2S(H2I(a)), "GetDown" ) == 0 ) then set tt[Int] = CreateTimer() call StoreInteger(cache, I2S(H2I(a)), "GetDown", 1) call StoreInteger(cache, I2S(H2I(tt[Int])), "unit", H2I(a)) call TimerStart(tt[Int],0.02,false,function GetDown) set Int = Int+1 set tt[Int] = null else endif set z = z + (1-(z/MaxHeight))*(1-(d/ElevatorRange))*HeightChange call UnitAddAbility(a, 'Amrf') call SetUnitFlyHeight(a, z, 1000) call UnitRemoveAbility(a, 'Amrf') else endif set remaining = GetStoredReal(cache, I2S(H2I(a)), "remaining" ) if (d < DamageRange) and IsUnitSpellAffected(a,hero) then call UnitDamageTarget(hero, a, DamageAmount(level), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS) if ((SpellEffectID != 0) and (remaining == 0.00)) then set dummy = CreateUnit(GetOwningPlayer(hero),SpellCastDummyID,xx,yy,0) call UnitAddAbility(dummy, SpellEffectID) call SetUnitAbilityLevel( dummy ,SpellEffectID, level ) call IssueTargetOrder( dummy,SpellAbilityOrder, a ) call StoreReal(cache, I2S(H2I(a)), "remaining", 10.00) call RemoveEffect.execute(a) else set remaining = remaining +0.25 call StoreReal(cache, I2S(H2I(a)), "remaining", remaining) endif else endif else endif endloop call TimerStart(t,TornadoTimer,false,function SuckActions) else call RemoveUnit(SFX) call SetUnitTimeScale(hero, 1.00) call DestroyEffect(e) call DestroyEffect(ee) call FlushStoredMission(cache, I2S(H2I(t))) endif set e = null set ee = null set a = null call DestroyGroup(g) set g = null call RemoveLocation(l) set l = null set SFX = null endfunction function TornadoStart takes nothing returns nothing local unit hero = GetSpellAbilityUnit() local integer level = GetUnitAbilityLevel(hero,TornadoSpell) local timer t = CreateTimer() local effect e = AddSpecialEffectTarget( TornadoEffect , GetTriggerUnit(), "sprite,first" ) local effect ee = null local location l = GetUnitLoc(hero) local unit TornadoSFX = CreateUnitAtLoc(GetOwningPlayer(hero),TornadoSFXID,l,0) call SetUnitTimeScale(hero, 1.80) call SetUnitTimeScale(TornadoSFX, 1.80) call SetUnitVertexColor(TornadoSFX, 200, 200, 200, 175 ) call StoreInteger(cache, I2S(H2I(t)), "hero", H2I(hero)) call StoreInteger(cache, I2S(H2I(t)), "SFX", H2I(TornadoSFX)) call StoreInteger(cache, I2S(H2I(t)), "e", H2I(e)) call StoreInteger(cache, I2S(H2I(t)), "ee", H2I(ee)) call StoreInteger(cache, I2S(H2I(t)), "level",level) call TimerStart(t,0.05,false,function SuckActions) call RemoveLocation(l) set l = null set e = null set ee = null set t = null set hero = null set TornadoSFX = null endfunction //=========================================================================== function InitTrig_Tornado takes nothing returns nothing local integer index set gg_trg_Tornado = CreateTrigger( ) set index = 0 loop call TriggerRegisterPlayerUnitEvent(gg_trg_Tornado, Player(index), EVENT_PLAYER_UNIT_SPELL_CHANNEL, null) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop call TriggerAddCondition( gg_trg_Tornado, Condition( function TornadoID ) ) call TriggerAddAction( gg_trg_Tornado, function TornadoStart ) endfunction - Chained Boulder(Earth/Stone) "Throws a boulder to an enemy which chains it up to it limiting the units movement range. Heavyness and range of the chain depends on the level of this spell." Quote (Code) // Chained Up // Earth/Nature/Rock - Submission for the Spell Olympics 2008 // Created by JonNny aka WorIdEdit - Please give credits if you use this Spell in your map ///What you need to implent this spell is a cache(look in the Init Trigger) + globals in the main script + these things : //1. The Ability which runs this Script (adjustable in line 13) //2. The Dummy-Unit for the Boulder (adjustable line 17) //3. The Dummy-Unit for the Chain (adjustable in line 18) globals constant integer ChainedUpSpell = 'A003' //The ID of the casted Spell constant real BoulderHeight = 50.00 //The height of the boulder when lying of the ground constant real ChainHeight = 40.00 //Defines the height the chain will lock up constant real ChainPartDistance = 35.00 //The Distance between each part of the chain constant integer BoulderID = 'h004' //The Unit ID of the Boulder constant integer ChainPartID = 'h005' //The Unit ID of Dummy Unit for the chain constant real ChainHoldTimer = 0.03 //Set the time the Chain function executes constant string BoulderDeathEffect = "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl" //The effect which appears when the boulder is removed constant real BoulderSpeedThrown = 12.00 //The speed the boulder is thrown endglobals function BoulderWeight takes real level returns real return (0.5-0.15*level) //Declares how easy it is to pull this boulder (1 = 100% = easy , 0 = 0% = not moveable) endfunction function ChainLength takes real level returns real return 375.00-(50.00*level) //Defines the length of the chain for each level endfunction function Duration takes real level returns real return 12+(4*level) // The Time this Boulder will last endfunction function Height takes real d returns real return 0.70*d // The max.height the Boulder will reach on this throw endfunction function ChainedUpID takes nothing returns boolean return GetSpellAbilityId() == ChainedUpSpell //The condition this script runs (Casted spell must be your spell) endfunction ////////////////////////////Chained//Up//Spell//Script/////////////////////////////////////////////////////////////////////////////////////// function GetDistance takes unit u , unit uu returns real local real x = GetUnitX(u) local real y = GetUnitY(u) local real xx = GetUnitX(uu) local real yy = GetUnitY(uu) return SquareRoot((xx-x)*(xx-x)+(yy-y)*(yy-y)) endfunction function RemoveUnitDelayed takes unit u , real t returns nothing call TriggerSleepAction(t) call RemoveUnit(u) endfunction function ChainHold takes nothing returns nothing local timer t = GetExpiredTimer() local unit array chain local unit target = I2U(GetStoredInteger(cache, I2S(H2I(t)), "target")) local unit boulder = I2U(GetStoredInteger(cache, I2S(H2I(t)), "boulder")) local real x = GetUnitX(target) local real y = GetUnitY(target) local real xx = GetUnitX(boulder) local real yy = GetUnitY(boulder) local real s = 0.00 local real level = GetStoredInteger(cache, I2S(H2I(t)), "level") local real d = ChainLength(level) local real angle = bj_RADTODEG * Atan2(y - yy, x - xx) local real z = 0.00 local real tb = GetDistance(target,boulder) local effect e = null local location l = null if GetDistance(target,boulder) > d then set angle = bj_RADTODEG * Atan2(y - yy, x - xx) set s = (tb - d )* BoulderWeight(level) call SetUnitX(target,(xx + d * Cos(angle * bj_DEGTORAD))) call SetUnitY(target,(yy + d * Sin(angle * bj_DEGTORAD))) call SetUnitPosition( boulder ,( GetUnitX(boulder)+ s * Cos((0+angle) * bj_DEGTORAD)),(GetUnitY(boulder)+ s * Sin((0+angle) * bj_DEGTORAD))) else endif set i = 1 set ii = GetStoredInteger(cache, I2S(H2I(t)), "ChainParts") loop exitwhen i>ii set chain[i] = I2U(GetStoredInteger(cache, I2S(H2I(t)), I2S(i))) call SetUnitFacingTimed( chain[i], angle+90, 0.01 ) set z = ChainHeight +(I2R(i)/I2R(ii)*GetUnitFlyHeight(target))- (Sin(((GetDistance(chain[i],boulder)/tb))*3.1415)*ChainHeight*2.25*((1-tb/ChainLength(GetStoredInteger(cache, I2S(H2I(t)), "level"))))) call SetUnitFlyHeight (chain[i] , z , 400) set x = GetUnitX(boulder) + (((tb-45)*i/ii)+45)*0.95 * Cos(angle * bj_DEGTORAD) set y = GetUnitY(boulder) + (((tb-45)*i/ii)+45)*0.95 * Sin(angle * bj_DEGTORAD) call SetUnitPosition(chain[i],x,y) set chain[i] = null set i = i + 1 endloop if (GetUnitState(target, UNIT_STATE_LIFE) > 0) and (GetUnitState(boulder, UNIT_STATE_LIFE) > 0) then call TimerStart(t,ChainHoldTimer,false,function ChainHold) else set i = 1 set ii = GetStoredInteger(cache, I2S(H2I(t)), "ChainParts") loop exitwhen i>ii set chain[i] = I2U(GetStoredInteger(cache, I2S(H2I(t)), I2S(i))) call RemoveUnit(chain[i]) set chain[i] = null set i = i + 1 endloop set l = GetUnitLoc(boulder) set e = AddSpecialEffectLoc(BoulderDeathEffect,l) call DestroyEffect(e) call KillUnit(boulder) set e = null call RemoveLocation(l) set l = null call RemoveUnitDelayed.execute(boulder,0.25) call FlushStoredMission(cache, I2S(H2I(t))) endif set boulder = null set target = null set t = null endfunction function BoulderThrow takes nothing returns nothing local timer t = GetExpiredTimer() local unit boulder = I2U(GetStoredInteger(cache, I2S(H2I(t)), "boulder")) local unit target = I2U(GetStoredInteger(cache, I2S(H2I(t)), "target")) local real z = 0.00 local unit caster = null local real d = GetStoredReal(cache, I2S(H2I(t)), "d") local real angle = bj_RADTODEG * Atan2(GetUnitY(boulder) - GetUnitY(target), GetUnitX(boulder) - GetUnitX(target))+180.00 local real dd = GetDistance(boulder,target) local integer level = GetStoredInteger(cache, I2S(H2I(t)), "level") local unit array chain local real tx local real ty local effect e = null local location l = null if dd < 100 then set caster = I2U(GetStoredInteger(cache, I2S(H2I(t)), "caster")) call SetUnitPathing(boulder, true ) call SetUnitTimeScale(boulder, 0.00) call SetUnitFlyHeight (boulder , BoulderHeight , 4000) call SetUnitPosition( boulder ,GetUnitX(boulder),GetUnitY(boulder)) set l = GetUnitLoc(boulder) set e = AddSpecialEffectLoc(BoulderDeathEffect,l) call DestroyEffect(e) set e = null call RemoveLocation(l) set l = null set i = 1 set ii = R2I((ChainLength(level)-45)/ChainPartDistance) call StoreInteger(cache, I2S(H2I(t)), "ChainParts", ii) loop exitwhen i>ii set tx = GetUnitX(boulder) + (dd*i/ii) * Cos(angle * bj_DEGTORAD) set ty = GetUnitY(boulder) + (dd*i/ii) * Sin(angle * bj_DEGTORAD) set chain[i] = CreateUnit(GetOwningPlayer(caster),ChainPartID,tx,ty,angle) call SetUnitTimeScale(chain[i], 2.50) call StoreInteger(cache, I2S(H2I(t)), I2S(i), H2I(chain[i])) set chain[i] = null set i = i + 1 endloop call TimerStart(t,ChainHoldTimer,false,function ChainHold) set caster = null else set z = 0.00 + Sin(((d-dd+100)/(d)*3.1415))*Height(d) call UnitAddAbility(boulder, 'Amrf') call UnitRemoveAbility(boulder, 'Amrf') call SetUnitFlyHeight (boulder , z , 4000) call SetUnitPosition(boulder,GetUnitX(boulder) + BoulderSpeedThrown * Cos(angle * bj_DEGTORAD),GetUnitY(boulder) + BoulderSpeedThrown * Sin(angle * bj_DEGTORAD)) call TimerStart(t,ChainHoldTimer,false,function BoulderThrow) endif set t = null set boulder = null set target = null endfunction function ChainUp takes nothing returns nothing local unit u = GetSpellAbilityUnit() local unit target = GetSpellTargetUnit() local real xx = GetUnitX(target) local real yy = GetUnitY(target) local real tx = 0.00 local real ty = 0.00 local integer level = GetUnitAbilityLevel(u,ChainedUpSpell) local timer t = CreateTimer() local unit boulder = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),BoulderID,xx,yy,0.00) local real x = GetUnitX(boulder) local real y = GetUnitY(boulder) local real d = SquareRoot((xx-x)*(xx-x)+(yy-y)*(yy-y)) local real angle = bj_RADTODEG * Atan2(yy - y, xx - x) call SetUnitPathing(boulder, false ) call UnitAddAbility(boulder, 'Amrf') call UnitRemoveAbility(boulder, 'Amrf') call SetUnitFlyHeight (boulder , BoulderHeight , 4000) call UnitApplyTimedLife( boulder, 'BTLF', 30.00 ) call SetUnitPosition(boulder,GetUnitX(u),GetUnitY(u)) call StoreInteger(cache, I2S(H2I(t)), "level" , level) call StoreInteger(cache, I2S(H2I(t)), "target", H2I(target)) call StoreInteger(cache, I2S(H2I(t)), "boulder", H2I(boulder)) call StoreInteger(cache, I2S(H2I(t)), "caster", H2I(u)) call StoreReal(cache, I2S(H2I(t)), "d", GetDistance(u,target)) call TimerStart(t,ChainHoldTimer,false,function BoulderThrow) set t = null set u = null set boulder = null set target = null endfunction //=========================================================================== function InitTrig_Chained_Up takes nothing returns nothing local integer index set gg_trg_Chained_Up = CreateTrigger( ) set index = 0 loop call TriggerRegisterPlayerUnitEvent(gg_trg_Chained_Up, Player(index), EVENT_PLAYER_UNIT_SPELL_CAST, null) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop call TriggerAddCondition( gg_trg_Chained_Up, Condition( function ChainedUpID ) ) call TriggerAddAction( gg_trg_Chained_Up, function ChainUp ) endfunction
Message edited by JonNny - Sunday, 2008-09-14, 5:12 PM |
|
| |
Hanky | Date: Sunday, 2008-09-14, 8:27 PM | Message # 2 |
Lieutenant colonel
Group: Moderators
Messages: 116
Status: Offline
| Hmm kewl nice to see it here :D. But have you asked for permission to upload it here? I dunno if there is a rule that say that you only allowed to post it at wc3campaigns.net. But when there is no rule against it nice to see it.
Made by Smoe reworked by GiR aka Darkt3mpl3r
|
|
| |
Briegxal | Date: Thursday, 2009-04-16, 4:44 PM | Message # 3 |
Private
Group: Users
Messages: 2
Status: Offline
| nice spells
|
|
| |
JonNny | Date: Friday, 2009-04-24, 3:28 PM | Message # 4 |
Lieutenant
Group: Moderators
Messages: 50
Status: Offline
| Hmm.. i forgot to update it here... There is a "new" spell in there now also added another small Spellpack ive made Edit: wtf , i cannot edit my first post anyway , adding it here ~.~ Quote //////////////////////////////////////Globals with important values//////////////////////////////////////// scope LiveDistortion globals private real ReleaseDistance = 10.00 // The Distance the missiled being released of / coming back to the caster private integer DummyID = 'h001' //The Missile dummy ID (Rawcode) private integer EssenceSpell = 'A000' //Spell ID (Rawcode) private integer CastDummyID = 'h002' //A normal dummy to cast the effect (Rawcode) private integer LiveDistortionEffectSpell = 'A001' //The Spell which is casted on each hit enemy (Rawcode) private string EffectOrderID = "unholyfrenzy" //Order ID of the Spell (LiveDistortionEffectSpell) efect whih should last after being hit private real EssenceSpeed = 0.085 //Defines how fast the missiles are with setting the duration (also faster missiles with longer distance) private real PercentageSpeedReduce = 0.02 //The rate the missiles get slower, a too high value causes the spell not to finish private real TimerPeriod = 0.0275 //How fast the execution is private real LDDummyMaxHeight = 340.00 //Height the missiles reach on their flight private real LDDummyMinHeight = 50.00 //Min. Height of the missiles private real SpinRate = 0.03 //The rate the Missiles begin to spin after reaching 1/2 of the way private real HealthStealRange = 80.00 //the collision of the missile in which it steals damages enemies private string HealSpecialeffect = "Abilities\\Spells\\Undead\\Darksummoning\\DarkSummonTarget.mdl" // Special effect when healing the caster private string LiveStealEffect = "Abilities\\Weapons\\ChimaeraAcidMissile\\ChimaeraAcidMissile.mdl" // Special effect when hitting an enemy private real MissileStartScale = 0.7 //The scale the missile has at the beginning private real MissileScaleIncrease = 0.08//The scale the missile gets bigger when stealing hp private timer t = CreateTimer() //Do not delete private boolexpr filter = null endglobals ///////////////////////////////////Main Struckt//Do not change////////////////////////////////////////////// private struct Essences static integer Index = 0 static Essences array Data unit array EssenceDummy [15] //The array must be the max. value of missiles which are created each cast (in this case , EssencesPerLevel(3) = 3*3+3 = 12) real array angle [15] //same as above group array DamagedUnits [15] // same as above real array MissileScale [15] // same as above group GotBuff = CreateGroup() unit Caster integer level real d = 0.00 integer EssenceAmount real StolenHealth = 0 static method create takes nothing returns Essences local Essences data = Essences.allocate() set Essences.Data[Essences.Index] = data set Essences.Index = Essences.Index + 1 return data endmethod endstruct ///////////////////////////////////Defining most relevant Values//////////////////////////////////////////////// private constant function EssencesPerLevel takes integer level returns integer return 3 * level + 3 // Number of missiles created per level endfunction private constant function EssencesRangePerLevel takes real level returns real return 200.00 + 40.00 * level // Max. Range the missiles reach on their flight (also affects their movementspeed) endfunction private constant function StolenHealthPerLevel takes real level returns real return 25.00 + level * 15.00 //Defines how much damage the missiles deal/steal endfunction private constant function PercentageHealPerLevel takes real level returns real return 0.2 + level * 0.1 endfunction private function DistanceMovement takes real d returns real return SquareRoot(Sin(d)*Sin(d)) //defining the movement of the missiles that they also come back , i suggest not to change it endfunction private function StealHealthCondition takes unit a , unit b returns boolean return not(IsUnitType(a, UNIT_TYPE_MECHANICAL)) and not(IsUnitType(a, UNIT_TYPE_MAGIC_IMMUNE)) and IsUnitType(a, UNIT_TYPE_GROUND) and IsPlayerEnemy(GetOwningPlayer(a),GetOwningPlayer(b)) and (GetWidgetLife(a) > 0) // The condition if a unit is damaged endfunction private function HeightFunction takes real d returns real local real x = 0.4*(bj_PI - d) // Its a matching function for the height movement of the missiles, a parabula would have been too easy :P return LDDummyMaxHeight * (Pow(x,-Pow(x,0.8))-1) endfunction private function RunCondition takes nothing returns boolean return GetSpellAbilityId() == EssenceSpell //The condition if the spell is casted endfunction private constant function NullFilter takes nothing returns boolean return true endfunction ////////////////////////////////Main script// Do not edit unless you understand it//////////////////////////////// private function callback takes nothing returns nothing local Essences data local integer i = 0 local integer ii = 0 local real x = 0.00 local real y = 0.00 local integer a = 0 local group g = CreateGroup() local unit b = null local unit dummy = null // looping through all structs loop exitwhen i >= Essences.Index set data = Essences.Data[i] set data.d = data.d + EssenceSpeed - (PercentageSpeedReduce*data.d) set a = 0 // looping through each missile of the struct loop exitwhen a > data.EssenceAmount call SetUnitX(data.EssenceDummy[a], GetUnitX(data.Caster) + (ReleaseDistance + EssencesRangePerLevel(I2R(data.level)) * DistanceMovement(data.d)) * Cos(data.angle[a])) call SetUnitY(data.EssenceDummy[a], GetUnitY(data.Caster) + (ReleaseDistance + EssencesRangePerLevel(I2R(data.level)) * DistanceMovement(data.d)) * Sin(data.angle[a])) call GroupEnumUnitsInRange(g,GetUnitX(data.EssenceDummy[a]),GetUnitY(data.EssenceDummy[a]),HealthStealRange,filter) // looping through each unit in range of each missile loop set b = FirstOfGroup(g) exitwhen b==null call GroupRemoveUnit(g,b) //checking if the unit is damage and stealing its hp °,.,° if IsUnitInGroup(b,data.DamagedUnits[a]) == false and data.d <= (3.14159/2) and StealHealthCondition(b,data.Caster) then call GroupAddUnit(data.DamagedUnits[a],b) set data.MissileScale[a] = data.MissileScale[a] + MissileScaleIncrease call SetUnitScale(data.EssenceDummy[a],data.MissileScale[a],data.MissileScale[a],data.MissileScale[a]) set data.StolenHealth = data.StolenHealth + StolenHealthPerLevel(I2R(data.level)) call UnitDamageTarget(data.Caster,b,StolenHealthPerLevel(data.level),true, false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS) call DestroyEffect(AddSpecialEffectTarget(LiveStealEffect, b, "origin") ) //casting the effect after being hit at each unit , using the group to avoid dopling dummies for one enemy if IsUnitInGroup(b,data.GotBuff) == false then call GroupAddUnit(data.GotBuff,b) set dummy = CreateUnit(GetOwningPlayer(data.Caster),CastDummyID,GetUnitX(b),GetUnitY(b),0) call UnitAddAbility(dummy,LiveDistortionEffectSpell) call SetUnitAbilityLevel(dummy,LiveDistortionEffectSpell,data.level) call UnitApplyTimedLife(dummy, 'BTLF', 0.75) call IssueTargetOrder( dummy, EffectOrderID,b ) endif endif endloop //setting the missiles height if (HeightFunction(data.d)) >= LDDummyMinHeight then set data.angle[a] = data.angle[a] + SpinRate * 1.5 * (data.d-1) call SetUnitFlyHeight(data.EssenceDummy[a], HeightFunction(data.d), 1000) endif set a = a + 1 endloop set a = 0 //3.14159 is the value the spell is finished if data.d >= bj_PI then //cleaing all variables loop exitwhen a > data.EssenceAmount call RemoveUnit(data.EssenceDummy[a]) set data.EssenceDummy[a] = null call DestroyGroup(data.DamagedUnits[a]) set data.DamagedUnits[a] = null set a = a + 1 endloop call DestroyEffect(AddSpecialEffectTarget(HealSpecialeffect, data.Caster, "origin")) call DestroyGroup(data.GotBuff) set data.GotBuff = null //healing the caster if GetUnitState(data.Caster, UNIT_STATE_LIFE) > 0 then // If desired a display of the amount of hp healed can be added here (PercentageHealPerLevel(I2R(data.level)) * data.StolenHealth) call SetWidgetLife(data.Caster,GetWidgetLife(data.Caster)+ PercentageHealPerLevel(I2R(data.level)) * data.StolenHealth) endif set data.Caster = null call Essences.destroy(data) set ii = i loop exitwhen ii >= Essences.Index set Essences.Data[ii-1] = Essences.Data[ii] set ii = ii + 1 endloop set i = i -1 set Essences.Index = Essences.Index - 1 set ii = 0 endif set i = i + 1 endloop call DestroyGroup(g) set g = null set b = null set dummy = null endfunction private function Live_Distortion_Actions takes nothing returns nothing local integer a = 0 local real angle = 0.00 local unit caster = GetTriggerUnit() local integer level = GetUnitAbilityLevel(caster,EssenceSpell) local real x = GetUnitX(caster) local real y = GetUnitY(caster) local real d = 0.00 local integer EssencesAmount = EssencesPerLevel(level) local real z = (2*bj_PI / I2R(EssencesAmount)) // Creating the Struct call Essences.create() set Essences.Data[Essences.Index-1].Caster = caster set Essences.Data[Essences.Index-1].level = level set Essences.Data[Essences.Index-1].EssenceAmount = EssencesAmount loop exitwhen a > EssencesAmount // Creating the missiles here set angle = z * I2R(a) set Essences.Data[Essences.Index-1].angle[a] = angle set Essences.Data[Essences.Index-1].EssenceDummy[a] = CreateUnit(GetOwningPlayer(caster), DummyID , x + ReleaseDistance * Cos(angle),y + ReleaseDistance * Sin(angle) , angle * (180.0/bj_PI)) set Essences.Data[Essences.Index-1].DamagedUnits[a] = CreateGroup() set Essences.Data[Essences.Index-1].MissileScale[a] = MissileStartScale set a = a + 1 endloop if Essences.Data[Essences.Index-1].Index == 1 then call TimerStart(t, TimerPeriod, true, function callback) endif set caster = null endfunction //=========================================================================== function InitTrig_Live_Distortion takes nothing returns nothing local integer index local boolexpr cond = Condition( function RunCondition ) set filter = Filter(function NullFilter) set gg_trg_Live_Distortion = CreateTrigger( ) set index = 0 loop call TriggerRegisterPlayerUnitEvent(gg_trg_Live_Distortion, Player(index), EVENT_PLAYER_UNIT_SPELL_CAST, filter) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop call TriggerAddCondition( gg_trg_Live_Distortion, cond ) call TriggerAddAction( gg_trg_Live_Distortion, function Live_Distortion_Actions ) set cond = null //Preloading the used effect models call Preload(HealSpecialeffect) call Preload(LiveStealEffect) endfunction endscope Quote (Mind Burst) //////////////////////////////////////Globals with important values//////////////////////////////////////// scope MindBurst globals private real ReleaseDistance = 20.00 // The Distance the missiled being released infront of the caster private integer DummyID = 'h003' //The Missile dummy ID (Rawcode) private integer MindBurstSpell = 'A002' //Spell ID (Rawcode) private integer CastDummyID = 'h002' //A normal dummy to cast the effect (Rawcode) private integer MindBurstEffectSpell = 'A004' //The Spell which is casted on each hit enemy (Rawcode) private string EffectOrderID = "rejuvination" //Order ID of the Spell(Mind Burst Buff Effect) effect whih should last after being hit private real MissileSpeed = 9 //Defines how fast the missiles are private real TimerPeriod = 0.0275 //How fast the execution is private real MissileHeight = 80 // Defines the missiles basic height (they spin arround this) should be bigger than SpinStarRadius that they do not touch the ground private real SpinStartRadius = 60 // Sets the spin radius when they are created , why moving it decreases (look below) private real SpinEndRadius = 10 // Sets the spin radius the missiles got at the end private real StartScale = 0.85 // While moving missiles change their scale , this is their start scale (look below) private real EndScale = 0.275 // This is the missiles end scale private real SpinRate = 0.275 // The rate the missiles spin private real AdditionalDamageRange = 50 //The additional range for hitting a target , the real range will be the current Spinradius + This value (this case its 110 at the start and 60 at the end) private string DamageEffect = "Abilities\\Weapons\\WingedSerpentMissile\\WingedSerpentMissile.mdl" // Special effect when hitting an enemy private string HealEffect = "Abilities\\Spells\\Items\\AIma\\AImaTarget.mdl" // Special effect at the caster when being heald (missiles hit a unit with mana) private string MissilesDeath = "Abilities\\Spells\\Orc\\LightningBolt\\LightningBoltMissile.mdl" //Special effect whe the missiles are removed private timer t = CreateTimer() //Do not delete private boolexpr filter = null //Do not delete endglobals ///////////////////////////////////Main Struckt//Do not change////////////////////////////////////////////// private struct Missiles static integer Index = 0 static Missiles array Data unit array missiles [2] // The 2 missiles real angle real x real y real a unit caster group DamagedUnits = CreateGroup() // group to avoid damaging a unit twice real rangeleft integer level static method create takes nothing returns Missiles local Missiles data = Missiles.allocate() set Missiles.Data[Missiles.Index] = data set Missiles.Index = Missiles.Index + 1 return data endmethod endstruct ///////////////////////////////////Defining most relevant Values//////////////////////////////////////////////// private constant function MissileRangePerLevel takes real level returns real // The range the missiles reach per level return 550 + 225 * level endfunction private constant function StolenManaPerLevel takes real level returns real // Amount of mana stolen directly and transfered to the caster return 5.0 + 5.0*level endfunction private constant function DamagePerLevel takes real level returns real //Amount of damage dealt when a unit is hit return 30.00 + level * 20.00 endfunction private function DealDamageCondition takes unit a , unit b returns boolean // The condition if a unit is damaged return not(IsUnitType(a, UNIT_TYPE_MECHANICAL)) and not(IsUnitType(a, UNIT_TYPE_MAGIC_IMMUNE)) and IsUnitType(a, UNIT_TYPE_GROUND) and IsPlayerEnemy(GetOwningPlayer(a),GetOwningPlayer(b)) and (GetWidgetLife(a) > 0) // The condition if a unit is damaged endfunction private function ManaDrainCondition takes unit a returns boolean // Additional condition (including DealDamageCondition) if the caster can directly steal mana return (GetUnitState(a,UNIT_STATE_MANA) > 0.0) endfunction private function RunCondition takes nothing returns boolean return GetSpellAbilityId() == MindBurstSpell //The condition if the spell is casted endfunction private constant function NullFilter takes nothing returns boolean return true endfunction ////////////////////////////////Main script// Do not edit unless you understand it//////////////////////////////// private function callback takes nothing returns nothing local Missiles data local integer i = 0 local integer ii = 0 local real x = 0.00 local real y = 0.00 local real z = 0 local integer a = 0 local group g = CreateGroup() local unit b = null local unit dummy = null local real radius local real scale // looping through all structs loop exitwhen i >= Missiles.Index set data = Missiles.Data[i] set a = 0 set z = data.rangeleft / MissileRangePerLevel(data.level) set scale = EndScale+(StartScale-EndScale)*z set radius = SpinEndRadius+(SpinStartRadius-SpinEndRadius)*z // Moving the missiles and setting their scale ect. depending on the left range call SetUnitX(data.missiles[0], data.x + MissileSpeed * Cos(data.angle) + Cos(data.angle+bj_PI/2) * Cos(data.a) * radius) call SetUnitY(data.missiles[0], data.y + MissileSpeed * Sin(data.angle) + Sin(data.angle+bj_PI/2) * Cos(data.a) * radius) call SetUnitFlyHeight(data.missiles[0], MissileHeight + Cos(data.a+bj_PI/2) * radius, 1000) call SetUnitScale(data.missiles[0],scale,scale,scale) call SetUnitX(data.missiles[1], data.x + MissileSpeed * Cos(data.angle) + Cos(data.angle+bj_PI/2) * Cos(data.a+bj_PI) * radius) call SetUnitY(data.missiles[1], data.y + MissileSpeed * Sin(data.angle) + Sin(data.angle+bj_PI/2) * Cos(data.a+bj_PI) * radius) call SetUnitFlyHeight(data.missiles[1], MissileHeight + Cos(data.a-bj_PI/2) * radius, 1000) call SetUnitScale(data.missiles[1],scale,scale,scale) set data.x = data.x + MissileSpeed * Cos(data.angle) set data.y = data.y + MissileSpeed * Sin(data.angle) set data.a = data.a + SpinRate set data.rangeleft = data.rangeleft - MissileSpeed set a = 0 // looping through all units in range call GroupEnumUnitsInRange(g, data.x, data.y, radius + AdditionalDamageRange, filter) loop set b = FirstOfGroup(g) exitwhen b==null call GroupRemoveUnit(g,b) //checking if they are alrady damaged if IsUnitInGroup(b,data.DamagedUnits) == false and DealDamageCondition(b,data.caster) then //damaging + casting buff call GroupAddUnit(data.DamagedUnits,b) call UnitDamageTarget(data.caster,b,DamagePerLevel(I2R(data.level)),true, false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS) call DestroyEffect(AddSpecialEffectTarget(DamageEffect, b, "chest") ) set dummy = CreateUnit(GetOwningPlayer(data.missiles[0]),CastDummyID,GetUnitX(b),GetUnitY(b),0) call UnitAddAbility(dummy,MindBurstEffectSpell) call SetUnitAbilityLevel(dummy,MindBurstEffectSpell,data.level) call UnitApplyTimedLife(dummy, 'BTLF', 0.75) call IssueTargetOrder( dummy, EffectOrderID,b ) // Checking if unit has mana to steal it if ManaDrainCondition(b) then call DestroyEffect(AddSpecialEffectTarget(HealEffect, data.caster, "origin") ) if (GetUnitState(b,UNIT_STATE_MANA) > StolenManaPerLevel(I2R(data.level))) then call SetUnitState(b, UNIT_STATE_MANA,GetUnitState(b,UNIT_STATE_MANA)-StolenManaPerLevel(I2R(data.level))) call SetUnitState(data.caster, UNIT_STATE_MANA,GetUnitState(data.caster,UNIT_STATE_MANA)+StolenManaPerLevel(I2R(data.level))) else call SetUnitState(data.caster, UNIT_STATE_MANA,GetUnitState(data.caster,UNIT_STATE_MANA)+GetUnitState(b,UNIT_STATE_MANA)) call SetUnitState(b, UNIT_STATE_MANA,0) endif endif endif endloop // Checking if the missiles reached their end point if data.rangeleft < 0 then call DestroyEffect(AddSpecialEffect(MissilesDeath,data.x,data.y) ) set ii = i // destryoing the missiles call RemoveUnit(data.missiles[0]) set data.missiles[0] = null call RemoveUnit(data.missiles[1]) set data.missiles[1] = null call DestroyGroup(data.DamagedUnits) set data.DamagedUnits = null set data.caster = null call Missiles.destroy(data) loop exitwhen ii >= Missiles.Index set Missiles.Data[ii-1] = Missiles.Data[ii] set ii = ii + 1 endloop set i = i -1 set Missiles.Index = Missiles.Index - 1 set ii = 0 endif set i = i + 1 endloop call DestroyGroup(g) set g = null set b = null set dummy = null endfunction private function Mind_Burst_Actions takes nothing returns nothing local unit caster = GetTriggerUnit() local integer level = GetUnitAbilityLevel(caster,MindBurstSpell) local real angle = Atan2(GetLocationY(GetSpellTargetLoc()) - GetUnitY(caster), GetLocationX(GetSpellTargetLoc()) - GetUnitX(caster)) local real x = GetUnitX(caster) + ReleaseDistance * Cos(angle) local real y = GetUnitY(caster) + ReleaseDistance * Sin(angle) // Creating the Struct call Missiles.create() set Missiles.Data[Missiles.Index-1].caster = caster set Missiles.Data[Missiles.Index-1].angle = angle set Missiles.Data[Missiles.Index-1].rangeleft = MissileRangePerLevel(level) set Missiles.Data[Missiles.Index-1].level = level set Missiles.Data[Missiles.Index-1].x = x set Missiles.Data[Missiles.Index-1].y = y set Missiles.Data[Missiles.Index-1].missiles[0] = CreateUnit(GetOwningPlayer(caster), DummyID , x , y , angle * (180.0/bj_PI)) set Missiles.Data[Missiles.Index-1].missiles[1] = CreateUnit(GetOwningPlayer(caster), DummyID , x , y , angle * (180.0/bj_PI)) if Missiles.Data[Missiles.Index-1].Index == 1 then call TimerStart(t, TimerPeriod, true, function callback) endif set caster = null endfunction //=========================================================================== function InitTrig_Mind_Burst takes nothing returns nothing local integer index local boolexpr cond = Condition( function RunCondition ) set filter = Filter(function NullFilter) set gg_trg_Mind_Burst = CreateTrigger( ) set index = 0 loop call TriggerRegisterPlayerUnitEvent(gg_trg_Mind_Burst, Player(index), EVENT_PLAYER_UNIT_SPELL_CAST, filter) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop call TriggerAddCondition( gg_trg_Mind_Burst, cond ) call TriggerAddAction( gg_trg_Mind_Burst, function Mind_Burst_Actions ) set cond = null //Preloading the used effect models call Preload(DamageEffect) call Preload(HealEffect) call Preload(MissilesDeath) endfunction endscope
Message edited by JonNny - Friday, 2009-04-24, 3:35 PM |
|
| |
|