• 🏆 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!

[JASS] Converting Problem

Status
Not open for further replies.
Level 31
Joined
May 3, 2008
Messages
3,155
  • Arrow Split 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Arrow Split (Red Ranger)
    • Actions
      • Set SA_castpt = (Position of (Triggering unit))
      • Set SA_tmppt = (Target point of ability being cast)
      • Set SA_real = (Angle from SA_castpt to SA_tmppt)
      • Set SA_tarpt = (SA_castpt offset by 100.00 towards SA_real degrees)
      • Unit - Create 1 Dummy 1 (Arrow Split) for (Owner of (Triggering unit)) at SA_tarpt facing SA_tmppt
      • Unit - Order (Last created unit) to Move To SA_tmppt
      • Set SA_real = ((Distance between SA_castpt and SA_tmppt) / 522.00)
      • Unit - Add a SA_real second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation(udg_SA_castpt)
      • Custom script: call RemoveLocation(udg_SA_tarpt)
      • Custom script: call RemoveLocation(udg_SA_tmppt)
  • Arrow Split 2
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Dummy 1 (Arrow Split)
    • Actions
      • Set SA_tmppt3 = (Position of (Triggering unit))
      • For each (Integer Arrow_Split) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set SA_tmppt2 = (SA_tmppt3 offset by 300.00 towards (SA_real + 30.00) degrees)
          • Unit - Create 1 Dummy 2 (Arrow Split) for (Owner of (Triggering unit)) at SA_tmppt3 facing SA_tmppt2
          • Unit - Add a 0.30 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to Orc Tauren Chieftain - Shockwave SA_tmppt2
          • Set SA_real = (SA_real + 30.00)
          • Custom script: call RemoveLocation(udg_SA_tmppt2)
      • Custom script: call RemoveLocation(udg_SA_tmppt3)
      • Set SA_real = 0.00
JASS:
function Arrow_Split_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A62X'
endfunction

function Arrow_Split_Actions takes nothing returns nothing
    local unit caster=GetTriggerUnit()
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real x2=GetSpellTargetX()
    local real y2=GetSpellTargetY()
    local real sd=(GetUnitFacing(caster) + 100)
    local real td
    local unit lastcreated=CreateUnit(GetOwningPlayer(caster),'n61Q',x1,y1,sd)
    call IssuePointOrder(lastcreated,"move",x2,y2)
    set td=SquareRoot((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))/522.
    call UnitApplyTimedLife(lastcreated,'BTLF',td)
    set caster=null
    set lastcreated=null
endfunction

function Arrow_Death_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit())=='n61Q'
endfunction

function Arrow_Death_Actions takes nothing returns nothing
    local unit dead=GetTriggerUnit()
    local unit lastCreated=null
    local real x1=GetUnitX(dead)
    local real y1=GetUnitY(dead)
    local integer Arrow_Split=1
    local real SA_real=0
    local real missilefacing=bj_RADTODEG*Atan2(y1,x1) 
    local real newX
    local real newY
    loop
        exitwhen Arrow_Split>12
        set newX=x1+300*Cos(SA_real+.523599)
        set newY=y1+300*Sin(SA_real+.523599)
        set lastCreated=CreateUnit(GetOwningPlayer(dead),'n61R',x1,y1,missilefacing)
        call UnitApplyTimedLife(lastCreated,'BTLF',.30)
        call IssuePointOrder(lastCreated,"shockwave",newX,newY)
        set SA_real=SA_real+.523599
        set Arrow_Split=Arrow_Split+1
    endloop
    set dead=null
    set lastCreated=null
endfunction

//===========================================================================

constant function CSAS takes nothing returns boolean
    return true
endfunction

function InitTrig_Arrow_Split takes nothing returns nothing
    local trigger T=CreateTrigger()
    local trigger T2=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function CSAS)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI),EVENT_PLAYER_UNIT_DEATH,null)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Arrow_Split_Actions)
    call TriggerAddCondition(T,Condition(function Arrow_Split_Conditions))
    call TriggerAddAction(T2,function Arrow_Death_Actions)
    call TriggerAddCondition(T2,Condition(function Arrow_Death_Conditions))
    set FF=null
    set T=null
    set T2=null
