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

[General] Where could I find the prototype and usage of function?

Status
Not open for further replies.
Level 1
Joined
Jul 25, 2012
Messages
7
Where could I find the prototype and usage of function?
I have downloaded this map, and it contains many function which are new to me. Im noob.
http://www.thehelper.net/threads/re...what-more-complete-writeup.48922/#post-422499

Example
How to find prototype of function ReviveHeroLoc, CreateNUnitsAtLoc, GetPlayerStartLocationLoc, GetOwningPlayer?

function Trig_KeepPlayerAlive_Actions takes nothing returns nothing
if ( Trig_KeepPlayerAlive_Func002C() ) then
call ReviveHeroLoc( GetDyingUnit(), GetPlayerStartLocationLoc( GetOwningPlayer( GetDyingUnit() ) ), false )
else
call CreateNUnitsAtLoc( 1, GetUnitTypeId( GetDyingUnit() ), GetOwningPlayer( GetDyingUnit() ), GetPlayerStartLocationLoc( GetOwningPlayer( GetDyingUnit() ) ), bj_UNIT_FACING )
endif
endfunction
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If you're using GUI, simply create something on the trigger first like this;
  • Kill Unit
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Unit - Kill (Triggering unit)
And then go to Edit > Convert To Custom Text

There you will see a direct translate from GUI to JASS which looks like this;
JASS:
function Trig_Kill_Unit_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'AUan' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Kill_Unit_Actions takes nothing returns nothing
    call KillUnit( GetTriggerUnit() )
endfunction

//===========================================================================
function InitTrig_Kill_Unit takes nothing returns nothing
    set gg_trg_Kill_Unit = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Kill_Unit, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Kill_Unit, Condition( function Trig_Kill_Unit_Conditions ) )
    call TriggerAddAction( gg_trg_Kill_Unit, function Trig_Kill_Unit_Actions )
endfunction
 
Level 1
Joined
Jul 25, 2012
Messages
7
Sorry, but I dont know how to create a trigger by GUI like you...
Some site say that text editor is better than GUI, so I start with text editor...
Where could I find the guide to start?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
By Text Editor you mean you're using vJASS/JASS (the second code I posted in previous post) ?
Yeah, vJASS > JASS > GUI in terms of efficiency, it's up to you which one you want to choose, GUI is not that bad from my perspective, as long my trigger does not has any bug/causes leaks/lag, I am satisfied enough with GUI.
Eventhough they say GUI is slow, but they are fast to my eyes, this is good enough.

Now, you're probably gonna need a new installed features called "vJASS" which stands for vanilla JASS (Just Another Scripting Syntax), get it here, all instructions on that page, I'm sure you can do it: http://www.hiveworkshop.com/forums/...d-install-confige-jngp-160547/?highlight=JNGP
JNGP stands for Jass NewGen Pack, it's the name of the feature and the programming language used by it is vJASS.

Happy coding :)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I always use this link as my reference for JASS functions: http://jass.sourceforge.net/doc/api/common_j-functions.shtml
I don't know the server is down, I just visited it last night and working fine :(

Well, basically you want to know each function's usage right ?
Like, what KillUnit do, what IssueOrderTargetById do, etc, right ?

Well for me, I'm using GUI right ?
Therefore what I always do is that each time I want to code in JASS, I will make it in GUI first then Convert To Custom Text and I can see clearly each function name and what it does.
 
Level 1
Joined
Jul 25, 2012
Messages
7
If you're using GUI, simply create something on the trigger first like this;
  • Kill Unit
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Unit - Kill (Triggering unit)
I cant find the event Unit - A unit Starts the effect of an ability...
 

Attachments

  • w001.jpg
    w001.jpg
    309.4 KB · Views: 68
Level 1
Joined
Jul 25, 2012
Messages
7
File common.j and blizzard.j dont have constants meaning...
What does this constant mean?
bj_UNIT_FACING

CreateNUnitsAtLoc
Parameters: integer count, integer unitId, player whichPlayer, location loc, real face.
Return Type: Group.

What is the meaning of parameter face?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Parameter is the data which signals the user to input correct values for that function.
For example, CreateNUnitsAtLoc(integer count, integer unitId, player whichPlayer, location loc, real face)

integer count - the number of units spawn per function

integer unitId - the raw ID of a unit (you can go to Object Editor -> Units Tab -> Press CTRL + D to see raw id of each unit

player whichPlayer - which player do you want to give ownership of the units that is/are about to be created ? Remember, in JASS, Player 1 (GUI) = Player 0 (JASS), so, if you want to give the ownership of the units to Player 1, you would have to type this into the parameter "Player (0)", this will return as Player 1 (Red)

location loc - where is the location of the unit that is to be created

real face - facing degree of the unit right after creation (ranging from 0 ~ 360)

Example of usage:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spawn
    • Actions
      • Custom script: call CreateNUnitsAtLoc(3, 'hfoo', GetTriggerPlayer(), GetUnitLoc(GetTriggerUnit()), 0.00)
This will create 3 Footmans for Player that cast the spell "Spawn" at the location of the casting unit, Footman will face 0.00 degrees in the map.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Def, you leak locations, bwahahaha!
I expect he do not understand about leaks yet, might as well just give him the most basic trigger there is to not confuse his thinking about this matter.

That's why I said to start with GUI first, because it has the function Convert To Custom Text which slowly teaches you which function behave the way you want it, and how to use it.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The JNGP has a built-in function list. Whenever a page in trigger editor is in text format, there will be buttons of the plugin above the text area, one being Function List. You can browse and search there with the exception of the newer hashtable functions that did not exist back then. bj_UNIT_FACING would be a constant, so switch to constants and you can see what it's set to. The bj functions and constants are compounds and supportive stuff not really needed. They are not native, meaning they do not directly call the game engine but other native functions or bjs. Guess they were invented in conjunction with GUI, to simplify some things for the novices.

That being said, GUI is more secure, jass is a direct approach, so you have more freedom and can thereby do more shit. If you are able to write jass, you will hardly need GUI anymore. As mckill2009 said, it may help to understand some things though because you also work in the WE environment, where you create objects, that you may want to reference in your code and therefore need to know how to call them. And in GUI, the API is sorted by categories, which might help to get some overview of functions. A common learning method of jass is to convert some GUI triggers and take a look into other maps.

I am glad however, that someone finally wants to start with jass because a lot of people on the hive here are stuck on GUI, which undoubtly contains a lot of flaws/disadvantages.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
(v)Jass is not the end of the flagpole either btw. Jass is the most direct language wc3 understands but you can help yourself with other languages to construct your code and the whole map archive. I am currently using lua and some small programs in visual basic, have replaced the jasshelper.exe to do some things before the code is checked to be able to modify it with external resources in order to synchronize object editor object creation with trigger data and to speed up map saving and loading.
 

nGy

nGy

Level 11
Joined
Apr 15, 2011
Messages
123
Now, you're probably gonna need a new installed features called "vJASS" which stands for vanilla JASS (Just Another Scripting Syntax),
Offtopic: I always thought vanilla JASS would be the original JASS and vJASS stood for "very JASS".

Ontopic: Although that might not be your actual problem: bj_Unit_Facing is the standard facing angle of buildings (which is 270 degrees).
 
Status
Not open for further replies.
Top