• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Star Beam Blast Goes Through Collision. Need Help!

Status
Not open for further replies.
Level 2
Joined
Jun 19, 2023
Messages
6
I am making a star beam blast that pushes allies and enemies with a knockback effect. However, when I use the ability near the water, the star beam blast would push them from the land into the water due to no collision. Is there a way to fix this in Jass? Thanks!

Inhale Ability
JASS:
//===========================================================================
function Trig_Inhale_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'S002'
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 udg_AllyPushUnit = GetSpellTargetUnit()        //Ally being loaded

      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
      set u_position = 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 Ability
JASS:
function Trig_Exhale_Cast_Conditions takes nothing returns boolean
   
    return GetSpellAbilityId() == 'S001' 
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 Ability
JASS:
//For the enemies condition
function Trig_Exhale_Enemies_Function takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitAliveBJ(GetFilterUnit()) == true ) and ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_DeDeDe)) == true ) and ( IsUnitInGroup(GetFilterUnit(), udg_EnemyPushGroup[0]) == false ) and ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitAliveBJ(GetFilterUnit()) == true ) and ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_DeDeDe)) == true ) and ( IsUnitInGroup(GetFilterUnit(), udg_EnemyPushGroup[0]) == false ) and ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false ) and ( IsUnitAliveBJ(GetFilterUnit()) == true ) and ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_DeDeDe)) == true )
endfunction
//------------------------------------------->

//------------------------------------------->
//Loop Push KnockBack for Enemies
function Trig_Exhale_Loop_Enemies_Function takes nothing returns nothing

    set udg_PointArea[20] = PolarProjectionBJ(udg_PointArea[5], 70, udg_DeDeDe_Angle[0])
    call SetUnitPositionLoc( GetEnumUnit(), udg_PointArea[20] )
   
endfunction

//Ending Damage Explosion
function Trig_Exhale_Loop2_Function takes nothing returns nothing
    call UnitDamageTargetBJ( udg_DeDeDe, GetEnumUnit(), ( ( 0.05 * I2R(GetHeroStatBJ(bj_HEROSTAT_STR, udg_DeDeDe, true)) ) * I2R(GetUnitAbilityLevelSwapped('S002', udg_DeDeDe)) ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN )
endfunction


//--------------------------------------------------------------------->
function Trig_Exhale_Actions takes nothing returns nothing
       
        set udg_Int = udg_Int + 3
       
        
        call BJDebugMsg(I2S(udg_Int))
   
        call SetUnitPathing( udg_AllyPushUnit, true )        // Turn on collision for Ally in Belly
   

        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], 20, udg_DeDeDe_Angle[0])            //udg_PointArea[4] is setting itself to be an offset of udg_PointArea[3] and will keep looping
   
    set udg_PointArea[5] = PolarProjectionBJ(udg_PointArea[4], 200, udg_DeDeDe_Angle[0])

    call SetUnitPositionLoc( udg_AllyPushUnit, udg_PointArea[5] )
   
    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)

//--------------------------------------------------------------------------------------->
               
    set udg_EnemyPushGroup[1] = GetUnitsInRangeOfLocMatching(200, udg_PointArea[5], Condition(function Trig_Exhale_Enemies_Function))
    call ForGroupBJ( udg_EnemyPushGroup[1], function Trig_Exhale_Loop_Enemies_Function )
    call SetUnitPathing( GetEnumUnit(), true )        // Turn on collision for Enemy Group
   
   
//--------------------------------------------------------------------------------------->   

    call TriggerSleepAction(3.8)
       
   
   
    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[20])
        call RemoveLocation(udg_PointArea[3])
              call RemoveLocation(udg_PointArea[4])
        call RemoveLocation(udg_PointArea[5])

        //Explosion Damage
        call ForGroupBJ( udg_EnemyPushGroup[1], function Trig_Exhale_Loop2_Function )
        set udg_EnemyPushGroup[1] = null
    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
 
Level 25
Joined
Feb 27, 2019
Messages
846
An item with 16 colision size is often placed on co-ordinates to check pathability in which case two things can happen.
1. The item gets placed exactly on the co-ordinates
2. The item cant be placed on the exact co-ordinates so its placed nearby
Then a check is made to see if the item is located at the co-ordinates it was originally created at. This check is fairly good but a problem occurs when a 16 colision size item is used to determine if a 32 colision sized unit can fit somewhere. There are knockback systems such as GUI Knockback 2.5D v4.2.5.0 out there that handle it better.
JASS:
    call SetItemPosition(udg_K2DItem, udg_PrkX, udg_PrkX)
     if GetWidgetX(udg_K2DItem) == udg_PrkX and GetWidgetY(udg_K2DItem) == udg_PrkX then
    call SetUnitX(udg_PrkTrgt[udg_PrkInt], udg_PrkX)
    call SetUnitY(udg_PrkTrgt[udg_PrkInt], udg_PrkY)
    endif
    call SetItemPosition(udg_K2DItem, udg_K2DMaxX, udg_K2DMaxY)
    call SetItemVisible(udg_K2DItem, false)
 
Status
Not open for further replies.
Top