endfunction



  • Flashlight
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flashlight (Prophet)
    • Actions
      • Set dummy_pt = (Position of (Triggering unit))
      • Set tar_u = (Target unit of ability being cast)
      • Set tar_pt = (Position of tar_u)
      • Set dist = 522.00
      • Set exp_r = 0.20
      • Set lvl = (Level of Flashlight (Prophet) for (Triggering unit))
      • Unit - Create 1 Dummy 1 (Flashlight) for (Owner of (Triggering unit)) at dummy_pt facing tar_pt
      • Set dum_u = (Last created unit)
      • Unit - Order dum_u to Orc Far Seer - Chain Lightning tar_u
      • Unit - Add a exp_r second Generic expiration timer to dum_u
      • Unit - Create 1 Dummy 1 (Flashlight) for (Owner of (Triggering unit)) at tar_pt facing tar_pt
      • Unit - Add a exp_r second Generic expiration timer to dum_u
      • Set dum_u = (Last created unit)
      • Unit - Order dum_u to Human Mountain King - Storm Bolt tar_u
      • For each (Integer FlashLight) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set tar_pt2 = (tar_pt offset by dist towards ang degrees)
          • Unit - Create 1 Dummy 2 (Flashlight) for (Owner of (Triggering unit)) at tar_pt facing tar_pt2
          • Set dum_u = (Last created unit)
          • Unit - Add a (exp_r + 1.30) second Generic expiration timer to dum_u
          • Unit - Order dum_u to Move To tar_pt2
          • Unit - Create 1 Dummy 3 (Flashlight) for (Owner of (Triggering unit)) at tar_pt2 facing tar_pt
          • Set dum_u = (Last created unit)
          • Unit - Set level of Chain Lightning (Multiple Target) (Dummy Ability) for dum_u to lvl
          • Unit - Add a (exp_r + 1.30) second Generic expiration timer to dum_u
          • Unit - Order dum_u to Orc Far Seer - Chain Lightning tar_u
          • Set ang = (ang + 36.00)
          • Custom script: call RemoveLocation(udg_tar_pt2)
      • Set ang = 0.00
      • Custom script: call RemoveLocation(udg_dummy_pt)
      • Custom script: call RemoveLocation(udg_tar_pt)
JASS:
function Flashlight_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A62P'
endfunction

function Flashlight_Actions takes nothing returns nothing
    local unit caster=GetTriggerUnit()
    local unit lastcreated
    local location target=GetSpellTargetLoc()
    local real angle
    local real distance = 522.00
    local real life_duration = 0.20
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real x2=GetLocationX(target)
    local real y2=GetLocationY(target)
    local integer level
    local integer FL = 1
    set udg_dummy_pt = GetUnitLoc(caster)
    set udg_tar_u = GetSpellTargetUnit()
    set udg_tar_pt = GetUnitLoc(udg_tar_u)
    set level = GetUnitAbilityLevel(caster,'A61T')
    set lastcreated=CreateUnit(GetOwningPlayer(caster),'n61I',x1,y1,x2, y2)
    call IssueTargetOrder(lastcreated, "chainlightning", udg_tar_u)
    call UnitApplyTimedLife(lastcreated,'BTLF',life_duration)
    call UnitApplyTimedLife(lastcreated,'BTLF',life_duration)
    call IssueTargetOrder( lastcreated, "thunderbolt", udg_tar_u )
    set lastcreated=null
    loop
        exitwhen FL > 10
        set udg_tar_pt2 = PolarProjectionBJ(udg_tar_pt, distance, angle)
        set lastcreated=CreateUnit(GetOwningPlayer(caster),'n61I',x1,y1,x2,y2)
        call UnitApplyTimedLife(lastcreated,'BTLF',life_duration + 1.30)
        call IssuePointOrderLoc (lastcreated, "move", x2,y2)
        set lastcreated=CreateUnit(GetOwningPlayer(caster),'n61I',x1,y1,x2,y2)
        call SetUnitAbilityLevel (lastcreated, 'A61V', level)
        call UnitApplyTimedLife(lastcreated,'BTLF',life_duration + 1.30)
        call IssueTargetOrder( lastcreated, "thunderbolt", udg_tar_u )
        set angle = ( angle + 36.00 )
        call RemoveLocation(udg_tar_pt2)
        set FL = FL + 1
        set lastcreated=null
    endloop
    set angle = 0.00
    call RemoveLocation(udg_dummy_pt)
    call RemoveLocation(udg_tar_pt)
