• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Blizzard

Status
Not open for further replies.
Level 2
Joined
Mar 22, 2006
Messages
14
Well hi, I am trying to create a JASS Spell but it is hardly working. Whenever I want to cast my spell, the game will fall out.
My main goal of the spell is this : Calling down waves of blizzard, and in the area of the blizzard will spawn randomly frost nova's. Here is my spell :
Code:
function Trig_Blizzard_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A004' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blizzard_Func004C takes nothing returns boolean
    if ( not ( GetUnitCurrentOrder(GetSpellAbilityUnit()) == String2OrderIdBJ("blizzard") ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blizzard_Actions takes nothing returns nothing
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h001', GetOwningPlayer(GetSpellAbilityUnit()), GetSpellTargetLoc(), GetUnitLoc(GetAttacker()) )
    call UnitApplyTimedLifeBJ( 5.00, 'BTLF', GetLastCreatedUnit() )
    call IssuePointOrderLocBJ( GetLastCreatedUnit(), "frostnova", OffsetLocation(GetSpellTargetLoc(), GetRandomPercentageBJ(), GetRandomPercentageBJ()) )
    if ( Trig_Blizzard_Func004C() ) then
        call ConditionalTriggerExecute( gg_trg_Blizzard )
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_Blizzard takes nothing returns nothing
    set gg_trg_Blizzard = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Blizzard, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Blizzard, Condition( function Trig_Blizzard_Conditions ) )
    call TriggerAddAction( gg_trg_Blizzard, function Trig_Blizzard_Actions )
endfunction
 
Level 9
Joined
Aug 27, 2004
Messages
471
It seems I beat you to this spell by a few months :p.

http://www.wc3sear.ch/index.php?p=Spells&ID=1308&sid=

Heres the code (Might be complicated & long) PS: You need Kattanas handler system for this.

Code:
function SetupIcyDeathVars takes integer level returns nothing
local real array Sky_Shard_Damage
local real array Sky_Shard_Frost_Duration
local real array Earth_Shard_Damage
local real array Range
local integer array MaxSkyShards
local integer array MaxEarthShards
local integer array Speed

//--------------------------------------------------------------------------------
//Set variable values here, an explination of what is what can be found in the Icy Death Q and A. (The disabled trigger)

set Sky_Shard_Damage[1] = 0.00 //Default 0.00
set Sky_Shard_Damage[2] = 0.00 //Default 0.00
set Sky_Shard_Damage[3] = 0.00 //Default 0.00
set Sky_Shard_Damage[4] = 0.00 //Default 0.00
set Sky_Shard_Damage[5] = 0.00 //Default 0.00

set Sky_Shard_Frost_Duration[1] = 1.00 //Default 1.00
set Sky_Shard_Frost_Duration[2] = 2.00 //Default 2.00
set Sky_Shard_Frost_Duration[3] = 3.00 //Default 3.00
set Sky_Shard_Frost_Duration[4] = 4.00 //Default 4.00
set Sky_Shard_Frost_Duration[5] = 5.00 //Default 5.00

set Earth_Shard_Damage[1] = 30.00 //Default 30.00
set Earth_Shard_Damage[2] = 40.00 //Default 40.00
set Earth_Shard_Damage[3] = 50.00 //Default 50.00
set Earth_Shard_Damage[4] = 60.00 //Default 60.00
set Earth_Shard_Damage[5] = 70.00 //Default 70.00

set Range[1] = 180.00 //Default 180.00
set Range[2] = 225.00 //Default 225.00
set Range[3] = 270.00 //Default 270.00
set Range[4] = 315.00 //Default 315.00
set Range[5] = 370.00 //Default 370.00

set MaxSkyShards[1] = 4 //Default 4
set MaxSkyShards[2] = 5 //Default 5
set MaxSkyShards[3] = 6 //Default 6
set MaxSkyShards[4] = 7 //Default 7
set MaxSkyShards[5] = 8 //Default 8

set MaxEarthShards[1] = 3 //Default 3
set MaxEarthShards[2] = 4 //Default 4
set MaxEarthShards[3] = 5 //Default 5
set MaxEarthShards[4] = 6 //Default 6
set MaxEarthShards[5] = 7 //Default 7

set Speed[1] = 1 //Default 1
set Speed[2] = 1 //Default 1
set Speed[3] = 1 //Default 1
set Speed[4] = 1 //Default 1
set Speed[5] = 1 //Default 1

//This is the end of the variable setup.
//--------------------------------------------------------------------------------


call SetHandleReal(GetTriggeringTrigger(), ("Sky_Shard_Damage"), Sky_Shard_Damage[level])
call SetHandleReal(GetTriggeringTrigger(), ("Sky_Shard_Frost_Duration"), Sky_Shard_Frost_Duration[level])
call SetHandleReal(GetTriggeringTrigger(), ("Earth_Shard_Damage"), Earth_Shard_Damage[level])
call SetHandleReal(GetTriggeringTrigger(), ("Range"), Range[level])
call SetHandleInt(GetTriggeringTrigger(), ("MaxSkyShards"), MaxSkyShards[level])
call SetHandleInt(GetTriggeringTrigger(), ("MaxEarthShards"), MaxEarthShards[level])
call SetHandleInt(GetTriggeringTrigger(), ("Speed"), Speed[level])

endfunction



function SpellRawCode takes nothing returns integer
return 'A000'
endfunction

function IDC takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == SpellRawCode() ) ) then
        return false
    endif
    return true
