Making My Meat Hook MUI

CrackUps

New Member
Reaction score
7
Ok I've created a meat hook that will track it's target if you've targetted a unit or just travel normally if you target the ground. What i want to do now is make it MUI but am pretty unsure on how to do this. It is entirely coded with GUI and would preferably like to keep it like that if possible as I wanted to make it into a hook for GUI coders to use. If it's too hard to make MUI in GUI i'm fine with it being in Jass but then it'll be for my own use (not vJass though please). Could somebody please help me with this.

Map and triggers attached.

Code:
Cast
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to (==) Meat Hook [GUI] 
    Actions
        Custom script:   local location TempLoc = GetSpellTargetLoc()
        Set Caster = (Triggering unit)
        Set TargetUnit = (Target unit of ability being cast)
         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TargetUnit Equal to (==) No unit
            Then - Actions
                Unit - Create 1 Dummy Target for (Owner of Caster) at (TempLoc) facing Default building facing (270.0) degrees
                Set TargetUnit = (Last created unit)
            Else - Actions
        Set Angle = (Angle from (Position of Caster) to (Position of TargetUnit))
        Set DistanceCoveredMax = (((Level of (Ability being cast) for Caster) x 1000) + 0)
        Trigger - Turn on Create <gen>
        Custom script:   call RemoveLocation(TempLoc)
Code:
Create
    Events
        Time - Every 0.04 seconds of game time
    Conditions
    Actions
        Custom script:   local location TempLoc1 = GetUnitLoc(udg_Caster)
        Custom script:   local location TempLoc2 = GetUnitLoc(udg_Joint[1])
        Custom script:   local location TempLoc3 = GetUnitLoc(udg_TargetUnit)
        Custom script:   local location TempLoc4 = GetUnitLoc(udg_Joint[udg_NumberOfJoints])
        Custom script:   local location TempLoc5
        Custom script:   local location TempLoc6
         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in PotentialTargets) Equal to (==) 0
            Then - Actions
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        DistanceCoveredCurrent Greater than or equal to (>=) DistanceCoveredMax
                    Then - Actions
                        Trigger - Turn on Retract <gen>
                        Trigger - Turn off Create <gen>
                    Else - Actions
                         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                NumberOfJoints Equal to (==) 0
                            Then - Actions
                                Unit - Create 1 Joint for (Owner of Caster) at ((TempLoc1) offset by 80.00 towards Angle degrees) facing Angle degrees
                                Set DistanceCoveredCurrent = (DistanceCoveredCurrent + 80)
                                Set NumberOfJoints = (NumberOfJoints + 1)
                                Set Joint[NumberOfJoints] = (Last created unit)
                                Custom script:   call RemoveLocation(TempLoc1)
                            Else - Actions
                                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Unit-type of TargetUnit) Equal to (==) Dummy Target
                                    Then - Actions
                                        Unit - Move Joint[1] instantly to ((TempLoc2) offset by 40.00 towards (Facing of Joint[1]) degrees), facing (Facing of Joint[1]) degrees
                                        Set DistanceCoveredCurrent = (DistanceCoveredCurrent + 40)
                                        Custom script:   call RemoveLocation(TempLoc2)
                                        Custom script:   call RemoveLocation(TempLoc3)
                                    Else - Actions
                                        Unit - Move Joint[1] instantly to ((TempLoc2) offset by 40.00 towards (Angle from (TempLoc2) to (TempLoc3)) degrees), facing (Angle from (TempLoc2) to (TempLoc3)) degrees
                                        Set DistanceCoveredCurrent = (DistanceCoveredCurrent + 40)
                                        Custom script:   call RemoveLocation(TempLoc2)
                                        Custom script:   call RemoveLocation(TempLoc3)
                                Unit - Create 1 Joint for (Owner of Caster) at ((TempLoc1) offset by 40.00 towards (Angle from (TempLoc1) to (TempLoc4)) degrees) facing (TempLoc4)
                                Custom script:   call RemoveLocation(TempLoc1)
                                Custom script:   call RemoveLocation(TempLoc4)
                                Set NumberOfJoints = (NumberOfJoints + 1)
                                Set Joint[NumberOfJoints] = (Last created unit)
                                 Do Multiple ActionsFor each (Integer A) from 2 to NumberOfJoints, do (Actions)
                                    Loop - Actions
                                        Custom script:   set TempLoc5 = GetUnitLoc(udg_Joint[GetForLoopIndexA()])
                                        Custom script:   set TempLoc6 = GetUnitLoc(udg_Joint[( GetForLoopIndexA() - 1 )])
                                        Unit - Move Joint[(Integer A)] instantly to ((TempLoc5) offset by 40.00 towards (Angle from (TempLoc5) to (TempLoc6)) degrees), facing (TempLoc6)
                                        Custom script:   call RemoveLocation(TempLoc5)
                                        Custom script:   call RemoveLocation(TempLoc6)
            Else - Actions
                Set Snagged = True
                Animation - Change Joint[1]'s animation speed to 0.00% of its original speed
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Target belongs to an ally of (Owner of Caster)) Equal to (==) True
                    Then - Actions
                    Else - Actions
                        Unit - Cause Caster to damage Target, dealing ((Real((Level of Meat Hook [GUI]  for Caster))) x 100.00) damage of attack type Normal and damage type Normal
                        Special Effect - Create a special effect attached to the chest of Target using Objects\Spawnmodels\Human\HumanBlood\HeroBloodElfBlood.mdl
                        Special Effect - Destroy (Last created special effect)
                Unit - Turn collision for Target Off
                Trigger - Turn on Retract <gen>
                Trigger - Turn off Create <gen>
         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Unit-type of TargetUnit) Equal to (==) Dummy Target
            Then - Actions
                Set PotentialTargets = (Units within 120.00 of (Position of Joint[1]) matching ((Matching unit) Not equal to (!=) Caster))
                Set Target = (First unit of group PotentialTargets)
            Else - Actions
                Set PotentialTargets = (Units within 120.00 of (Position of Joint[1]) matching ((Matching unit) Equal to (==) TargetUnit))
                Set Target = (First unit of group PotentialTargets)
