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

Lumber to Ammo

Status
Not open for further replies.
Level 5
Joined
Jul 18, 2010
Messages
159
Event unit is being attacked
Actions - substract 1 lumber from owner of attacking unit maybe?
 
I suggest using the damage detection system by either Bribe or looking_for_help to ensure that this http://www.hiveworkshop.com/forums/2297217-post5.html doesn't happen to your map. A unit is attacked means when the attacking unit begins to order the attack... It does not mean that the attacked unit has been damaged yet. This means that anyone can cheat your map by spamming the stop button.

Then with a DDS it's quite simple, will edit in a bit to show an example.
[trigger=looking_for_help Damage Detection System]
LumberToAmmo
Events
Game - PDD_damageEventTrigger becomes Equal to 1.00
Conditions
PDD_damageType Equal to PDD_PHYSICAL
(Unit-type of PDD_source) Equal to Blood Mage
Actions
Player - Add -1 to (Owner of PDD_source) Current lumber
[/trigger]
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Do you want to have ranged units use the ammo?

Seems like a pretty obvious question.
A better question would be:
Do you want to remove the lumber when the projectile has reached it's target or when the projectile is fired and is the difference between those two moments large enough to fire another shot?
 
Level 11
Joined
Jun 26, 2014
Messages
497
I managed to make it myself... is this good?

  • Ammo
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Attacking unit)) Current lumber) Greater than 0
        • Then - Actions
          • Player - Set (Owner of (Attacking unit)) Current lumber to (((Owner of (Attacking unit)) Current lumber) - 1)
        • Else - Actions
          • Unit - Order (Attacking unit) to Stop
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Nope.

The event "A unit Is attacked" runs when a unit is starting to attack.

Lets say I want to attack you with a hammer... no I am not the paladin.
To attack you, I have to swing my hammer at you. When my hammer hits you, you are taking damage.

When I am starting to swing my hammer, you are attacked (attacked is not damaged).
So the event "A unit Is attacked" runs.

Then after a short time, my hammer hits you, you are damaged.
So the event "A unit Takes damage" runs. (This is a non-existing event for generic units.)

If I give my unit a different order or he is interrupted during that short time. You have removed lumber but I haven't damaged you.

The problem is that "A unit Takes damage" can only be made on a singular unit.
A plain DDS keeps track of all units in the map and give them that event.
So now you have an event "A unit Takes damage" and now you cannot abuse the "stop" order anymore because you can't stop the unit from damaging after that event has fired.

There is one other problem.

Imagine a ranged unit.
The archer draws his bow. -> A unit Is attacked
The archer fires his arrow. -> -
The arrow hits it's target. -> A unit Takes damage

For ranged units, there is a delay between the last two.
For melee units, it is not.
You have to ask yourself: Are my units that have this lumber ammo able to fire a second arrow before the first one hits it's target?
Or are the "arrows" actually bullets from a gun and fire with such high velocity that the gunner has no chance to ever fire 2 bullets?
 
I find it okay with the concept, except the glitching technique from the event itself.
However, in logic, I think it's okay to deplete ammo before the actual fire, but the issue is that if other command is issued during the period, then an ammo is permanently gone D:

This thread reminds me of an old spell in my old mapping contest entry :D
 
You can remove stop nowadays to fix this bug funny enough not many knew beforehand. =)

By using http://www.hiveworkshop.com/forums/...ttons-remove-patrol-hold-position-etc-261633/ .
Players can no longer press or hold down order keys to exploit this function however they can still right-click.

I suggest using both unit is attacked and the DDS so you can remove ammo before it damages the unit. You already got half of it correct, just use the DDS to check if it hit. Evasion might prove problematic though.
 
Level 6
Joined
Feb 16, 2014
Messages
193
I have asked this before tho,but the ammo was gold
maybe this help:
  • attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Player - Add -1 to (Owner of (Attacking unit)) Current lumber
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Attacking unit)) Current lumber) Equal to 0
        • Then - Actions
          • Unit - Order (Attacking unit) to Stop
        • Else - Actions
