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

[General] some questions

Status
Not open for further replies.
Level 7
Joined
Feb 14, 2008
Messages
289
yo, i got quite a few questions. All of which are specific about little details and really dont have time to read massive tutorials for one thing at a time. (college full-time) while i am at it, i think learning jazz a bit will help my class.

note: i am trying to understand by analyzing codes other people have made.

from the Code of this map: http://www.hiveworkshop.com/forums/spells-569/shadow-step-v1-3-a-197510/?prev=status=a

1.
JASS:
globals
    private constant integer ABILID = 'ABSS' // raw code of ability "Shadow Step"
    private constant integer DUMABILID1 = 'ASS1' // raw code of ability "Shadow Swap"
    private constant integer DUMABILID2 = 'ASS0' // raw code of ability "Shadow Step (Illusion)"
    private constant integer CASTID = 'cAST' // raw code of unit "Caster Dummy"
    
    private constant real OFFSET = 100. // offset distance from the target
    private constant real PERIOD = 0.1 // update interval for shadow fade and illusion timer
    private constant real SHADOW_DIST = 50. // distance interval where a shadow is created
    private constant real TRANS = 150. // 0 = completely transparent, maximum of 255
    private constant real FADE_DUR = 1. // time for shadows to fade
    private constant real FADE_RATE = TRANS * PERIOD / FADE_DUR // rate of fading
    
    private constant real TURN_RATE = 0.6 // caster's turn rate
    private constant string ANIM = "slam" // animation to be played by shadows
    private constant real ANIM_TIME = 0.5665 // animation time for ANIM
    private constant real ANIM_TIME_SCALE = ANIM_TIME / FADE_DUR // time scale for shadows
    
    private constant attacktype ATK = ATTACK_TYPE_HERO // attack type of damage
    private constant damagetype DMG = DAMAGE_TYPE_NORMAL // damage type of damage
endglobals

the word "private" means what? that the constant only applys to the function it is inside? which would make no sense since the global function never actually uses it, just makes it.

2. Where does Jass BEGIN? Like, when u cast an ability, what would cause the entire code to start when the ability is cast. Do you use GUI to start it? (of course with functions having conditions, no need to have all the conditioning in gui)

3. Also, all of the functions actually begin in "private static/dynamic method". Shouldnt functions begin in "function"? also, does the word static/dynamic mean you cannot change any of the variables inside them? no matter what u set them to outside the function? and what is "method" vs "struct data/fade" is struct like a sub-procedure since it requires nothing and returns nothing?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
1. Private means the variable/method/function/struct can't be accessed from outside the library/scope. The value can't be read or manipulated from outside.

2. Typically you register some kind of event.

For structs, you can use onInit method:
JASS:
private static method onInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function thistype.condition))
    set t = null
endmethod

for libraries:
JASS:
library SomeLibrary initializer InitThisLibrary
...
private function InitThisLibrary takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function condition))
    set t = null
endfunction

^The example event used here is Starts the effect of an ability.

3. Methods are like functions. You use methods inside structs, that is all. Outside structs, use functions.

Static means the method isn't instance spesific. More info here: http://www.hiveworkshop.com/forums/tutorial-submission-283/introduction-struct-207381/
 
Level 7
Joined
Feb 14, 2008
Messages
289
1. Private means the variable/method/function/struct can't be accessed from outside the library/scope. The value can't be read or manipulated from outside.

2. Typically you register some kind of event.

For structs, you can use onInit method:
JASS:
private static method onInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function thistype.condition))
    set t = null
endmethod

for libraries:
JASS:
library SomeLibrary initializer InitThisLibrary
...
private function InitThisLibrary takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function condition))
    set t = null
endfunction

^The example event used here is Starts the effect of an ability.

3. Methods are like functions. You use methods inside structs, that is all. Outside structs, use functions.

Static means the method isn't instance spesific. More info here: http://www.hiveworkshop.com/forums/tutorial-submission-283/introduction-struct-207381/

1. I have no actually covered libraries yet but it looks like a collection of functions in an area right?
2. what is OnInit? does it mean on initilization?
3. ty for link! i will look it over when i have time.
 
Level 7
Joined
Feb 14, 2008
Messages
289
2. Typically you register some kind of event.

so lets say you cast roar. and there should be functions that occur once roar is cast.
how would that be made? Normally to me a function must first be called before it can do anything.

does this mean the game actually analyze all functions on its own in an infinite loop without necessarily requiring special calls for them to occur if they contain a line that analyzes conditions?
 
Level 6
Joined
Jun 16, 2007
Messages
235
does this mean the game actually analyze all functions on its own in an infinite loop without necessarily requiring special calls for them to occur if they contain a line that analyzes conditions?

Yes and no.
A lame implementation would call them all but there are many optimizations a smart programmer can make (and despite what BJism noobs thinks Blizzard has smart programmers)

For example you can remember what functions returned true, and place them higher in the loop structure. (some form of B-tree usually)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
This is plain JASS, registes the cast event for an ability which has the A000 id. You can check ability ids in object editor by clicking Ctrl+D.

JASS:
function ST_Action takes nothing returns nothing
    call BJDebugMsg("hi")
endfunction

function ST_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function InitTrig_SomeTrigger takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction(t, function ST_Action)
    call TriggerAddCondition(t, Condition(function ST_Condition))
    set t = null
endfunction
 
Status
Not open for further replies.
Top