Code:
Retract
    Events
        Time - Every 0.04 seconds of game time
    Conditions
    Actions
        Custom script:   local location TempLoc1 = GetUnitLoc(udg_Joint[1])
        Custom script:   local location TempLoc2 = GetUnitLoc(udg_Joint[2])
        Custom script:   local location TempLoc3 = GetUnitLoc(udg_Caster)
        Custom script:   local location TempLoc4 = GetUnitLoc(udg_Joint[udg_NumberOfJoints - 1])
        Custom script:   local location TempLoc5
        Custom script:   local location TempLoc6
        Custom script:   local location TempLoc7
         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                NumberOfJoints Equal to (==) 0
            Then - Actions
                Set DistanceCoveredCurrent = 0
                Set Snagged = False
                Unit - Turn collision for Target On
                Custom script:   call DestroyGroup(udg_PotentialTargets)
                Set Target = No unit
                Trigger - Turn off Retract <gen>
            Else - Actions
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Snagged Equal to (==) True
                    Then - Actions
                    Else - Actions
                         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Unit-type of TargetUnit) Equal to (==) Dummy Target
                            Then - Actions
                                Set PotentialTargets = (Units within 120.00 of (Position of Joint[1]) matching ((Matching unit) Not equal to (!=) Caster))
                                Set Target = (First unit of group PotentialTargets)
                            Else - Actions
                                Set PotentialTargets = (Units within 120.00 of (Position of Joint[1]) matching ((Matching unit) Equal to (==) TargetUnit))
                                Set Target = (First unit of group PotentialTargets)
                 Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        NumberOfJoints Greater than (>) 1
                    Then - Actions
                         Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Number of units in PotentialTargets) Not equal to (!=) 0
                            Then - Actions
                                Set Snagged = True
                                Animation - Change Joint[1]'s animation speed to 0.00% of its original speed
                                Unit - Move Target instantly to ((TempLoc1) offset by 40.00 towards (Facing of Joint[1]) degrees), facing (Facing of Target) degrees
                                Custom script:   call RemoveLocation(TempLoc1)
                            Else - Actions
                        Unit - Move Joint[1] instantly to (TempLoc2), facing Angle degrees
                        Custom script:   call RemoveLocation(TempLoc1)
                        Custom script:   call RemoveLocation(TempLoc2)
                    Else - Actions
                        Unit - Remove Joint[1] from the game
                Unit - Move Joint[NumberOfJoints] instantly to ((TempLoc3) offset by 40.00 towards (Angle from (TempLoc3) to (TempLoc4)) degrees), facing (TempLoc4)
                Custom script:   call RemoveLocation(TempLoc3)
                Custom script:   call RemoveLocation(TempLoc4)
                 Do Multiple ActionsFor each (Integer A) from ((NumberOfJoints - 1) x -1) to -2, do (Actions)
                    Loop - Actions
                        Custom script:   set TempLoc5 = GetUnitLoc(udg_Joint[(GetForLoopIndexA() *-1)])
                        Custom script:   set TempLoc6 = GetUnitLoc(udg_Joint[( ( GetForLoopIndexA() * -1 ) + 1 )])
                        Custom script:   set TempLoc7 = GetUnitLoc(udg_Joint[( ( GetForLoopIndexA() * -1 ) - 1 )])
                        Unit - Move Joint[((Integer A) x -1)] instantly to ((TempLoc6) offset by 40.00 towards (Angle from (TempLoc6) to (TempLoc5)) degrees), facing (TempLoc7)
                        Custom script:   call RemoveLocation(TempLoc5)
                        Custom script:   call RemoveLocation(TempLoc6)
                        Custom script:   call RemoveLocation(TempLoc7)
                Unit - Remove Joint[NumberOfJoints] from the game
                Set NumberOfJoints = (NumberOfJoints - 1)
 

