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

[Trigger] Random Impact Shots Help?!?!

Status
Not open for further replies.
Level 3
Joined
Mar 26, 2008
Messages
53
Move this into the Jass threads if itsa Jass related question.

I need to know how to make ranged units shoot their shots randomely at an area they target.

The specs of this idea:
Unit: Archer. Uses Artillery as its attack style for the use of attack ground.
Needing a GUI or Jass code that basically does -
Condition/Event - (unit) owned by (player) attacks a target*
Action - Order (unit) to do 'order' (attack ground) at random point within 250(being the circular area around the attacked target) of *target unit* (or attacked unit).
Loop action

Is this doable in GUI or do I need a Jass code?

If this is even doable, than can I please have an example of how to get this to work?
I'll give cookehs!!!!!
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
I just want to understand it right...

You want the archer to Attack Ground, when an unit comes within the attacking range of her? Or should she attack first? Is the Archer existing only at one place, or are there many Archers around?

What type of map do you need it for?

/Regards
 
Level 3
Joined
Mar 26, 2008
Messages
53
The Archer is free moving like any other unit built, so technically the script needed needs to be a gameplay generic type that will respond to any archer on the field being ordered to attack any unit of another player (or atleast its targetted unit that it was told to attack).

The script's trigger would be "Archer" is "Ordered to (Attack)" unit (any unit).
The responce to this event then would set off "Order unit "Archer" to do Order (attack Ground) at Random point at 250 (being the radius area around the unit she would be attacking) at target point of "targetted unit/Attacked unit" - I'm not sure how to specify a generic function for the archer's targetted unit that you told it to attack.

If you can help, credit will be passed on and you'll get Cookehs!!!!
-=Peace=-
 

Rmx

Rmx

Level 19
Joined
Aug 27, 2007
Messages
1,164
Event : a unit is attacked .

Condition : //player owner off attacking unit equal to player 1 or whatever you won't
//Unit of type attacking unit is equal to archer

Action : issue order attacking unit to ( postion of polar offeset) attack ground of attacked unit offeset by 250 at random degree
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Well this how it should look in the normal way:
  • Archer Attack Ground
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Archer
    • Actions
      • Set AttackPoint1 = (Position of (Triggering unit))
      • Set AttackPoint2 = (AttackPoint1 offset by (Random real number between 0.00 and 250.00) towards (Random real number between 0.00 and 360.00) degrees)
      • Unit - Order (Attacking unit) to Attack Ground AttackPoint2
      • Custom script: call RemoveLoaction( udg_AttackPoint1 )
      • Custom script: call RemoveLoaction( udg_AttackPoint2 )
This is not enough!
The trigger above will order the unit to continue attacking AttackPoint2 and will not change if you not order it to stop. Thats why we need to do following:
  • Archer Attack Ground
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Archer
    • Actions
      • Set AttackPoint1 = (Position of (Triggering unit))
      • Set AttackPoint2 = (AttackPoint1 offset by (Random real number between 0.00 and 250.00) towards (Random real number between 0.00 and 360.00) degrees)
      • Unit - Order (Attacking unit) to Attack Ground AttackPoint2
      • Custom script: call RemoveLoaction( udg_AttackPoint1 )
      • Custom script: call RemoveLoaction( udg_AttackPoint2 )
      • Set Count1 = (Count1 + 1)
      • Set TempArcher[Count1] = (Attacking unit)
      • Countdown Timer - Start TempTimer[Count1] as a One-shot timer that will expire in 1.00 seconds
      • Trigger - Add to Archer Hold <gen> the event (Time - (Last started timer) expires)
And this is followed up by a "reset" archer trigger:
  • Archer Hold
    • Events
    • Conditions
    • Actions
      • Set Count2 = (Count2 + 1)
      • Unit - Order TempArcher[Count2] to Stop
      • Set TempArcher[Count2] = No unit
Use the two last trigger for best result:)

/Regards
 
Level 7
Joined
Dec 8, 2005
Messages
319
another thing you might want to look into is artfact td... i am not sure if it is protected or not... but look for the beer well tower... if you would like to give a differant way to do it but eccho seems to have a good solution as well.
 
Level 3
Joined
Mar 26, 2008
Messages
53
Thanks all for thw awsome support. I will attempt to use these ideas. Expect a quick reply back after my test!
Here goes nothin...

-=Peace-ness-kinda=-
 
Level 3
Joined
Mar 26, 2008
Messages
53
Ok, it could've been much worse, but needless to say the trigger actually failed in its attempt.

