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

[Trigger] Bullet Projectile

Status
Not open for further replies.
Since my computer is stuffed, I need to check something. Will this work?:

Shoot:
A Unit Casts Shoot
Condition Blah Blah cooldown, buffs etc
For Each Int A From 1 - (number of bullet types) Do:
If GunTypeArmed[Int A] = True
Then Create 1 BulletType[Int A] at Position of Caster Offset by 100 Facing Facing Angle of Caster
Add Last Created Unit to Bullets
Pick Every Unit In Bullets
Add Event to Damage: Picked Unit Comes within Range of a Unit

This creates a bullet dummy every time someone triggers it and adds an event to Damage.

BulletTravel:
Every 0.01 Seconds of Game
For Each Int From 1 - Number of Units In Bullets Do:
Pick Random Unit from Bullets
Remove Picked Unit from Bullets
Add Picked Unit to AlreadyMovedBullets
Set TempPoint = Position of Picked Unit Offset by 50 Facing Picked Unit Facing Angle
Move Instantly Picked Unit to TempPoint
call RemoveLocation(udg_TempPoint)
-------------------------------------
Add All Units In AlreadyMovedBullets into Bullets

This moves the dummy a little further depending on speed and type ie. moves it.

Damage:
Condition Blah blah invulnerability, unit type etc
Picke Every Unit Within 100 of Triggering Unit And Do:
For Each Int A From 1 - (number of bullet types) Do:
If Unit Type of Triggering Unit = BulletType[Int A]
Then Set Life of Picked Unit = Current Life - AmountofDamage[Int A]
Kill Triggering Unit

This detects if the bullet 'hits' a unit using a previously added event. Can be copied to damage destructables, specific targets etc.

All those For Each Int and array variables(must be preset to the right values) are for determining the bullet type from a picked up item (or whatever else) therefore dealing the right amount of damage.

Not very neat, and not perfected, but the concept is right. Don't go on about leaks and stuff. So, just tell me if this works, and find any bugs or shortcuts. Thanks.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Right-click on the trigger you want to copy and select Copy as Text. Then, in your post, include the copied text within
  • tags. The result is something that is half-readable:
  • [trigger]Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Banish
    • Actions
      • Do nothing
 
I would use the trigger tags, but I can't coz my WE is stuffed, which is also why I'm checking if it works, otherwise I'd use those triggers in a test map. And even if I used them without copying text, it would be just as messy as the untagged comment.

0.03-5 seconds? But I thought you'd have to use one action for each individual bullet because of TempPoint, which sets a new location every time, otherwise it would set the location in numerous places.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Pharaoh_ said:
Position of Picked unit responds to several units at the same time.

It responds to several units one after another, actually. Nothing happens simultaneously in WarCraft, which is why you can use global variables to "transfer" the values of local variables to the called function (this has no relevance in with GUI).
 
Level 8
Joined
Apr 30, 2009
Messages
338
it might sound weird but think of it this way

in theory, every action in a given trigger without waits happens simultaneously, in the order they are listed

and doing the "pick every unit in group" thing is just a more-readable way of stacking the same sequence of actions over and over.
 
Status
Not open for further replies.
Top