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

Bullet System using Item Charges

Status
Not open for further replies.
Level 7
Joined
Jun 8, 2010
Messages
283
Hey guys, Ive made a simple bullet system before in an old map but this time im trying to use a bullet system that incorporates item charges rather than using both gold and lumber as the clip and ammunition.

Anyhow, each item or weapon has a different amount of bullets in the clip (charges). So a shot gun would only have about 8-12 bullets where as an assault rifle would have something like 180.

So to define exactly what kind of gun the hero has I defined it like so:
  • m16
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to M16 Assault Rifle (Charged/Active)
    • Actions
      • Unit - Add M16 Armor Bonus to (Hero manipulating item)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Hero manipulating item)) Equal to Player 1 (Red)
        • Then - Actions
          • -------- Equip(1) = Player One (Red) --------
          • Set activegun[EQUIP[1]] = (Item being manipulated)
        • Else - Actions
          • Do nothing
Soo where the m16 actual gun attachment in "Add M16 Armor Bonus" will be added where the gun attachment point is defined as "Weapon" using an m16 weapon attachment model. Sadly we come to our first problem:
1) The weapon attachment does not appear when you "Add the Ability" to the unit when the user clicks on it. I could easily just make the ability as an item ability and attach that to the m16 item, but then it would automatically equip the weapon. What I want exactly is the user manually selecting which gun to choose by clicking on it, thus giving our hero the appropriate weapon attachment.

So with that trigger, we must also define when to remove the ability with the following trigger:
  • drop m16
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to M16 Assault Rifle (Charged/Active)
    • Actions
      • Unit - Remove M16 Armor Bonus from (Hero manipulating item)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Hero manipulating item)) Equal to Player 1 (Red)
        • Then - Actions
          • -------- Equip(1) = Player One (Red) --------
          • Set activegun[EQUIP[1]] = No item
        • Else - Actions
          • Do nothing
And here is problem number 2. For some reason I never really liked the "Remove Ability". From what I understand the remove ability would PERMANENTLY remove it from the hero and thus not allowing the hero to regain that ability when they pick up and use the m16 item.

To top it all, we have the final problem with the actual subtraction of the charges.
  • Attack Charged
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Unit-type of (Attacking unit)) is A Hero) Equal to True
      • ((Owner of (Attacking unit)) controller) Equal to User
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in activegun[EQUIP[1]]) Greater than 0
        • Then - Actions
          • Player - Add -1 to (Owner of (Attacking unit)) Current lumber
        • Else - Actions
          • Unit - Order (Attacking unit) to Stop
Here our m16 has 180 bullets, so each time the hero goes through a cycle of an attack, we subtract 1 item charge. Here is the trigger I used to subtract for each attack. When the charges on the weapon (m16 in this instance) reaches to 0, the user can no longer fire the weapon, hence the Stop Command, until I reload. Which I have no problems with the reload as its an easy trigger.

Could someone help me out with this? I really dont know whats going on.

Best Regards,
Atmosferic

ps. A similar system can be found on the map I Am Legend if ever need to look for references.
 
Level 5
Joined
May 13, 2010
Messages
146
I don't think I understood everything but here's a few things.

About the attachment.. Where did you define the attachment point ? In the object editor, editing the effect? If so.. I suggest changing it to a special effect. Why make a whole custom buff when you can just create a special effect on the unit with an attachment point - "weapon" or "hand", set a special effect variable as the last created special effect and then just use the variable to destroy the effect in a case of unequiping or of the depletion of ammo. I don't have World Editor right now, so I'm not sure about thing going that way.. :D

The second problem is the one I really cannot understand.You've made a trigger which adds a buff to the hero with the gun, then you remove that buff when the hero with the gun unequips the gun. You stated that remove makes the hero unable to acquire the same buff again after it has been removed, but that's what the ADD function does, I think. It just adds the buff again, no borders. If you would use the special effect method, as I recommended, the actions would be something like the following :

Equip attachment -
Units acquires an item
Item being manipulated equal to M-16
Create a special effect attached to the hand of triggering unit using <the model :D>
Set PlayerOne'sGun (named it so that you can understand it's function, it could be the triggering player or smth) last created special effect.

Unequip remove attachment -
Unit loses an item
Item being manipulated equal to item carried by hero of type M-16 ( or something like that)
Destroy PlayerOne'sGun. ( or the owner of the triggering unit or smth :D)


I hope it helps but I'm not quite sure that it would.. It's quite hard doing triggers in your head without looking at the worldedit :D
Bye for now :)
 