endfunction

//Sky portion finishing

function SkyFinishPortion takes nothing returns nothing
local effect Morbid82 = GetHandleEffect(GetExpiredTimer(), "FrozenSfx2150")
local unit FOG = GetHandleUnit(GetExpiredTimer(), "FOGCurrent2150")
call SetUnitMoveSpeed(FOG, (GetUnitDefaultMoveSpeed(FOG)))
call DestroyEffect(Morbid82)
set FOG = null
set Morbid82 = null
endfunction

//Sky Damage Portion.

function SkyDamagePortion takes nothing returns nothing
local timer array FrostTimer
local effect array Freezer
local real PointHitX = 0
local real PointHitY = 0
local real Range = GetHandleReal(GetExpiredTimer(), "Range2150")
local real Durant = GetHandleReal(GetExpiredTimer(), "FrostyDur2150") //Duration
local real Damage = GetHandleReal(GetExpiredTimer(), "Damage2150")
local integer Groupies = 0
local integer CountA = 0 
local integer CountB = 0
local group Radialian
local location FinLocation
local unit FOG
local unit caster = GetHandleUnit(GetExpiredTimer(), "CastingHero2150")
local player owner = GetOwningPlayer(caster)
set PointHitX = GetHandleReal(GetExpiredTimer(), "PHX")
set PointHitY = GetHandleReal(GetExpiredTimer(), "PHY")
set FinLocation = Location(PointHitX, PointHitY)
set Radialian = GetUnitsInRangeOfLocAll(Range, FinLocation)
set Groupies = CountUnitsInGroup(Radialian)
set FOG = FirstOfGroup(Radialian)
loop
 exitwhen(Groupies <= 0)
 set Groupies = CountUnitsInGroup(Radialian)
 set FOG = FirstOfGroup(Radialian)
   if(IsUnitAliveBJ(FOG) == true) then
     if(IsUnitEnemy(FOG, owner) == true) then
      call UnitDamageTargetBJ(caster, FOG, Damage, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL)
      call SetUnitMoveSpeed(FOG, (GetUnitDefaultMoveSpeed(FOG)) - 100)
      set FrostTimer[CountA] = CreateTimer()
      set Freezer[CountA] = AddSpecialEffectTarget("Abilities\\Spells\\Other\\FrostDamage\\FrostDamage.mdl", FOG, "overhead")

      call SetHandleHandle(FrostTimer[CountA], "FrozenSfx2150", Freezer[CountA])
      call SetHandleHandle(FrostTimer[CountA], "FogCurrent2150", FOG)

      call TimerStart(FrostTimer[CountA], Durant, false, function SkyFinishPortion)
      call GroupRemoveUnit(Radialian, FOG)

      set CountA = (CountA + 1)
     endif
   endif
endloop
call DestroyGroup(Radialian)
set Radialian = null
set FOG = null
call RemoveLocation(FinLocation)
set FinLocation = null
set owner = null
set caster = null
set CountB = CountA
loop
 exitwhen(CountB <= 0)
 call DestroyEffect(Freezer[CountB])
 set Freezer[CountB] = null
 set CountB = (CountB - 1)
