• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Gun Bullet System?

Status
Not open for further replies.
Level 8
Joined
Jul 23, 2005
Messages
329
Meh, I made this a while ago...

  • Event and Create Bullet
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
    • Actions
      • Wait 0.01 seconds
      • Unit - Order (Ordered unit) to Stop
      • Set PassUnit = (Ordered unit)
      • Set BulletsFired = 1
      • -------- Create a bullet and set its variables --------
      • Set TempPoint = (Position of PassUnit)
      • Set TempPoint2 = (TempPoint offset by 100.00 towards (Facing of PassUnit) degrees)
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Set TempPoint = (Target point of issued order)
      • Unit - Create 1 Bullet Dummy for (Owner of PassUnit) at TempPoint2 facing (Angle from TempPoint2 to TempPoint) degrees
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Unit Group - Add (Last created unit) to Bullet
      • Unit - Set the custom value of (Last created unit) to 0
      • Unit - Set (Last created unit) movement speed to 75.00
      • Set BulletHasBounced[(Integer A)] = False
      • Set BulletsOn = (BulletsOn + 1)
      • Set BulletsFired = (BulletsFired - 1)
  • Update Bullet
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • BulletsOn Greater than 0
    • Actions
      • Unit Group - Pick every unit in Bullet and do (Actions)
        • Loop - Actions
          • -------- Bullet detected, move it --------
          • Set TempPoint2 = (Position of (Picked unit))
          • Set TempPoint = (TempPoint2 offset by (Current movement speed of (Picked unit)) towards (Facing of (Picked unit)) degrees)
          • Set TempReg = (Region centered at TempPoint with size (200.00, 200.00))
          • -------- Create a temporary unit group --------
          • Set BulletHit = (Units in TempReg)
          • For each (Integer A) from 1 to (Number of units in BulletHit), do (Actions)
            • Loop - Actions
              • Set TempUnit = (Random unit from BulletHit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit is dead) Equal to True
                • Then - Actions
                  • Unit Group - Remove TempUnit from BulletHit
                • Else - Actions
                  • Do nothing
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Terrain pathing at TempPoint of type Walkability is off) Equal to False
                  • (BulletHit is empty) Equal to True
            • Then - Actions
              • -------- No Collision: Move the unit --------
              • Unit - Move (Picked unit) instantly to TempPoint
            • Else - Actions
              • -------- Collision: Damage and remove the bullet --------
              • For each (Integer B) from 1 to (Number of units in BulletHit), do (Actions)
                • Loop - Actions
                  • Set TempUnit = (Random unit from BulletHit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (TempUnit belongs to an enemy of (Owner of (Picked unit))) Equal to True
                    • Then - Actions
                      • Unit - Cause (Picked unit) to damage circular area after 0.00 seconds of radius 100.00 at TempPoint, dealing 75.00 damage of attack type Chaos and damage type Normal
                      • Unit - Kill (Picked unit)
                      • Unit Group - Remove (Picked unit) from Bullet
                      • Set BulletsOn = (BulletsOn - 1)
                      • Custom script: call RemoveLocation(udg_TempPoint)
                      • Custom script: call RemoveLocation(udg_TempPoint2)
                      • Custom script: call RemoveRect(udg_TempReg)
                      • Custom script: call DestroyGroup(udg_BulletHit)
                      • Skip remaining actions
                    • Else - Actions
                      • -------- NO TEAMKILL --------
                      • Unit - Move (Picked unit) instantly to TempPoint
                      • Custom script: call RemoveLocation(udg_TempPoint)
                      • Custom script: call RemoveLocation(udg_TempPoint2)
                      • Custom script: call RemoveRect(udg_TempReg)
                      • Custom script: call DestroyGroup(udg_BulletHit)
                      • Skip remaining actions
              • -------- The colission is not with a unit, but with a wall. Bounce it off --------
              • -------- But first, check if its bounced before and kill i t --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of (Picked unit)) Equal to 0
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Facing of (Picked unit)) Less than or equal to 45.00
                              • (Facing of (Picked unit)) Greater than or equal to 315.00
                          • And - All (Conditions) are true
                            • Conditions
                              • (Facing of (Picked unit)) Less than or equal to 225.00
                              • (Facing of (Picked unit)) Greater than or equal to 135.00
                    • Then - Actions
                      • Unit - Create 1 Bullet Dummy for (Owner of (Picked unit)) at (Position of (Picked unit)) facing (180.00 - (Facing of (Picked unit))) degrees
                      • Unit Group - Add (Last created unit) to Bullet
                      • Unit - Kill (Picked unit)
                      • Unit Group - Remove (Picked unit) from Bullet
                      • Unit - Set the custom value of (Last created unit) to 1
                    • Else - Actions
                      • Unit - Create 1 Bullet Dummy for (Owner of (Picked unit)) at (Position of (Picked unit)) facing (360.00 - (Facing of (Picked unit))) degrees
                      • Unit Group - Add (Last created unit) to Bullet
                      • Unit - Kill (Picked unit)
                      • Unit Group - Remove (Picked unit) from Bullet
                      • Unit - Set the custom value of (Last created unit) to 1
                • Else - Actions
                  • -------- Its bounced before: KILL IT! --------
                  • Unit - Cause (Picked unit) to damage circular area after 0.00 seconds of radius 100.00 at TempPoint, dealing 75.00 damage of attack type Chaos and damage type Normal
                  • Unit - Kill (Picked unit)
                  • Unit Group - Remove (Picked unit) from Bullet
                  • Set BulletsOn = (BulletsOn - 1)
          • -------- Clean up the Unit Group --------
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
          • Custom script: call RemoveRect(udg_TempReg)
          • Custom script: call DestroyGroup(udg_BulletHit)
