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.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top