endloop
loop
 exitwhen(CountA <= 0)
 call DestroyTimer(FrostTimer[CountA])
 set FrostTimer[CountA] = null
 set CountA = (CountA - 1)
endloop
set CountA = 0
set CountB = 0
set PointHitX = 0.00
set PointHitY = 0.00
set Range = 0.00
set Damage = 0.00
set Durant = 0.00
endfunction

//Sky Portion

function SkyPortion takes real painful, integer spd, real range, integer maxama, location targpos, real frosty, unit caster returns nothing
local effect array Effects
local location array HitPoint
local timer array TillFor
local real array XS
local real array YS
local real array FinWait
local integer lvl = GetHandleInt(GetTriggeringTrigger(), "levelism")
local real FinFrosty = frosty
local real RanX = 0
local real RanY = 0
local real MaxWait = (1.62 / I2R(lvl))
local real MinWait = (1.02 / I2R(lvl))
local real TargposX = GetLocationX(targpos)
local real TargposY = GetLocationY(targpos)
local real passX = 0
local real passY = 0
local integer CountA = 0
local integer CountB = 0
 loop
  exitwhen(CountA >= maxama)
  set FinWait[CountA] = (GetRandomReal(MinWait, MaxWait))
  set RanX = (GetRandomReal((range - (range * 2)), (range)))
  set RanY = (GetRandomReal((range - (range * 2)), (range)))
  set HitPoint[CountA] = Location((TargposX + RanX), (TargposY + RanY))
  set Effects[CountA] = AddSpecialEffectLoc("Abilities\\Spells\\Human\\Blizzard\\BlizzardTarget.mdl", HitPoint[CountA])  
  
  set TillFor[CountA] = CreateTimer()
  set passX = GetLocationX(HitPoint[CountA])
  set passY = GetLocationY(HitPoint[CountA])
   
  call SetHandleReal(TillFor[CountA], ("FrostyDur2150"), FinFrosty)
  call SetHandleReal(TillFor[CountA], ("Damage2150"), painful)
  call SetHandleReal(TillFor[CountA], ("Range2150"), range)
  call SetHandleReal(TillFor[CountA], ("PHX"), passX)
  call SetHandleReal(TillFor[CountA], ("PHY"), passY)
  call SetHandleHandle(TillFor[CountA], "CastingHero2150", caster)

  call TimerStart(TillFor[CountA], 0.80, false, function SkyDamagePortion)
  call TriggerSleepAction(FinWait[CountA])
  set CountA = (CountA + 1)
 endloop
set CountB = CountA
loop
 exitwhen(CountB <= 0)
 call RemoveLocation(HitPoint[CountB])
 set HitPoint[CountB] = null
 call DestroyTimer(TillFor[CountB])
 set TillFor[CountB] = null
 call DestroyEffect(Effects[CountB])
 set Effects[CountB] = null
 set CountB = (CountB - 1)
endloop
endfunction

//Earth portion
function EarthPortion takes real painful, real range, integer maxama, location targpos, unit casterunit returns nothing
local location array TargetPoint
local effect array DestroEff
local integer lvl = GetHandleInt(GetTriggeringTrigger(), "levelism")
local real TargposX = GetLocationX(targpos)
local real TargposY = GetLocationY(targpos)
local real RanX = 0.00
local real RanY = 0.00
local real Twait = 0.00
local real Mawait = (0.80 / I2R(lvl))
local real Miwait = (0.20 / I2R(lvl))
local integer CountA = 0
local unit FOG
local group TotalTargs
local player owner = GetOwningPlayer(casterunit)
set TotalTargs = GetUnitsInRangeOfLocAll(range, targpos)
loop
 exitwhen(CountA == maxama)
 set RanX = (GetRandomReal((range - (range * 2)), (range)))
 set RanY = (GetRandomReal((range - (range * 2)), (range)))
 set TargetPoint[CountA] = Location((RanX + TargposX), (RanY + TargposY))
 set DestroEff[CountA] = AddSpecialEffectLoc("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl", TargetPoint[CountA])
 set TotalTargs = GetUnitsInRangeOfLocAll(range, TargetPoint[CountA])
 set FOG = FirstOfGroup(TotalTargs)
  if(IsUnitAliveBJ(FOG) == true) then
   if(IsUnitEnemy(FOG, owner) == true) then
   call UnitDamageTargetBJ(casterunit, FOG, painful, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL)
   endif
  endif
