• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!

[Trigger] Ammo clip thing..

Status
Not open for further replies.
Level 17
Joined
Nov 26, 2007
Messages
1,964
Ok so i've got this ammo clipish system in my map. It uses this bullet system which I kinda made which works fine but the clip system doesnt.

No ammo is depleted from the user, I'm not even sure if reloading works because no ammo is removed so...

Anyway, this is a long list of triggers so bare with me:

  • Equpping
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Battlerifle
          • Battlerifletrue[(Player number of (Owner of (Hero manipulating item)))] Equal to False
        • Then - Actions
          • Set Shotguntrue[(Player number of (Owner of (Hero manipulating item)))] = False
          • Set Battlerifletrue[(Player number of (Owner of (Hero manipulating item)))] = True
          • Sound - Play Reload <gen> at 100.00% volume, attached to (Hero manipulating item)
          • Set Items[1] = (Item carried by (Casting unit) in slot 1)
          • Set Itemcharge[1] = (Charges remaining in (Item carried by (Casting unit) in slot 1))
          • Set Items[2] = (Item carried by (Casting unit) in slot 2)
          • Set Itemcharge[2] = (Charges remaining in (Item carried by (Casting unit) in slot 2))
          • Set Items[3] = (Item carried by (Casting unit) in slot 3)
          • Set Itemcharge[3] = (Charges remaining in (Item carried by (Casting unit) in slot 3))
          • Set Items[4] = (Item carried by (Casting unit) in slot 4)
          • Set Itemcharge[4] = (Charges remaining in (Item carried by (Casting unit) in slot 4))
          • Set Items[5] = (Item carried by (Casting unit) in slot 5)
          • Set Itemcharge[5] = (Charges remaining in (Item carried by (Casting unit) in slot 5))
          • Set Items[6] = (Item carried by (Casting unit) in slot 6)
          • Set Itemcharge[6] = (Charges remaining in (Item carried by (Casting unit) in slot 6))
          • Unit - Replace (Casting unit) with a Battle Rifle using The old unit's relative life and mana
          • For each (Integer A) from 1 to 6, do (Hero - Give Items[(Integer A)] to (Last replaced unit))
          • For each (Integer A) from 1 to 6, do (Item - Set charges remaining in (Item carried by (Last replaced unit) in slot (Integer A)) to Itemcharge[(Integer A)])
          • Unit - Set (Last replaced unit) acquisition range to 0.00
          • Selection - Select (Last replaced unit) for (Owner of (Last replaced unit))
          • Set Playermarine[(Player number of (Owner of (Last replaced unit)))] = (Last replaced unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Shotgun
              • Shotguntrue[(Player number of (Owner of (Hero manipulating item)))] Equal to False
            • Then - Actions
              • Set Shotguntrue[(Player number of (Owner of (Hero manipulating item)))] = True
              • Set Battlerifletrue[(Player number of (Owner of (Hero manipulating item)))] = False
              • Sound - Play Reload <gen> at 100.00% volume, attached to (Hero manipulating item)
              • Unit - Replace (Casting unit) with a Shotgun using The old unit's relative life and mana
              • Set Items[1] = (Item carried by (Casting unit) in slot 1)
              • Set Itemcharge[1] = (Charges remaining in (Item carried by (Casting unit) in slot 1))
              • Set Items[2] = (Item carried by (Casting unit) in slot 2)
              • Set Itemcharge[2] = (Charges remaining in (Item carried by (Casting unit) in slot 2))
              • Set Items[3] = (Item carried by (Casting unit) in slot 3)
              • Set Itemcharge[3] = (Charges remaining in (Item carried by (Casting unit) in slot 3))
              • Set Items[4] = (Item carried by (Casting unit) in slot 4)
              • Set Itemcharge[4] = (Charges remaining in (Item carried by (Casting unit) in slot 4))
              • Set Items[5] = (Item carried by (Casting unit) in slot 5)
              • Set Itemcharge[5] = (Charges remaining in (Item carried by (Casting unit) in slot 5))
              • Set Items[6] = (Item carried by (Casting unit) in slot 6)
              • Set Itemcharge[6] = (Charges remaining in (Item carried by (Casting unit) in slot 6))
              • Unit - Set (Last replaced unit) acquisition range to 0.00
              • For each (Integer A) from 1 to 6, do (Hero - Give Items[(Integer A)] to (Last replaced unit))
              • For each (Integer A) from 1 to 6, do (Item - Set charges remaining in (Item carried by (Last replaced unit) in slot (Integer A)) to Itemcharge[(Integer A)])
              • Selection - Select (Last replaced unit) for (Owner of (Last replaced unit))
              • Set Playermarine[(Player number of (Owner of (Last replaced unit)))] = (Last replaced unit)
            • Else - Actions
              • Do nothing

Shotguntrue and Battlerifletrue are Boolean arrays.

Items is an Item var (Duh) and Item charges is an integer.

This trigger is supposed to change the unit and equip him with the gun. I use the boolean for the other triggers.

  • Aquire
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Battlerifle
        • Then - Actions
          • Set HasItemBRIN[(Player number of (Owner of (Hero manipulating item)))] = (HasItemBRIN[(Player number of (Owner of (Hero manipulating item)))] + 1)
          • Set Battlerifle[(Player number of (Owner of (Hero manipulating item)))] = (Item being manipulated)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Shotgun
            • Then - Actions
              • Set HasItemShottyIN[(Player number of (Owner of (Hero manipulating item)))] = (HasItemShottyIN[(Player number of (Owner of (Hero manipulating item)))] + 1)
              • Set Shotgun[(Player number of (Owner of (Hero manipulating item)))] = (Item being manipulated)
            • Else - Actions
              • Do nothing
HasitemBR and Hasitemshotgun are integers. I used a kind of simplistic system so that you cannot have 2 guns of the same type at the same time by setting your integer (player number based) to the current + 1, so if it equals 2 you cannot aquire another one of that gun, and when you lose a gun its -1 so its 0 again. This is preset in init as 0. Also it sets the Shotgun and Battlerifle item vars when you aquire the item so it can be used in other triggers


  • Reloading
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Shotgun Shells
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Shotguntrue[(Player number of (Owner of (Hero manipulating item)))] Equal to True
              • (Charges remaining in (Item being manipulated)) Greater than 0
            • Then - Actions
              • Item - Set charges remaining in Shotgun[(Player number of (Owner of (Hero manipulating item)))] to ((Charges remaining in (Item carried by (Hero manipulating item) of type Shotgun)) + 1)
              • Sound - Play Reload <gen> at 100.00% volume, attached to (Hero manipulating item)
              • Sound - Destroy (Last played sound)
            • Else - Actions
              • Do nothing
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Rifle clip
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Battlerifletrue[(Player number of (Owner of (Hero manipulating item)))] Equal to True
                  • (Charges remaining in (Item being manipulated)) Greater than 0
                • Then - Actions
                  • Item - Set charges remaining in Battlerifle[(Player number of (Owner of (Hero manipulating item)))] to 30
                  • Sound - Play Reload <gen> at 100.00% volume, attached to (Hero manipulating item)
                  • Sound - Destroy (Last played sound)
                • Else - Actions
                  • Do nothing
            • Else - Actions
              • Do nothing
This is the reloading trigger. Where if you use an item (Shotgun shells or Rifle clips) it reloads either the shotgun or Battlerifle respectivly.

The booleans here are used because I want the hero to only be able to reload the gun if he is actually using it. Here I used the Item vars (Shotgun and Battlerifle) that I set earlier.

  • No Multiple Weapons
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HasItemBRIN[(Player number of (Owner of (Hero manipulating item)))] Equal to 2
          • (Item-type of (Item being manipulated)) Equal to Battlerifle
        • Then - Actions
          • Unit - Order (Hero manipulating item) to drop (Item being manipulated) at (Position of (Hero manipulating item))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HasItemShottyIN[(Player number of (Owner of (Hero manipulating item)))] Equal to 2
              • (Item-type of (Item being manipulated)) Equal to Shotgun
            • Then - Actions
              • Unit - Order (Hero manipulating item) to drop (Item being manipulated) at (Position of (Hero manipulating item))
            • Else - Actions
              • Do nothing
This one is just so that you cannot have 2 of the same gun. This one seems to be working but I'd thought I might include it anyway..

  • Dropping gun
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Unit-type of (Hero manipulating item)) Equal to Battle Rifle
              • (Item-type of (Item being manipulated)) Equal to Battlerifle
        • Then - Actions
          • Set HasItemBRIN[(Player number of (Owner of (Hero manipulating item)))] = (HasItemBRIN[(Player number of (Owner of (Hero manipulating item)))] - 1)
          • Set Battlerifletrue[(Player number of (Owner of (Hero manipulating item)))] = False
          • Set Items[1] = (Item carried by (Casting unit) in slot 1)
          • Set Itemcharge[1] = (Charges remaining in (Item carried by (Casting unit) in slot 1))
          • Set Items[2] = (Item carried by (Casting unit) in slot 2)
          • Set Itemcharge[2] = (Charges remaining in (Item carried by (Casting unit) in slot 2))
          • Set Items[3] = (Item carried by (Casting unit) in slot 3)
          • Set Itemcharge[3] = (Charges remaining in (Item carried by (Casting unit) in slot 3))
          • Set Items[4] = (Item carried by (Casting unit) in slot 4)
          • Set Itemcharge[4] = (Charges remaining in (Item carried by (Casting unit) in slot 4))
          • Set Items[5] = (Item carried by (Casting unit) in slot 5)
          • Set Itemcharge[5] = (Charges remaining in (Item carried by (Casting unit) in slot 5))
          • Set Items[6] = (Item carried by (Casting unit) in slot 6)
          • Set Itemcharge[6] = (Charges remaining in (Item carried by (Casting unit) in slot 6))
          • Unit - Replace (Hero manipulating item) with a Weaponless using The old unit's relative life and mana
          • For each (Integer A) from 1 to 6, do (Hero - Give Items[(Integer A)] to (Last replaced unit))
          • For each (Integer A) from 1 to 6, do (Item - Set charges remaining in (Item carried by (Last replaced unit) in slot (Integer A)) to Itemcharge[(Integer A)])
          • Unit - Set Playermarine[(Player number of (Owner of (Last replaced unit)))] acquisition range to 1.00
          • Set Playermarine[(Player number of (Owner of (Last replaced unit)))] = (Last replaced unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Unit-type of (Hero manipulating item)) Equal to Shotgun
                  • (Item-type of (Item being manipulated)) Equal to Shotgun
            • Then - Actions
              • Set HasItemShottyIN[(Player number of (Owner of (Hero manipulating item)))] = (HasItemShottyIN[(Player number of (Owner of (Hero manipulating item)))] - 1)
              • Set Shotguntrue[(Player number of (Owner of (Hero manipulating item)))] = False
              • Unit - Replace (Hero manipulating item) with a Weaponless using The old unit's relative life and mana
              • Set Items[1] = (Item carried by (Casting unit) in slot 1)
              • Set Itemcharge[1] = (Charges remaining in (Item carried by (Casting unit) in slot 1))
              • Set Items[2] = (Item carried by (Casting unit) in slot 2)
              • Set Itemcharge[2] = (Charges remaining in (Item carried by (Casting unit) in slot 2))
              • Set Items[3] = (Item carried by (Casting unit) in slot 3)
              • Set Itemcharge[3] = (Charges remaining in (Item carried by (Casting unit) in slot 3))
              • Set Items[4] = (Item carried by (Casting unit) in slot 4)
              • Set Itemcharge[4] = (Charges remaining in (Item carried by (Casting unit) in slot 4))
              • Set Items[5] = (Item carried by (Casting unit) in slot 5)
              • Set Itemcharge[5] = (Charges remaining in (Item carried by (Casting unit) in slot 5))
              • Set Items[6] = (Item carried by (Casting unit) in slot 6)
              • Set Itemcharge[6] = (Charges remaining in (Item carried by (Casting unit) in slot 6))
              • Unit - Set Playermarine[(Player number of (Owner of (Last replaced unit)))] acquisition range to 1.00
              • For each (Integer A) from 1 to 6, do (Hero - Give Items[(Integer A)] to (Last replaced unit))
              • For each (Integer A) from 1 to 6, do (Item - Set charges remaining in (Item carried by (Last replaced unit) in slot (Integer A)) to Itemcharge[(Integer A)])
              • Set Playermarine[(Player number of (Owner of (Last replaced unit)))] = (Last replaced unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item being manipulated)) Equal to Battlerifle
                • Then - Actions
                  • Set HasItemBRIN[(Player number of (Owner of (Hero manipulating item)))] = (HasItemBRIN[(Player number of (Owner of (Hero manipulating item)))] - 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of (Item being manipulated)) Equal to Shotgun
                    • Then - Actions
                      • Set HasItemShottyIN[(Player number of (Owner of (Hero manipulating item)))] = (HasItemShottyIN[(Player number of (Owner of (Hero manipulating item)))] - 1)
                    • Else - Actions
                      • Do nothing

