HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

I got my first function in blizzard.j!!!

07-21-2003, 06:44 AM#1
gurubvin
after a few evenings working on it, prayer, and pm's to aiandy, i've finally gotten a function into blizzard.j. it's a round math function that will round the first number to the nearest - whatever the second number is.

function Round takes real roundednumber, real divisor returns real

local real currentnumber = 0.00
local real lowend = 0.00
local real highend = 0.00

loop
set lowend = currentnumber
set currentnumber = currentnumber + divisor
set highend = currentnumber
exitwhen (currentnumber >= roundednumber)
endloop

if ((highend - roundednumber) <= (roundednumber - lowend)) then
return highend
else
return lowend
endif

endfunction

here it is if neone wants it. also i found a little issue with tft if neone is altering blizz.j for it. it might just be a bug, but on my comp, you actually need to import blizz.j into your map, or campaign, in order for wc3 to use ur altered blizz.j instead of the original one. you CANNOT, judging from my exp, just create a scripts folder in your wc3 folder and save your altered blizz.j there. if you get no compile errors, but your map will not load up, it might be on account of this.

aiandy, thanks for the help.
07-21-2003, 06:48 AM#2
gurubvin
here's another thing to the noobs, from a noob. if you're adding to blizz.j and you're getting errors but you're code looks good, it might be because you've called a function that's not written until l8r on in blizz.j. when you call it wc3 can't figure out what you're calling and hence u get an error.
07-21-2003, 08:19 AM#3
AIAndy
Since TFT or RoC 1.10 there are 2 new folders in the mpqs that override other folders.
Melee_V0 has highest priority for RoC melee, Melee_V1 for TFT. There is also Custom_V0 and Custom_V1. Now if you something in there in its respective subfolder that one gets taken over the standard one.
Ex.: Melee_V0\Scripts\Blizzard.j is loaded instead of Scripts\Blizzard.j unless the first is in an MPQ and the second is in a map.
07-21-2003, 09:17 AM#4
gurubvin
wat r these new folders for?
07-21-2003, 12:41 PM#5
AIAndy
They allow to put different versions of a file in a map or mpq for TFT and RoC. FOr some files that can cause that when you put them in the map in the standard folders they work, but not in e.g. war3patch.mpq .
One more thing: In RoC 1.10 (without TFT) Allow Local Files does not work.

But in TFT or RoC with TFT putting a changed Blizzard.j in a Scripts subfolder of Warcraft3 works fine for me.
07-24-2003, 02:13 PM#6
DaKaN
Also know that there is a header feature in the TFT editor, so custom functions you want to refer to alot can be placed in the maps header, and just called normaly.

To get to the header, goto the trigger editor, and above any of the folders is the map name.w3x click on that and the blank header will show. Its very useful.
07-24-2003, 04:57 PM#7
gurubvin
thanks dakan. i prefer the blizz.j method cuz im doing a campaign with a new engine and it would occupy alot of space if i loaded it on every map. btw, ur campaign sounds rather groovy.

question for neone who looks at this. i haven't actually messed with the files in common.j, but is it possible to create new var types? more specifically a new class, or object, i forget which it's called.

like expanding an array to a vector (2d array), or a stack. i made a function that'll let u access an array like a vector, but it's simulated, and is limited to having both values in the array as integers. plus it's a function, not really a new class.

jass is more powerful than i first thought. i don't know it's full caps though, and i was wondering if the new class is an option.

thanks.
07-24-2003, 05:40 PM#8
DaKaN
J file is defantly the way to go for campaigns, but for single maps, the header is wonderful :)

as far as new var types or classes... I never really tried so I cannot say. Never found a use for this stuff in wc3 mapping
07-24-2003, 08:52 PM#9
magnus99
You can but its rather pointless unless you want to have two types that are exactly the same (e.g., good_unit and bad_unit which are both the same as unit) just so the type checker will verify that when you mean to use a good_unit you don't actually assign a bad_unit. To declare the types you'd do:

Code:
type good_unit extends unit
type bad_unit extends unit

But not much more than that. The types declared in common.j are all classes internal to the warcraft III engine so you can't muck with the internals of any object without passing it to a native function which is also handled by the engine. So creating a new class would require adding it to the internal codebase which is obviously not possible with jass. And you can not create composite types in jass -- objects that compose two or more other objects -- besides arrays, which are internally managed, because there are no first class pointers in jass (i.e., you can't say unit->hitpoints because deferencing anything is illegal; only the internals of the game engine can do it with native functions).

Edit: However, you *can* write a "pre-processor" program that recognizes, say your 2D array syntax and just converts it to some legal jass. Its fairly easy to do if you know some other programming language and don't need too fancy syntax. I write a couple perl scripts a while back to emulate linked-lists, queues, and stacks with arrays that converted syntas like "my_queue->push(whatever)" to the corresponding queue function call. Don't think I have it anymore though.
07-25-2003, 02:50 AM#10
gurubvin
thanks for the info magnus. i don't think itll be worth the effort to write a preprocessor prog. thanks though. out of curiosity, how would u load that into wc3? would it be like how they did the camer for fps mod?

this is to neone visiting here: i know some people doing campaigns are doing new functions to suit their needs. also some mapmakers. would u guys want to compile all our new functions and give it to scio for the new umswe?
07-25-2003, 09:37 AM#11
AIAndy
A preprocessor would be an external program that processes your written script and as an output gives the actual script that War3 could understand.
07-25-2003, 09:50 AM#12
gurubvin
thanks andy. so would u need to run the pre processor b4 every map, or would there be someway to embed it in the wc3 engine?
07-25-2003, 09:31 PM#13
AIAndy
You'd only need to run the preprocessor whenever you change the script.