JASS Loops

elmstfreddie

The Finglonger
Reaction score
203
Requesting a rename to "Elm's JASS Questions"
K I used the search, couldn't find anything.
I wanna know something REALLY easy...
And it MAY appear there is a huge delay to the question... lol jk anyhow

1. (solved)
How do you make local loops in JASS? GUI being for every integer a from 1-10, but that's global obviously. How would you make a local loop?

2. (solved)
How do you do powers? I tried ^ but JASSCraft told me it was unrecognized :confused:

3. (solved)
How do I make floating text? I used...
JASS:
set t = CreateTextTag()
call SetTextTagColor(t,100,20,20,0)
call SetTextTagLifespan(t,1.00)
call SetTextTagPos(t,aX,aY,0.00)
call SetTextTagVelocity(t,0.00,50.00)
call SetTextTagText(t,"DEATHENING BLOW!",8.00)
call SetTextTagVisibility(t,true)

Why doesn't that work?

4. (solved)
Ok, nice, my floating text won't fade >.<
JASS:
                set t = CreateTextTag()
                call SetTextTagPermanent(t,false)
                call SetTextTagColor(t,255,20,20,255)
                call SetTextTagFadepoint(t,(1.00-(0.05*l)))
                call SetTextTagPos(t,GetUnitX(a),GetUnitY(a),0.00)
                call SetTextTagVelocity(t,0.00,0.036)
                call SetTextTagText(t,(I2S(((10*l)*2))+&quot;!&quot;),0.022)
                call SetTextTagVisibility(t,true)


Outta questions for awhile, finished my spell. Thanks for the help everyone.
 

Sim

Forum Administrator
Staff member
Reaction score
534
You are also not forced to loop using integers.

Code:
local group g = CreateGroup()
local unit target
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
    set target = FirstOfGroup(g)
    exitwhen target == null
//  ***ACTIONS***
    call GroupRemoveUnit(g, target)
endloop
set target = null
set g = null
 
I

IKilledKEnny

Guest
Loops in JASS are any actions that repeat themselves until a condition which is defined it met.

As you were shown you declare loops by doing so:

loop
exitwhen=//condition
//actions
endloop
 

elmstfreddie

The Finglonger
Reaction score
203
Thanks kenny, but I already knew that (I dun even know how).
I just needed to know how to make a loop stop at a certain count.
Oops.. Forgot to rep.
(Kenny, I can't rep you again yet)

Edit > Another question (added to first post also)
How do you do powers? I tried ^ but JASSCraft said Unrecognized Character: ^
 

elmstfreddie

The Finglonger
Reaction score
203
I'm not bumping, just double posting to inform you I have changed the idea of this thread. I have a second question, check first post >.<
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
Code:
native Pow      takes real x, real power returns real

Don't use it on any power less than 4 though... x * x (x * x * x) is always faster.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Thanks, but I decided to use something else anyways :(

'nother question: How do I make floating text? I used...
JASS:
set t = CreateTextTag()
call SetTextTagColor(t,100,20,20,0)
call SetTextTagLifespan(t,1.00)
call SetTextTagPos(t,aX,aY,0.00)
call SetTextTagVelocity(t,0.00,50.00)
call SetTextTagText(t,&quot;DEATHENING BLOW!&quot;,8.00)
call SetTextTagVisibility(t,true)

Why doesn't that work?

Does it syntax, or does it not work?

Did you declare the "aX" and "aY" variables? I don't see at the moment why it wouldn't work.. :)
 

elmstfreddie

The Finglonger
Reaction score
203
I don't see anything.
And yes, those are set.

Those things are actually separated by things. I'll show you what I mean. (This is my REAL trigger)
JASS:
            set t = CreateTextTag()
            call SetTextTagColor(t,100,20,20,0)
            call SetTextTagLifespan(t,1.00)
            call SetTextTagPos(t,GetUnitX(a),GetUnitY(a),0.00)
            call SetTextTagVelocity(t,0.00,50.00)
            if(l == 15) then
                call SetTextTagText(t,&quot;DEATHENING BLOW!&quot;,8.00)
                call SetTextTagVisibility(t,true)
                call KillUnit(b)
                call TriggerSleepAction(5.00)
                call RemoveUnit(b)
                return
            else
                call SetTextTagText(t,I2S(((10*l)*2)),8.00)
                call SetTextTagVisibility(t,true)
            endif
 
1

1337D00D

Guest
wat about L? is that set?

And check to make sure your text isn't in the center of the map. if it is, then that means theres a problem with locations.
 

elmstfreddie

The Finglonger
Reaction score
203
L is set, and where I'm testing is basically the middle. I don't see anything at all.
JASSCraft also gives no errors.
But it doesn't work when I test T_T (other stuff in the same function occur though, so it DOES get to there)
 
H

Hossomi

Guest
There may be some problem with L, so it's not 15...

Really.. I don't see any problem =/
 

elmstfreddie