endfunction

//===========================================================================

constant function GSF takes nothing returns boolean
    return true
endfunction

function InitTrig_Flashlight takes nothing returns nothing
    local trigger T=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function GSF)
    loop
    exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
    call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_SPELL_EFFECT,FF)
    set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Flashlight_Actions)
    call TriggerAddCondition(T,Condition(function Flashlight_Conditions))
    set FF=null
    set T=null
endfunction

  • Set Attacking Damage
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Unit Group - Add (Attacking unit) to Electric_Attack
  • Set Non Attacking Damage
    • Events
      • Unit - A unit Starts the effect of an ability
      • Unit - A unit Begins channeling an ability
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from Electric_Attack
  • Electric Chain Add 1
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Trigger - Add to Electric Chain Hit <gen> the event (Unit - (Triggering unit) Takes damage)
  • Electric Chain Add 2
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Group[1] = (Units in (Playable map area))
      • Unit Group - Pick every unit in Group[1] and do (Actions)
        • Loop - Actions
          • Trigger - Add to Electric Chain Hit <gen> the event (Unit - (Picked unit) Takes damage)
      • Custom script: call DestroyGroup (udg_Group[1])
  • Electric Chain Hit
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to Prophet
      • (Level of Electric Chain (Prophet) for (Damage source)) Greater than or equal to 1
      • ((Damage source) is in Electric_Attack) Equal to True
    • Actions
      • Set Electric_Punch_Hits[(Custom value of (Damage source))] = (Electric_Punch_Hits[(Custom value of (Damage source))] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Electric_Punch_Hits[(Custom value of (Damage source))] Equal to (10 - (Level of Electric Chain (Prophet) for (Damage source)))
        • Then - Actions
          • Special Effect - Create a special effect attached to the (weapon + left) of (Damage source) using Abilities\Spells\Orc\LightningShield\LightningShieldTarget.mdl
          • Set Electric_Punch_Effect[(Custom value of (Damage source))] = (Last created special effect)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Electric_Punch_Hits[(Custom value of (Damage source))] Equal to (11 - (Level of Electric Chain (Prophet) for (Damage source)))
            • Then - Actions
              • Set Capacitor_Point[1] = (Position of (Damage source))
              • Unit - Create 1 Dummy (Electric Strike) for (Owner of (Damage source)) at Capacitor_Point[1] facing Default building facing degrees
              • Unit - Add Electric Strike (Dummy Ability) to (Last created unit)
              • Unit - Set level of Electric Strike (Dummy Ability) for (Last created unit) to (Level of Electric Chain (Prophet) for (Damage source))
              • Unit - Order (Last created unit) to Orc Far Seer - Chain Lightning (Triggering unit)
              • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
              • Special Effect - Destroy Electric_Punch_Effect[(Custom value of (Damage source))]
              • Custom script: call RemoveLocation (udg_Capacitor_Point[1])
              • Set Electric_Punch_Hits[(Custom value of (Damage source))] = 0
            • Else - Actions
JASS:
function Electric_Chain_Attacked_Actions takes nothing returns nothing
    call GroupAddUnit(udg_Electric_Attack, GetAttacker())
endfunction

function Electric_Chain_None_Attacking_Damage_Actions takes nothing returns nothing
    call GroupRemoveUnit(udg_Electric_Attack, GetTriggerUnit())
endfunction

function Electric_Chain_Add_1_Actions takes nothing returns nothing
    call TriggerRegisterUnitEvent(T5, GetTriggerUnit(), EVENT_UNIT_DAMAGED )
endfunction

function Trig_Electric_Chain_Add_2_Actions_2 takes nothing returns nothing
    call TriggerRegisterUnitEvent(T5, GetEnumUnit(), EVENT_UNIT_DAMAGED )
endfunction

function Electric_Chain_Add_2_Actions takes nothing returns nothing
    set udg_Group[1] = GetUnitsInRectAll(GetPlayableMapRect())
    call ForGroupBJ( udg_Group[1], function Electric_Chain_Add_2_Actions_2 )
    call DestroyGroup (udg_Group[1])
endfunction

function Electric_Chain_Hit_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetEventDamageSource()) == 'H602' ) ) then
        return false
    endif
    if ( not ( GetUnitAbilityLevelSwapped('A61Y', GetEventDamageSource()) >= 1 ) ) then
        return false
    endif
    if ( not ( IsUnitInGroup(GetEventDamageSource(), udg_Electric_Attack) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Electric_Chain_Hit_Func002Func002C takes nothing returns boolean
    if ( not ( udg_Electric_Punch_Hits[GetUnitUserData(GetEventDamageSource())] == ( 11 - GetUnitAbilityLevelSwapped('A61Y', GetEventDamageSource()) ) ) ) then
        return false
    endif
    return true
endfunction

function Trig_Electric_Chain_Hit_Func002C takes nothing returns boolean
    if ( not ( udg_Electric_Punch_Hits[GetUnitUserData(GetEventDamageSource())] == ( 10 - GetUnitAbilityLevelSwapped('A61Y', GetEventDamageSource()) ) ) ) then
        return false
    endif
    return true
endfunction

function Electric_Chain_Hit_Actions takes nothing returns nothing
    set udg_Electric_Punch_Hits[GetUnitUserData(GetEventDamageSource())] = ( udg_Electric_Punch_Hits[GetUnitUserData(GetEventDamageSource())] + 1 )
    if ( Trig_Electric_Chain_Hit_Func002C() ) then
        call AddSpecialEffectTargetUnitBJ( ( "weapon" + "left" ), GetEventDamageSource(), "Abilities\\Spells\\Orc\\LightningShield\\LightningShieldTarget.mdl" )
        set udg_Electric_Punch_Effect[GetUnitUserData(GetEventDamageSource())] = GetLastCreatedEffectBJ()
    else
        if ( Trig_Electric_Chain_Hit_Func002Func002C() ) then
            set udg_Capacitor_Point[1] = GetUnitLoc(GetEventDamageSource())
            call CreateNUnitsAtLoc( 1, 'h60W', GetOwningPlayer(GetEventDamageSource()), udg_Capacitor_Point[1], bj_UNIT_FACING )
            call UnitAddAbilityBJ( 'A61X', GetLastCreatedUnit() )
            call SetUnitAbilityLevelSwapped( 'A61X', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A61Y', GetEventDamageSource()) )
            call IssueTargetOrderBJ( GetLastCreatedUnit(), "chainlightning", GetTriggerUnit() )
            call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
            call DestroyEffectBJ( udg_Electric_Punch_Effect[GetUnitUserData(GetEventDamageSource())] )
            call RemoveLocation (udg_Capacitor_Point[1])
            set udg_Electric_Punch_Hits[GetUnitUserData(GetEventDamageSource())] = 0
        else
        endif
    endif
endfunction

//===========================================================================

constant function GSEC takes nothing returns boolean
    return true
endfunction

function InitTrig_Electric_Chain takes nothing returns nothing
    local trigger T=CreateTrigger()
    local trigger T2=CreateTrigger()
    local trigger T3=CreateTrigger()
    local trigger T4=CreateTrigger()
    local trigger T5=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function GSEC)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_ATTACKED,null)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI), EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI), EVENT_PLAYER_UNIT_SPELL_CHANNEL,null)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI), EVENT_PLAYER_UNIT_SPELL_CAST,null)
        call TriggerRegisterEnterRegion(T3,Player(TI), GetWorldBounds() )
        call TriggerRegisterTimerEvent(T4,Player(TI),1.00 )
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Electric_Chain_Attacked_Actions)
    call TriggerAddAction(T2,function Electric_Chain_None_Attacking_Damage_Actions)
    call TriggerAddAction(T3,function Electric_Chain_Add_1_Actions)
    call TriggerAddAction(T4,function Electric_Chain_Add_2_Actions)
    call TriggerAddAction(T5, function Electric_Chain_Hit_Actions )
    call TriggerAddCondition(T5, Condition( function Electric_Chain_Hit_Conditions ) )
    set FF=null
    set T=null
    set T2=null
    set T3=null
    set T4=null
    set T5=null
