HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Using common.ai functions in normal JASS

09-04-2006, 08:08 PM#1
moyack
Hi:

The title say it all. Is it possible to use functions from common.ai in normal JASS scripting?? and in the other way, is it possible to use normal JASS functions in JASS AI??
09-04-2006, 08:09 PM#2
PipeDream
Try it
09-04-2006, 08:26 PM#3
MeanMachine
Some work and some don't . Though in order to use them, you have to import a custom common.j/ai which includes these functions. For example by putting this line in the common.j :
Collapse JASS:
function GetUnitGoldCost takes integer unitid returns integer
you can use GetUnitGoldCost in triggers. (don't you just love Blizzard for not including GetUnitGoldCost ,GetItemGoldCost and the wood equivallents in the first place). Though sometimes when you save the map it may give an unknown function error. Just save again.
09-04-2006, 10:00 PM#4
moyack
Quote:
Originally Posted by PipeDream
Try it
Actually, I tried, and I get a mistake :(

The reason to make this queston is: JASS AI is that, JASS, you use the same syntax, language grammar and the same data types, but they're not compatible. So I though there should be a way to do that (as MeanMachine explained me). I'm not sure if it's safe to modify common.j so I prefer not to touch that. Thanks for the comments.
09-04-2006, 10:08 PM#5
PipeDream
Mucking with common.j is safe, but you can't do much. Besides the couple natives, you can add types which return bug to integers for some quick and dirty fake type safety.
09-04-2006, 10:28 PM#6
MeanMachine
It's perfectly safe don't worry. I use it on two of my current projects and no erros whatsoever. (except the save thing i mentioned. but that's no big deal)
09-05-2006, 11:22 AM#7
blu_da_noob
Quote:
Originally Posted by PipeDream
Besides the couple natives, you can add types which return bug to integers for some quick and dirty fake type safety.

You can add handle extensions? That should be fun :P
09-05-2006, 01:29 PM#8
Vexorian
Is it really safe? As in even safe for multiplayer? If so we can try to have auto return bug.

Collapse Would it work?:
type handle extends integer
type integer extends handle
type integer extends unit

Should try it asap

Edit: nah you can't use type (name) for an already declared name, I guess JASS has handle, integer, real and stuff already declared. And you can't extend a non-handle type

Edit II: It would be cool to rename all the type names into short ugly names, would be the ultimate obfuscation, but it would require custom blizzard.j as well

Collapse JASS:
function c1 takes a1 C2 A1 c3 returns a2
 local a1 c4
   ....
endfunction
09-05-2006, 01:32 PM#9
The)TideHunter(
Whao!
This could be great, new handle types that blizz dident create, like projectiles!
=o
09-05-2006, 01:43 PM#10
Vexorian
sure
Collapse JASS:
type cscollisionmissile extends unit
type cstable extends handle

But notice how impractical would this be, we would have to import the kinda huge common.j besides of the need to make even more return bug exploiters.
09-05-2006, 01:53 PM#11
blu_da_noob
Common.j is only ~14kb after MPQ compression.
09-05-2006, 02:01 PM#12
The)TideHunter(
It might increase filesize, but would extremely help.
EDIT: If we changed GUI like WEU, we could have seperate folders with things like tables, projectiles, etc whith custom functions, they would have their own id (or would they).
09-05-2006, 06:23 PM#13
PipeDream
I don't think it helps in practice at all. if you want custom types the way to do it is something that compiles down to JASS. if that's just typing then it's fairly trivial transformation (just substitution)

You can't change existing type names because they are registered with their full names like "Hplayer". you would have to modify warcraft. I don't know if you can get away with extending and using the sub type. it won't help with compression because repeated patterns will already be going into the dictionary. obfuscation is useless.