Attachments

  • Tracking Meat Hook [GUI] Non-MUI No Leaks.w3x
    23.5 KB · Views: 131

Viikuna

No Marlo no game.
Reaction score
265
I dont really know how to make things MUI in GUI, but I have seen some MUI GUI tutorial here, maybe you should search for it?

Anyways, it is really cool spell, so I think you should just learn Jass. Jass is cool and vJass makes everything so nice and smoot.
 

Viikuna

No Marlo no game.
Reaction score
265
Normal Jass really sucks, try to do something with it without losing your mind. vJass is must have. Unless you are a mac user, you should really use vJass.
 

Cheddar

This is the way it was meant to be.
Reaction score
126
Rough idea on how to make it MUI:

Change all of these variables to arrays (stay with me). Create a new Integer variable called "MeatHookCastNumber".

Now, when a unit casts, add 1 to MeatHookCastNumber. The initial cast gives it a value of 1.

When you set all of your variables in the first trigger, set them to things like "DistanceCoveredMax[MeatHookCastNumber]". When it gets to the other triggers, use the function "For each Integer A from 1 to (MeatHookCastNumber) so each person who has their hook set fires it.

If I have 5 people who have ever casted the ability (even if there is a half-hour Meat Hook drought period), MeatHookCastNumber will stay at 5 until there is another cast.

Rough and untested, but I hope it serves as a bit of a pavement to the future.
 

CrackUps

New Member
Reaction score
7
Well i don't want it in vJass as i can't code in vJass so it's pretty useless for me i woulda just used the Meat Hook that has already been made then
 

Cheddar

This is the way it was meant to be.
Reaction score
126
The only JASS I know is RemoveLocation and DestroyGroup.

I'm talking about GUI here
 

Kazuga

Let the game begin...
Reaction score
110
Cheddar, he's talking about mine and Vilkuna's post.

Well you say you don't know vJass, do you know Jass then? vJass is exactly like Jass but you have some more tools etc that you're able to use, for example structs. But making your spell MUI in GUI isn't that hard, do what Cheddar told you and you will do just fine.
 

CrackUps

New Member
Reaction score
7
This is as far as I got (the ???? is placed in spots where I don't know what to put in as i don't know how to use the local unit from one trigger in another)

Code:
function NotCasterCheck takes nothing returns boolean
    local unit Caster = ????
    return ( GetFilterUnit() != Caster )
endfunction

function IsTargetUnitCheck takes nothing returns boolean
    local unit TargetUnit = ????
    return ( GetFilterUnit() == TargetUnit )
endfunction