endfunction

I try to convert this spells to JASS for better efficiency.

Upon casting, this spells would create 1 arrow infront of the caster (offset 100) and then move forward to the targeted location. Upon reaching the target location, it would split into 12 arrows.

Well, I am not quite familiar with real x/y. Any resolution with it?
 
Last edited:
Level 22
Joined
Dec 31, 2006
Messages
2,216
Here's the first one:
JASS:
function Arrow_Split_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A62P'
endfunction

function Arrow_Split_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit lastcreated
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real x2=GetSpellTargetX()
    local real y2=GetSpellTargetY()
    local real sd = (GetUnitFacing(caster) + 100)
    local real td
    set lastcreated=CreateUnit(GetOwningPlayer(caster),'n610', x1,y1, sd)
    call IssuePointOrder (lastcreated,"move",x2,y2)
    set td = SquareRoot((y2-y1) * (y2-y1) + (x2-x1) * (x2-x1))/522.
    call UnitApplyTimedLife(lastcreated,'BTLF',td)
    set caster = null
    set lastcreated = null
endfunction

//===========================================================================

function InitTrig_Arrow_Split takes nothing returns nothing
    local trigger T = CreateTrigger()
    local integer TI = 0
    loop
        exitwhen (TI >= bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T, Player(TI), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set TI = TI + 1
    endloop
    call TriggerAddAction(T,function Arrow_Split_Actions)
    call TriggerAddCondition(T,Condition(function Arrow_Split_Conditions))
    set T = null
endfunction
I'll fix the second one tomorrow if no one has already done it when I come back.
 
You can probably merge it into one trigger:
(btw, you don't need the globals block, simply remove that entire thing and its contents, that is just for implementation)
JASS:
globals
    hashtable udg_MyHashtable
    //this is just to state what globals you need
    //change this to whatever hashtable you are using
    //or make a new one
    //you don't need this block
    //simply open this file in some word document thing or in JASSCraft/TESH
    //then use the "Replace" tool to replace "udg_MyHashtable" with your hashtable's name.
endglobals

function Arrow__Split takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local unit dead = LoadUnitHandle(udg_MyHashtable,id,0)
    local unit lastCreated = null
    local real x1 = GetUnitX(dead)
    local real y1 = GetUnitY(dead)
    local integer Arrow_Split = 1
    local real SA_real = 0
    local real missilefacing= bj_RADTODEG*Atan2(y1,x1) 
    local real newX
    local real newY
    loop
        exitwhen Arrow_Split > 12
        set newX = x1 + 300 * Cos(SA_real+.523599)
        set newY = y1 + 300 * Sin(SA_real+.523599)
//might as well just use radians, .523599 in radians is approximately 30 degrees
        set lastCreated = CreateUnit(GetOwningPlayer(dead),'n61R',x1,y1,missilefacing)
        call UnitApplyTimedLife(lastCreated,'BTLF',.30)
        call IssuePointOrder(lastCreated,"shockwave",newX,newY)
        set SA_real = SA_real+.523599
        set Arrow_Split = Arrow_Split + 1
    endloop
    call PauseTimer(t)
    call DestroyTimer(t)
    call FlushChildHashtable(udg_MyHashtable,id)
    set t = null
    set dead = null
    set lastCreated = null
endfunction

function Arrow_Split_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A62P'
endfunction

function Arrow_Split_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local timer t = CreateTimer()
    local integer id = GetHandleId(t)
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real x2=GetSpellTargetX()
    local real y2=GetSpellTargetY()
    local real sd = (GetUnitFacing(caster) + 100)
    local real td
    local unit lastcreated = CreateUnit(GetOwningPlayer(caster),'n610',x1,y1,sd)
    
    call IssuePointOrder (lastcreated,"move",x2,y2)
    set td = SquareRoot((y2-y1) * (y2-y1) + (x2-x1) * (x2-x1))/522.
    call UnitApplyTimedLife(lastcreated,'BTLF',td)
    call SaveUnitHandle(udg_MyHashtable,id,0,lastcreated)
    call TimerStart(t,td,false,function Arrow__Split)
    
    set t = null
    set caster = null
    set lastcreated = null
endfunction

//===========================================================================

function InitTrig_Arrow_Split takes nothing returns nothing
    local trigger T = CreateTrigger()
    local integer TI = 0
    set udg_MyHashtable = InitHashtable()
    //If you've already done this for your hashtable, you can remove the "set udg_MyHashtable = InitHashtable()" line^
    loop
        exitwhen (TI >= bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T, Player(TI), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set TI = TI + 1
    endloop
    call TriggerAddAction(T,function Arrow_Split_Actions)
    call TriggerAddCondition(T,Condition(function Arrow_Split_Conditions))
    set T = null
endfunction

Try that out. It might not be the most optimal and I haven't looked over the code thoroughly enough but try that and see if it works.
 
Ok, I changed it:
JASS:
function ArrowDeathCond takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'n610'
endfunction

function Arrow__Split takes nothing returns nothing
    local unit dead = GetTriggerUnit()
    local unit lastCreated = null
    local real x1 = GetUnitX(dead)
    local real y1 = GetUnitY(dead)
    local integer Arrow_Split = 1
    local real SA_real = 0
    local real missilefacing= bj_RADTODEG*Atan2(y1,x1) 
    local real newX
    local real newY
    loop
        exitwhen Arrow_Split > 12
        set newX = x1 + 300 * Cos(SA_real+.523599)
        set newY = y1 + 300 * Sin(SA_real+.523599)
//might as well just use radians, .523599 in radians is approximately 30 degrees
//it is slightly faster
        set lastCreated = CreateUnit(GetOwningPlayer(dead),'n61R',x1,y1,missilefacing)
        call UnitApplyTimedLife(lastCreated,'BTLF',.30)
        call IssuePointOrder(lastCreated,"shockwave",newX,newY)
        set SA_real = SA_real+.523599
        set Arrow_Split = Arrow_Split + 1
    endloop
    set dead = null
    set lastCreated = null
endfunction

function Arrow_Split_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A62P'
endfunction

function Arrow_Split_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real x2=GetSpellTargetX()
    local real y2=GetSpellTargetY()
    local real sd = (GetUnitFacing(caster) + 100)
    local real td
    local unit lastcreated = CreateUnit(GetOwningPlayer(caster),'n610',x1,y1,sd)
    
    call IssuePointOrder (lastcreated,"move",x2,y2)
    set td = SquareRoot((y2-y1) * (y2-y1) + (x2-x1) * (x2-x1))/522.
    call UnitApplyTimedLife(lastcreated,'BTLF',td)
    
    set caster = null
    set lastcreated = null
endfunction

//===========================================================================

function InitTrig_Arrow_Split takes nothing returns nothing
    local trigger T = CreateTrigger()
    local trigger T2 = CreateTrigger()
    local integer TI = 0
    loop
        exitwhen (TI >= bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T, Player(TI), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI),EVENT_PLAYER_UNIT_DEATH,null)
        set TI = TI + 1
    endloop
    call TriggerAddAction(T,function Arrow_Split_Actions)
    call TriggerAddCondition(T,Condition(function Arrow_Split_Conditions))
    call TriggerAddCondition(T2,Condition(function ArrowDeathCond))
    call TriggerAddAction(T2,function Arrow__Split)
    set T = null
    set T2 = null
endfunction

It is still inside one trigger (although technically it creates two) and doesn't need any globals. Untested though.
 
Try adding these debug messages:
JASS:
function ArrowDeathCond takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'n610'
endfunction

function Arrow__Split takes nothing returns nothing
    local unit dead = GetTriggerUnit()
    local unit lastCreated = null
    local real x1 = GetUnitX(dead)
    local real y1 = GetUnitY(dead)
    local integer Arrow_Split = 1
    local real SA_real = 0
    local real missilefacing= bj_RADTODEG*Atan2(y1,x1) 
    local real newX
    local real newY
    loop
        exitwhen Arrow_Split > 12
        set newX = x1 + 300 * Cos(SA_real+.523599)
        set newY = y1 + 300 * Sin(SA_real+.523599)
//        call BJDebugMsg("Angle: "+R2S(bj_RADTODEG*(SA_real+.523599)))
//used to check the angle
        call BJDebugMsg("Movement: "+" ( "+R2S(newX)+" , "+R2S(newY)+" )")
//might as well just use radians, .523599 in radians is approximately 30 degrees
//it is slightly faster
        set lastCreated = CreateUnit(GetOwningPlayer(dead),'n61R',x1,y1,missilefacing)
        call UnitApplyTimedLife(lastCreated,'BTLF',.30)
        call IssuePointOrder(lastCreated,"shockwave",newX,newY)
        set SA_real = SA_real+.523599
        set Arrow_Split = Arrow_Split + 1
    endloop
    set dead = null
    set lastCreated = null
endfunction

function Arrow_Split_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A62P'
endfunction

function Arrow_Split_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real x2=GetSpellTargetX()
    local real y2=GetSpellTargetY()
    local real sd = (GetUnitFacing(caster) + 100)
    local real td
    local unit lastcreated = CreateUnit(GetOwningPlayer(caster),'n610',x1,y1,sd)
    call BJDebugMsg("Spell has started!")
    
    call IssuePointOrder (lastcreated,"move",x2,y2)
    call BJDebugMsg("Target Coordinates: "+"( "+R2S(x2)+" , "+R2S(y2)+" )")
    set td = SquareRoot((y2-y1) * (y2-y1) + (x2-x1) * (x2-x1))/522.
    call UnitApplyTimedLife(lastcreated,'BTLF',td)
    call BJDebugMsg("Timed Life: "+ R2S(td))
    
    set caster = null
    set lastcreated = null
endfunction

//===========================================================================

function InitTrig_Arrow_Split takes nothing returns nothing
    local trigger T = CreateTrigger()
    local trigger T2 = CreateTrigger()
    local integer TI = 0
    loop
        exitwhen (TI >= bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T, Player(TI), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI),EVENT_PLAYER_UNIT_DEATH,null)
        set TI = TI + 1
    endloop
    call TriggerAddAction(T,function Arrow_Split_Actions)
    call TriggerAddCondition(T,Condition(function Arrow_Split_Conditions))
    call TriggerAddCondition(T2,Condition(function ArrowDeathCond))
    call TriggerAddAction(T2,function Arrow__Split)
    set T = null
    set T2 = null
endfunction

It will tell you:
  • When the spell has started.
  • The target coordinates of the ability.
  • The timed life duration of the dummy.
  • The angle in which the arrows move after the first dies.
  • The XY coordinates that the arrows will move to.
 
Level 31
Joined
May 3, 2008
Messages
3,155
well, do you have any idea how to did this jass part?

JASS:
local real sd=(GetUnitFacing(caster) + 100)

Cause the actual gui was like this.

  • Set SA_tarpt = (SA_castpt offset by 100.00 towards SA_real degrees)
cast pt was position of triggering unit and offset by 100 towards angle between target point of ability being cast.

also, i was trying to convert electric chain and flashlight ability.. was meet with a slight of.. ugh problem.
 
That function is polar projection. Basically:
JASS:
function ProjectExample takes nothing returns nothing
    local real sourceX = GetUnitX(GetTriggerUnit())
    local real sourceY = GetUnitY(GetTriggerUnit())
    local real angle = GetUnitFacing(GetTriggerUnit())+100
    local real newX = sourceX + 50 * Cos(angle*bj_DEGTORAD)
    local real newY = sourceY + 50 * Sin(angle*bj_DEGTORAD)
endfunction

It takes the sourceX and sourceY, then it adds 50 to the coordinates, making it move 50 to the right, and 50 upward (coordinates). However, it is multiplied by Cos(angle*bj_DEGTORAD) and Sin(angle*bj_DEGTORAD). This determines what angle it will be moved toward. The "angle" part is degrees, but since Cos and Sin natives take radians, we must multiply the angle by bj_DEGTORAD (or Pi/180) to convert it to radians.

Here are simple functions that might help you, it makes it similar to the GUI syntax:
JASS:
function PolarProjectionX takes real x, real angle, real distance returns real
    return x + distance*Cos(angle*bj_DEGTORAD)
endfunction
function PolarProjectionY takes real y, real angle, real distance returns real
    return y + distance*Sin(angle*bj_DEGTORAD)
endfunction

Where the angle is in degrees.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
JASS:
local unit u = GetTriggerUnit()
local real tx = GetSpellTargetX() //Target point
local real ty = GetSpellTargetY() //Target point

local real x1 = GetUnitX(u) //SA_castpt
local real y1 = GetUnitY(u) //SA_castpt

local real a = Atan2(ty - y1, tx - x1) //Angle between caster and target point

local real x2 = x1 + 100 * Cos(a) //SA_tarpt
local real y2 = y1 + 100 * Sin(a) //SA_tarpt

Edit: Rofl, a bit late :D
 
Level 31
Joined
May 3, 2008
Messages
3,155
my spells still bug. I have to update it to the latest patch soon though...

try tell me where else i haven't fix. :p

JASS:
function Arrow_Split_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A62X'
endfunction

function Arrow_Split_Actions takes nothing returns nothing
    local unit caster=GetTriggerUnit()
    local real x1=GetUnitX(caster)
    local real y1=GetUnitY(caster)
    local real sd=(GetUnitFacing(caster) + 100)
    local real x2 = x1 + 100 * Cos(sd*bj_DEGTORAD)
    local real y2 = y1 + 100 * Sin (sd*bj_DEGTORAD)
    local real td
    local unit lastcreated=CreateUnit(GetOwningPlayer(caster),'n61Q',x1,y1,sd)
    call IssuePointOrder(lastcreated,"move",x2,y2)
    set td=SquareRoot(((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))/522)
    call UnitApplyTimedLife(lastcreated,'BTLF',td)
    set caster=null
    set lastcreated=null
endfunction

function Arrow_Death_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit())=='n61Q'
endfunction

