2 Questions easy as hell for JASSers

KvickaN

TH.net Regular
Reaction score
24
Ok guys I just want to tell you that I do not know ANY JASS AT ALL!

That out of the way, couple of questions!

1. What do I change here to make the hook go THRUE trees?

Code:
scope MeatHook

globals
    private constant integer MH_ID = 'A000'  //Raw code of the Meat Hook ability
    private constant integer Hook_Part_ID = 'h001'  //Raw code of the Hook Part unit
    private constant string Eyecandy = "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodFootman.mdl"  //SFX created on target
    private constant real Range_Base_Value = 700  //Formula for hook range = level * Max_Range_Increment + Range_Base_Value
    private constant real Max_Range_Increment = 600
    private constant real Max_Range = 1000  //A limit for the range of the hook - it will NOT go above this range. Don't want a limit? Then set this value to something... big.
    private constant real Dmg_Base = 300  //Formula for hook damage = level * Dmg_Base
    private constant real Speed = 30  //The distance between 2 Hook_Part_ID units/how fast the hook goes, however, speed should generally be modified through Timer_Interval
    private constant real AoE = 80  //How close a target needs to be to be snagged (remember this adds to the total range of the hook)
    private constant real Timer_Interval = 0.03
endglobals

private struct dat
    unit u
    unit array D[500]
    real ang
    integer lvl
    real rng
    real OX
    real OY
    integer i
    unit p
endstruct

private function Cond takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true and IsUnitType(GetFilterUnit(), UNIT_TYPE_FOOT) == true and GetWidgetLife(GetFilterUnit()) > 0.405 and GetFilterUnit() != bj_ghoul[1]
endfunction

private function Uncreate takes nothing returns nothing
    local timer T = GetExpiredTimer()
    local dat dd = dat(GetHandleInt(T, "dd"))
    local real PX = dd.OX + dd.rng * Cos(dd.ang)
    local real PY = dd.OY + dd.rng * Sin(dd.ang)    
    
    set dd.rng = dd.rng - Speed
    call RemoveUnit(dd.D[dd.i])
    set dd.i = dd.i - 1
    call SetUnitX(dd.p, PX)
    call SetUnitY(dd.p, PY)
    
    if dd.i == 0 then
        call SetUnitPathing(dd.p, true)
        call PauseUnit(dd.p, false)
        set dd.p = null
        set dd.u = null
        call dd.destroy()
        call FlushHandleLocals(T)
        call PauseTimer(T)
        call DestroyTimer(T)
    endif
    
    set T = null
endfunction

private function Create takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local dat d = dat(GetHandleInt(t, "d"))
    local real PX = d.OX + d.rng * Cos(d.ang)
    local real PY = d.OY + d.rng * Sin(d.ang)
    local real r = d.lvl * Max_Range_Increment + Range_Base_Value
    local group g
    local boolexpr b
    local timer T
    
    set d.rng = d.rng + Speed
    
    if d.rng < r and d.rng < Max_Range and d.p == null then
        set g = CreateGroup()
        set bj_ghoul[1] = d.u
        set b = Condition(function Cond)
        call GroupEnumUnitsInRange(g, PX, PY, AoE, b)
        set d.p = FirstOfGroup(g)
        if d.p != null then
            call UnitDamageTarget(d.u, d.p, d.lvl * Dmg_Base, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
            call DestroyEffect(AddSpecialEffectTarget(Eyecandy, d.p, "origin"))
            call SetUnitPathing(d.p, false)
            call PauseUnit(d.p, true)
            call SetUnitX(d.p, PX)
            call SetUnitY(d.p, PY)
            return
        endif        
        set d.D[d.i] = CreateUnit(GetOwningPlayer(d.u), Hook_Part_ID, PX, PY, d.ang * bj_RADTODEG)
        set d.i = d.i + 1
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
    else
        set T = CreateTimer()
        set d.rng = d.rng - Speed
        call SetHandleInt(T, "dd", d)
        call TimerStart(T, Timer_Interval, true, function Uncreate)
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
        set T = null
    endif
    
    set t = null
endfunction

private function Cast takes nothing returns nothing
    local timer t = CreateTimer()
    local location l = GetSpellTargetLoc()
    local dat d = dat.create()
    
    set d.u = GetTriggerUnit()
    set d.ang = Atan2(GetLocationY(l)-GetUnitY(d.u), GetLocationX(l)-GetUnitX(d.u))
    set d.lvl = GetUnitAbilityLevel(d.u, MH_ID)
    set d.rng = Speed
    set d.OX = GetUnitX(d.u)
    set d.OY = GetUnitY(d.u)
    set d.i = 1
    
    call SetHandleInt(t, "d", d)
    call TimerStart(t, Timer_Interval, true, function Create)
    
    call RemoveLocation(l)
    
    set t = null
    set l = null
endfunction

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == MH_ID
endfunction

function InitTrig_Meat_Hook takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Cast )
    set t = null
