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.
 
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)
 
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.
 
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
 
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
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      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