Anyway, would be great if someone just took a look at the code.
Not really sure how to do that in JASSRight now the spell is not userimportingfriendly at all :/
(constant) function dmg takes integer lvl returns integer
return 30*(lvl-1) + 50
endfunction
(private) function InitDmg takes nothing returns nothing
set dmgarr[0] = 50
set dmgarr[1] = 60
set dmgarr[2] = 70
endfunction
um, Zack, Is your code a GUI-converted one? The method you use in that code is very similar to GUI ones. It look like you convert a GUI spell to custom text, put all function to one trigger, get rid of all BJs, optimize it with local variable, then re-optimize it a bit.Anyway, would be great if someone just took a look at the code. I want to know how to make this spell better![]()
Mage_Goo said:'Trigger Function does not exist in database: DisplayTexToPlayer'
sorry, it's my typo. the real error is this:'Trigger Function does not exist in database: DisplayTextToPlayer'His function is missing one letter?
He is missing a t, : DisplayTextToPlayer
library HandleData
//====================================================================================================
globals
private constant integer MAX_HANDLE_ID_COUNT = 408000
endglobals
//==================================================================================================
globals
private integer array csdata[MAX_HANDLE_ID_COUNT]
private constant integer MIN_HANDLE_ID=0x100000
endglobals
function SetData takes handle h, integer v returns nothing
debug if(GetHandleId(h)-MIN_HANDLE_ID>=MAX_HANDLE_ID_COUNT) then
debug call BJDebugMsg("SetData: Handle id too big, increase the max handle id count or use gamecache instead")
debug endif
set csdata[GetHandleId(h)-MIN_HANDLE_ID]=v
endfunction
function GetData takes handle h returns integer
debug if(GetHandleId(h)-MIN_HANDLE_ID>=MAX_HANDLE_ID_COUNT) then
debug call BJDebugMsg("GetData: Handle id too big, increase the max handle id count or use gamecache instead")
debug endif
return csdata[GetHandleId(h)-MIN_HANDLE_ID]
endfunction
endlibrary
library UtliltyFunctions initializer Init
//==================================================================================================
// Geometry
function ABU takes unit a, unit b returns real // Angle between units
return Atan2(GetUnitY(b) - GetUnitY(a), GetUnitX(b)- GetUnitX(a))
endfunction
function DBU takes unit a, unit b returns real // Distance between units
local real dx = GetUnitX(b) - GetUnitX(a)
local real dy = GetUnitY(b) - GetUnitY(a)
return SquareRoot(dx * dx + dy * dy)
endfunction
function DBPXY takes real x1, real y1, real x2, real y2 returns real // Distance between coords
local real dx = x2 - x1
local real dy = y2 - y1
return SquareRoot(dx * dx + dy * dy)
endfunction
globals
private location LOC = Location(0.,0.)
endglobals
function GetXYZ takes real x, real y returns real
call MoveLocation(LOC,x,y)
return GetLocationZ(LOC)
endfunction
//==================================================================================================
// Returns true or false where a boolexpr is needed; usesful for avoiding null leak
globals
boolexpr B_TRUE=null
boolexpr B_FALSE=null
endglobals
private function rettrue takes nothing returns boolean
return true
endfunction
private function retfalse takes nothing returns boolean
return false
endfunction
// Unit group manipulation
globals
private group GNear = CreateGroup()
endglobals
function GetNearestUnit takes group source, real x, real y returns unit // Name says it all
local unit dum
local unit current = null
local real dist = 999999.
local real r
call GroupClear(GNear)
call GroupAddGroup(source,GNear)
loop
set dum = FirstOfGroup(GNear)
exitwhen dum==null
call GroupRemoveUnit(GNear,dum)
set r = DBPXY(x,y,GetUnitX(dum),GetUnitY(dum))
if r<dist then
set dist = r
set current = dum
endif
endloop
return current
endfunction
//==================================================================================================
private function Init takes nothing returns nothing
set B_TRUE = Condition(function rettrue)
set B_FALSE = Condition(function retfalse)
endfunction
endlibrary
library UtliltyFunctions initializer Init
//==================================================================================================
// Geometry
function ABU takes unit a, unit b returns real // Angle between units
return Atan2(GetUnitY(b) - GetUnitY(a), GetUnitX(b)- GetUnitX(a))
endfunction
function DBU takes unit a, unit b returns real // Distance between units
local real dx = GetUnitX(b) - GetUnitX(a)
local real dy = GetUnitY(b) - GetUnitY(a)
return SquareRoot(dx * dx + dy * dy)
endfunction
function DBPXY takes real x1, real y1, real x2, real y2 returns real // Distance between coords
local real dx = x2 - x1
local real dy = y2 - y1
return SquareRoot(dx * dx + dy * dy)
endfunction
globals
private location LOC = Location(0.,0.)
endglobals
function GetXYZ takes real x, real y returns real
call MoveLocation(LOC,x,y)
return GetLocationZ(LOC)
endfunction
//==================================================================================================
// Returns true or false where a boolexpr is needed; usesful for avoiding null leak
globals
boolexpr B_TRUE=null
boolexpr B_FALSE=null
endglobals
private function rettrue takes nothing returns boolean
return true
endfunction
private function retfalse takes nothing returns boolean
return false
endfunction
// Unit group manipulation
globals
private group GNear = CreateGroup()
endglobals
function GetNearestUnit takes group source, real x, real y returns unit // Name says it all
local unit dum
local unit current = null
local real dist = 999999.
local real r
call GroupClear(GNear)
call GroupAddGroup(source,GNear)
loop
set dum = FirstOfGroup(GNear)
exitwhen dum==null
call GroupRemoveUnit(GNear,dum)
set r = DBPXY(x,y,GetUnitX(dum),GetUnitY(dum))
if r<dist then
set dist = r
set current = dum
endif
endloop
return current
endfunction
//==================================================================================================
private function Init takes nothing returns nothing
set B_TRUE = Condition(function rettrue)
set B_FALSE = Condition(function retfalse)
endfunction
endlibrary
I'm sorry, but you're incorrect. It is a very good method of doing function spell values. The constant keyword makes it so Vexorian's Map Optimizer will inline the function call (If you only use the level variable once, then even jasshelper will inline it), which means you're doing the raw math in the function as needed. If you use the global method, you're doing an array set in a function call (slowish) and then an array lookup to get the value (fastish). The difference is so negligible between the two cases at the end of the day that it can be ignored. They are effectively the same in speed.Eccho said:Normally this is not a good way, as I've heard returning strings like that is bad or unsafe (dont remember why though)
Yeah, I guess it has something to do with your JNGP...
here is the code:
JASS:library HandleData //==================================================================================================== globals private constant integer MAX_HANDLE_ID_COUNT = 408000 endglobals //================================================================================================== globals private integer array csdata[MAX_HANDLE_ID_COUNT] private constant integer MIN_HANDLE_ID=0x100000 endglobals function SetData takes handle h, integer v returns nothing debug if(GetHandleId(h)-MIN_HANDLE_ID>=MAX_HANDLE_ID_COUNT) then debug call BJDebugMsg("SetData: Handle id too big, increase the max handle id count or use gamecache instead") debug endif set csdata[GetHandleId(h)-MIN_HANDLE_ID]=v endfunction function GetData takes handle h returns integer debug if(GetHandleId(h)-MIN_HANDLE_ID>=MAX_HANDLE_ID_COUNT) then debug call BJDebugMsg("GetData: Handle id too big, increase the max handle id count or use gamecache instead") debug endif return csdata[GetHandleId(h)-MIN_HANDLE_ID] endfunction endlibrary
JASS:library UtliltyFunctions initializer Init //================================================================================================== // Geometry function ABU takes unit a, unit b returns real // Angle between units return Atan2(GetUnitY(b) - GetUnitY(a), GetUnitX(b)- GetUnitX(a)) endfunction function DBU takes unit a, unit b returns real // Distance between units local real dx = GetUnitX(b) - GetUnitX(a) local real dy = GetUnitY(b) - GetUnitY(a) return SquareRoot(dx * dx + dy * dy) endfunction function DBPXY takes real x1, real y1, real x2, real y2 returns real // Distance between coords local real dx = x2 - x1 local real dy = y2 - y1 return SquareRoot(dx * dx + dy * dy) endfunction globals private location LOC = Location(0.,0.) endglobals function GetXYZ takes real x, real y returns real call MoveLocation(LOC,x,y) return GetLocationZ(LOC) endfunction //================================================================================================== // Returns true or false where a boolexpr is needed; usesful for avoiding null leak globals boolexpr B_TRUE=null boolexpr B_FALSE=null endglobals private function rettrue takes nothing returns boolean return true endfunction private function retfalse takes nothing returns boolean return false endfunction // Unit group manipulation globals private group GNear = CreateGroup() endglobals function GetNearestUnit takes group source, real x, real y returns unit // Name says it all local unit dum local unit current = null local real dist = 999999. local real r call GroupClear(GNear) call GroupAddGroup(source,GNear) loop set dum = FirstOfGroup(GNear) exitwhen dum==null call GroupRemoveUnit(GNear,dum) set r = DBPXY(x,y,GetUnitX(dum),GetUnitY(dum)) if r<dist then set dist = r set current = dum endif endloop return current endfunction //================================================================================================== private function Init takes nothing returns nothing set B_TRUE = Condition(function rettrue) set B_FALSE = Condition(function retfalse) endfunction endlibrary
JASS:library UtliltyFunctions initializer Init //================================================================================================== // Geometry function ABU takes unit a, unit b returns real // Angle between units return Atan2(GetUnitY(b) - GetUnitY(a), GetUnitX(b)- GetUnitX(a)) endfunction function DBU takes unit a, unit b returns real // Distance between units local real dx = GetUnitX(b) - GetUnitX(a) local real dy = GetUnitY(b) - GetUnitY(a) return SquareRoot(dx * dx + dy * dy) endfunction function DBPXY takes real x1, real y1, real x2, real y2 returns real // Distance between coords local real dx = x2 - x1 local real dy = y2 - y1 return SquareRoot(dx * dx + dy * dy) endfunction globals private location LOC = Location(0.,0.) endglobals function GetXYZ takes real x, real y returns real call MoveLocation(LOC,x,y) return GetLocationZ(LOC) endfunction //================================================================================================== // Returns true or false where a boolexpr is needed; usesful for avoiding null leak globals boolexpr B_TRUE=null boolexpr B_FALSE=null endglobals private function rettrue takes nothing returns boolean return true endfunction private function retfalse takes nothing returns boolean return false endfunction // Unit group manipulation globals private group GNear = CreateGroup() endglobals function GetNearestUnit takes group source, real x, real y returns unit // Name says it all local unit dum local unit current = null local real dist = 999999. local real r call GroupClear(GNear) call GroupAddGroup(source,GNear) loop set dum = FirstOfGroup(GNear) exitwhen dum==null call GroupRemoveUnit(GNear,dum) set r = DBPXY(x,y,GetUnitX(dum),GetUnitY(dum)) if r<dist then set dist = r set current = dum endif endloop return current endfunction //================================================================================================== private function Init takes nothing returns nothing set B_TRUE = Condition(function rettrue) set B_FALSE = Condition(function retfalse) endfunction endlibrary
I'm sorry, but you're incorrect. It is a very good method of doing function spell values. The constant keyword makes it so Vexorian's Map Optimizer will inline the function call (If you only use the level variable once, then even jasshelper will inline it), which means you're doing the raw math in the function as needed. If you use the global method, you're doing an array set in a function call (slowish) and then an array lookup to get the value (fastish). The difference is so negligible between the two cases at the end of the day that it can be ignored. They are effectively the same in speed.
The WC3 Map Optimizer will, which is (should) be used on every map these spells get used in. In that light, they are equally efficient and should be judged equally.Eccho said:That's true, but what about the case where you don't have JNGP and doesn't use vJass. Nothing will inline those functions in those cases.
# 70 % of the winner shall be determined by the contest's appointed judge(s).
# 30 % of the winner shall be determined by the results of a public poll.
yeah, you're right. Something happened to my JNGP.Yeah, I guess it has something to do with your JNGP...
What other options are there?Guys, I am making the poll now. Question: Since there are 18 entries, should I make the poll multiple choice?
Single-choice, which is usually what we have for arena contests
Why multiple choice? I was under the impression that in voting you picked your favorite submission, not favorite(s)? In the long run it really doesn't have a huge impact on anything, so I don't really care, it's just an odd choice since there's really nothing to gain from it. The more entries you vote for, the less net effect your vote has, so it's always more efficient for your favorite to only vote for one entry. Whether you enable mult-voting or not, I'll still only vote for one entry.
If you want to try it, though, why not?
Why multiple choice? I was under the impression that in voting you picked your favorite submission, not favorite(s)? In the long run it really doesn't have a huge impact on anything, so I don't really care, it's just an odd choice since there's really nothing to gain from it. The more entries you vote for, the less net effect your vote has, so it's always more efficient for your favorite to only vote for one entry.
yeah sure why not
well, it's good then.The WIP one is almost entirely incomplete, so maybe that one shouldn't be considered. The one that was posted a little late is no problem at all, however.
Ah, I see. It should really be scaled to whomever got the highest score, not the number of votes cast. That way someone always gets a 100% on the voting section (makes sense) and there's no need for multi-vote nonsense.