Quick Vjass Help

Legacyspy

New Member
Reaction score
19
I was wondering if anyone could help me modify a knock back system by triggerhappy.

Each time the knock back system moves a unit by an increment, I want the unit being moved to be dealt 5 damage by udg_hero[1].
udg_hero[1] is a unit array.

I tried inserting the code
JASS:
call UnitDamageTarget( udg_Hero[1], d.u, 5.00, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL )


In the loop containing
JASS:
call SetUnitX(d.u, x)
call SetUnitY(d.u, y)
I placed it after that code.

However I got some errors and was not sure how to progress.

The other thing I would like to do is before the unit is moved, check if the flying height is greater than 165 * cliff level @ the point it is being moved to.
1 Cliff level is about a flying height of 165. I don't want the unit to be able to be knocked up cliffs.

This I have no idea how to do.

The original code is below
JASS:
library UKS // Version 1.02

globals
    private constant boolean SHOW_EFFECT = true 
    // Show effect on unit when he gets knockbacked
    private constant boolean DESTROY = true
    // Set to yes if you want to destroy doodads
    private constant string EFFECT_POS = "origin" 
    // where on the unit to show the effect
    private constant string EFFECT_GROUND = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl" 
    // The effect when a unit is knocked on ground
    private constant string EFFECT_WATER = "Abilities\\Weapons\\WaterElementalMissile\\WaterElementalMissile.mdl" 
    // The effect when a unit is knocked on water
    private constant real INTERVAL = 0.03 
    // How fast the timer will run periodicly

   // End of Configurables. Necessary globals. \\

    private timer TIMER = CreateTimer() 
    private integer COUNT = 0
endglobals

private struct UKSData
    unit u
    real speed
    real dec
    real ticksMax
    real ticksCur
    location l
    static UKSData array List
    
    static method create takes unit u1, location l1, real speed1, real dec returns UKSData
        local UKSData d = UKSData.allocate()
        local real dx = GetUnitX(u1) - GetLocationX(l1)
        local real dy = GetUnitY(u1) - GetLocationY(l1)
        set d.l = l1
        set d.u = u1
        set d.speed = speed1
        set d.dec = dec
        set d.ticksMax = SquareRoot(dx * dx + dy * dy)
        set d.ticksCur = 0
        set .List[COUNT] = d
        return d
    endmethod
    
    method onDestroy takes nothing returns nothing
        set .u = null
        set .l = null
        call RemoveLocation(.l)
    endmethod
    
endstruct

private function DestructGroup takes nothing returns nothing
    call KillDestructable(GetEnumDestructable())
endfunction

private function DestroyDestruct takes unit u returns nothing
    local rect r
    local real centerX = GetUnitX(u)
    local real centerY = GetUnitY(u)
    local real radius = 90
    local location loc = GetUnitLoc(u)
    if (radius >= 0) then
        set bj_enumDestructableCenter = loc
        set bj_enumDestructableRadius = radius
        set r = Rect(centerX - radius, centerY - radius, centerX + radius, centerY + radius)
        call EnumDestructablesInRect(r, filterEnumDestructablesInCircleBJ, function DestructGroup)
        call RemoveRect(r)
        call RemoveLocation(loc)
    endif
    set r = null
    set loc = null
endfunction

private function MoveUnits takes nothing returns nothing
    local integer i = 0
    local UKSData d
    local real x
    local real y
    local real x1
    local real y1
    local real dx
    local real dy
    local real d2
    local group g = CreateGroup()
    local boolexpr filter
    loop
        exitwhen i >= COUNT
        set d = UKSData.List<i>
        set x1 = GetUnitX(d.u)
        set y1 = GetUnitY(d.u)
        set dx = GetLocationX(d.l) - x1
        set dy = GetLocationY(d.l) - y1
        set d2 = SquareRoot(dx * dx + dy * dy)
        set x = x1 + d.speed * dx / d2
        set y = y1 + d.speed * dy / d2
        call SetUnitX(d.u, x)
        call SetUnitY(d.u, y)
        
        if SHOW_EFFECT == true then
          if IsTerrainPathable(x,y,PATHING_TYPE_FLOATABILITY) then
            call DestroyEffect(AddSpecialEffectTarget(EFFECT_GROUND, d.u, EFFECT_POS))
          elseif not IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) then
            call DestroyEffect(AddSpecialEffectTarget(EFFECT_WATER, d.u, EFFECT_POS))
          endif
        endif
        
        if DESTROY == true then
            call DestroyDestruct(d.u)
        endif
        
        set d.ticksCur = d.ticksCur + d.speed
        
        if d.speed - d.dec &gt;= 0.000 then
            set d.speed = d.speed - d.dec
        endif
        
        if d.ticksCur &gt;= d.ticksMax or d.ticksCur &lt;= 1 or d.speed &lt;= 1 then
            set COUNT = COUNT - 1
            set UKSData.List<i> = UKSData.List[COUNT]
            set i = i - 1
            if COUNT &lt;= 0 then
                call PauseTimer(TIMER)
                set COUNT = 0
            endif
            call UKSData.destroy (d)
        endif
        set i = i + 1
    endloop
    set g = null
    set filter = null
endfunction

public function KnockUnit takes unit u, location l, real speed, real decrement returns nothing
    local UKSData d = UKSData.create(u,l,speed,decrement)
    set COUNT = COUNT + 1
    if COUNT == 1 then
       call TimerStart(TIMER, INTERVAL, true, function MoveUnits)
    endif
endfunction

endlibrary
</i></i>


Thanks for taking the time to read this.
 

Kenny

Back for now.
Reaction score
202
JASS:
call UnitDamageTarget( udg_Hero[1], d.u, 5.00, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL )


UnitDamageTarget() has more parameters than what you have given. Try this:



Also, remember to post anything that is written in JASS in
JASS:
 tags, makes it easier to read.

As for the fly height thing, you would probably have to use GetLocationZ() to find the z height of the unit and the surrounding area. It can become complicated. My knockback system in the systems section on this site checks for unpathable terrain, so that units will not go up cliffs, however they will also not go down them. May come in handy, but it depends on what your looking for.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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