pew pew. A very neat update in my opinion. I again rewrote the whole system to archieve even more configurability and ease the working with it.
It now features 2 struct types, one is called lane and the other is called spawn.
The lane is obviously the way a spawn moves, which still uses rects. (Since you can easily move them within the editor)
A spawn contains the data to spawn units. Each spawn requires one lane, one owner (a player), one unit type, an amount and an interval.
This features in-game changes of everything, means you can replace (or change) the lane, the player, the unit type, the amount and even the interval while the game is running.
You can also get the revertion of any lane (pretty useful for AoS maps, you just have to create half the lanes and get the reversed ones)
staticmethod create takes Lane, player, integer id, integer amount, real time returnsthistype method startSpawn takesnothingreturnsnothing method pauseSpawn takesnothingreturnsnothing method setSpawningUnit takesinteger id returnsnothing method setSpawnCount takesinteger amount returnsnothing method setOwner takesplayerreturnsnothing method setLane takes Lane returnsnothing method setInterval takesrealreturnsnothing
Enough talked, let's come to the code:
Code
library SpawnAndMove
globals //Which order get's issued to spawned units publicstring ISSUED_ORDER = "attack" //Distance to check if the unit is near his next waypoint (Set this higher if your rects are big) privateconstantreal CHECK_DISTANCE = 500.
staticmethod create takes Lane l, player p, integer toSpawn, integer count, real time returnsthistype localthistypethis = thistype.allocate() localtrigger t = CreateTrigger() localinteger i = 0
setthis.lane = l
setthis.owner = p setthis.spawned = toSpawn setthis.spawnCount = count setthis.interval = time
Yeah, that's your opinion, but IMO, it's alot easier for some people like this.
Fair enough.
Quote:
Ok I reworked your points.
Remove set Create = null from the loop, it only needs to be nulled once your done using the variable. (Place it at the bottom of the function, out of the loop.)
thx :) I think alot of people who aren't so good with JASS might find this easier. Also, this doesn't need any other system to function.
Quote:
Remove set Create = null from the loop, it only needs to be nulled once your done using the variable. (Place it at the bottom of the function, out of the loop.)
meh, didn't knew. I never null anything basicly. But thanks for your help.
I'm pretty sure you could do this stuff in structs, and have public function which make instances of the structs (i.e. create a Spawn or a WayPoint object). If you do it right, the user could still setup a Spawn or Waypoint with one line of code, but it will reduce the size of the map dramatically; you wouldn't be copy/pasting the whole system code each time you used it.
Whenever you update, you should delete outdated code/instructions in the original post. You can keep the old code in your own files if you want.
This version is looking better, but I'm not really sure what you're doing with "MoveInteger" and "CondMoveInt". I have an idea that will make this system both easier to use, and easier to understand the code. My idea is to make a SpawnPath struct and a WayPoint struct. Each SpawnPath object will contain a list of WayPoint objects that the spawns will walk to, in the order of the Waypoints in the list. Here's the basic layout (missing a bunch of stuff):
my idea stuff
library APN requires List //a library that allows you to easily make lists struct WayPoint WayPoint nextWayPoint = 0 privaterect wpRect
struct SpawnPath IntegerList waypoints //IntegerList is a list of integers. //struct instances are basically integers. //declare your variables like theTimer, unitType, howMany, howOften, etc.
method addWayPoint takesrect whichRect returnsnothing local WayPoint newWP = WayPoint.create(whichRect) set WayPoint(.waypoints[.waypoints.size-1]).nextWayPoint = newWP //the last waypoint's next waypoint is now the waypoint we just created call .waypoints.addLast(newWP) //now the new waypoint has been added to the end of the list endmethod endstruct
Well, I hope you get the general idea. Send me a PM if you need more explanation. I am happy to help. Btw, here's the List library that you'll need.
I am currently building something like this,
which creates for 2 teams the routes and then adds information
to the unit themself, on which route they are, and which the next
point is they have to move to.
Hey I see you used my suggestions :D You are learning quickly. You should really update the original post with that code. The only thing I don't get is what the units do once they reach the second waypoint. I don't see you making any events for when the spawned units enter the rects, to order them to move to the next ones. Did you test this code to see if it works?
It's not finished yet, I'm still encountering a problem that all units are moving into the same rect at once(if you've done multiple spawns - maybe its just a failure of my setup but idk)
Anyway I updated the code, maybe someone will notice the bug.
And yes, I kind of used your suggestions :)
privatefunction init takesnothingreturnsnothing local WayPoint wp = 0 local Way wy = 0 localunit u = CreateUnit(Player(0), 'hpea', 0., 0., 270.)
//: Instaciate a new way set wy = Way.create() //: Add a new waypoint call wy.addWayPoint(WayPoint.create(0., 0., 192., 192., TARGET_TOLERANCE)) //: Add a unit to the way, starting at waypoint 0. call wy.addUnit(u, 0) endfunction
endscope
Mine does the following: You can determine whether spellcasts, stop order and hold position orders will move the unit again to the target upon finishing order.
Also its pretty easy to create waypoints and its customizeable.
You also don't need a system to move units, its doing everything on its own.
I might post mine when its finished.
edit: so back to yours, its pretty basic, but cool.