HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

importing a custom common.j with GetUnitGoldCost.

01-22-2009, 04:18 PM#1
Troll-Brain
First i want it able to work for all and on battle.net (so don't talk about japi)
I've read that is possible, but i don't know how to make it.
I tried to add this line
Collapse JASS:
native function GetUnitGoldCost takes integer unitid returns integer
at the end of my exported common.j, and then import it in the map with the path scripts\common.j
I've also tried to remove the word "native".

But i can't save the map without any error, even if i don't try to use the function GetUnitGoldCost in the map.

Could you explain plz how i can make it and/or attach a demo map ?
01-22-2009, 05:10 PM#2
Captain Griffen
You can't.

We have a GetUnitGoldCost script in our database (I think) if you want it for units (as opposed to structures). Structures are a bit trickier, but there's one for that in the database too (mine actually) that needs someone to try and build it first, but meh.
01-22-2009, 05:12 PM#3
akolyt0r
how should that work ?
only natives hardcoded in warcraft III (dlls and executables) can be used ....japi extends this functionality by injecting additional hardcoded natives in warcraft executable ...
01-22-2009, 05:21 PM#4
Troll-Brain
http://www.wc3campaigns.net/showthre...etUnitGoldCost

So what it was only a theory, or we were able to do it on 2006 but not anymore now ?
Or i missunderstand something ?
01-22-2009, 05:50 PM#5
akolyt0r
oh yes ...ai commands nice ...
however most ov them dont work ...seems like that Getunitgoldcost stopped working some patches ago ..huh ?! (doesnt work with 1.21 either)

but i already found one native that works...blah
sure there are more
Quote:
Originally Posted by working, to be continued
native GetEnemyPower takes nothing returns integer //returns 0 for me..
native TownWithMine takes nothing returns integer //0 aswell
native GetUnitGoldCost takes integer unitid returns integer //WORKS but not for custom units.
native GetUnitWoodCost takes integer unitid returns integer //WORKS but not for custom units.
native GetUnitBuildTime takes integer unitid returns integer //WORKS but not for custom units.

native UnitAlive takes unit id returns boolean //Works even for custom units ...nice one.
//did benchmark ...30% faster then GetWidgetLife(unit)>0
01-22-2009, 05:52 PM#6
Troll-Brain
Quote:
Originally Posted by akolyt0r
oh yes ...ai commands nice ...
however most ov them dont work ...seems like that Getunitgoldcost stopped working some patches ago ..huh ?! (doesnt work with 1.21 either)

but i already found one native that works...blah sure there are more
Ok, but i still don't figure how to add it, could you explain it plz ?
01-22-2009, 05:59 PM#7
akolyt0r
as you have done it aswell ...
Quote:
native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer
add it to common.j
import it ...save...
then change path to scripts\common.j save again

but dont use those natives on custom units. Will crash the game.
01-22-2009, 06:49 PM#8
Troll-Brain
It still doesn't work for me o_O, i've tried the function UnitAlive.
Did you recently tested it, and if you had it succesfully, could you attach a map plz.
01-22-2009, 07:02 PM#9
akolyt0r
sure ...

tested this map with both 1.21 and 1.22 ...worked for both (for me)
Attached Files
File type: w3xcustomCommon.j.w3x (55.9 KB)
01-22-2009, 07:36 PM#10
Troll-Brain
Oh it seems i can't use the common.j extracted from war3.mpq and war3x.mpq (patch 1.22)
Now it works, thx.

But just to know which common.j did you used, the one included in the JNGP ?
01-22-2009, 08:08 PM#11
akolyt0r
that should be the reason mine is extracted of the war3Patch.mpq (of my 1.21 installation)
the one that came with JNGP is the japi one !?
01-22-2009, 09:35 PM#12
Troll-Brain
The folder JassHelper have the same common.j of war3patch.mpq
The folder japi have the ... japi one

It seems Blizzard have added some types and functions during the patchs.

I didn't know that, i've started to use the editor when all types/functions were done.
I've learned the lesson, always check in the war3pactch.mpq first.