• 🏆 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!

Beginning JASS Tutorial Series

Level 12
Joined
Aug 20, 2007
Messages
866
Unless your dyslexic, please don't spell words wrong, or use incorrect words. I cannot tell what 'complination' is supposed to mean. My strongest guess is 'compilation', 2nd guess would be 'complaint'.

I meant read through the rest of it, because your supposed to stick it in a trigger and use it. Simply making the function will not do anything, as you had described.

When he says make a trigger, he is assuming your moving from GUI to JASS. You should not convert the trigger to custom text, in your events put a normal GUI event for 'Left Key', and put for 'Actions', find the 'Custom Script' and type in 'call HelloWorld()'

It should look somewhat like this...

  • Events
    • 'Left Key Press'
  • Conditions
  • Actions
    • Custom Script: call HelloWorld()
And as for this tutorial sucks, don't blame the tutorial, there is such a thing as being stupid

I don't think your stupid though, I had the same problems with these tutorials, and really got quite pissed when I started. You just need to keep at it, try every possibility, and above all else being a lazy schmuck cannot help.
 
Level 24
Joined
May 9, 2007
Messages
3,563
Quite framkly I think that it is a quality tutorial.

The answer, wuite simply is:

JASS is crap.


Sorry, to all you dedicated JASS'ers out there, but as a language it is quite frankly lame. Compared to something like Pytohn, or C it does not compare.

Still, I'm going to learn it, and it can do powerful things in Warcraft.
 
Level 2
Joined
Jan 6, 2008
Messages
25
Thanks for the reply, herman, but the reason it's missing an endfunction in the shown code is because I only showed the relevant part to what I was talking about.

