• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Random Attack Position (Errr...look inside) Second part.

Status
Not open for further replies.
Level 3
Joined
Mar 11, 2014
Messages
26
Hi guys, I would like to use what this brother asked for in 2009 on my map.


Can someone fix this

base.gif
Tempest
  • joinminus.gif
    events.gif
    Events
    • line.gif
      joinbottom.gif
      unit.gif
      Unit - A unit Is attacked
  • joinminus.gif
    cond.gif
    Conditions
    • line.gif
      joinbottom.gif
      if.gif
      (Unit-type of (Attacking unit)) Equal to Tempest Artillery Tank
  • joinbottomminus.gif
    actions.gif
    Actions
    • empty.gif
      join.gif
      set.gif
      Set TempPoint = (Position of (Attacked unit))
    • empty.gif
      join.gif
      set.gif
      Set TempPoint1 = (TempPoint offset by (Random real number between 0.00 and TempestRandomAttackX) towards (Random angle) degrees)
    • empty.gif
      join.gif
      set.gif
      Set TempestPoint1 = (Position of (Attacking unit))
    • empty.gif
      join.gif
      set.gif
      Set TempestPoint2 = (Position of (Attacked unit))
    • empty.gif
      join.gif
      set.gif
      Set TempestRandomAttackX = ((Distance between TempestPoint1 and TempestPoint2) / 30.00)
    • empty.gif
      join.gif
      unit.gif
      Unit - Order (Attacking unit) to Attack Ground TempPoint1
    • empty.gif
      join.gif
      page.gif
      Custom script: call RemoveLocation(udg_TempPoint1)
    • empty.gif
      join.gif
      page.gif
      Custom script: call RemoveLocation(udg_TempPoint)
    • empty.gif
      join.gif
      page.gif
      Custom script: call RemoveLocation(udg_TempestPoint1)
    • empty.gif
      joinbottom.gif
      page.gif
      Custom script: call RemoveLocation(udg_TempestPoint2)
The objetive is:
"Alright, so im fairly sure if you guys have played any other RTS, artillery behaves different since their projectiles dont usually land dead on their specified target, they often hit a random area in a small zone.
however, as we all know, wc3 units are always dead smack on target.
so how would i create random attack ground targets?"
 
Level 13
Joined
Feb 5, 2018
Messages
567
Set TempPoint1 = (TempPoint offset by (Random real number between 0.00 and TempestRandomAttackX) towards (Random angle) degrees)

You set this before you have set the TempestRandomAttackX. Therefore the offset is always 0.

Also you don't need to set the point of the attacked unit twice. You can reference one point with multiple different variables.
unit.gif
Unit - Order (Attacking unit) to Attack Ground TempPoint1
This won't work since the unit has the attack order and it won't interupt it.

What we could do is fake the attack with 1 damage and then make a dummy unit to attack the random or location or use a missile system and create the missile on the fake attack. Relativistic Missiles [vJASS][LUA][GUI]

If you are making a RTS map I highly recommend learning the missile system one. At first it looks intimidating, but really all you need to learn is to set up the missiles and system takes care of everything else.
events.gif
Events
  • line.gif
    joinbottom.gif
    unit.gif
    Unit - A unit Is attacked
Both these comes with a downside if we use this event thought. You can spam S to trigger the attack event literally hundreds of times in a matter of seconds. So it would really be better to use a unit takes damage event and then launch the randomattack event. Personally I would go for a damage event + missile system, but it is up to you how you want to make it.

  • Tempest
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Rifleman
    • Actions
      • Set VariableSet TempestAttacker = (Attacking unit)
      • Set VariableSet TempestTarget = (Triggering unit)
      • -------- --------
      • Set VariableSet TempestLoc[1] = (Position of TempestAttacker)
      • Set VariableSet TempestLoc[2] = (Position of TempestTarget)
      • -------- Offset --------
      • Set VariableSet TempestOffset = (Random real number between 1.00 and 200.00)
      • -------- --------
      • Set VariableSet TempestLoc[3] = (TempestLoc[2] offset by TempestOffset towards (Random real number between 1.00 and 90.00) degrees.)
      • -------- --------
      • Unit - Create 1 Mortar Team for (Owner of TempestAttacker) at TempestLoc[1] facing Default building facing degrees
      • Set VariableSet TempestDummy = (Last created unit)
      • Unit - Order TempestDummy to Attack Ground TempestLoc[3]
      • Unit - Add a 4.00 second Generic expiration timer to TempestDummy
      • Custom script: call RemoveLocation(udg_TempestLoc[1])
      • Custom script: call RemoveLocation(udg_TempestLoc[2])
      • Custom script: call RemoveLocation(udg_TempestLoc[3])
