• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Tips and Tricks

Status
Not open for further replies.
Level 18
Joined
Sep 14, 2012
Messages
3,413
JASS

Don't use GetWidgetX/Y.

Never use location, use real instead.

Use only conditions and no actions.
It involves using Timer and not TSA (TriggerSleepAction or Wait in GUI).
NEVER USED PolledWait (game time in GUI). It leaks and is innacurate as hell :eek:

To heal a unit -> SetWidgetLife()
To damage a unit -> UnitDamageTarget()

Use only FirstOfGroup loop and try to avoid for groups.
When using the FirstOfGroup loop use the boolexpr inside the loop.

Use a variable when refering twice or more to something.

Don't null local player handle. It is pointless.

Null global variables handle after usage :goblin_yeah:

Always trust this

GUI

Always use multiple ITE -> So you don't use the Do Nothing shit xD


@JASS AND GUI (not vJASS at all) -> This proves to be useful :3 If you want to convert vJASS to JASS.
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
to know jass, you must know how the syntax works
and to know the scripts you could convert GUI triggers to jass
i could be wrong though
i'm also a beginner at jass, so i don't know much

by the way, here is my tips & tricks
destroy unused variables to avoid leaks!
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
So, best way to learn jass is to convert your triggers into custom script and inspect how they are written, the end
Next stop: tutorial:
i will only teach you about function calls here, all other optimization stuff will be learned when trying to make spells, people will tell you the wrong and goof things and you will be better at jass by then

functions:

example:
  • Unit - Pause (Triggering Unit)
in jass:
call PauseUnit(GetTriggerUnit(), true)
for instance, this line "calls" PauseUnit function, it takes arguments (needed stuff to work with) and make the desired thing... in here, PauseUnit will get the unit handle GetTriggerUniit() and the boolean true (true to pause, false to unpause)

Okay, let's ease a little now:

JASS:
function Example takes unit U, boolean B returns boolean
    if B then 
        return IsUnitHidden(U)
    else
        return (GetWidgetLife(U) < 0)
    endif
    return false
endfunction

i created a function, a weird one btw, it will tell you if the unit is hidden if the boolean you give it is true, and it will give you if the unit is dead if the boolean you give it is false, example:

JASS:
//here, we set a local boolean
local boolean B
//now we use our function:
set B = Example(GetLastCreatedUnit(), true)
//now, B will be true if the last created unit is hidden, and false if it isn't

//another one:
set B = Example(GetLastCreatedUnit(), false)
//now, B will be true if the unit is dead, false if he is alive

//btw, the "//" before some sentences is to start a trigger comment ;P

Hope it helped :grin: :wink:
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
JASS:
function Example takes unit U, boolean B returns boolean
    if B then
        return IsUnitHidden(U)
    else
        return (GetWidgetLife(U) < 0)
    endif
    return false
endfunction
->
JASS:
function Example takes unit U, boolean B returns boolean
    return (B and IsUnitHidden(u)) or (not(B) and GetWidgetLife(U)<0))
endfunction
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
destroy unused variables to avoid leaks!
Destroy the objects and null the references to avoid memory leaks (for both objects and references)

Yeah sorry didn't update.
Don't take it till I prove it.
Sorry to sound like an asshole, I just woke up and I saw this, I'm the one who should apologize dude.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Already did, but my brain ain't working at the moment when I try to parse vjass. Maybe later lol
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Oh, I understand now. You need to use polar projection for that, are you going to use custom script or you code in jass?
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Oh God... okay here's what you could do:

JASS:
    call SetUnitX(yourUnit,udg_PosX)
    call SetUnitX(yourUnit,udg_PosY)
    call SetUnitFacing(yourUnit,udg_Angle)
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Why would you avoid that call? It's better than using polar projection.
Wait a minute... Could you tell me what are you exactly doing, I think I haven't understood exactly what you want to do.
 
Level 11
Joined
Aug 6, 2009
Messages
697
Why would you avoid that call? It's better than using polar projection.
Wait a minute... Could you tell me what are you exactly doing, I think I haven't understood exactly what you want to do.

Nevermind, it's fine.
Anyways, new problem.
I took on a GUI spell request where it extends then returns to the caster(not the problem).
However, the problem is that when the hero moves, and the spell is still active, the dummy units need to maintain the circle formation around the hero as it moves(I've tried a couple of things and nothing worked, my only idea is using a variable to track each one and (Amount Of Units Using it at the time)*36*36 every 0.03 seconds would probably cause lag.

PS:It's Razor's spell from Dota 2 called Plasma Field or something.
 
Level 11
Joined
Aug 6, 2009
Messages
697
Increase the range first, using "polar projection" from the caster's position, move the dummies
I already did polar offset based on the position of the caster but it didn't work.
I was thinking about using a maxdistance and a regular distance so if the distance is over maxdistance it will subtract the difference and put it in its original place.
But yet again, this would require me giving each of them there own distance array. I'm going to try this when I get home from school.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
@Jad

It is not simple, how can create a one unique group that handles all of the missile?
the kb3d has a line damage that only damages unit once but PER 1 missile they can damage the affected unit on the another missile source.
But the Plasma Field ability from ( Dota ) can detect if the unit is damaged by another damage source of the missile.
 
Status
Not open for further replies.
Top