function Arrow_Death_Actions takes nothing returns nothing
    local unit dead=GetTriggerUnit()
    local unit lastCreated=null
    local real x1=GetUnitX(dead)
    local real y1=GetUnitY(dead)
    local integer Arrow_Split=1
    local real SA_real=0
    local real missilefacing=bj_RADTODEG*Atan2(y1,x1) 
    local real newX
    local real newY
    loop
        exitwhen Arrow_Split>12
        set newX=x1+300*Cos(SA_real+.523599)
        set newY=y1+300*Sin(SA_real+.523599)
        set lastCreated=CreateUnit(GetOwningPlayer(dead),'n61R',x1,y1,missilefacing)
        call UnitApplyTimedLife(lastCreated,'BTLF',.30)
        call IssuePointOrder(lastCreated,"shockwave",newX,newY)
        set SA_real=SA_real+.523599
        set Arrow_Split=Arrow_Split+1
    endloop
    set dead=null
    set lastCreated=null
endfunction

//===========================================================================

constant function CSAS takes nothing returns boolean
    return true
endfunction

function InitTrig_Arrow_Split takes nothing returns nothing
    local trigger T=CreateTrigger()
    local trigger T2=CreateTrigger()
    local integer TI=0
    local filterfunc FF=Filter(function CSAS)
    loop
        exitwhen (TI>=bj_MAX_PLAYER_SLOTS)
        call TriggerRegisterPlayerUnitEvent(T,Player(TI),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        call TriggerRegisterPlayerUnitEvent(T2,Player(TI),EVENT_PLAYER_UNIT_DEATH,null)
        set TI=TI+1
    endloop
    call DestroyBoolExpr(FF)
    call DestroyFilter(FF)
    call TriggerAddAction(T,function Arrow_Split_Actions)
    call TriggerAddCondition(T,Condition(function Arrow_Split_Conditions))
    call TriggerAddAction(T2,function Arrow_Death_Actions)
    call TriggerAddCondition(T2,Condition(function Arrow_Death_Conditions))
    set FF=null
    set T=null
    set T2=null
endfunction
 
Status
Not open for further replies.
Top