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

Complex question about the creation of stg that provides 'Water Radius'.

Status
Not open for further replies.
Level 1
Joined
Mar 20, 2011
Messages
5
Hello guys.

There's an agriculture system in my map where plants can only be built near water. Each plant has a specific placement - water radius require.

And that was fine, so far. But then I realised, considering the fact that there aren't a lot of lakes and rivers in the map, the game would be more predictable, since everybody would set their bases near those water spots.

How to solve that? Well, maybe players could build stg which provides water radius. And I decided the building would be a well.

Ok, but how to provide water radius through that well?

Event: Unit - a unit finishes construction
Condition: (unit type of (tringgering unit) equal to Well)
Action: ???

I don't know. Does anybody?
 
Level 1
Joined
Mar 20, 2011
Messages
5
Well... For me the name says what it is... But I'll try to put into other words:
Water Radius Require is the quantity of necessity that a building has to be placed near some source of water. That's determinated by a radius... Radius:100 = the building can only be placed beside water. Radius 500 = the building can be placed a little further... And so on.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
  • Actions
    • Set Loc1 = (Position of Plant)
    • Set Group = (Units within Plant Water Radius of Loc1 matching ((Unit-type of (Matching unit)) Equal to Water Well))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Group is empty) Equal to False
      • Then - Actions
        • -------- Cancel construction --------
      • Else - Actions
        • -------- Water nearby --------
    • Custom script: call DestroyGroup(udg_Group)
    • Custom script: call RemoveLocation(udg_Loc1)
 
Level 1
Joined
Mar 20, 2011
Messages
5
Dúvida.png

I know I'm asking a lot from your kindness, but could you please tell me how you set 'Plant water radius of Loc1'?

I can't find anything about water radius =\
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Hahaha :p I didn't use the editor to do that... (just wrote it here like plain text).

I thought you had some kind of system to easily see which plants have which water radius.
Like this:

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set PlantCount = (PlantCount + 1)
      • Set PlantType[PlantCount] = Plant1
      • Set PlantWaterRadius[PlantCount] = 100.00
      • Set PlantCount = (PlantCount + 1)
      • Set PlantType[PlantCount] = Plant2
      • Set PlantWaterRadius[PlantCount] = 200.00
      • Set PlantCount = (PlantCount + 1)
      • Set PlantType[PlantCount] = Plant3
      • Set PlantWaterRadius[PlantCount] = 300.00
Where PlantCount is an integer
PlantType is a unit-type array
PlantWaterRadius is a real array.

So you can do this:

  • For each (Integer A) from 1 to PlantCount, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructed structure)) Equal to PlantType[(Integer A)]
        • Then - Actions
          • Set TempInt = (Integer A)
          • Custom script: set bj_forLoopAIndex = 100
        • Else - Actions
The complete trigger would look something like this:

  • Check Plants
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • -------- Get the built plant --------
      • For each (Integer A) from 1 to PlantCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Constructed structure)) Equal to PlantType[(Integer A)]
            • Then - Actions
              • Set TempInt = (Integer A)
              • Custom script: set bj_forLoopAIndex = 100
            • Else - Actions
      • -------- Check if there's a well near the plant --------
      • Set Loc = (Position of (Constructed structure))
      • Set Group = (Units within PlantWaterRadius[TempInt] of Loc matching ((Unit-type of (Matching unit)) Equal to Farm))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Group is empty) Equal to True
        • Then - Actions
          • Unit - Remove (Constructed structure) from the game
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Loc)
      • Custom script: call DestroyGroup(udg_Group)

If you wish more information, that's why I'm here for ^^
 
Level 1
Joined
Mar 20, 2011
Messages
5
Okay.

I couldn't get this part:

Set Loc = (Position of (Constructed structure))
Set Group = (Units within PlantWaterRadius[TempInt] of Loc matching ((Unit-type of (Matching unit)) Equal to Farm))

Loc = 'position of the plant'.
And... If the plant is within a radius of 'position of the plant' maching bla bla bla...

If the plant is within a radius of itself, it goes to the group?

Did I get it right?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
It depends of the editor water radius runs via the water flag for terrain generation or the water pathing for the pathing system. If it is the water flag for terrain generation you will need to use triggers. If it is water pathing, just make the strucutre add some water pathing under it.

If it works with only the initial pathing map water pathing, then triggers will also be needed.
 
Status
Not open for further replies.
Top