Level 7
Joined
Jun 8, 2010
Messages
283
The attachment model is attached to the "Weapon" Point on the model. I wanted to use the Special Effect but special effects usually leak without a Custom Script to clean it up when I Destroy it. I will go on ahead and completely trigger it then using Create and Destroy Special Effects, but how do I clean the Leak up when I destroy the Special Effect?

Edit: Nvm here it is:
  • Events-
  • Conditions-
  • Actions-
  • Set Temp_Point = (Center of (Playable map area))
  • Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
  • Special Effect - Destroy (Last created special effect)
  • Custom script: call RemoveLocation (udg_Temp_Point)
For the second problem, the Add Ability for some reason never worked for me after using a Remove Ability. If you look in the WE GUI for "Remove Ability" it has noted that "If the ability is removed through this trigger, it will remove the ability permanently." Ive worked with the Remove Ability in the past and I never really got the Add Ability to work once I called the Remove Ability, or is this just me? Ill have to probably double check.

The first two triggers were made for two things:
1) Define exactly what gun I have equipped for that specific player
In the conditional of the m16 item being clicked, the weapon attachment will be attached to the "Weapon Point" of the hero
2) Store the weapon-type into a variable for each player
ie. activegun[EQUIP(1)] is just a variable to store Player One's (Red) equipped weapon so that when player one attacks, the third trigger "Attack Charged" will check exactly what weapon it is and apply accordingly.

The BIGGEST of my concern now is the last trigger "Attack Charged", my unit continues to stop, so theres something wrong with my variables or triggers or what?

I have a big question. How do I add an m16 and completely change the Hero's Stats AND Damage (Dice, Dice Sides, Dice Base) without replacing that hero with another hero.

Like each weapon will have different stats and change the Hero's attack damage accordingly.
m16 (assault rifle) will have very Fast Attack Speed, Medium Accuracy, Medium Damage, Medium Reload Speed with damage of 50-119
glock (handgun) will have medium attack speed, high accuracy, medium reload speed and a damage of 30-60

I found this JASS System, but im not sure if its exactly what Im looking for, or is there an easier way to accomplish this?
 
Level 7
Joined
Jun 8, 2010
Messages
283
Thank you InfinateAnswers, with heavy modification I managed to get the system properly working. I have a couple questions though.

How would you change the Hero's damage display in the character card (ie. Damage Type: Peirce, Attack Type: Normal, Damage (50-100) and make it accurate to "Unit - Cause (Attacking unit) to damage (Attacked unit), dealing (Random real number between 75.00 and 118.00) damage of attack type Pierce and damage type Normal
"?

Also how would I change the attack cool down? Lets say I make a shotgun, how would I change the attack cool down so that the Assault Rifle would have a .30 cool down and the shotgun would have a 1.6 cool down?

Basically how do I change the things to display dynamically?
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
Very simple to that, i wouldve originally made it for you like that but i thought all u wanted was the weapon and damage and bulleting, to do this you must create a hero replacement, but carry over his items but change his type, like lets say i click on the unequiped item make the trigger to change the acualy character to the unit you want with the attack speed and type of dmg

Edit: An easy way to do this is to give the item "Unequipped" the ability of morph
 
Level 5
Joined
May 13, 2010
Messages
146
Meh, I didn't help with anything, I feel miserable :sad:

Anyways, I'm glad you made it work with a little help :D
 
Level 7
Joined
Jun 8, 2010
Messages
283
Ah i see, so that means I have to make a hero for each gun? AK47, Glock, M16, AK47 etc.
Hmmm, I okay then Ill try that out :D

So i suppose I will have to make a bear form for the unit with the equip item. But is bear form seemless in selection? Meaning the players wont even notice if the unit changed (ie blinking) or their selection is canceled. So like if the hero is running and switches weapon, the Move order is canceled out with stop, then the hero will morph, then switch.

Also there is a problem, I cant use morph as the unit has morph for Dual Weidling guns not singular.
 
Level 7
Joined
Jun 8, 2010
Messages
283
Okay well I made a custom bear form, took out the tech tree req, made alternative and normal forms to "Marine" and "Marine(m16) respectively. I gave the ability to the item, but it didnt work. I made it an item ability and still it didnt work. Any ideas?
 
Level 7
Joined
Jun 8, 2010
Messages
283
Im trying everything, its still wont work.

Currently here is what the modified Bear Form ability is:
Code:
Data Alternate Form Unit: TUCU Marine (M16)
Data Normal Form Unit: TUCU Marine (Norm)
Mana Cost: 0
Tech Tree Requirements: N/A
Tech Tree Requirement Levels: N/A
Name: Switch to M16