It still has an endfunction and everything, the only addition is one line that is correctly written and everything and I dunno why the lack of savability happens ;(
 
Level 10
Joined
Aug 19, 2008
Messages
491
Unless your dyslexic, please don't spell words wrong, or use incorrect words. I cannot tell what 'complination' is supposed to mean. My strongest guess is 'compilation', 2nd guess would be 'complaint'.

I meant read through the rest of it, because your supposed to stick it in a trigger and use it. Simply making the function will not do anything, as you had described.

When he says make a trigger, he is assuming your moving from GUI to JASS. You should not convert the trigger to custom text, in your events put a normal GUI event for 'Left Key', and put for 'Actions', find the 'Custom Script' and type in 'call HelloWorld()'

It should look somewhat like this...

  • Events
    • 'Left Key Press'
  • Conditions
  • Actions
    • Custom Script: call HelloWorld()
And as for this tutorial sucks, don't blame the tutorial, there is such a thing as being stupid

I don't think your stupid though, I had the same problems with these tutorials, and really got quite pissed when I started. You just need to keep at it, try every possibility, and above all else being a lazy schmuck cannot help.

I'm so sorry for my bad English. When I wrote it I was starving and couldn't think straight.
Well, first of all I don't have dyslexic (I can tell beacuse my neighbour have it), and second of all the word I was trying to describe would be something like "my complaining text" which would be more acurate.

Now I see that I should have used a GUI Trigger, NOT a JASS Trigger and for that you have my thanks.
And now I have a new question: do I need to convert the trigger to Custom Text?

I hope you find this Quote's spelling better then my last one (really, really sorry for my awfull English)
And this tutorial doesn't suck (like I wrote) beacuse people obviously find it helpful so there must be something I'm missunderstanding.
 
Level 12
Joined
Aug 20, 2007
Messages
866
Converting GUI to JASS comes later once one has learned all they need to know about functions {declarations, parameters, calling, returning}

When you reach this point...

GUI is actually a bad version of JASS (literally, the war3 processor converts GUI into a horribly odd-looking JASS script)

When you use the 'Convert to Custom Text' button, you get a glimpse of what it looks like

You'll notice something along these lines...

JASS:
function <triggername>_Actions takes nothing returns nothing
    //Your actions
endfunction

function <triggername>_Conditions takes nothing returns boolean
    //Your conditions
endfunction

function InitTrig_<triggername> takes nothing returns nothing
    set gg_trg_<triggername> = CreateTrigger()
    call <Function name for your GUI event>(<parameters for the GUI event>)
    call TriggerAddAction(gg_trg_<triggername>, function <triggername>_Actions)
    call TriggerAddCondition(gg_trg_<triggername>, function <triggername>_Conditions)
endfunction

Now this probably looks extremely confusing, but I want you to focus on the 'CreateTrigger()' portion. This creates what JASSers call a 'handle'. A handle is basically a big piece of information that has special syntax and can do certain things. Here, our handle is a trigger, and what trigger handles do, is pretty much exactly what a normal GUI trigger can do. The important part right now, is registering events.

You can register an event to a trigger, and it will run like this...

When the specific event occurs...

JASS:
if <TriggersAddedConditions> then
    <TriggersAddedActions
endif

An if-then similar to this will run and check to see whether or not the trigger will fire.

Your probably thinking to yourself, great, but how does the 'CreateTrigger()' function get called???

Well, the war3 processor has a 'main' function that runs all the various commands you told your WE to do in the different WE interfaces{such as creating units}. This 'main' function also calls each of your 'InitTrig_' functions

In order to have your function called in the 'main', you must fulfill 3 conditions.

1. You must create a regular GUI trigger and convert it to custom text, this doesn't sound like a big deal, but when you use the 'Custom Script' at the top of the trigger editor, you start to wish you didn't need to do this.

2.The next condition, is that the function must start with 'InitTrig_'

3.Lastly, after the 'InitTrig_' you must have the name of your trigger, this is because the war3 processor must need to know which functions are just functions and which one will be called in the main.
 
Level 22
Joined
Jun 24, 2008
Messages
3,050
Ehrm.. You guys lost me after "HelloWorld" :D

JASS:
function UnitCreation takes nothing returns nothing
  local unit u = CreateUnit(XXX)
endfunction

What should be in the XXX? The Rawcode (h001)? Or the Name? (Ninja) or What?

And my W/E Keeps bugging with the GUI triggers also, after i made a mistake in JASS:
Please? Can anyone help?
 
Level 12
Joined
Aug 20, 2007
Messages
866
Turn off or remove all of your JASS code until you find what is bugged and whats not.

The JASS Vault

Search around here for any questions you have about JASS functions, they will be in the common.j section

function CreateUnit takes player id, integer unitid, real x, real y, real face returns unit

player id --> the variable type is 'player', and the name is 'id'

The name gives a hint to what the parameter is logically, here meaning the identity of the unit, or its owner

integer unitid --> An integer variable, the name is 'unitid', through experience I've learned this is the place for a units rawcode

real x --> simple enough, the exact x coordinate of where the unit will be placed

real y --> exact y coordinate

real face --> The degrees the unit will face, please note that this is in degrees, not radians

And that 'returns' bit means that you can set this function to a variable, as you have done already.

Your function could possibly look like this...

JASS:
function UnitCreation takes nothing returns nothing
    local real x = GetRandomReal(0,10000)
    local real y = GetRandomReal(0,10000)
    local real face = GetRandomReal(0,360)
    local player owner = Player(GetRandomInt(0,10))
    local unit u = CreateUnit(owner, 'A001', x, y, face)
endfunction
 
Level 12
Joined
Aug 20, 2007
Messages
866
I'm not sure what you mean. As far as I know, your wrong, reals can be any real number, and the syntax for getting a random real in JASS is using that GetRandomReal function
 
Level 8
Joined
Nov 29, 2007
Messages
371
I personally found the tutorial very helpful, perhaps you should try another tutorial or try one for pascal or C [they are somewhat similar in structure as programming languages to JASS, though they are of course much more powerful]

The hello world program is just a program that prints the words "Hello World" onto the screen, its a standard programming thing and is about the simplest program you can write.

I recommend reading Herman's posts in this thread, he's very good at explaining JASS to people.

This is an example of the Hello World program, written in Pascal:
Code:
program helloWorld;

begin
   write('Hello World!);
end.

compare that with the JASS version:
JASS:
function helloWorld takes nothing returns nothing
   call BJDebugMsg("Hello World")
endfunction

You can clearly see the similarities.
 
Level 2
Joined
Aug 17, 2008
Messages
22
THIS DID NOT HELP ME AT ALL when u were talking about the units it didnt say to put it in the custom script or the trigger which completely destroyed all of this. and made it hella confusing to me
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
THIS DID NOT HELP ME AT ALL when u were talking about the units it didnt say to put it in the custom script or the trigger which completely destroyed all of this. and made it hella confusing to me
That's why i took first time i readed it.
I didn't read it twice and i didn't read any other jass tutorial.
Belive me, you don't realise yet but it actualy helped you a lot!:smile:(as it helped me a lot)
 
Level 1
Joined
Dec 1, 2008
Messages
1
I can't make the spell code work :sad:
It keeps saying I have undeclared variables. Here are the variables it says are undeclared, and how I set them:
Code:
set temp_loc = GetUnitLoc(temp)
set blinkEffect = AddSpecialEffectLox("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", temp_loc)
set gg_trg_slash = CreateTrigger()
Plz help :sad:
 
Level 1
Joined
Dec 28, 2008
Messages
3
When i start the game after donw everything in the first lesson, two error says that the trigger will be disabled. whats wrong??
 
Level 1
Joined
Jan 20, 2009
Messages
5
hey well thank you for the tutorial i'd like to ask about challenge 4
i got the way to to get the numbers of the perfect divisions but my problem is to display the text Oo
when ever i make a syntax check jasscraft promps me that it can't turn an integer to a string
i tried using call BJDebugMsg(x) but still it gives me the same messege
how am i supposed to get the message like you ask me ?
ex. for n=12
1,2,3,4,6,12
 
Level 1
Joined
Jan 20, 2009
Messages
5
hmmm that solved 1 problem
but the problem is that it will display in the game just the number and not like 1 string like "1,2,3,4,6,12"
it will be:
"1"
"2"
"3"
etc..

how am i supposed to make it a long 1 string with all the numbers
 
Level 1
Joined
Jan 20, 2009
Messages
5
JASS:
//your function head
//init locals
local string output = ""
//do stuff
//when you receive a value...
output = output + I2S(value) + ","
//at the end of the function...
call BJDebugMsg(SubString(output,0,StringLength(output)-1))

well i understand what you did here
but can you please explain the function SubString?
why can't i just type BJDebugMsg(output)?
 
Level 12
Joined
Aug 31, 2008
Messages
1,121
Wiped out my whole question i asked before you all read it and laughed to death.
I forgot what Killunit actually was, a function form common.j/blizzard.j (I don't know the difference. How come neither of them actually have the hashtable type, but it can be used in WE?
 
Last edited:
Level 1
Joined
Jan 16, 2009
Messages
2
JASS is great not just cus it's easier, and makes life so much simpler(made it for me, before, I din't even know to make a simple open/close gate trigger in the GUI) but is also a long-term investment; think about it. When Starcraft II comes out, I bet it'll be heavily based on Warcraft 3, including the JASS.
 
Level 6
Joined
Aug 13, 2009
Messages
197
Jass is pretty similar to Visual Basic and since I'm a Visual Basic programmer it was quite easy to understand everything.

Thanks, great tutorial, helped me a lot, after some hours studying jass from this tutorial I, finally, can create my own Jass scripts without problems.

Tutorial Rating: 5/5
Keep it up!

Appreciated,
Ragnaros
 
Level 10
Joined
Jan 24, 2009
Messages
606
JASS:
function Slash_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A001' 
endfunction

function Slash_Actions takes nothing returns nothing

local unit caster = GetSpellAbilityUnit()
local location start_position = GetUnitLoc(caster)
local group enemies = CreateGroup()
local unit temp
local integer count = 5
local location temp_loc
    call GroupEnumUnitsInRangeOfLoc(enemies, start_position,500.0, null)    
    loop
        set temp = FirstOfGroup(enemies)
        exitwhen temp == null or count == 0
        if IsUnitEnemy(temp, GetOwningPlayer(caster)) then
            set temp_loc = GetUnitLoc(temp)
            call SetUnitPositionLoc(caster, temp_loc)
            call UnitDamageTarget(caster,temp,50,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL,null)
            set count = count - 1
            call RemoveLocation(temp_loc)
        endif
        call GroupRemoveUnit(enemies,temp)
    endloop
call SetUnitPositionLoc(caster,start_position)
call RemoveLocation(start_position)
call DestroyGroup(enemies)
set caster = null
set start_position = null
set enemies = null
set temp = null
endfunction

function InitTrig_Slash takes nothing returns nothing
 local trigger gg_trg_Slash
 set gg_trg_Slash = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT) 
    call TriggerAddCondition(gg_trg_Slash, Condition(function Slash_Condition))
    call TriggerAddAction(gg_trg_Slash, function Slash_Actions)
endfunction


Can any1 tell me why he is not moving? I used Shockwave as the Base Spell................
 
Top