set.gif
Set TempestRandomAttackX = ((Distance between TempestPoint1 and TempestPoint2) / 30.00)
Also this does not make any sense. The offset will always be the same depending on the distance. If you attack from max range, lets say its 900, the offset is always 900 / 30 = 30. 30 offset is nothing for an artillery unit. Point being, there is really no randomness in where the missile will land.
 
Last edited:
Level 3
Joined
Mar 11, 2014
Messages
26
These was a option by @Damage

To do this, I'd use 2 different triggers.
  • if.gif
    Artillery Accuracy Randomiser
  • events.gif
    Events
    • joinbottom.gif
      unit.gif
      Unit - A unit is attacked
  • cond.gif
    Conditions
    • joinbottom.gif
      if.gif
      Unit type of (Attacking Unit) equal to <Your Artillery Unit>
  • actions.gif
    Actions
    • join.gif
      set.gif
      Set TempLoc1 = (Position of (Triggering Unit))
    • join.gif
      set.gif
      Set TempLoc2 = TempLoc1 offset by (Random Real number between 0 and X) towards (Random Angle) degrees
    • join.gif
      unit.gif
      Unit - Order (Attacking Unit) to Attack Ground TempLoc2
    • join.gif
      page.gif
      Custom script: call RemoveLocation(udg_TempLoc1)
    • joinbottom.gif
      page.gif
      Custom script: call RemoveLocation(udg_TempLoc2)
Set the Value of X to be whatever you want. Make it smaller to make the artillery more accurate.

For even more realism, change the value of X to be distance dependant.
For example, X could be
  • set.gif
    Set Point1 = Position of (Attacking Unit)
  • set.gif
    Set Point2 = Position of (Triggering Unit)
  • set.gif
    Set X = (Distance between Point1 and Point2) / 20.00
  • page.gif
    Custom script: Call RemoveLocation (udg_Point1)
  • page.gif
    Custom script: Call RemoveLocation (udg_Point2)
This would make your artillery much more accurate when shooting at closer ranges, but very inaccurate over a long distance. By dividing by twenty, the inaccuracy is scaled to 5% of the distance that is being fired. A reasonable scaler would be to replace the number 20 with anything between 15 and 40.

Then, in a separate trigger.
  • if.gif
    Stop Firing
  • events.gif
    Events
    • joinbottom.gif
      timer.gif
      Time - Every Y seconds of Game Time
  • cond.gif
    Conditions
  • events.gif
    Events
    • join.gif
      set.gif
      Set ArtilleryUnits = Units in (Playable Map Area) matching ((Current Order of (Matching Unit) equal to Order(attackground) and (Unit type of (Matching Unit)) equal to <Your Unit>))
    • joinminus.gif
      unitgroup.gif
      Unit Group - Pick Every unit in ArtilleryUnits and Do (Actions)
      • line.gif
        joinbottom.gif
        unit.gif
        Unit - Order (Picked Unit) to Stop
    • joinbottom.gif
      page.gif
      Custom script: call DestroyGroup(udg_ArtilleryUnits)
The value of Y should be just a tiny bit over the attack speed of your artillery units (eg. 0.03 seconds longer). If you have multiple types of artillery, you should make a trigger for each to avoid them being unable to attack due to being ordered to stop.

EDIT: Made it leak free also, for completion purposes.

The main problem with this method however is that the inaccuracy can be bypassed by specifically telling your units to attack ground at the position of the enemies, thereby bypassing the inaccuracy trigger. However, it will only fire once at that accuracy, due to the stop trigger
 