Its in GUI :\
 
Last edited:
Level 8
Joined
Jul 23, 2005
Messages
329
Edited, but you don't need to delete your post...

In any case, hows it not MUI?

EDIT: I mean, I had more than one bullet on the game at one time... and the player thing shouldn't be that different.
 
Level 8
Joined
Jul 23, 2005
Messages
329
Okay, I'll admit that. Still MUI tho, even if its not that efficient.

On the other hand, we're gettign a little off topic here. Anyone else wanna show a gun bullet system for Magni?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
This is the JASS section not the GUI section in which case you should be lucky you were not punished for submitting a GUI system here.

Thread moved to " Spells & Systems ", a link will be left for 24 hours.

HappyTauren, like I said the collision detection method I made for the bullets is FINE since a bullet is small and you already have unit collision. Also the entire method I used was a easy and foolproof collision detection system which is not the most efficent. I would actually use the unit displacement collision detection system but I never have tried it and so it would have taken much longer to make. The bullet system is fine like it is since all it has to do is collide with objects like walls and such and not act as a collidable object.
 
Level 4
Joined
Dec 14, 2004
Messages
85
I already have a very effective one made(yes in jass, kind of a duh) basically it loops a GetLocationZ(loc) check to see if for the direction the bullet is traveling (the 3 dimensional direction) if it would ever find the bullet below the ground.

Then also I have a checker that looks for dodadds in the area and checks to see if they are bullet blockable dodadds and if they are in a 90 deg direction in front of the unit. after it decides that it is an object that blocks bullets it sees if the object is in the direct path of the target and if it is, it sets the distance between the 2 as the max distance of the bullet. if it finds another object closer that is in between the 2 it sets that as the new max distance

So actually that bottem paragraph is the first code to run. So after it finds the max distance of the bullet(which is the distance from shooter to target if there are no objects blocking.) then it runs the GetLocationZ check(which I call a Line of Sight(LOS) check in my code) and then if the LOS and the Object Stop check return true, it hurts the target and if false it does not and creates the effect wherever it decides the bullet stopped instead.

And I run alot of fully automatic paced guns on this system and it doesn't slow down a bit. And trust me when there is a leak in a system that runs this often you find out pretty quickly. even one leak slows the comp horribly down in about 10 minutes.
 
Status
Not open for further replies.
Top