| 03-30-2007, 01:15 AM | #1 |
Since I didn't know where else to post this, I decided here was as good a place as any. With the dawn of precompilers, why is it that for configuration sections of spells we still use functions. I would think that it would be more logical, and it would greatly increase run time by decreasing the amount of function calls, to use globals. For example: JASS://################## CONFIGURATION SECTION ################### function Eviscerate_Configuration takes nothing returns nothing set Eviscerate_Damage[1] = 25 set Eviscerate_Damage[2] = 35 set Eviscerate_Damage[3] = 50 set Eviscerate_DamageCap[1] = 50 set Eviscerate_DamageCap[2] = 65 set Eviscerate_DamageCap[3] = 90 endfunction globals integer Eviscerate_SpellId = 'A000' // This is the raw code of the spell integer Eviscerate_BuffId = 'B000' // This is the raw code of the buff real Eviscerate_Range = 220 // This is the range in which the damage will be dealt //################## END OF CONFIGURATION SECTION ################### //For data which depends on the level of the ability, make an array //and set it in a "Configuration Function" which is run at map init real array Eviscerate_Damage real array Eviscerate_DamageCap endglobals //########################### SPELL SECTION ########################## ... JASS:... function InitTrig_Eviscerate takes nothing returns nothing set gg_trg_Eviscerate = CreateTrigger( ) call Eviscerate_Configuration() call TriggerRegisterAnyUnitEventBJ( gg_trg_Eviscerate, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Eviscerate, Condition( function Eviscerate_Conditions ) ) call TriggerAddAction( gg_trg_Eviscerate, function Eviscerate_Actions ) endfunction The one thing I am NOT sure about, however, is whether it is faster to reference an index of an array than to pump a value through a function. One pro of this change is that spells with non-linear data can have their data put in level by level, so that makes configuring those types of spells easier. One con though, is that it is a lot more confusing to read, and possibly more confusing to write. And, of course, it would require a precompiler. Hopefully the increase in performance can outweigh the cons. |
| 03-30-2007, 06:24 AM | #2 |
Inliners FTW. Constant functions get inlined by Vex's optimiser, so just run it through that and you can have the best of both world - speed and non-linear data. |
| 03-30-2007, 11:40 AM | #3 |
Also, you don't need to write the function call as you did -- Just use initializer functions (Since you're using vJass anyways, it appears). |
| 03-30-2007, 11:45 AM | #4 |
Is this from AotZ? Zhall's Evis? |
| 03-30-2007, 12:03 PM | #5 |
Hunh? No. Zhall's Evis was coded long before vJass was released. It's not like Eviscerate is a unique spell name anyway. :P |
| 03-30-2007, 01:15 PM | #6 |
The new JESP standard is a lot more flexible and is read as (has a config header, text name replace creates a new instance) 0.9.7.2 's changes to scopes(and therefore libraries) threaten to kill the JESP standard since they do this all in a very easy way. JASS://notice how just changing the scope name creates a different instance of the spell template scope SpellCodeName globals private constant real delay = 4.5 endglobals //================================= private function dostuff takes unit u returns nothing call KillUnit(u) endfunction private function onSpellEffect takes nothing returns nothing call PolledWait(delay) call SetTableReal("["+SCOPE_PRIVATE+"]", "..." , 3.0 ) //did you know that above is converted to "[SpellCodeName?__]" automatically? call dostuff() endfunction public function InitTrig takes unit u returns nothing //Becomes InitTrig_SpellCodeName... local trigger t=CreateTrigger() call TriggerAddAction(t, function onSpellEffect) call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT) // no need to set to null since it is never destroyed endfunction endscope |
| 03-30-2007, 11:21 PM | #7 |
Very enlightening. I had no idea the full extent of how powerful vJass really is. Thanks for the info. |