What this does is that, if you are equipped a gun and drop it you are replaced with a weaponless marine. I think this one should be working..

  • No Ammo
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(attack))
          • (Unit-type of (Attacking unit)) Equal to Shotgun
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in Shotgun[(Player number of (Owner of (Hero manipulating item)))]) Equal to 0
            • Then - Actions
              • Unit - Order (Ordered unit) to Stop
              • Sound - Play No_ammo__u <gen> at 100.00% volume, attached to (Attacking unit)
              • Floating Text - Create floating text that reads Reload! above (Ordered unit) with Z offset 5.00, using font size 9.00, color (100.00%, 0.00%, 0.00%), and 10.00% transparency
              • Floating Text - Show (Last created floating text) for (All players matching ((Owner of (Ordered unit)) Equal to (Matching player)))
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
            • Else - Actions
              • Item - Set charges remaining in Shotgun[(Player number of (Owner of (Ordered unit)))] to ((Charges remaining in Shotgun[(Player number of (Owner of (Ordered unit)))]) - 1)
              • Sound - Play shotgun <gen> at 100.00% volume, attached to (Attacking unit)
              • Sound - Destroy (Last played sound)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(attack))
              • (Unit-type of (Attacking unit)) Equal to Battle Rifle
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in Battlerifle[(Player number of (Owner of (Hero manipulating item)))]) Equal to 0
                • Then - Actions
                  • Unit - Order (Ordered unit) to Stop
                  • Sound - Play No_ammo__u <gen> at 100.00% volume, attached to (Attacking unit)
                  • Floating Text - Create floating text that reads Reload! above (Ordered unit) with Z offset 5.00, using font size 9.00, color (100.00%, 0.00%, 0.00%), and 10.00% transparency
                  • Floating Text - Show (Last created floating text) for (All players matching ((Owner of (Ordered unit)) Equal to (Matching player)))
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
                • Else - Actions
                  • Item - Set charges remaining in Battlerifle[(Player number of (Owner of (Ordered unit)))] to ((Charges remaining in Battlerifle[(Player number of (Owner of (Ordered unit)))]) - 3)
                  • Sound - Play Dual <gen> at 100.00% volume, attached to (Attacking unit)
                  • Sound - Destroy (Last played sound)
            • Else - Actions
              • Do nothing
