• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Star Dummies spawning at center of map

Level 2
Joined
Jun 19, 2023
Messages
6
Hello everybody. I am a newbie to JASS coding and I am trying to make this spell that shoots a star in a line. At the end of the effect, it creates an explosion, but the explosion keeps spawning at the center of the map. Can someone look at it and fix it for me. Thanks and appreciate yall!



Inhale Ability
JASS:
//===========================================================================
function Trig_Inhale_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Inhale_Actions takes nothing returns nothing
      local unit u = GetTriggerUnit()
      local location u_position = GetUnitLoc(u)
      local integer times
      local effect sand
      set times = 0
      //Heals for 7 times
      call UnitAddAbilityBJ( 'A03J', GetTriggerUnit() ) // Bonus 5 Armor
    
    loop
        exitwhen times == 7
        call SetWidgetLife(u, GetWidgetLife(u) + 20)      //Heal 20 health per time
        set u_position = GetUnitLoc(u)
        set sand = AddSpecialEffectLoc("Objects\\Spawnmodels\\Human\\FragmentationShards\\FragBoomSpawn.mdl", u_position) // Special Effect
        call CreateNUnitsAtLoc( 1, 'h02R', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
        call UnitApplyTimedLifeBJ( 2.69, 'BTLF', GetLastCreatedUnit() )
        call TriggerSleepAction(.5)
        set times = times + 1
    endloop
      call TriggerSleepAction(1)
      call UnitRemoveAbilityBJ('A03J', GetTriggerUnit())        // Get rid of bonus 5 armor
      set u = null

    
      call EnableTrigger(gg_trg_Exhale_Cast)
    
endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_Inhale takes nothing returns nothing
    set gg_trg_Inhale = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Inhale, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Inhale, Condition(function Trig_Inhale_Conditions))
    call TriggerAddAction(gg_trg_Inhale, function Trig_Inhale_Actions)
    set gg_trg_Inhale = null
endfunction




Exhale Cast
JASS:
function Trig_Exhale_Cast_Conditions takes nothing returns boolean
 
    return GetSpellAbilityId() == 'S000'
endfunction

function Trig_Exhale_Cast_Actions takes nothing returns nothing
   
   
      set udg_DeDeDe = GetTriggerUnit()
      set udg_DeDeDe_Angle[0] = GetUnitFacing(udg_DeDeDe)      //Setting angle
      set udg_PointArea[0] = GetUnitLoc(udg_DeDeDe)        //point variable
      set udg_PointArea[1] = GetSpellTargetLoc()
      //set udg_PointArea[2] = PolarProjectionBJ(udg_PointArea[0], 69, udg_DeDeDe_Angle[0] - 60)
   
      call TriggerSleepAction(.1)
   
   
      call PauseUnitBJ(true, udg_DeDeDe)
      call SetUnitAnimation(udg_DeDeDe, "Spell Channel")
      call SetUnitTimeScalePercent(udg_DeDeDe, 6.9)
   
      set udg_PointArea[2] = PolarProjectionBJ(udg_PointArea[0], 69, (udg_DeDeDe_Angle[0]))     //Star Effect
   
      call CreateNUnitsAtLoc(1, 'h00S', GetOwningPlayer(udg_DeDeDe),udg_PointArea[2], bj_UNIT_FACING)    //Spawn Star Effect
      call UnitApplyTimedLifeBJ( 3, 'BTLF', GetLastCreatedUnit() )
   
      set udg_DummyStuff[0] = GetLastCreatedUnit()    //Dummy for Star Effect
   
      call CreateNUnitsAtLoc(5, 'h00V', GetOwningPlayer(udg_DeDeDe),udg_PointArea[2], bj_UNIT_FACING)    //Spawn Dust Effect
      call UnitApplyTimedLifeBJ( 1, 'BTLF', GetLastCreatedUnit() )
      set udg_DummyStuff[1] = GetLastCreatedUnit()    //Dummy for Dust Effect
   
      //Pause so we can see two dust waves
      call TriggerSleepAction(1)
      call CreateNUnitsAtLoc(5, 'h00V', GetOwningPlayer(udg_DeDeDe),udg_PointArea[2], bj_UNIT_FACING)
      call UnitApplyTimedLifeBJ( 1, 'BTLF', GetLastCreatedUnit() )
      set udg_DummyStuff[2] = GetLastCreatedUnit()
   
      //Killing Dummies
      call KillUnit( udg_DummyStuff[0] )
      call KillUnit( udg_DummyStuff[1] )

      //Remove dummies
      call RemoveUnit(udg_DummyStuff[0])
      call RemoveUnit(udg_DummyStuff[1])
   
      call RemoveLocation(udg_PointArea[0])
      call RemoveLocation(udg_PointArea[1])
      call RemoveLocation(udg_PointArea[2])
   
  
      call SetUnitTimeScalePercent(udg_DeDeDe, 100)
      call EnableTrigger(gg_trg_Exhale)

   
   
   
endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_Exhale_Cast takes nothing returns nothing
    set gg_trg_Exhale_Cast = CreateTrigger()
    //call TriggerRegister__(gg_trg_NewTrigger, )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Exhale_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Exhale_Cast, Condition(function Trig_Exhale_Cast_Conditions))
    call TriggerAddAction(gg_trg_Exhale_Cast, function Trig_Exhale_Cast_Actions)
endfunction

Exhale
JASS:
function Trig_Exhale_Actions takes nothing returns nothing
     
        set udg_Int = udg_Int + 3
     
      
        call BJDebugMsg(I2S(udg_Int))
 
     
        set udg_PointArea[3] = GetUnitLoc(udg_DummyStuff[2])        //Dummy is Dust Effect            //udg_PointArea[3] is the starting location of the star and udg_DummyStuff[2] is the White Dust
    set udg_PointArea[4] = PolarProjectionBJ(udg_PointArea[3], 6.9, udg_DeDeDe_Angle[0])            //udg_PointArea[4] is setting itself to be an offset of udg_PointArea[3] and will keep looping
 
    call SetUnitPositionLoc(udg_DummyStuff[2], udg_PointArea[4])        //Dummy is White Dust Effect
    //call SetUnitTimeScalePercent( udg_DummyStuff[2], 1)
    call CreateNUnitsAtLoc(1, 'h00T', GetOwningPlayer(udg_DeDeDe),udg_PointArea[4], bj_UNIT_FACING)        //This is Brown Small Dust Effect
    call UnitApplyTimedLifeBJ( .2 ,'BTLF', GetLastCreatedUnit() )
    call CreateNUnitsAtLoc(1, 'h00S', GetOwningPlayer(udg_DeDeDe), udg_PointArea[4], bj_UNIT_FACING)  //This is star effect
    call UnitApplyTimedLifeBJ( .2 ,'BTLF', GetLastCreatedUnit() )
    call PauseUnitBJ(false, udg_DeDeDe)
    call TriggerSleepAction(5)
     
 
 
    if udg_Int >= 369 then
     
        call CreateNUnitsAtLoc(1, 'h01R', GetOwningPlayer(udg_DeDeDe), udg_PointArea[4], bj_UNIT_FACING)
        call UnitApplyTimedLifeBJ( 1 ,'BTLF', GetLastCreatedUnit() )
     

        call KillUnit( udg_DummyStuff[2] )
        call RemoveUnit(udg_DummyStuff[2])
     
     
     
        call RemoveLocation(udg_PointArea[3])
              call RemoveLocation(udg_PointArea[4])
    endif 
     
 
    call DisableTrigger( GetTriggeringTrigger() )
 
endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_Exhale takes nothing returns nothing
    set gg_trg_Exhale = CreateTrigger()
    //call TriggerRegister__(gg_trg_NewTrigger, )
    call DisableTrigger(gg_trg_Exhale)
    call TriggerRegisterTimerEventPeriodic( gg_trg_Exhale, 0.03)
    call TriggerAddAction(gg_trg_Exhale, function Trig_Exhale_Actions)
endfunction


EDITED:
Sorry guys. I copy and pasted from the WC editor which is why there are no indents. I am not too sure how to make it look good with indents. My bad.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
I would look into learning more advanced techniques as it appears that you already have a solid understanding of Jass:

Using Waits aka TriggerSleepAction() in your Jass code sort of defeats the purpose of coding in my opinion. Waits are imprecise while Timers (what you should use) give you the exact control and precision you want. This is especially true when you want your custom spells to be flexible and work for any numbers of units with any cooldown and duration. We call those types of spells MUI (multi-unit-instanceable).

Oh, and if you aren't too far into development and are on patch 1.31+ I would suggest learning and using Lua > Jass. It's arguably better in every way with the only downside I can think of being a lack of resources since it hasn't been around as long as Jass. That being said, Bribe and Tasyen have you covered for the most part with their large number of Lua resources.
 
Last edited:
Top