Level 13
Joined
Feb 5, 2018
Messages
567
As I said, you can make it with the system I linked and use a Damage Detection Event.

It is very very bad to use "A unit is attacked event". What you did seems okish to me. If the small inaccuracy is something you can live with. I still don't understand the mathematics behind the distance calculation. It always returns the same offset from the same range. If anyting it should be

  • Set X = Random number between distance between Loc1 and Loc2
You can use whatever event you want to launch the missile with the missile system.
 
Level 13
Joined
Feb 5, 2018
Messages
567
I made an example for the Attack Event with the missile system. Why these systems are so good is that they are 100% MUI. Which means they work for any number of units at the same time. Also the system takes care of everything for you.

All we need to do is set up the missile and set up the triggers what we want to happen when the missile hits an enemy or reaches it destination or both!

I made the unit do a fake attack. It plays it's attack animation and then we just launch the missile to a random point. The missilesystem testmap also has lots of examples how to set up the missile. I recommend using it for these kind of purposes.

Finally it would still be better to either use the warcraft own damage event or this Damage Engine 5.A.0.0

  • Artillery Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Mortar Team
    • Actions
      • Set VariableSet AA_Attacker = (Attacking unit)
      • Set VariableSet AA_Target = (Triggering unit)
      • Unit - Interrupt AA_Attacker's Attack
      • Unit - Order AA_Attacker to Stop.
      • Set VariableSet AA_Start = (Position of AA_Attacker)
      • Set VariableSet AA_Finish = (Position of AA_Target)
      • -------- Set up missile --------
      • -------- Attacker/Caster --------
      • Set VariableSet MissileSource = AA_Attacker
      • -------- Owner --------
      • Set VariableSet MissileOwner = (Owner of AA_Attacker)
      • -------- Points --------
      • Set VariableSet MissileFinish = (AA_Start offset by (Random real number between (Distance between AA_Finish and AA_Start) and (Distance between AA_Finish and AA_Start)) towards (Random real number between 1.00 and 45.00) degrees.)
      • Set VariableSet MissileStart = AA_Start
      • -------- Set up Arc --------
      • Set VariableSet MissileArc = 35.00
      • -------- Speed --------
      • Set VariableSet MissileSpeed = 1200.00
      • -------- Model --------
      • Set VariableSet MissileModel = Abilities\Weapons\Mortar\MortarMissile.mdl
      • -------- Damage --------
      • Set VariableSet MissileDamage = 50.00
      • -------- Launch the missile --------
      • Set VariableSet Missile_onFinish = Artillery Attack On Finish <gen>
      • Trigger - Run MissileCreate <gen> (ignoring conditions)
      • -------- Clean Up --------
      • Custom script: call RemoveLocation(udg_AA_Start)
      • Custom script: call RemoveLocation(udg_AA_Finish)

  • Artillery Attack On Finish
    • Events
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 135.00 of MissileFinish matching ((((Matching unit) is alive) Equal to True) and ((Matching unit) Not equal to MissileSource)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of MissileSource).) Equal to True
              • ((Picked unit) is invulnerable) Equal to False
            • Then - Actions
              • Unit - Cause MissileSource to damage (Picked unit), dealing MissileDamage damage of attack type Siege and damage type Normal
            • Else - Actions
 
Level 3
Joined
Mar 11, 2014
Messages
26
I made an example for the Attack Event with the missile system. Why these systems are so good is that they are 100% MUI. Which means they work for any number of units at the same time. Also the system takes care of everything for you.

All we need to do is set up the missile and set up the triggers what we want to happen when the missile hits an enemy or reaches it destination or both!

I made the unit do a fake attack. It plays it's attack animation and then we just launch the missile to a random point. The missilesystem testmap also has lots of examples how to set up the missile. I recommend using it for these kind of purposes.