This ability is attached to the "Holster/Unequip M16" Item, basically when the hero picks up the item he will "bear form morph" into the m16 unit.

Edit: The problem I think is that you cant make Bear Form Ability on an Item when used?
Edit 2: Well I changed it so that the ability would be an item ability, then I went to the item itself and changed it to Valid Target for Transformation to True and it worked. But then here comes my problem that I was mentioning several posts back..

When the unit morphed (bear formed) into the m16 unit, the unit used it's Attack Alternative Animation. My unit's Attack alternative animation is holding two guns (dual weilding) instead of one gun. So when morphing from the no-gun unit to the m16 gun unit, he is using the Alternative Attack Animation (Dual Weilding) which was my concern from the beginning..

So what now?
 
Last edited:
Level 7
Joined
Jun 8, 2010
Messages
283
Okay well I got the item working, but I had to make a seperate item. The charged equipped item wouldnt work for some reason, so yeah. I did manage to get it to work though, but the model uses the Death and Death Alternative animation instead of the morph, why is that?

Edit: Okay, yeah the Cooldown Group was set to Item Mana Regain which was constantly active. The unit successfully switched to the m16 unit, and the proper morph animation was used, but now lies the problem...

I noticed that morph ability works differently, its actually More than just replacing the unit. It replaces the unit with the alternative unit, but also it would only use the alternative unit's alternative animations (attack, run, idle, attack ready, etc). As I have said before, the alternative attack animation is used when the hero is Dual Weilding, and that is not what I want. I want the hero to switch to the m16 character but at the same time Use the Regular Attack Animations, not the Alternative Attack Animation of Dual Wielding. How would I get around this?

All animation tags with:
Alternate (Attack Alternate, Death Alternate, Stand Ready Alternate, Walk Alternate, Morph Alternate, Decay Flesh Alternate, Decay Alternate) are used for Dual Wielding weapons (Dual pistols, Dual Smgs, etc)
Defend (Attack Defend, Death Defend, Stand Ready Defend etc) are used for Melee Attacks (Axe, Bare Hands, Baseball Bat)
and Default animations (Attack, Deah, Walk, Stand, Stand 2, Decay etc) are animations used when using One Ranged weapon (pistols, snipers, assault rifles, etc)
 
Last edited:
Level 7
Joined
Jun 8, 2010
Messages
283
Could I send you the map? Ill send it to you in a pm and you will understand what I am talking about when you equip the gun then see the unit fires with Dual Weild Gun animations (Alternative).

You will also see that if you Select the Switch to Melee ability, your character will holster his weapon and switch to melee.
 
Level 7
Joined
Jun 8, 2010
Messages
283
and what would I put in that Field Value? If I wanted Alternate I would put in "Alternate" for the Attack Alternate, Walk Alternate etc, but what would I put in for the Attack and Walk, it has no prefix?

Im not sure exactly what to put, could you show me more in depth?

Chocobo in the Ability Tutorial from TheHelper.net said:
As raw data "Animnames"
"Art - Animation Names" allows you to assign animation what unit will use if ability is being used. You can see most usable animations from small preview screen when you have "Unit Tool Palette" active. In Object Editor you can' t assign specific animation, only type. It means if you got 2 different "spell" animations it will randomly pick between these two animations. If for example unit dosn' t have "spell, throw" animation it will move one step back and tries to play "spell" animation.

...

As raw data "SpecialArt"
"Art- Special" creates model at point of ability caster. Is something like a universal Data field, as in an effect whose appearance may vary depending on the ability itself (Credits to SFilip for last sentence.).
NOTE: Works for ability "Blink".
According to the Ability Tutorial I dont think those are what the field values are for. The SpecialArt isnt specifically used for that, and the -Morph Animation cannot be found in the Stats section of the ability in Object Editor.
 
Level 7
Joined
Jun 8, 2010
Messages
283
Okay, well.. "Alternate" and "Defend" are the prefixes for the animation tags in a warcraft 3 model. An animation tag is the animation labels that tell Warcraft which animation to associate it to a specific action/command.

For example:

Attack Defend:
The "Attack" Tag here is the animation classification. This animation is classified as an "Attack" animation, or when the unit attacks, this animation will plau. Now notice that the "Defend" suffix tag is there. This suffix indicates that the unit will only use this specific animation when the unit is using a "Defend" ability AND is attacking.

Walk Defend:
If the unit is defending and ISNT attacking but moving then we would use the Walk Defend animation. Again Walk is the animation classification that tells us the unit is walking.

