| 07-25-2007, 04:46 PM | #1 |
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) 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 |
| 07-25-2007, 05:10 PM | #2 |
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 |
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 |
read this. The last 4 JASS boxes show you how to:
|
| 07-25-2007, 08:56 PM | #5 | |
Quote:
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. |