Tested and it works
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
I have asked this before tho,but the ammo was gold
maybe this help:
  • attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Player - Add -1 to (Owner of (Attacking unit)) Current lumber
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Attacking unit)) Current lumber) Equal to 0
        • Then - Actions
          • Unit - Order (Attacking unit) to Stop
        • Else - Actions
Tested and it works

Ok imagine the folowing situation:

You have a gun
Code:
You point it at your targer
You press the trigger
Gun expends ammo
Projectile flies
Projectile hits
Target is damaged

This is what we want right ?

The above trigger with this event
  • Unit - A unit Is attacked
Does NOT work like this.

The above trigger works like this:
Code:
You have a gun
You point it at your targer == Unit - A unit Is attacked >> Trigger runs
Gun expends ammo
You press the trigger
Projectile flies
Projectile hits
Target is damaged

So if I do
Code:
You have a gun
You point gun 
You lower gun

You will actualy get
Code:
You have a gun
You point gun >> Trigger runs
Gun expends ammo
You lower gun

Did you shoot ? No. Did the gun expend ammo ? Yes. Do you see the problem now ?

If you implement a DDS you can detect when damage is dealt. If damage was dealt that means that all of the previous "events" have occured but if a gun is pointed it does not mean that it was fired !


Edit// Sorry for weird fonts/styling.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Ah, yea, this will actually work if the unit has no attack animation wind-up (attacks instantly) and the projectile has no speed (hits instantly)...

PS: I almost wrote death animation -_-
And sorry, didn't really read all the posts above... just saw the last few...
 
Level 11
Joined
Jun 26, 2014
Messages
497
Okay guys din't really expect so much replies. So most of my units/heroes have instant attack so it doesn't really matter. For the main heroes they are soldiers so they attack from range. When ever irl you shoot a gun the moment the shell is fired then you lose ... well one of you shell/ammo so I guess the way I'm doing it is okay? Right? Tell me if I'm wrong so I can fix whatever is wrong also sorry for my english not my mother language. :)

Edit: btw it really doesn't matter if you lose ammo after the shot or after the hit. The purpose of this is just to stop the unit from attack when out of lumber/ammo.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
hmm... it looks like you didnt understood it correctly.

Lets explain again:

When I want to attack you, I have to string up my bow (is that correct english?)
Then I start drawing my arrow to the bow, I am attacking you.
Then I loose my arrow, the lumber is removed from your resources.
Then the arrow hits you, I am damaging you.


What you do is slightly different.
When I want to attack you, I have to string up my bow (is that correct english?)
Then I start drawing my arrow to the bow, I am attacking you, the lumber is removed from your resources.
Then I loose my arrow.
Then the arrow hits you, I am damaging you.


What if I start drawing my bow and then put it back? In that case the lumber is lost but I still have my arrow in my hand.

That is why your method doesn't work.
We call that "Abuse of stop order" even though every interrupt and other order has the same effect.


When you use a DDS, you can remove the lumber when the arrow hits it's target.
When I want to attack you, I have to string up my bow (is that correct english?)
Then I start drawing my arrow to the bow, I am attacking you.
Then I loose my arrow.
Then the arrow hits you, I am damaging you, the lumber is removed from your resources.


That is also not what you want and has a similar bug:

I have 1 arrow (lumber).
I draw my bow.
I loose the arrow.
I draw a new arrow.
The first arrow hits its target and I lose an arrow (lumber)... uhm... but I am now actually aiming my next arrow even though I haven´t got an arrow with me.


If it is possible that I can start shooting the next arrow before the first one hit it´s target, then you require to remove ranged attacks and invoke their projectiles with a missile system instead.
This will require you to edit all ranged units data fields and save their (ranged) attack type.

It will be a lot of work but is the only actual way to do it.
 
Level 11
Joined
Jun 26, 2014
Messages
497
hmm... it looks like you didnt understood it correctly.