set FOG = null
set Twait = (GetRandomReal(Miwait, Mawait))
call TriggerSleepAction(Twait)
call DestroyEffectBJ(DestroEff[CountA])
set DestroEff[CountA] = null
call RemoveLocation(TargetPoint[CountA])
set TargetPoint[CountA] = null
set CountA = (CountA + 1)
endloop
set owner = null
call DestroyGroup(TotalTargs)
set TotalTargs = null
set TargposX = 0.00
set TargposY = 0.00
set RanX = 0.00
set RanY = 0.00
set Twait = 0.00
set Miwait = 0.00
set Mawait = 0.00
set CountA = 0
endfunction

//Casterpause
function CasterPause takes unit caster, boolean pausetype returns nothing
call PauseUnit(caster, pausetype)
if(pausetype == true) then
call ResetUnitAnimation(caster)
call SetUnitAnimation(caster, "channel")
else
call ResetUnitAnimation(caster)
endif
endfunction

//Main body\\

function IcyDeath takes nothing returns nothing
local real FinSkyDam
local real FinSkyDur
local real FinEarthDam
local real FinRange
local integer FinSkyMax
local integer FinEarthMax
local integer FinSpeed
local unit casteram = GetSpellAbilityUnit()
local location casterpos = GetUnitLoc(GetSpellAbilityUnit())
local location TP = GetSpellTargetLoc()
local integer alvl = GetUnitAbilityLevel(GetSpellAbilityUnit(), SpellRawCode())

call SetHandleHandle(GetTriggeringTrigger(), "casterunit", casteram)
call SetHandleInt(GetTriggeringTrigger(), "levelism", alvl)

call SetupIcyDeathVars(alvl)

set FinSkyDam = GetHandleReal(GetTriggeringTrigger(), "Sky_Shard_Damage")
set FinSkyDur = GetHandleReal(GetTriggeringTrigger(), "Sky_Shard_Frost_Duration")
set FinEarthDam = GetHandleReal(GetTriggeringTrigger(), "Earth_Shard_Damage")
set FinRange = GetHandleReal(GetTriggeringTrigger(), "Range")
set FinSkyMax = GetHandleInt(GetTriggeringTrigger(), "MaxSkyShards")
set FinEarthMax = GetHandleInt(GetTriggeringTrigger(), "MaxEarthShards")
set FinSpeed = GetHandleInt(GetTriggeringTrigger(), "Speed")

call CasterPause(casteram, true)
call SkyPortion(FinSkyDam, FinSpeed, FinRange, FinSkyMax, TP, FinSkyDur, casteram)
call EarthPortion(FinEarthDam, FinRange, FinEarthMax, TP, casteram)
call CasterPause(casteram, false)

set casteram = null
call RemoveLocation(casterpos)
set casterpos = null
call RemoveLocation(TP)
set TP = null
set FinSkyDam = 0.00
set FinSkyDur = 0.00
set FinEarthDam = 0.00
set FinRange = 0.00
set FinSkyMax = 0
set FinEarthMax = 0
set FinSpeed = 0
endfunction
//===========================================================================
function InitTrig_Icy_Death takes nothing returns nothing
    local trigger t
    set t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function IDC ) )
    call TriggerAddAction( t, function IcyDeath)
endfunction

Yeah, its a painfully long spell. Mostly to avoid the use of dummies. Feel free to poke around this code.
 
Level 2
Joined
Sep 10, 2004
Messages
21
@HeaL: Your Trigger crashes the game because it recalls the same function over and over again, with no wait in between.
JASS:
call ConditionalTriggerExecute( gg_trg_Blizzard )
will call itself, and , since theres no wait, the conditions are all true and your computer has lots of work ;)
just call a
JASS:
PolledWait(1)
before the ConditionalTriggerExecute line.

And, like PurplePoot noted, the Frost Nova is a Unit-targeting spell, so you should perhaps create invisible units that are targeted like Vexorian does in his Caster system sample map - or you can use another spell for the frost nova effect.
 
Status
Not open for further replies.
Top