• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Starfall via Trigger

Status
Not open for further replies.
Level 8
Joined
Mar 24, 2011
Messages
353
I need an spell to my druid named Wrath of Nature, the spell is literally in function equal to "Starfall" ability of Priestess of the Moon, Channeled, picks random units nearby caster channeling and do damage. But i dont can uses the "Starfall" ability because two problem:
1) I want do the "damage" calculed in caster/channeler Int (Int x 2)
2) When unit is "hited" by the "Falling Star" he is "slowed"

Basically i need an system / spell in function like Starfall ability, but the damage is calculed in Int of Caster/Channeler and the hited unit/victim is slowed too

Can someone help me? :ogre_haosis::ogre_haosis:
 
Level 12
Joined
Jan 2, 2016
Messages
973
JASS:
library SpeedChange
   
    globals
        private hashtable Table = InitHashtable()
        private hashtable SpeedTable = InitHashtable()
        constant real MinMoveSpeed = 1.00
    endglobals

    private function GetActualEndSpeed takes real init, real modif returns real
        local real result = init * modif
        if result < MinMoveSpeed then
            return MinMoveSpeed
        endif
        return result
    endfunction
   
    private function GetActualEndSpeedLinear takes real def, real init, real modif returns real
        local real result = init - def*(1-modif)
        if result < MinMoveSpeed then
            return MinMoveSpeed
        endif
        return result
    endfunction

    private function OnExpire2 takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer id = GetHandleId(t)
        local integer buff_ab = LoadInteger(Table, id, 'babi')
        local unit u = LoadUnitHandle(Table, id, 'unit')
        local integer id2 = GetHandleId(u)
        local real current_speed = LoadReal( SpeedTable , id2 , 0 )
        local real speed_change = LoadReal( SpeedTable , id2 , buff_ab )
        local integer temp_int = LoadInteger( SpeedTable , id2 , 1 )
        call SetUnitMoveSpeed( u , current_speed * speed_change )
        call RemoveSavedReal( SpeedTable, id2, buff_ab )
        call UnitRemoveAbility( u , buff_ab )
        call RemoveSavedHandle(Table, id2, buff_ab)
        call FlushChildHashtable(Table, id)
        call DestroyTimer(t)
        if temp_int == 1 then
            call FlushChildHashtable( SpeedTable , id2 )
        else
            call SaveReal( SpeedTable , id2 , 0 , current_speed * speed_change )
            call SaveInteger( SpeedTable , id2 , 1 , temp_int - 1 )
        endif
        set t = null
        set u = null
    endfunction

    function ChangeUnitSpeed2 takes unit u, real speed_modifier, real duration, boolean linear, integer buff_ability, boolean building_up returns nothing
        local timer t = LoadTimerHandle(Table, GetHandleId(u), buff_ability)
        local integer id
        local integer id2 = GetHandleId(u)
        local real time
        local real init_speed = LoadReal( SpeedTable, id2, 0 )
        local real end_speed
        local integer temp_int = LoadInteger( SpeedTable, id2, 1 ) + 1
        if init_speed == 0 then
            set init_speed = GetUnitDefaultMoveSpeed(u)
        endif
        if t != null then
            set id = GetHandleId(t)
            set time = TimerGetRemaining(t) + duration
        else
            set t = CreateTimer()
            set id = GetHandleId(t)
            call SaveTimerHandle(Table, id2, buff_ability, t )
            set time = duration
        endif
        if time == duration then
            if linear then
                set end_speed = GetActualEndSpeedLinear( GetUnitDefaultMoveSpeed(u), init_speed, speed_modifier )
            else
                set end_speed = GetActualEndSpeed(init_speed, speed_modifier)
            endif
            call SetUnitMoveSpeed( u , end_speed )
            call SaveUnitHandle(Table, id, 'unit', u )
            call SaveReal( SpeedTable, id2, 0, end_speed )
            call SaveInteger( SpeedTable, id2, 1, temp_int)
            call SaveReal( SpeedTable, id2, buff_ability, init_speed / end_speed)
            call UnitAddAbility( u , buff_ability )
            call SaveInteger(Table, id, 'babi', buff_ability )
        endif
        if building_up then
            call TimerStart( t, time, false, function OnExpire2 )
        else
            call TimerStart( t, duration, true, function OnExpire2 )
        endif
        set t = null
        set u = null
    endfunction

endlibrary

