• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Question about Timers, Structs, and vJass

Status
Not open for further replies.
Level 3
Joined
Aug 27, 2011
Messages
41
So I was wondering about a couple of things in vJass.

  1. Can you pass a Struct as parameters?
  2. Can you use any existing variable type in a Struct or are there some that wont work?
  3. Is there any variable type similar to object, like most modern coding languages? (Yes I know highly doubtful, but I thought I'd ask.)
  4. Do Struct function the same as the modern language's Struct? Such as you can only add variables and not functions, and or methods.

Any help on any of these would be great :)
 
Level 3
Joined
Aug 27, 2011
Messages
41
Awesome that solves almost everything Yay thanks XD. I was hoping they were more like classes instead of "dumb"/"plain" structs (normal structs are called that in most programming languages lol). I figured as much about the object type lol you never know how awesome something is until you can't have it. I thought of one more question though, what is the base class of units and destructables, is it widgets, and can you damage them both from the base class?
 
2. You can't use a variable of type "code" inside a struct (because you can't declare a code array in jass and that structs are basically arrays).

About widgets, yes it is the parent of units, destructables and items.
You can use those two functions for damaging them :
JASS:
native  SetWidgetLife   takes widget whichWidget, real newLife returns nothing
native UnitDamageTarget             takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
 
Level 3
Joined
Aug 27, 2011
Messages
41
Thank you both, for the info about the widget I though that it was I just wasn't sure lol :)

@Garfield why didn't I think of looking it up in Jasscraft lol

@Tirlititi so if I can't use code, is there a replacement, that I could use, such as a method that calls a method that was passed as parameter?
 
Function interfaces are good for dynamic attachment, because they conceal a lot of the complication, and you can store them into arrays. But yeah they are slower and generate copies of the function for no reason.

I use boolexprs when I need to store a function into an array, because you can make a boolexpr array but you can't make a code array.

You can call a boolexpr like this:

JASS:
ForceEnumPlayersCounted(force /* this needs to be your own, created force */, boolexpr, 1)
 
Status
Not open for further replies.
Top