endfunction

endscope

2.
Code:
IsUnitType(GetFilterUnit(), UNIT_TYPE_WHAT_SHALL_STAND_HERE_IF_I_WANT_MOVEMENT_TYPE_FOOT?)

+rep for helpers! :)
 

Infinity.4Sk

New Member
Reaction score
6
Im not really sure but maybe the hook has to somehow 'ignore' doodads like trees and gold mines and other objects dont know how to do this but i think thats what u have to do:confused:
 

KvickaN

TH.net Regular
Reaction score
24
Im not really sure but maybe the hook has to somehow 'ignore' doodads like trees and gold mines and other objects dont know how to do this but i think thats what u have to do:confused:

Exactly, its going to be easy for the ones knowing JASS to help me with this :)
 

N-a-z-g-u-l

New Member
Reaction score
30
1. i dont see anything in the script which could stop the spell when there is a tree...

2.
Code:
    constant unittype UNIT_TYPE_HERO                        = ConvertUnitType(0)
    constant unittype UNIT_TYPE_DEAD                        = ConvertUnitType(1)
    constant unittype UNIT_TYPE_STRUCTURE                   = ConvertUnitType(2)

    constant unittype UNIT_TYPE_FLYING                      = ConvertUnitType(3)
    constant unittype UNIT_TYPE_GROUND                      = ConvertUnitType(4)

    constant unittype UNIT_TYPE_ATTACKS_FLYING              = ConvertUnitType(5)
    constant unittype UNIT_TYPE_ATTACKS_GROUND              = ConvertUnitType(6)

    constant unittype UNIT_TYPE_MELEE_ATTACKER              = ConvertUnitType(7)
    constant unittype UNIT_TYPE_RANGED_ATTACKER             = ConvertUnitType(8)

    constant unittype UNIT_TYPE_GIANT                       = ConvertUnitType(9)
    constant unittype UNIT_TYPE_SUMMONED                    = ConvertUnitType(10)
    constant unittype UNIT_TYPE_STUNNED                     = ConvertUnitType(11)
    constant unittype UNIT_TYPE_PLAGUED                     = ConvertUnitType(12)
    constant unittype UNIT_TYPE_SNARED                      = ConvertUnitType(13)

    constant unittype UNIT_TYPE_UNDEAD                      = ConvertUnitType(14)
    constant unittype UNIT_TYPE_MECHANICAL                  = ConvertUnitType(15)
    constant unittype UNIT_TYPE_PEON                        = ConvertUnitType(16)
    constant unittype UNIT_TYPE_SAPPER                      = ConvertUnitType(17)
    constant unittype UNIT_TYPE_TOWNHALL                    = ConvertUnitType(18)    
    constant unittype UNIT_TYPE_ANCIENT                     = ConvertUnitType(19)
    
    constant unittype UNIT_TYPE_TAUREN                      = ConvertUnitType(20)
    constant unittype UNIT_TYPE_POISONED                    = ConvertUnitType(21)
    constant unittype UNIT_TYPE_POLYMORPHED                 = ConvertUnitType(22)
    constant unittype UNIT_TYPE_SLEEPING                    = ConvertUnitType(23)
    constant unittype UNIT_TYPE_RESISTANT                   = ConvertUnitType(24)
    constant unittype UNIT_TYPE_ETHEREAL                    = ConvertUnitType(25)
    constant unittype UNIT_TYPE_MAGIC_IMMUNE                = ConvertUnitType(26)

that are the only UNIT_TYPE variables... i dont think it is possible to check if the unit has foot-movement... (perhaps you could create a unit in water and see what happens, it acts different from other movement types, but thats quite complicated)
 
S

sinners_la_b

Guest
If you want it to only effect foot movement, you will have to settle for UNIT_TYPE_GROUND as i dont think there is a foot movement constant. Note that UNIT_TYPE_GROUND will effect hovering units as well.
 

Infinity.4Sk

New Member
Reaction score
6
the pudges in the map can slowly go through trees so the hook should only hit something that moves by foot making it ignore all other types so if you make that only hit movement type foot part this will mean that any amphibious movement or horse or hover is not affected this would however solve the problem
 

KvickaN

TH.net Regular
Reaction score
24
Changed so pudges cant go thure the trees anymore and ill try GROUND instead now.

Oh and when the hook hits a tree it bounces at the side... I want it to go right thrue.

+rep for helpers, thanks.

Ground worked, thanks.

Just want the hook to ignore all objects now... :)
 
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