A few more Questions with JASS

TheCrystal

New Member
Reaction score
36
Well, I'm new to JASS and all so I'm kind of cheating with GUI on some of my "Err, what do I do?" moments.

1. I'm trying to make a KB system for me (I rather not download one) and I'm having it activate every .03 seconds with a Timer.
Here's the GUI trig

Trigger:
  • KnockBackCall Copy
    • Events
      • Time - ThreeHundredthOfSecTimer expires
    • Conditions
    • Actions
      • Custom script: call KnockBack()


It works, I know it but there's a problem with the KB part itself.

JASS:
function KnockBack takes nothing returns nothing
    local group g = CreateGroup()
    local unit u = null
    local integer i = 0
    call GroupAddGroup(BeingKnockedBack,g)
    call DisplayTextToPlayer(Player(0),0,0,"KnockBackLoopActivating")
    loop           
        set u = FirstOfGroup(g)        
        exitwhen u == null
        set i = GetUnitUserData(u)
        call GroupRemoveUnit(g,u)
        call SetUnitX(u,GetUnitX(u)+15*Cos(KnockBackAngleReal<i>*bj_DEGTORAD))
        call SetUnitY(u,GetUnitY(u)+15*Sin(KnockBackAngleReal<i>*bj_DEGTORAD))
        set KnockBackReal<i>=KnockBackReal<i>-15
            if KnockBackReal<i> &lt;= 30 then
                call GroupRemoveUnit(BeingKnockedBack,u)
            endif
    endloop
endfunction</i></i></i></i></i>

The Text doesn't display, but if I put it BEFORE I set the Group, it displays. I'm not sure what's wrong here.

(Btw, how would I do events with functions?)
2. From what I understand I have to null locals such as "local unit u = BLEH" correct? And points, etc. So I'd best do this by doing a "local unit u = null" and all that at the END of a function?

3. Since I'm guessing points leak, would this leak?
(Writing this up in Firefox, sorry if I messed something up)
JASS:
function BLEH takes unit whichunit returns nothing
    local unit u = whichunit
    local real opx = GetUnitX(u)
    local real opy = GetUnitY(u)

Or only when the thing returns specifically with a Point, like GetUnitLoc?


4. Am I doing the KB for 1 all wrong or am I on the right path? (Trial and Error)

Thanks in advance.



Edit:
5. I'm trying to base an equation or something off of an AoE deal, the damage lowering the farther out of range the unit gets. So if the ability does say, 100 damage with 100 AoE, the unit at the edge of the AoE should have 1 damage dealt. Is there an equation or something I can get out of this that someone is willing to figure out for me? I can't seem to imagine one.
 

cleeezzz

The Undead Ranger.
Reaction score
268
1. what is the group BeingKnockedBack, you sure it isn't null?

2. you dont really have to null in the beginning, but at the end is a must. (or whenever your finished with it)

3. x and y do not leak, they are reals. locations do leak, but to answer your question, it still leaks because you didn't null u.

>Or only when the thing returns specifically with a Point, like GetUnitLoc?

when it returns locations (real x and y are not locations)

4. where are you setting, KnockBackReal, KnockBackAngleReal. and the way you loop through FirstOfGroup would just move the unit instantly to the end of the knockback.

5. pick units in range (the AOE). FirstOfGroup through them, calculate the distance from target point to unit.

lets say your AOE is 500. Then figure out a damage that sounds reasonable when divided by distance. such as 500 dmg. 500 dmg at 1 range = 500. 500 dmg at 500 range = 1 dmg.

(be careful of divide by 0 error)
 

TheCrystal

New Member
Reaction score
36
1.
I see your point, I just tested the Add Knock Back function and it seems to be half working as well. It seems to be surrounded about the group.

Here's the "Add Unit to Group" trigger.
JASS:
function AddKnockBack takes unit whichunit, location whichlocation, real power returns nothing
    local unit u = whichunit
    local real opx = GetLocationX(whichlocation) //Origin Point
    local real opy = GetLocationY(whichlocation)
    local real upx = GetLocationX(GetUnitLoc(u)) //Unit Point
    local real upy = GetLocationY(GetUnitLoc(u))
    call DisplayTextToPlayer(Player(0),0,0,&quot;1234&quot;)
    set KnockBackReal[GetUnitUserData(u)] = power
    set KnockBackAngleReal[GetUnitUserData(u)] = bj_RADTODEG*Atan2(upy-opy,upx-opx)
    call DisplayTextToPlayer(Player(0),0,0,&quot;4567&quot;)
    call GroupAddUnit(BeingKnockedBack,u)
    call DisplayTextToPlayer(Player(0),0,0,&quot;891011&quot;)
endfunction


891011 doesn't appear.

Here's the JASSInit trigger.

JASS:
globals
    integer IndexNumber = 1 //Reset once hit 8000
    real array IndexReal
    real array IndexReal2
    integer array IndexInteger
    real array KnockBackReal
    real array KnockBackAngleReal
    group BeingKnockedBack
endglobals


I'm pretty sure it's working since the index is working fine.



2. I see, so I'll add a set u = null at the end of the loop then.

4. The setting of the unit X and Y, what would you suggest I do there? Just move by 15, and remove 15 from the "Power" variable? That seems too robotic.

5. Divide the damage by range? That'd be all, "1 range = 500 damage, 2 range is 250", which I don't like at all. I want it to spread it out evenly, so a unit (100 at target point, 100 AoE) at 50 range do 50 damage.
 

cleeezzz

The Undead Ranger.
Reaction score
268
for the group, i dont think you ever initialized it, set KnockBackGroup = CreateGroup()

oops i meant subtract

500 dmg - distance

500 dmg at 500 range = 0 dmg

500 dmg at 5 range = 495
 

TheCrystal

New Member
Reaction score
36
What of times when it does 50 damage in an 150 AoE?



Edit: Works now that I've fixed the code.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • 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 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