My results: Test involved multiple archers auto targetting enemy troops.
The archers used the trigger, atleast part of it. Only 1 archer actually had both triggers work on her. There was still a problem even beyond that. No archer fired a shot.
They would be registered as attacking ground but would just be standing there in their stand anims doing nothing. The could be ordered away easily. I noticed that however if they were in range of the targets to be shot at, they would glith and try to use the "stop" command untill they were out of range.
The one archer that did make full use of the trigger system never shot aswell. Her command card was flashing from going from attack to attack ground, holding that order for 1 second (as im guessing its supposed to) then stopping, instantly aquiring a target and TRYING to attack again, looping over and over. Pulling the one archer away is rough, as she only moves for 1 second untill the trigger created order is given again.

Lastly, I tried multiple variations of this trigger system and i could never ever get it to look like what it did above. I have no idea what the "Count1 + 1" was or is and I went through every single possible variable function to find matching results to what I saw.
The trigger that ordered the archer to attack the random point i could never match to what I saw. I either ended up using "Math-Random Number" on both or going "(Math-Random Number 0 to 250), (Math-Random Angle). There was no "towards" nor was I able to specify degrees. Again I went through every function.
I'm also assuming that with the custom script, its "RemoveLocation" and not "RemoveLoaction".
Removing these scripts entirely still gave me the same results i just listed.
The second reset trigger was also far fetching as "Count2= Count2 + 1" i couldnt get. Plus, I didnt even know why it was there.

It makes no sense to me as i can understand when the archers will fire, but nothing happens; but none the less I simply had problems reading this example because while i could see sense in it on here, in the editor, i failed to find out how to recreate what i seeing.

Maybe its my fault. It took me some time to even set variables right b/c im new to them and didnt know wich functions to select for them at first. Either way... doomed! Dooooooomed!
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Okay lets straight this out... I tested the trigger myself now and saw that it indeed didnt work.

This is what you have to change:
-> The Archer can't have any movement speed. Therefor set the movement speed to 0 (maybe you must have movement speed, but it doesn't work).
-> The Cooldown Timer is bugged or doesnt act like it shall. To fix this you must instead add another "dummy-unit" (do you know what that is?) to make the Stop trigger work properly.

this is the working trigger (works for me) of this experiment:
  • Archer Attack Ground
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Archer
    • Actions
      • Set AttackPoint1 = (Position of (Attacked unit))
      • Set AttackPoint2 = (AttackPoint1 offset by (Random real number between 0.00 and 250.00) towards (Random angle) degrees)
      • Unit - Order (Attacking unit) to Attack Ground AttackPoint2
      • Set Count1 = (Count1 + 1)
      • Set TempArcher[Count1] = (Attacking unit)
      • Unit - Create 1 YOUR_DUMMY for Neutral Passive at AttackPoint2 facing Default building facing degrees
      • Set TempDummy[Count1] = (Last created unit)
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation( udg_AttackPoint1 )
      • Custom script: call RemoveLocation( udg_AttackPoint2 )
And then:
  • Archer Hold
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to YOUR_DUMMY
    • Actions
      • Set Count2 = (Count2 + 1)
      • Unit - Order TempArcher[Count2] to Stop
      • Set TempArcher[Count2] = No unit
      • Set TempDummy[Count2] = No unit
-> The glitch is happening when a target is just within the area of "the range of the Archer" (500), allowing our random point to most likely fall outside the required lenght sometimes... To fix this, you need to change some more properties of the Archer, in the Unit Editor:
dothisej3.jpg


-> The Count1 and Count2 is simply just an integer to calculate and debug the whole system, so that right archer are attack grounding, and stopping, and right dummy unit to spawn as well. When a Archer attacks, count1 is increasing with one, therefor the arrays of all used arrayvariables also increase by one. The count2 variable does the same thing. When the dummy unit dies, its increasing by 1, and then it can order the right archer to stop.
-> The "towards" function is found when chosing point, using the fuction "Point with polar offset". From there you can set the random offset (from 0 to 250 in this case), and "towards a (random angle)".
-> Yes, it should be call RemoveLocation (not Loaction), look throgh the trigger again, and you see that that is not the only thing i've changed.

Hope it works now, it did for me.
 
Level 3
Joined
Mar 26, 2008
Messages
53
Wow, Im surprised I got it to work this Far o_O
This is awsome how its working thus far but yeah, like you pointed out, they only work when the archers are set to having no Movement speed.
I wonder if this is another variable option I can set for (1.00 seconds) once the archer becomes the Attacking Unit. It'll reset with the Archer Hold trigger set. I'll have to experiment
Althought I got it to work, there was only one error I cant figure out on how to change: Units explode when you hit them. Its part of the "Revenge" animations that you can turn off under "Art-Special", but when you do so, the unit simply disappears intead of splattering.
This is a problem gameplay wise, as there are no corpses to ressurect/consume/raise.
If I cant change this to where the unit killed leaves a corpse behind, then I dont know if I can fully use this system on Archer type units. Which would suck o_O
 
Status
Not open for further replies.
Top