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

[Trigger] crop farm trigger

Status
Not open for further replies.
Level 13
Joined
Sep 24, 2007
Messages
1,023
well first of all i would like to thank everyone who will be as kind to help me
i need help in making a trigger that once a player builds a farm every 30 seconds or so about 3 crops spawn arond it that if they are killed u get more lumber
 
Level 15
Joined
Jan 16, 2008
Messages
1,244
The triggers should look like this.
CropCreate.jpg
variable rnd is a random real number array.
CropBonus.JPG
replace footman with your crop unit in both triggers.
change the raw values to your preferences.
you can control number of crops spawned, spawning area, spawning interval and lumber gained for kill.
I hope this helps, enjoy!
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
The problem is - it leaks.

I think that to remove the leaks it must use the "FirstOfGroup" action which is in JASS.

Just to give you basic guidence if you want to create it:

You pick all units of the type you want, you then select the "first unit" of the group with the "FirstOfGroup(groupName)", then you do your actions - set a location on him, set a new location at the place you want (a random place near him), then create there the crop, remove the location (or 2 if you used 2, if you do this in JASS you could use X,Y for the second one), you then remove the "first unit" from the group with the "GroupRemoveUnit(groupName,unit_you_want_to_be_removed)", and then you pick the next "first unit" of the group.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I didn't say your trigger is bad, its actualy the best the GUI can offer in this situation.
I just noted that out since the probability of this trigger running a lot of times in the map is high (actualy it seems like it will... without any probability ^^), the maker should note that it leaks.

I take it as a rule that triggers that run more then one time should always be 100% non-leaking, so im sorry if I offended you in any way.

[offtopic] And just a tip, if you are trying to learn JASS through the normal WE, don't.
You can either use JassCraft or JNGP (Jass New Gen Pack = vJass), they are about x10000 usefull then the sucky WE lol.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Actualy, I thought on this and also the "Random unit from group" can be used here via GUI. Here is the concerning trigger:

  • Untitled Trigger 008
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Set Farms = (Units of type Footman)
      • For each (Integer A) from 1 to (Number of units in Farms), do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Random 1 units from Farms) and do (Actions)
            • Loop - Actions
              • For each (Integer B) from 1 to (Random integer number between 1 and 3), do (Actions)
                • Loop - Actions
                  • Set Point[0] = (Position of (Picked unit))
                  • Set Point[1] = (Point[0] offset by (Random real number between 50.00 and 300.00) towards (Random real number between 0.00 and 359.00) degrees)
                  • Unit - Create 1 Footman for Neutral Passive at Point[1] facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_Point[0])
                  • Custom script: call RemoveLocation(udg_Point[1])
              • Unit Group - Remove (Picked unit) from Farms
      • Custom script: call DestroyGroup(udg_Farms)
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
The problem with that tutorial (well it isn't really the tut's fault) is that I don't think that anyone that reads it will actually understand what he reads.
I for one, read it (didn't even know what are locals back then) and I hardly understood what it does and how it helps.

Concerning this specific question, locals won't really help.
It has to use a group and use either the "GroupPickRandomUnit" or the "FirstOfGroup" actions.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Are you talking about the points and group removing scripts I put there ? Also in JASS you need to put them, for example:

JASS:
local group g = someGroup
// actions
call DestroyGroup(g)
set g = null
and

JASS:
local location l = someWhere
local real x = GetLocationX(l)
local real y = GetLocationY(l)
call RemoveLocation(l)
set l = null
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
If you are using JassCraft, don't write your code in the WE as it always crashes at unexpected times lol.
Just check your code with the Syntax Checker of JassCraft, it always find the problems ! :) (oh well... almost always lol).

The WE however... if you have 1 typing mistake it will suddenly report to you about 300+ other "wrong" things (yes, it did it to me tons of times...).
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Gallin, I will repeat myself yet again.

If your trigger leaks locations (I.E - it doesn't use a group with a loop like I did), you are in big deep trouble.
Think about it like this - every 30 seconds, your map will leak 2x(number of farms) locations.
So, if you have 10 farms, it will leak 20 locations, if you have 100 farms, it will leak 200.
Since this trigger runs every 30 seconds... thats REALLY BAD !

You don't have to use my trigger, you can continue leaking, we tried to help you, now its your choice if you want to use that help or not, but atleast show us some gratitude please.


[backToNonTopic] what do you mean you don't get it ?

Syntax Errors are the "real" problems. If you have one, check it right away.
Usually they just come from forgetting to make a "call" before calling something, or giving too much/not as much as needed arguments into a function.

And are you using the JassCraft Syntax Checker ? because it sounds like you don't.
 
Level 15
Joined
Jan 16, 2008
Messages
1,244
Yeah, well, that's because THAT F*** TRIGGER MAY BE LEAKING. Do you even know what a leak causes over time? Leak wastes your RAM and once your RAM is filled up, there are many unpleasant possible events. The best thing: It is gonna crash your warcraft. The worst thing: It's gonna crash your windows. Good thing is this is not permanent since RAM gets reset every time you turn your computer on. Bad thing is... Well how many people will be playing a map that keeps crashing their computer? None i think...
 
Status
Not open for further replies.
Top