• 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.

[JASS] JASS question

Status
Not open for further replies.
Level 12
Joined
Mar 16, 2006
Messages
992
I've been lazy. I should probably have learned JASS 3 years ago when I started my project, but it's been so off and on(with time) that I never sat down for it.

Is it possible with JASS to monitor the entire map(160x160)'s units to see when they're within range of a building, then have the unit attack the building, if they're not attacking another unit? The units are consistently being spawned, so it would have to be able to update new units, not preset units already on the map.

If unit is 100y from building and building is not invulnerable, order unit to attack building.

But then, have a script to monitor when enemies are attacking them, so they can be ordered to attack their attacker, and if they kill the attacker, back to the building, if it's alive?

I could probably figure something out with GUI, but I believe JASSing this would be much more beneficial. Plus I want to alpha/beta test my map already.
 
Level 7
Joined
Mar 16, 2008
Messages
348
i think that's possible but i would take some days to do it, and i don't have the time right now, and are the building spawned in certain locations or random locations(if they are in random locations then i believe it's really hard or impossible to do that)
 
Level 12
Joined
Mar 16, 2006
Messages
992
i think that's possible but i would take some days to do it, and i don't have the time right now, and are the building spawned in certain locations or random locations(if they are in random locations then i believe it's really hard or impossible to do that)

The buildings have set locations.

And if it matters, there are 5 ranks of each unit, and 8 different units.

I messed around in the AI editor, but didn't find anything near the same as what I need for my map. The controllers are neutral computers, with scripted behaviours. The only problem I'm having now is buildings not being attacked. They just stand there and take the punishment from towers.
 
Level 7
Joined
Mar 16, 2008
Messages
348
I believe that is possible but i have to go now since it's 2:00 am here :/ but tomorrow i may make that since my project is being worked on with terraining and items.So cya tomorrow i guess. Btw i have one more question but i will only see the answer tomorrow:
Is the range between the towers a minimum of 210--250? else players could bug the monsters to just stay there between the towers and keep deciding which tower to attack.
 
Level 12
Joined
Mar 16, 2006
Messages
992
I believe that is possible but i have to go now since it's 2:00 am here :/ but tomorrow i may make that since my project is being worked on with terraining and items.So cya tomorrow i guess. Btw i have one more question but i will only see the answer tomorrow:
Is the range between the towers a minimum of 210--250? else players could bug the monsters to just stay there between the towers and keep deciding which tower to attack.

I'll explain it in detail.

The towers are far apart. FAR apart. The units are ordered to attack move to the tower if it's alive. What ends up happening is the units all circle the tower, but don't attack it.

I need melee units to attack the tower, when within X range. And I need ranged units to attack the tower, when within Y range.

BUT. If another unit comes and attacks them, I want them to defend themselves. I want them to fight back, but not randomly attack things-- I want them to attack one unit until either of them dies. As soon as that happens, if the it is still alive, I want it to attack the tower again.

------------
What I need:
A detection script for melee units near vulnerable buildings.
A detection script for ranged units near vulnerable buildings.
A detection script building attackers, so if/when they're attacked, they pick their first attacker and attack them until one of them die, then go back to attacking the first building if still alive. If not still alive, move to the next location.

Doesn't sound so bad when I write it like that. I'll probably try to put it together in GUI and race you!

------------
Edit:
Well, I guess I had a good amount of time to figure out how I'm going to try this with GUI. Basically involves unique custom values for spawned units, two unitgroups, and a bunch of range if alive/then attack detection scripts.

I wish you luck with the JASS version. I hope mine works. I leave for home in the next few minutes to find out if it does!
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
In GUI it will probably look something like this:
  • Untitled Trigger 001
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set Buildings = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to True))
      • Set Units = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to False))
      • For each (Integer A) from 1 to (Number of units in Buildings), do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Random 1 units from Buildings) and do (Actions)
            • Loop - Actions
              • Unit Group - Remove (Picked unit) from Buildings
              • Set SingleBuilding = (Picked unit)
              • Set SingleBuildingLoc = (Position of SingleBuilding)
              • For each (Integer A) from 1 to (Number of units in Units), do (Actions)
                • Loop - Actions
                  • Unit Group - Pick every unit in (Random 1 units from Units) and do (Actions)
                    • Loop - Actions
                      • Unit Group - Remove (Picked unit) from Buildings
                      • Set SingleUnit = (Picked unit)
                      • Set SingleUnitLoc = (Position of SingleUnit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • And - All (Conditions) are true
                            • Conditions
                              • (Distance between SingleUnitLoc and SingleBuildingLoc) Less than or equal to 100.00
                              • (Current order of SingleUnit) Not equal to (Order(attack))
                              • (Current order of SingleUnit) Not equal to (Order(spell))
                        • Then - Actions
                          • Unit - Order SingleUnit to Attack SingleBuilding
                          • Custom script: call RemoveLocation(udg_SingleBuildingLoc)
                          • Custom script: call RemoveLocation(udg_SingleUnitLoc)
                        • Else - Actions

It will probably lag like hell though.
Loops inside loops isn't a good thing, especially at this size of loops.
 
Level 12
Joined
Mar 16, 2006
Messages
992
In GUI it will probably look something like this:
  • Untitled Trigger 001
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set Buildings = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to True))
      • Set Units = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to False))
      • For each (Integer A) from 1 to (Number of units in Buildings), do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Random 1 units from Buildings) and do (Actions)
            • Loop - Actions
              • Unit Group - Remove (Picked unit) from Buildings
              • Set SingleBuilding = (Picked unit)
              • Set SingleBuildingLoc = (Position of SingleBuilding)
              • For each (Integer A) from 1 to (Number of units in Units), do (Actions)
                • Loop - Actions
                  • Unit Group - Pick every unit in (Random 1 units from Units) and do (Actions)
                    • Loop - Actions
                      • Unit Group - Remove (Picked unit) from Buildings
                      • Set SingleUnit = (Picked unit)
                      • Set SingleUnitLoc = (Position of SingleUnit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • And - All (Conditions) are true
                            • Conditions
                              • (Distance between SingleUnitLoc and SingleBuildingLoc) Less than or equal to 100.00
                              • (Current order of SingleUnit) Not equal to (Order(attack))
                              • (Current order of SingleUnit) Not equal to (Order(spell))
                        • Then - Actions
                          • Unit - Order SingleUnit to Attack SingleBuilding
                          • Custom script: call RemoveLocation(udg_SingleBuildingLoc)
                          • Custom script: call RemoveLocation(udg_SingleUnitLoc)
                        • Else - Actions

It will probably lag like hell though.
Loops inside loops isn't a good thing, especially at this size of loops.

Thanks for the effort, but I've already got my GUI almost working. No loops required, or lag. Just really tricky unit assignment.

Since I'm running an anti backdoor script on my map, I can set it so only the vulnerable buildings are scripted. =)
 
Level 17
Joined
Apr 13, 2008
Messages
1,608
Do you use the "Unit - Unit comes within real range of unit?"
It would make things much easier than loops and crazy conditions (yea, I read that you solved this without loops).

You could also make another trigger, if your creeps get attacked you order them to attack their attackers unless they are more than 2500 range away from their path or something.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
GhostWolf's method breaks for the second requirement, that they will stop attacking the building when necessary.

Just use TriggerRegisterUnitInRange, as emperor_d3st said, since "attack" issued to a point will set buildings as low priority over units.

native TriggerRegisterUnitInRange takes trigger whichTrigger, unit whichUnit, real range, boolexpr filter returns event

(whichUnit is the unit they must approach)
 
Level 12
Joined
Mar 16, 2006
Messages
992
Do you use the "Unit - Unit comes within real range of unit?"
It would make things much easier than loops and crazy conditions (yea, I read that you solved this without loops).

You could also make another trigger, if your creeps get attacked you order them to attack their attackers unless they are more than 2500 range away from their path or something.

GhostWolf's method breaks for the second requirement, that they will stop attacking the building when necessary.

Just use TriggerRegisterUnitInRange, as emperor_d3st said, since "attack" issued to a point will set buildings as low priority over units.

native TriggerRegisterUnitInRange takes trigger whichTrigger, unit whichUnit, real range, boolexpr filter returns event
(whichUnit is the unit they must approach)

Well, I've got the GUI version working perfectly(so far!). I'll probably end up just learning JASS and converting it myself, but not while I have so much work to be done.

Thanks for the help, guys.
 
Status
Not open for further replies.
Top