Lets explain again:

When I want to attack you, I have to string up my bow (is that correct english?)
Then I start drawing my arrow to the bow, I am attacking you.
Then I loose my arrow, the lumber is removed from your resources.
Then the arrow hits you, I am damaging you.


What you do is slightly different.
When I want to attack you, I have to string up my bow (is that correct english?)
Then I start drawing my arrow to the bow, I am attacking you, the lumber is removed from your resources.
Then I loose my arrow.
Then the arrow hits you, I am damaging you.


What if I start drawing my bow and then put it back? In that case the lumber is lost but I still have my arrow in my hand.

That is why your method doesn't work.
We call that "Abuse of stop order" even though every interrupt and other order has the same effect.


When you use a DDS, you can remove the lumber when the arrow hits it's target.
When I want to attack you, I have to string up my bow (is that correct english?)
Then I start drawing my arrow to the bow, I am attacking you.
Then I loose my arrow.
Then the arrow hits you, I am damaging you, the lumber is removed from your resources.


That is also not what you want and has a similar bug:

I have 1 arrow (lumber).
I draw my bow.
I loose the arrow.
I draw a new arrow.
The first arrow hits its target and I lose an arrow (lumber)... uhm... but I am now actually aiming my next arrow even though I haven´t got an arrow with me.


If it is possible that I can start shooting the next arrow before the first one hit it´s target, then you require to remove ranged attacks and invoke their projectiles with a missile system instead.
This will require you to edit all ranged units data fields and save their (ranged) attack type.

It will be a lot of work but is the only actual way to do it.

Okay got it. But I don't know if it is that much of a problem. I prefer not going to deep into this because I'm a newbie at triggers and it really doesn't matter that much ... anyway you get more gold so if you lose like 10-20 ammo from the stop abuse its not that big of a problem :)
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Then at least use the second method.
The one with the DDS.
That one has not got the stop abuse but has the ghost ammo.

A DDS is not very hard to implement and will work very good in this situation.
I recommend this one by looking_for_help as I know that it can split basic attacks and spell damage apart.

All you have to do is change the event in your trigger.
 
Level 11
Joined
Jun 26, 2014
Messages
497
Then at least use the second method.
The one with the DDS.
That one has not got the stop abuse but has the ghost ammo.

A DDS is not very hard to implement and will work very good in this situation.
I recommend this one by looking_for_help as I know that it can split basic attacks and spell damage apart.

All you have to do is change the event in your trigger.

Bro ... I told you I'm a noob I barely made the triggers for the ammo. How am I supposed to do the DDS? :D
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
You are NOT doing the DDS, somebody (looking_for_help) was kind enough to make one himself and release it to the public so people can have a bug-less mods even if they have no idea what the hell is happening inside the DDS and what kind of magic runs it.
 
Level 6
Joined
Feb 16, 2014
Messages
193
Ok imagine the folowing situation:

You have a gun
Code:
You point it at your targer
You press the trigger
Gun expends ammo
Projectile flies
Projectile hits
Target is damaged

This is what we want right ?

The above trigger with this event
  • Unit - A unit Is attacked
Does NOT work like this.

The above trigger works like this:
Code:
You have a gun
You point it at your targer == Unit - A unit Is attacked >> Trigger runs
Gun expends ammo
You press the trigger
Projectile flies
Projectile hits
Target is damaged

So if I do
Code:
You have a gun
You point gun 
You lower gun

You will actualy get
Code:
You have a gun
You point gun >> Trigger runs
Gun expends ammo
You lower gun

Did you shoot ? No. Did the gun expend ammo ? Yes. Do you see the problem now ?

If you implement a DDS you can detect when damage is dealt. If damage was dealt that means that all of the previous "events" have occured but if a gun is pointed it does not mean that it was fired !


Edit// Sorry for weird fonts/styling.
Hmm.. Yea i think i see the problem. Thx for pointing that out :thumbs_up:
 
Status
Not open for further replies.
Top