The Finglonger
Reaction score
203
I'm tired of these mother***king triggers on this mother***king website!
Ok, here's my full trigger (updated a bit). Still doesn't work with the floating text. Please do not steal, I'm planning on entering this in the spell contest.
JASS:
function Trig_Slash_Actions takes nothing returns nothing
    local unit a = GetTriggerUnit()
    local unit b = GetSpellTargetUnit()
    local real aX
    local real aY
    local real bX
    local real bY
    local real nX
    local real nY
    local texttag t
    local integer l = 1
    loop 
        exitwhen l &gt; (GetUnitAbilityLevel(a,&#039;A000&#039;)*5)
        if((GetRandomInt(1,15)) &gt;= l) then
            if((GetUnitState(b,UNIT_STATE_LIFE))== 0) then
                call PauseUnit(b,false)
                call PauseUnit(a,false)
                call PauseUnit(a,false)
                set t = null
                set a = null
                set b = null  
                return
            endif
            call PauseUnit(a,true)
            call PauseUnit(b,true)
            set aX = GetUnitX(a)
            set aY = GetUnitY(a)
            set bX = GetUnitX(b)
            set bY = GetUnitY(b)
            call UnitDamageTargetBJ(a,b,((10.00*l)*2),ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL)
            set nX = GetLocationX(GetUnitLoc(b)) + 150.00 * Cos(l*45.00*(3.14159/180.00))//Setting polar offsets
            set nY = GetLocationY(GetUnitLoc(b)) + 150.00 * Sin(l*45.00*(3.14159/180.00))//
            call SetUnitPosition(a,nX,nY)
            call SetUnitFacing(a,((l*45.00)+180.00))
            call SetUnitAnimation(a,&quot;attack&quot;)
            if(l == 15) then
                set t = CreateTextTag()
                call SetTextTagColor(t,100,20,20,0)
                call SetTextTagLifespan(t,1.00)
                call SetTextTagPos(t,GetUnitX(a),GetUnitY(a),0.00)
                call SetTextTagVelocity(t,0.00,50.00)
                call SetTextTagText(t,&quot;DEATHENING BLOW!&quot;,8.00)
                call SetTextTagVisibility(t,true)
                call PauseUnit(a,false)
                call PauseUnit(b,false)
                call KillUnit(b)
                call TriggerSleepAction(5.00)
                call RemoveUnit(b)
                return
            else
                set t = CreateTextTag()
                call SetTextTagColor(t,100,20,20,0)
                call SetTextTagLifespan(t,1.00)
                call SetTextTagPos(t,GetUnitX(a),GetUnitY(a),0.00)
                call SetTextTagVelocity(t,0.00,50.00)
                call SetTextTagText(t,(I2S(((10*l)*2))+&quot;!&quot;),8.00)
                call SetTextTagVisibility(t,true)
            endif
            call TriggerSleepAction((1.00-(0.05*l)))
        else
            call PauseUnit(b,false)
            call PauseUnit(a,false)
            set t = null
            set a = null
            set b = null  
            return
        endif
        set l = l + 1
    endloop
    call PauseUnit(b,false)
    call PauseUnit(a,false)    
    set t = null
    set a = null
    set b = null                
endfunction

Oh, and I put in a set player property thing for testing, and it did change my gold. So it gets there, the floating text just won't appear =/
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Code:
Floating Text - Create floating text that reads (Name of (Ability being cast)) above (Casting unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 100.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
Floating Text - Change (Last created floating text): Disable permanence

Basic GUI example.
Shows the ability that was cast above the unit, floating up and away.

Same thing in JASS natives:
JASS:
local texttag tt = CreateTextTag()
call SetTextTagText(tt, GetAbilityName(GetSpellAbilityId()), 0.023)
call SetTextTagPosUnit(tt, GetSpellAbilityUnit(), 0)
call SetTextTagColor(tt,255,0,255,255)
call SetTextTagVelocity(tt, 0, 0.036)
call SetTextTagFadepoint(tt, 2.0)
call SetTextTagLifespan(tt, 3.0)
call SetTextTagPermanent(tt, false)


Now, "velocity" for example:
GUI has 64 there, JASS uses 0.036! For the same value!

Basically, your text probably appears just fine.
However, it floats and fades instantly.


Your parameters are all way off.
Have a look at the original BJ functions to see what they are doing with their values.

And, 100,20,20 should probably be 255,50,50. :p
 

Arkan

Nobody rides for free
Reaction score
92
You're exiting the loop when l == 15, if you set it to l == 16 or l > 15 it will probably work.

if(l == 15) then could also set this line to l == 14

This would only work when you have level 3 of the ability though.

EDIT: What AceHart said might also help :)
 

elmstfreddie

The Finglonger
Reaction score
203
Thanks ace, I'm new to JASS as you probably know. I didn't know whether to use percents or hex for the colour, but that wasn't my problem. I'll check out the speed thing.

Edit > Naw, still won't appear.
Is there any particular order which the functions need to be in?
 

substance

New Member
Reaction score
34
JASS:
call SetTextTagText(t,(I2S(((10*l)*2))+&quot;!&quot;),8.00)


Your height is way too big, notice that function's parameters :

JASS:
native SetTextTagText takes texttag t, string s, real height returns nothing


It says height, not size. There is a difference. So how do you get a height based on size?

JASS:
function TextTagSize2Height takes real size returns real
    return size * 0.023 / 10
endfunction


so 8 translates to about 0.018.
 

elmstfreddie

The Finglonger
Reaction score
203
In 9453458353645% of situations (yeah that's right, figure how THAT works) height and size are the same thing font wise.
Measured in pixels.
Anyways, giving THIS a try.
DAMN, it worked. Thanks.

OK, another question. Check original post.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 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