Finally it would still be better to either use the warcraft own damage event or this Damage Engine 5.A.0.0

  • Artillery Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Mortar Team
    • Actions
      • Set VariableSet AA_Attacker = (Attacking unit)
      • Set VariableSet AA_Target = (Triggering unit)
      • Unit - Interrupt AA_Attacker's Attack
      • Unit - Order AA_Attacker to Stop.
      • Set VariableSet AA_Start = (Position of AA_Attacker)
      • Set VariableSet AA_Finish = (Position of AA_Target)
      • -------- Set up missile --------
      • -------- Attacker/Caster --------
      • Set VariableSet MissileSource = AA_Attacker
      • -------- Owner --------
      • Set VariableSet MissileOwner = (Owner of AA_Attacker)
      • -------- Points --------
      • Set VariableSet MissileFinish = (AA_Start offset by (Random real number between (Distance between AA_Finish and AA_Start) and (Distance between AA_Finish and AA_Start)) towards (Random real number between 1.00 and 45.00) degrees.)
      • Set VariableSet MissileStart = AA_Start
      • -------- Set up Arc --------
      • Set VariableSet MissileArc = 35.00
      • -------- Speed --------
      • Set VariableSet MissileSpeed = 1200.00
      • -------- Model --------
      • Set VariableSet MissileModel = Abilities\Weapons\Mortar\MortarMissile.mdl
      • -------- Damage --------
      • Set VariableSet MissileDamage = 50.00
      • -------- Launch the missile --------
      • Set VariableSet Missile_onFinish = Artillery Attack On Finish <gen>
      • Trigger - Run MissileCreate <gen> (ignoring conditions)
      • -------- Clean Up --------
      • Custom script: call RemoveLocation(udg_AA_Start)
      • Custom script: call RemoveLocation(udg_AA_Finish)

  • Artillery Attack On Finish
    • Events
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 135.00 of MissileFinish matching ((((Matching unit) is alive) Equal to True) and ((Matching unit) Not equal to MissileSource)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of MissileSource).) Equal to True
              • ((Picked unit) is invulnerable) Equal to False
            • Then - Actions
              • Unit - Cause MissileSource to damage (Picked unit), dealing MissileDamage damage of attack type Siege and damage type Normal
            • Else - Actions

The Relativistic Missiles [vJASS][LUA][GUI] make the next problems in my map

1699859501384.png


1699859534326.png


Do you know how I can solve it?
 
Level 13
Joined
Feb 5, 2018
Messages
567
Well it seems like you copied too much stuff. You only need the actual missile triggers. Everything else is whatever unless you want to use all the custom systems from the utilities folder.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
I've attached an example map that uses the Missile System to fire missiles at the player's mouse position. You can copy and paste the Missile System - Chopinski folder into your map to get everything needed for the system and be done with it.

Also, make sure that you've enabled JassHelper in your own map:
J.png


The other folder contains my own triggers which you can read and reference as examples of "how to use" the Missile System. I'm using another system here for the Mouse related stuff so don't let that confuse you. Understand that a system can be used in many different ways - and this just happens to be one of them.
 

Attachments

  • Mouse Missile System 3.w3m
    84 KB · Views: 8
Last edited:
Level 3
Joined
Mar 11, 2014
Messages
26
Hi @DoomBlade,

Sorry, I was away for work.

I made the correction and systems are working. Thank you very much for your help up to this point.

Now I detected the following problems:

1. The missiles only go to the right and don't care about my unit's attack range.

2. Missiles have no wait time to be fired and do not depend on the unit's attack animation.

3. The unit cannot cancel missiles.

4. The random attack area is just a line, not a circular area.

I've attached my map,

The unit is the Trebuchet in its armed form.
 

Attachments

  • Test.w3x
    526.5 KB · Views: 3
Level 13
Joined
Feb 5, 2018
Messages
567
Ok so what we should do is give the trebuchet a regular missile attack with no model and no AoE and 9999 missile speed. Set the attack cooldown to what you want.

Then we create the fake missile on damage event which I have mentioned before in this post. Get the damage engine and change your trigger event to "Damage event becomes equal to 1". Then add the condition checks and launch the missile triggers.

This should work since the trigger runs instantly. For the math problem I would just use random offsets with a default set of between some random number.

The goal here is that you will eventually figure some of the stuff out by yourself. It's a learning process. But for what you want you definetly need to use a damage event instead of attack event.
 
Status
Not open for further replies.
Top