My unit model is currently using an "Alternate" animation suffix tag. Alternate means that these animations will be used when the unit uses a Morph ability or an ability similar to that effect is used by the unit. In the map you have just observed, my marine used the Morph M16 ability when picking up the M16 Item. When he morphed he used the Alternate Animation. The Alternate Animation in my model specifically is used for when using a dual/two guns.

I hoped this clarifies the confusion, and sorry for not being specific.
 
Level 7
Joined
Jun 8, 2010
Messages
283
Oh i see.. well its fine. Im actually editing the model animation tags. Sadly I have to use 2 different models. Both can use the melee animation and one uses dual and the other one gun.

Just one question, how do you store the charge value when I unequip the weapon. When I have 0 ammo left the and unequip and then requip the weapon it will go back to a full 180, how would store it in a variable? Maybe im thinking too hard on this one. Also how do I set it so that the ammo for the weapon caps at 180 so that I dont over-reload past 180?
 
Level 7
Joined
Jun 8, 2010
Messages
283
I actually have a problem. I have a Bear Form ability on the Equip M16 item to change from the Melee Unit to the M16 Unit. I also have an Unequiip M16 with a similar Bear Form Ability BUT it changes the M16 Unit back to the Melee Unit.

This all works perfectly, however it doesnt. If I do the following actions:
Use/Click Equip M16 - The unit will change from Melee to the M16 unit and then with triggers the Unequip M16 Item will appear in it's inventory.
When I Use/Click the Unequip M16, the unit will change from the M16 Unit and back to the normal Melee unit and once again with triggers, an Equip M16 Item will be created. Now this is where the problem occurs...

Once I drop the the Equip M16 item, I would change from the Normal Unit and back into the m16. So basically I am stuck with the M16 unit Permenantly..

Heres are the items with their abilities. None listed stats are default
Code:
[B]Item Name: [/B]Equip M16 Assault Rifle
[B]Charges:[/B] 215
[B]Valid Target for Transformation:[/B] True
[B]Perishable:[/B] False
[B]Cooldown Group:[/B] Item Furbolg Summon
[B]Classification:[/B] Charged
[B]Item Ability:[/B] True
[SIZE="4"][B]Abilities:[/B][/SIZE]
   [B]A. Custom Bearform (melee to m16)[/B]
   [B]Item Ability:[/B] True
   [B]Alternate Form Unit:[/B] M16 Unit
   [B]Normal Form Unit:[/B] Melee Unit

   [B]B. Weapon Attachment[/B]
   [B]Art - Target: [/B]M16 Weapon.mdx
   [B]Art - Target Attachment Point:[/B] Weapon
Code:
[B]Item Name: [/B]Unequip M16 Assault Rifle
[B]Charges:[/B] 215
[B]Valid Target for Transformation:[/B] True
[B]Perishable:[/B] False
[B]Cooldown Group:[/B] Item Furbolg Summon
[B]Classification:[/B] Charged
[B]Actively Used:[/B] True
[SIZE="4"][B]Abilities:[/B][/SIZE]
   [B]A. Custom Bearform (m16 to melee)[/B]
   [B]Item Ability:[/B] True
   [B]Alternate Form Unit:[/B] Melee Unit
   [B]Normal Form Unit:[/B] M16 Unit

If more information is needed I would gladly list them for you.

Best Regards,
Atmosferic
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
your making a 3 way bear form. Thats only possible with triggers. Instead of worrying about melee give the unit a base item already equipted to start out with and unless u want to do some serious variables and triggers then dont make a melee but if u really insist i will make u a rough trigger for melee on drop

Edit: oh and one more thing u dont need 2 seperate bear form spells for m16 unit give the same one to each item. The ability will recongnize this and connect the 2 spells so that u can freely move from unequipped and equipped
 
Level 7
Joined
Jun 8, 2010
Messages
283
Oh I didnt notice that. Yeah I was trying to avoid triggering for this, but I suppose it will be better to trigger it. Ive been beginning to get into JASS lately, so a rough trigger would be fine as I will modify it later.

Even if I give the unit a starting off gun, he will have to drop it eventually when his inventory gets full. Theres multiple units the melee unit will have to morph into. Trust me if you've seen my previous map I sent you, the one I have now is loaded with a bunch of Variables and Integer variables all over the place, so I suppose it will do.

I just hope you dont use that horrid trigger:
  • Unit - Replace (Triggering unit) with a Footman using The old unit's relative life and mana
