• 🏆 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 JASS (or vJASS) system for custom projectiles

Status
Not open for further replies.
Okay, so I'm not a coder, but I've been wondering if the following is at all possible:

Say I want to make something like a Point Defense Drone from sc2 in Wc3 - that would require the missiles be targetable projectiles, aka, units, right? What I'm getting at more specifically is having a system that allows you to modify projectiles that are already in flight. With this I'm thinking about the various custom projectile libraries out there, coupled with a damage detection system that allows you to block damage (so you block the initial damage, which is instant, and instead trigger the custom projectile to fire immediately from the attacker). What that should give you control of is the projectile itself, right? That would mean that you can modify said projectile in midair - change it's appearance, destroy it like a Point Defense Drone in sc2 does, make it change course and hit another unit, etc.

Now, technically, all this sounds possible with the right libraries/systems. However, is that a viable system to have in, eg., a melee map? I'm not just talking abilities here, I'm talking about basic ranged attacks as well. Would it be an unreasonable resource hog, for instance?

Or is there a better way to do this?
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Question can be simplified as: "is using a projectile system viable in a melee map, (including change of attack projectile of units)".Because if you do that, implementing a point defense drone won't be much of a problem.
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Most or maybe every projectile system on this site uses small time intervals to move the projectiles, which is performance heavy. Above 20-50 projectiles -depending on the system and what else happens in your map- in the air at the same time you will get performance problems.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Most or maybe every projectile system on this site uses small time intervals to move the projectiles, which is performance heavy. Above 20-50 projectiles -depending on the system and what else happens in your map- in the air at the same time you will get performance problems.

20-50 projectiles sounds like a GUI system with Pick every unit in group.

Good projectile systems can handle hundreds. There are some projectile types that are much more expensive though, such as tracking ones.

I've personally made a 3D projectile system once that handled the movement of at least 600-700 projectiles at the same time without lagging. This system had no collision detection of any kind though.
 

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,516
Say I want to make something like a Point Defense Drone from sc2 in Wc3 - that would require the missiles be targetable projectiles, aka, units, right? What I'm getting at more specifically is having a system that allows you to modify projectiles that are already in flight. With this I'm thinking about the various custom projectile libraries out there, coupled with a damage detection system that allows you to block damage (so you block the initial damage, which is instant, and instead trigger the custom projectile to fire immediately from the attacker). What that should give you control of is the projectile itself, right? That would mean that you can modify said projectile in midair - change it's appearance, destroy it like a Point Defense Drone in sc2 does, make it change course and hit another unit, etc.

You're mostly correct, but if you're using timers to move the projectile (unit), there's no need to give the projectile an attack, and hence no reason to use damage detection - you can just search near the projectile for enemies and damage them as necessary.

Now, technically, all this sounds possible with the right libraries/systems. However, is that a viable system to have in, eg., a melee map?

No. Melee maps can't have triggers or they're not melee maps.

I'm not just talking abilities here, I'm talking about basic ranged attacks as well. Would it be an unreasonable resource hog, for instance?

Are you talking about replacing all ranged attacks in a map with a projectile system? Yes, it's possible. Since you mentioned melee maps I suppose you're talking about ~200 units. This is perfectly feasible and has been done before. I don't recall who it was, but someone triggered all the ranged projectiles in melee in order to make a time-warp spell (so you can "dodge" projectiles by making them move slowly)
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
You're mostly correct, but if you're using timers to move the projectile (unit), there's no need to give the projectile an attack, and hence no reason to use damage detection - you can just search near the projectile for enemies and damage them as necessary.

I am quite sure he meant using a damage detection system to detect when a unit attacks in order to replace the attack with a projectile.
With the usual system you can't detect when a ranged unit actually shoots a projectile, but only when the projectile hits.
 

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,516
I am quite sure he meant using a damage detection system to detect when a unit attacks in order to replace the attack with a projectile.
With the usual system you can't detect when a ranged unit actually shoots a projectile, but only when the projectile hits.

Ah right, yes that makes sense and is consistent with his story.
 
Yes, I meant what Xonok said. Also when I meant melee map, I was mostly referring to maps that function in the same way, no necessarily with vanilla units (as in, a mod). So you are saying it's possible? That's good news.

Would you happen to know any JASS/vJASS systems (since GUIs would cause problems apparently) that I could use?
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
I haven't used other people's systems much for this, but I've heard of 2 systems a lot:
xe by Vexorian
and Dirac's projectile system(don't remember the name)

In general the key to making a good projectile system is reducing the amount of calculations and overhead needed.
The ForGroup functions opens a new thread for every unit and is very slow.
Also, it is not necessary to recalculate angles every tick except if the projectile is tracking.
A good projectile system, in my opinion, has these features:
1. Uses projectile recycling/doesn't create a new unit for every projectile.
2. Stores units in a cheap data structure, such as this or maybe a linked list if absolutely necessary.
3. Splits all movement into basic velocities and accelerations, so that the calculations per tick(the most expensive thing) is minimal.
 
It is extremely easy to make a missile system which simply moves projectiles with a certain velocity. Usually, you want to use a missile struct, that contains the position and velocity vectors of the missile. If you link the structs together using a linked list (a kind of chain-like list), you can use a single timer with a low, periodic interval and loop through all missiles to update their speed and apply gravity to the z-axis.

The resource-heavy part is checking for collision, since this essentially requires you to loop through all other units on the map and comparing the distance to them,or use "group units in range", as most people do, but internally this likely does the same thing and is very slow. One way of reducing the effect of this is to only check for collision with the ground, as this is simple. Another is to check for collision with a given target, and only allow the missile to hit this, and no other.

If you allow the missile to collide with ANY unit, you can have a maximum of 30-50 missiles, depending on the method used. If you only allow collision with the ground or a single unit, you can support well over 300.
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Don't use Dirac's Missile library, because it is very flawed and you will quickly run into critical issues.
I'm currently releasing a compatible version of a missile system to his Missile lib (code is different, but API is the same).
I still have to fix some minor bugs, but very soon you are safe to use it.
You will then have full controll over every missile you create for your map.

Using onCollide, onTerrain, onDestructable, onPeriod (every fps), ... and dynamic parameters like
speed, angle, arc, curve, model, collision size, damage, target ... will offer you everything you need.
 
Status
Not open for further replies.
Top