This is the no ammo + removing ammo when firing trigger. This one doesnt work due to the fact that no ammo (Charges) are removed when firing. Im not sure if the hero is prevented from attacking because I've never run out of ammo since it doesnt deplete.


Ya thats pretty much it... This is my first time trying to make a system like this and I just winged it and guessed how it was made putting together this piece of larf.

Equipping the gun works fine, drop/aquire detection seems to work. But charges or ammo doesnt deplete from the gun when fired.


So any ideas? I hope someone bothers to read through all of this mess... (Ya i'm a messy triggerer)
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
icon4.gif
Sticky: Is your TRIGGER NOT WORKING? Post on Triggers & Scripts:
[self="http://www.hiveworkshop.com/forums/forumdisplay.php?f=269"]
triggersandscriptsforum.gif
»»» Triggers & Scripts
[/self]

(...)
Any trigger-fixing threads go on [self="http://www.hiveworkshop.com/forums/forumdisplay.php?f=269"]Triggers & Scripts[/self], while trigger-creation threads go on the World Editor Help Zone.
~Thread Moved
 
Level 2
Joined
Aug 31, 2008
Messages
22
Ok so i've got this ammo clipish system in my map. It uses this bullet system which I kinda made which works fine but the clip system doesnt.

No ammo is depleted from the user, I'm not even sure if reloading works because no ammo is removed so...

Anyway, this is a long list of triggers so bare with me:

  • Equpping
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Battlerifle
          • Battlerifletrue[(Player number of (Owner of (Hero manipulating item)))] Equal to False

You should try with "Battlerifletrue[(Player number of (Owner of (Triggering unit)))] Equal to False".
 
Level 8
Joined
Jun 25, 2007
Messages
165
Its because "[(Player number of (Owner of (Hero manipulating item)))]" is when the
events.gif
Event is
unit.gif
Uses/Acquires/Loses An Item (now the
events.gif
Event is A unit Starts the effect of an ability)... so the best way (i think) is:

  • Equpping
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Battlerifle
          • Battlerifletrue[(Player number of (Triggering player))] Equal to False
 
Level 17
Joined
Nov 26, 2007
Messages
1,964
OH!

Wow I feel stupid, all those lines must have screwed me up. Ill go fix that.

Edit: Equpping the weapon works fine, so even though I fixed that condition it didnt change anything.

Ill make it clear: My problem is that when the unit attacks he is not losing ammunition (Or charges) from the item. He's supposed to lose X charges from the equipped weapon when he fires, and then using a reload ability get them back.
 
Status
Not open for further replies.
Top