HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Parallel Data

07-25-2007, 04:46 PM#1
TheSecretArts
Big question. How can I manage large amounts of moving projectiles simulaneously using timers with vJASS.

Let me elaborate: (Syntax might not be write,i just wrote it off the top of my head based off something previous i did w/o structs, and it data collided)
Collapse JASS:
struct ProjDat
     real InitHeight
     real IFv
     real IFh
     real Fh
     real Fv
     real X
     real Y
     real FacingAngle
     integer TimesRan
endstruct
function MoveEx takes nothing returns nothing
     //moves stuff and manipulates data
endfunction
function Move takes real HorForce, real VerForce, real Height, real InitX, real InitY, real InitAngle returns nothing
     local timer t
     // create struct and sets respective values
     call CreateTimer(t)
     call TimerStart(t,true,function MoveEx)
     //closing stuff
endfunction
How do i prevent the data from colliding and causing data to merge (thats not good), IE: Projectile 2 data overwrites projectile 1 data before projectile 1 is destroyed / finished and causes projectile one to sit there and lag. Any help would be appreciated.
07-25-2007, 05:10 PM#2
Anitarf
It's always odd when someone asks a question right after posting an answer to it.

Structs are a great way to avoid the collision of data. When you call struct.create(), a part of the memory gets reserved and will not be given to future .create calls until you destroy it with struct.destroy(). So, as long as you're smart about using struct.destroy(), you're perfectly safe.
07-25-2007, 05:52 PM#3
moyack
Lol. In this moment I'm doing a projectile system for my project, and I can tell you that structs is the perfect solution for your problem. About the timer control, create in your library one private global timer and the loop script should move all the projectiles in the game, doing a timer per projectile is not efficient.

One question: Why are you using forces?? for movement purposes is easier to manage directly the speed and acceleration, just my opinion.
07-25-2007, 06:00 PM#4
Alexander244
read this. The last 4 JASS boxes show you how to:
  1. create and reference the struct
  2. attach the data to the struct
  3. loop through all the instances of that struct with one timer
  4. destroy an instance of the struct when you are done with it
07-25-2007, 08:56 PM#5
TheSecretArts
Quote:
Originally Posted by moyack
Lol. In this moment I'm doing a projectile system for my project, and I can tell you that structs is the perfect solution for your problem. About the timer control, create in your library one private global timer and the loop script should move all the projectiles in the game, doing a timer per projectile is not efficient.

One question: Why are you using forces?? for movement purposes is easier to manage directly the speed and acceleration, just my opinion.

I use forces because im moving in 3 dimensions and im using 2 quadratic equations that use a base force, and a resisting factor. XY Force and a Z force where XY is affected by Drag whilst Z is affected by Gravity. You see moyack, my projectiles 'die' only when they hit the ground, or if a unit comes first. Its not a point and homing shoot. These projectiles arent supposed to home. It adds more 'realism' that way... its like a better version of a single cluster rocket.

Its a basic concept that i use that would help. Im just worried about data mixing and handling each struct.
EDIT: read that link... very useful! +Rep... Id seen that tut before but i never read the whole thing.