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

[JASS] Questions revolving around JASS

Status
Not open for further replies.
Level 2
Joined
May 20, 2007
Messages
6
Hello, this is my first "real" post on this website and i have a few questions for you! I am taking a course on C++ and i know a bit of it, so i decided to learn JASS as well... now thing is, i understand how to type it out, to an extent at least. (Loops, functions, calling, etc.) However i am confused about a few things.

A) Why does every variable value or w/e it is have to be declared with parenthisis at the end?
Example:
JASS:
function variable_test takes nothing returns nothing
  local unit u = CreateUnit()
endfunction
(or is this just calling a function called "CreateUnit" ?? because if so then many of the tutorials should explain this feature because it seems to me that there're too many functions in them making things too complex for starters.

B) What are the commands of JASS, i'm talking about in example i've seen
JASS:
call BJDebugMsg("Hello World")

now my thing is, isn't calling "call" for calling functions? And is "BJDebugMsg("")" similar to the command "cout << " " << endl; " in c++ imported with iostream.h?

C) What are the commands to make the game do things!!!!!!! All of these example have been taken out of wyrmlords tutorial. Like he said...

JASS:
function Slash_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
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
    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
        endif
        call GroupRemoveUnit(enemies, temp)
    endloop
endfunction
function InitTrig_Slash takes nothing returns nothing
 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

was a spell... however how do you actually have the unit move around? it's like me having a "void main() { //calling random things } but not showing the functions being called. Can someone explain to me how to set things up like this?

D) does world editor work w/ c++?? if so is it plausible?

Thank you, i appreciate if you would answer these questions of mine! (i'm very confused about these things :hohum:)
 
Last edited:
Level 4
Joined
Jun 8, 2004
Messages
66
The best place to start is the JASS manual.
http://jass.sourceforge.net/doc/

Start by looking at the BJ functions, which will give you an idea of how the natives will be used. Once you're comfortable, make sure to mostly (if not exclusively) use natives which, used properly in your own functions, are generally far more efficient and less buggy than BJ's.

CreateUnit is a function. Functions without arguments passed to them just have the parentheses() at the end, but arguments would be passed inside the parentheses like with C.

You might want to experiment with the world editor by making some triggers with the UI editor and then converting them to jass (edit -> convert to custom text). You'll be able to make the connection between the UI descriptions of actions and the BJ functions behind them.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
  • Yes, that's calling a function called CreateUnit(which actually has parameters, you missed those)

    You could say local unit u = null or local integer i = 5

  • BJDebugMsg is sort of like printf. JassCraft has a very good native searcher, which is quite handy. As to 'call', all functions must have that if they're called without use of the return (ie if they're not used as a value).

  • In the example provided, SetUnitPositionLoc teleported the unit. You can issue orders (such as call IssuePointOrder(someUnit,"move",someX,someY)), or teleport the unit (such as call SetUnitPosition(someUnit,someX,someY))

  • Nope
 
Level 2
Joined
May 20, 2007
Messages
6
reply

i tried the jass manual thing... it's very disorienting and i'm rather lost about what it's trying to explain. I understand more or less how to code... i just don't understand certain things. are there include statements? And finally how the hell do i manipulate things actually in the game???? like in gui i could do... "unit- move (triggering) unit instantly to (center of playable map)" etc. How can i do things like that in JASS? Is GUI converted to custom text JASS?(unorganized JASS?) because i understand how to do in example....


function example takes nothing returns hi
local integer hi=2
return hi
end function

function example_loop takes integer returns integer
loop
bleh++
exitwhen bleh==5
endloop
end function

function example_call takes nothing returns nothing
local integer bleh= example()
local integer blah=example_loop(bleh)
endfunction

(i'm sure that i have a couple of mistakes but this is basic learning.) either way, how do i make it so that i actually can do soemthing other than manipulate fake date? because i understand how to set up "conditions where it's like "return condition== A001" basically stating that if condition ( as spell variable) is equal to the spell with the number "A001" then return "true" else return "false" however goign into this further waht do i do next? i want to in example move the triggering unti X paces. Thank you.
edit: (to the person who posted while i was posting this)
So are you saying that once you set a variable equal to a unit the variable is actually the unit so when i change the location it moves the unit? it's not like where it's not affected? If so that solves on mystery. The next is how would i create a new unit/special effect?
 
Last edited:
Level 13
Joined
Nov 22, 2006
Messages
1,260
Vexorian's introduction to JASS will maybe clear things up (I think it's far better than the thing you read).

That code you made, it's wrong. Just stick to basic things. GUI converted to custom text is JASS, because custom text = JASS.

Conditions return true if they are true, and they return false if they are false. I can't explain everything now, it's maybe hard to understand the structure of JASS at the beginning, but you'll get it eventually (Trig_SomeTrigger_Actions function holds the actions of a trigger, Trig_SomeTrigger_Conditions function holds the condition of a trigger, and it returns boolean, meaning are the conditions true or false).

I'm not a living tutorial here, go learn :)
 
Status
Not open for further replies.
Top