function SF_Fall takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local unit c = LoadUnitHandle( udg_Table, id, 'unit' )
    local player p = GetOwningPlayer(c)
    local real x = LoadReal( udg_Table, id, 'casx' )
    local real y = LoadReal( udg_Table, id, 'casy' )
    local group g = CreateGroup()
    local unit u
    call GroupEnumUnitsInRange( g, x, y, 500.00, null )
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        if IsUnitEnemy( u, p ) then
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Starfall\\StarfallTarget.mdl", u, "origin"))
            call UnitDamageTarget( c, u, 2*GetHeroInt(c, true) , true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
            call ChangeUnitSpeed2( u, 0.5, 3, true, 'A001', false )
        endif
        call GroupRemoveUnit(g, u)
    endloop
    call DestroyGroup(g)
    set g = null
    set c = null
    set p = null
    set t = null
endfunction        

function Trig_Starfall_Conditions takes nothing returns boolean
    local unit u
    local real x
    local real y
    local timer t
    local integer id
    if GetSpellAbilityId() == 'A000' then // 'A000' is the ID of your starfall
        set u = GetTriggerUnit()
        set t = CreateTimer()
        set x = GetUnitX(u)
        set y = GetUnitY(u)
        set id = GetHandleId(t)
        call SaveUnitHandle( udg_Table, id, 'unit', u )
        call SaveReal( udg_Table, id, 'casx', x )
        call SaveReal( udg_Table, id, 'casy', y )
        call SaveTimerHandle( udg_Table, GetHandleId(u), 'time', t )
        call TimerStart( t, 1.5, true, function SF_Fall )
        set u = null
        set t = null
    endif
    return false
endfunction

function SF_End takes nothing returns boolean
    local unit u
    local timer t
    if GetSpellAbilityId() == 'A000' then
        set u = GetTriggerUnit()
        set t = LoadTimerHandle(udg_Table, GetHandleId(u), 'time')
        call FlushChildHashtable(udg_Table, GetHandleId(t))
        call DestroyTimer(t)
        set t = null
        call FlushChildHashtable(udg_Table, GetHandleId(u))
        set u = null
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Starfall takes nothing returns nothing
    local trigger t = CreateTrigger()
    set gg_trg_Starfall = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Starfall, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddCondition( gg_trg_Starfall, Condition( function Trig_Starfall_Conditions ) )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
    call TriggerAddCondition( t, Condition(function SF_End))
    set t = null
endfunction
There :)
EDIT: Ops, forgot to add the slow...
EDIT 2: Okay, I added part of my slowing library, and now it slows :)

Now you need JNGP for it tho...
Tell me if I need to rework it for normal WE xP
 

Attachments

  • Temp.w3x
    20.2 KB · Views: 69
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
thanks, but i dont know nothing of Jazz, or how i can edite this spell / system for put in my map :/

..I just know how use trigger :/
dont can be via trigger? i dont know / use jazz :c
These are triggers... Even GUI triggers convert to JASS when you save the map.

You can edit it like any other script or programming language. JASS follows a pretty simple syntax.
 
Level 12
Joined
Jan 2, 2016
Messages
973
Alright, I made you a GUI version.
It still uses my Movespeed Library tho, which you don't need to change.
You just need to have it on your map, and you need to have JNGP.
You can find my library, with describtion here.
Here are the triggers:
  • Starfall Init
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Tranquility
    • Actions
      • Set Starfall_Unit[Starfall_Count] = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Starfall <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Starfall <gen>
        • Else - Actions
      • Set Starfall_Count = (Starfall_Count + 1)
  • Starfall
    • Events
      • Time - Every 1.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Starfall_Loop) from 0 to (Starfall_Count - 1), do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of Starfall_Unit[Starfall_Loop])
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 550.00 of TempPoint) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) belongs to an enemy of (Owner of Starfall_Unit[Starfall_Loop])) Equal to True
                  • ((Picked unit) is alive) Equal to True
                • Then - Actions
                  • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\NightElf\Starfall\StarfallTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Cause Starfall_Unit[Starfall_Loop] to damage (Picked unit), dealing (2.00 x (Real((Intelligence of Starfall_Unit[Starfall_Loop] (Include bonuses))))) damage of attack type Spells and damage type Magic
                  • Custom script: call ChangeUnitSpeed2( GetEnumUnit(), 0.5, 3, true, 'A001', false )
                • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint)
  • Starfall End
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Tranquility
    • Actions
      • Set TempBoolean = False
      • For each (Integer Starfall_End_Loop) from 0 to (Starfall_Count - 1), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to Starfall_Unit[Starfall_End_Loop]
            • Then - Actions
              • Set TempBoolean = True
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempBoolean Equal to True
            • Then - Actions
              • Set Starfall_Unit[Starfall_End_Loop] = Starfall_Unit[(Starfall_End_Loop + 1)]
            • Else - Actions
      • Set Starfall_Count = (Starfall_Count - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Starfall_Count Equal to 0
        • Then - Actions
          • Trigger - Turn off Starfall <gen>
        • Else - Actions
 

Attachments

  • Temp.w3x
    29.8 KB · Views: 56
Status
Not open for further replies.
Top