• 🏆 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!

[JASS] Structs, timers, and variables o my

Status
Not open for further replies.
Level 10
Joined
Jan 21, 2007
Messages
576
Alright so I am creating a projectile system and the main trigger is the one that moves them, each missile in flight is one instance of the struct and each instance of the struct contains these variables:
JASS:
unit m          //Missile
unit c          //Caster
effect mdl      //Model(special effect)
unit t          //Target
real sp         //Speed
integer ID      //Event Id
real x          //Missiles X coord
real y          //Missiles Y coord
real tx         //Target X
real ty         //Target Y
real d          //Distance Between m and t
real f          //Missiles Facing
integer Level   //Level
real dmg        //Damage done

Right now this doesn't lag with multiple missiles in flight but I was wondering if the amount of variables in a struct would cause lag if it gets any higher. 'And secondly, would it be faster to store the target X and Y in the struct and update it every iteration, or just GetUnitX(t) every iteration (I believe I only require it once per iteration). Same with the missile X and Y.
 
Gost said:
Right now this doesn't lag with multiple missiles in flight but I was wondering if the amount of variables in a struct would cause lag if it gets any higher.

Struct members are just global arrays, so no it won't cause any lag if there are more variables.
However if you are doing stuff with each of these variables per instance, it will be slower but not by much.
Depending on what you are doing with them.

Gost said:
'And secondly, would it be faster to store the target X and Y in the struct and update it every iteration, or just GetUnitX(t) every iteration (I believe I only require it once per iteration). Same with the missile X and Y.

Yes, it would be much faster to store it in a global and reference it.
 
Status
Not open for further replies.
Top