• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
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