//===========================================================================
function Extend takes nothing returns nothing
    local trigger c = CreateTrigger()
    local timer RetractTimer = CreateTimer()
    local boolean Snagged = false
    local group PotentialTargets
    local integer DistanceCoveredCurrent
    local integer NumberOfJoints
    local unit Caster = ????
    local unit TargetUnit = ????
    local unit Target
    local unit array Joint
    local integer DistanceCoveredMax = ( GetUnitAbilityLevel( Caster, 'A000' ) * 1000 )
    local location TempLoc1 = GetUnitLoc(Caster)
    local location TempLoc2 = GetUnitLoc(Joint[1])
    local location TempLoc3 = GetUnitLoc(TargetUnit)
    local location TempLoc4 = GetUnitLoc(Joint[NumberOfJoints])
    local location TempLoc5
    local location TempLoc6
    if CountUnitsInGroup(PotentialTargets) == 0 then
        if DistanceCoveredCurrent >= DistanceCoveredMax then
            call StoreInteger( udg_Cache, "Hook", "NumberOfJoints", NumberOfJoints )
            call StoreInteger( udg_Cache, "Hook", "DistanceCoveredCurrent", DistanceCoveredCurrent )
            
            call TimerStart( RetractTimer, 0.04, true, null )
            call TriggerRegisterTimerExpireEvent( c, RetractTimer )
            call DestroyTimer( ExtendTimer )
        else
            if NumberOfJoints == 0 then
                call CreateUnitAtLoc( GetOwningPlayer(Caster), 'h002', PolarProjectionBJ( TempLoc1, 80.00, udg_Angle), udg_Angle )
                set DistanceCoveredCurrent = ( DistanceCoveredCurrent + 80 )
                set NumberOfJoints = ( NumberOfJoints + 1 )
                set Joint[NumberOfJoints] = bj_lastCreatedUnit
                call RemoveLocation(TempLoc1)
            else
                if GetUnitTypeId(TargetUnit) == 'h001' then
                    call SetUnitPositionLoc(Joint[1], PolarProjectionBJ( TempLoc2, 40.00, GetUnitFacing(Joint[1])))
                    call SetUnitFacing(Joint[1], GetUnitFacing(Joint[1]))
                else
                    call SetUnitPositionLoc(Joint[1], PolarProjectionBJ( TempLoc2, 40.00, AngleBetweenPoints( TempLoc2, TempLoc3)) ) 
                    call SetUnitFacing( Joint[1], AngleBetweenPoints( TempLoc2, TempLoc3) )
                endif
                set DistanceCoveredCurrent = ( DistanceCoveredCurrent + 40 )
                call RemoveLocation(TempLoc2)
                call RemoveLocation(TempLoc3)
                call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', GetOwningPlayer(Caster), PolarProjectionBJ( TempLoc1, 40.00, AngleBetweenPoints( TempLoc1, TempLoc4)), TempLoc4 )
                call RemoveLocation(TempLoc1)
                call RemoveLocation(TempLoc4)
                set NumberOfJoints = ( NumberOfJoints + 1 )
                set Joint[NumberOfJoints] = bj_lastCreatedUnit
                set bj_forLoopAIndex = 2
                set bj_forLoopAIndexEnd = NumberOfJoints
                loop
                    exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
                    set TempLoc5 = GetUnitLoc(Joint[bj_forLoopAIndex])
                    set TempLoc6 = GetUnitLoc(Joint[( bj_forLoopAIndex - 1 )])
                    call SetUnitPositionLoc( Joint[bj_forLoopAIndex], PolarProjectionBJ( TempLoc5, 40.00, AngleBetweenPoints( TempLoc5, TempLoc6)))
                    call SetUnitFacing( Joint[bj_forLoopAIndex], AngleBetweenPoints( GetUnitLoc(Joint[bj_forLoopAIndex]), TempLoc6 ) )
                    call RemoveLocation(TempLoc5)
                    call RemoveLocation(TempLoc6)
                    set bj_forLoopAIndex = bj_forLoopAIndex + 1
                endloop
            endif
        endif
    else
        set Snagged = true
        call SetUnitTimeScale( Joint[1], 0.00 )
        if IsUnitAlly(Target, GetOwningPlayer(Caster)) == true then
        else
            call AddSpecialEffectTarget( "Objects\\Spawnmodels\\Human\\HumanBlood\\HeroBloodElfBlood.mdl", Target, "chest" )
            call DestroyEffect( bj_lastCreatedEffect )
        endif
        call SetUnitPathing( Target, false )
        call StoreInteger( udg_Cache, "Hook", "NumberOfJoints", NumberOfJoints )
        call StoreInteger( udg_Cache, "Hook", "DistanceCoveredCurrent", DistanceCoveredCurrent )
        
        call TimerStart( RetractTimer, 0.04, true, null )
        call TriggerRegisterTimerExpireEvent( c, RetractTimer )
        call DestroyTimer( ExtendTimer )
    endif
    if GetUnitTypeId(TargetUnit) == 'h001' then
        set PotentialTargets = GetUnitsInRangeOfLocMatching(120.00, GetUnitLoc(Joint[1]), Condition(function NotCasterCheck))
    else
        set PotentialTargets = GetUnitsInRangeOfLocMatching(120.00, GetUnitLoc(Joint[1]), Condition(function IsTargetUnitCheck))
    endif
    set Target = FirstOfGroup(PotentialTargets)
endfunction

//===========================================================================
function BeginHook takes nothing returns nothing
    local trigger b = CreateTrigger()
    local timer ExtendTimer = CreateTimer()
    local unit Caster = GetTriggerUnit()
    local unit TargetUnit = GetSpellTargetUnit()
    local location TempLoc = GetSpellTargetLoc()
    
    if TargetUnit == null then
        call CreateUnitAtLoc( GetOwningPlayer(Caster), 'h001', TempLoc, 270 )
        set TargetUnit = bj_lastCreatedUnit
    else
    endif
    set udg_Angle = AngleBetweenPoints(GetUnitLoc(Caster), GetUnitLoc(TargetUnit))
    
    call TimerStart( ExtendTimer, 0.04, true, null )
    call TriggerRegisterTimerExpireEvent( b, ExtendTimer )
    call TriggerAddAction( b, function Extend )
    call RemoveLocation(TempLoc)    
endfunction

//===========================================================================
function AbilityCheck takes nothing returns boolean
    if GetSpellAbilityId() == 'A000' then
        call BeginHook()
        return true
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Cast takes nothing returns nothing
    local trigger a = CreateTrigger(  )
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent( a, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null )
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
    call TriggerAddCondition( a, Condition( function AbilityCheck ) )
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top