I suppose I will remove the copied Bear Form ability, I didnt know the system already had that implemented. Because the ability automatically recognizes the two separate forms, it makes me have to use triggers!
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
Oh I didnt notice that. Yeah I was trying to avoid triggering for this, but I suppose it will be better to trigger it. Ive been beginning to get into JASS lately, so a rough trigger would be fine as I will modify it later.

Even if I give the unit a starting off gun, he will have to drop it eventually when his inventory gets full. Theres multiple units the melee unit will have to morph into. Trust me if you've seen my previous map I sent you, the one I have now is loaded with a bunch of Variables and Integer variables all over the place, so I suppose it will do.

I just hope you dont use that horrid trigger:
  • Unit - Replace (Triggering unit) with a Footman using The old unit's relative life and mana
I suppose I will remove the copied Bear Form ability, I didnt know the system already had that implemented. Because the ability automatically recognizes the two separate forms, it makes me have to use triggers!

I will make the horrid trigger look beutiful
 
Level 7
Joined
Jun 8, 2010
Messages
283
Ehhh its not that its just that once you use the replace unit, you have to use variables and locals to store the data of the replaced unit ie. exp, items, abilities etc..

And worse thing of all is that is not seamless, meaning when you replace the unit, it will be deselected which is rather annoying.

Great.. more work, thanks to the stupid complexity of Bear Form and the default recognition..
 
Level 7
Joined
Jun 8, 2010
Messages
283
Oh alright then :) By the way how would you make it so that the player can only have one Weapon equipped at a time?

So lets say I have a melee unit that is equipped with a knife (showing a knife attachment), then he picks up an m16 and then equips the M16. The melee unit with Bear Morph from the melee to the m16 but also will unequip the Knife Item and also equip the M16 Item?

So an equipment system basically. And how would I exactly make an ammo item that will only be used IF they have the specific weapon equipped? Currently my triggers use the item if they have it equipped, but when its not equipped the Ammo item is used up anyways and nothing happens :\
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
All that can be fixed by a simple trigger of unit uses item, item of type in heros inventory equals M16, Item type of item being manipulated = m16 ammo add those 2 conditions on the trigger used for ammo add on. and that would only be able to be achieved by triggers and i will make a whole system for equipting and unequipting and switching weapons
 
Level 7
Joined
Jun 8, 2010
Messages
283
Hmm that makes it rather simple. This will work for all players too correct? Like does a trigger like this collide with other players who meet these conditions at the same time?

This below trigger is activated when a unit uses the spell Flashlight.
  • flashlight universal
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Flashlight
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • flashlight Equal to True
        • Then - Actions
          • Special Effect - Create a special effect attached to the overhead of (Casting unit) using war3mapImported\Light_OFfWHite_10.MDX
          • Set flashlight_fx= (Last created special effect)
          • Set flashlight = False
        • Else - Actions
          • Special Effect - Destroy flashlight_fx
          • Set flashlight = True
The flashlight boolean here is used to check whether the unit's flash light is currently on or off so it can check when to specifically create the special effects for the spell.

Or will I have to use an Integer as an Index variable to determine a specific index for each player, where:
Code:
Flashlight[1] = if flashlight ability is on for player 1 - red
Flashlight[2] = if flashlight ability is on for player 2 - blue
such as the trigger below:
  • flashlight red
    • Events
      • Unit - A unit owned by Player 1 (Red) Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Flashlight
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • flashlight[1] Equal to True
        • Then - Actions
          • Special Effect - Create a special effect attached to the overhead of (Casting unit) using war3mapImported\Light_OFfWHite_10.MDX
          • Set flashlight_fx[1] = (Last created special effect)
          • Set flashlight[1] = False
        • Else - Actions
          • Special Effect - Destroy flashlight_fx[1]
          • Set flashlight[1] = True

EDIT: Dont forget to pm me your map for testing and the loading screen :D
 
Level 7
Joined
Jun 8, 2010
Messages
283
Haha alright then, Ill see what I can do for your loading screen.

Also do you just want me to send you my map I currently have right now so you can work on it from there rather than working from scratch :D?

Also do you have AIM, MSN, Yahoo, Steam, Skype or anything?
 
Level 7
Joined
Jun 8, 2010
Messages
283
I have added you. My AIM is thatadrian.

Anyways as for the system, hows it gong so far, any questions in particular you want me to clarify?

Offtopic: Also, for your loading screen I have several ideas, but id like to discuss them over aim rather than in PM as its too slow, and not on this thread for it will be even more off-topic.
 
Status
Not open for further replies.
Top