|
 |
| Author |
Message |
|
Mithy
|
Posted: 19 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
conKORD wrote: Code: debug: unitlist = { debug: 2={ "2", false }, debug: 3={ "3", false }, debug: 4={ "4", false }, debug: 5={ "5", false }, debug: 6={ "6", false } debug: } Those are actual indexes from Sync.UnitData? That's... odd, but the 'false' from their contents and nil from GetEntityById are not, because those probably aren't valid EntityIds. Are you doing this in OnSync before, or after running the old OnSync? conKORD wrote: SPEW(repr(UnitData)) always returns empty array This.. should not be happening. UnitData should always have something in it, unless I'm seriously underestimating the amount of info that passes through the sync. Try adding an ACU enhancement, and then checking UnitData, or something like that.
|
|
| Top |
|
 |
|
conKORD
|
Posted: 19 Aug, 2010
|
|
Joined: 26 Jul, 2007 Posts: 139
|
Mithy wrote: This.. should not be happening. UnitData should always have something in it, unless I'm seriously underestimating the amount of info that passes through the sync. Try adding an ACU enhancement, and then checking UnitData, or something like that. Still nothing. Where did you see working example of usage of UnitData? Mithy wrote: Those are actual indexes from Sync.UnitData? That's... odd, but the 'false' from their contents and nil from GetEntityById are not, because those probably aren't valid EntityIds. Are you doing this in OnSync before, or after running the old OnSync?
Before. Is it matter? And IDs in Sync.UnitData are IDs of little building drones that animates cybran's construction Looks like no IDs of normal units passes through Sync.UnitData 
|
|
| Top |
|
 |
|
Mithy
|
Posted: 19 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
I just tried it myself, and yeah, you're right. I'm not sure why those drone entityids are showing up, when nothing else does. Edit: Here's why, from Unit.lua:OnDestroy-- Code: Sync.UnitData[self:GetEntityId()] = false Likewise, the self.Sync metatable doesn't actually do anything to UnitData or Sync.UnitData on the sim side unless values are explicitly added, either. That's why nothing is showing up. However, as I understand it, enhancements should be showing up in UnitData, and they're not. Edit 2: Wrong again. From OnCaptured in Unit.lua: Code: local unitEnh = SimUnitEnhancements[entId] Totally different global table. Not sure how to access that on the user side, but it apparently doesn't use Sync.
|
|
| Top |
|
 |
|
BulletMagnet
|
Posted: 20 Aug, 2010
|
|
Joined: 05 Oct, 2007 Posts: 16425 Location: camping near the biggest power-up
|
Hopefully this one works better.
_________________
Nephylim wrote: But, an FA army in an FA environment just looks... right. Does anyone know how to use air transports? I cant get them to pick up troops.
|
|
| Top |
|
 |
|
Mithy
|
Posted: 20 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
Looks good, much less of a hitch when it triggers on a deposit. Also, I had no idea tables could have an index of 0, but apparently they can. I made a small enhancement-- in controls/worldview.lua, substituting this: Code: --Holding alt builds the highest tech available mex instead of tech 1 if IsKeyDown('Menu') and depositCat == 'MASSEXTRACTION' then for i=3, 1, -1 do local buildableUnits = EntityCategoryGetUnitList(buildableCategories * ParseEntityCategory(depositCat) * ParseEntityCategory('TECH'..i)) if buildableUnits[1] then buildBP = buildableUnits[1] break end end else local buildableUnits = EntityCategoryGetUnitList(buildableCategories * ParseEntityCategory(depositCat) * categories.TECH1) buildBP = buildableUnits[1] end for the 'local buildableUnits = ' etc that appears here in the else block allows you to hold alt to one-click-build the highest tech available mex, instead of only T1. This shouldn't conflict with any of the other scenarios where alt can be held to change behaviour, except in the case of a rebuildable wreck very near an empty deposit (e.g. storage), in which case the rebuild functionality will obviously still take precedence. Also, because of the increased trigger distance, the deposit check needs to be able to detect existing structures at the deposit location. I assume a GetUnitsInRect check will suffice, and I'll give this a shot. Edit: Apparently there are no location-based selection tools in the user layer? Yikes. Maybe UISelectionByCategory could work, as I think it can be used to select nearest to the cursor? Edit 2: UISelectByCategory is a no-go, since it actually changes UI selection. While we can re-select the previously selected units, FA's builder selection is so slow that doing two or three rapid selections like that freezes the interface for a second or so, and somehow causes the buildmode to not show (even though it is active, and clicking will still place the mex/hydro).
|
|
| Top |
|
 |
|
conKORD
|
Posted: 20 Aug, 2010
|
|
Joined: 26 Jul, 2007 Posts: 139
|
Below is slightly modified function from Supreme Economy to get actual unitlist. Currently it is best variant to do it. Code: local GetScore = import('/mods/TeamUtils/modules/mciscore.lua').GetScore
local lastFocusedArmy = 0 local emergencyResetProcedureStarted = false local UpdateFlag = false local UpdateCounter = 0 local allUnits = {} local Delay = 3 local resetcount=0 local resetflag=0 ###############################################################################
function UpdateControl(flag) #if flag == 1 then Reset() end UpdateCounter = UpdateCounter + flag if UpdateFlag and UpdateCounter <= 0 then #print("Updater: Disabled") import('/lua/ui/game/gamemain.lua').RemoveBeatFunction(UpdateAllUnits) UpdateFlag = false elseif UpdateFlag == false and UpdateCounter > 0 then #print("Updater: Enabled") import('/lua/ui/game/gamemain.lua').AddBeatFunction(UpdateAllUnits) Reset() UpdateFlag = true end end ############################################################################### function AddSelection() for _, unit in (GetSelectedUnits() or {}) do allUnits[unit:GetEntityId()] = unit end end
function Reset() import('/lua/ui/game/construction.lua').SaveCheckedTab() local currentlySelected = GetSelectedUnits() or {} local commandmode = import('/lua/ui/game/commandmode.lua') local currentCommand = commandmode.GetCommandMode()
UISelectionByCategory("ALLUNITS", false, false, false, false) AddSelection()
SelectUnits(currentlySelected) import('/lua/ui/game/construction.lua').RestoreCheckedTab() commandmode.StartCommandMode(currentCommand[1], currentCommand[2])
end
function Resetter(count) resetcount=count if resetcount>0 and resetflag==0 then ForkThread(ResetCounter) resetflag=1 end end
function ResetCounter() while (resetcount>0) do Reset() #print("Reset " .. resetcount) resetcount=resetcount-1 WaitSeconds(4) end resetflag=0 end
function EmergencyReset(targetUnitCount) WaitSeconds(Delay) local newTargetUnitCount = GetScore()[GetFocusArmy()].general.currentunits.count -- if after 10 seconds we are not loosing units and the unit count is still larger we have to do a reset if newTargetUnitCount >= targetUnitCount and newTargetUnitCount > table.getsize(allUnits) then #print("New units detected") Reset() end emergencyResetProcedureStarted = false end
function UpdateAllUnits() if GetFocusArmy() != lastFocusedArmy then Reset() lastFocusedArmy = GetFocusArmy() end
AddSelection() -- add focused (building or assisting) for _, unit in allUnits do if not unit:IsDead() and unit:GetFocus() and not unit:GetFocus():IsDead()then allUnits[unit:GetFocus():GetEntityId()] = unit:GetFocus() end end -- remove dead for entityid, unit in allUnits do if unit:IsDead() or unit:GetArmy() != GetFocusArmy() then allUnits[entityid] = nil continue end end -- emergency reset local targetNumOfUnits = GetScore()[GetFocusArmy()].general.currentunits.count if not emergencyResetProcedureStarted and targetNumOfUnits > table.getsize(allUnits) then emergencyResetProcedureStarted = true ForkThread(EmergencyReset, targetNumOfUnits) end end
function GetAllUnits() return allUnits end
function GetACU() local ACU = {} for entityid, unit in allUnits do if unit:IsInCategory("COMMAND") then ACU[entityid] = unit end end return ACU end And I have some ideas how to improve rebuild function. 1)With pressed control (for example) ,before ordering to rebuild, add order to reclaim wreck to get back 90% of mass instead of 50%. Could be not possible if reclaim unit requires wreck ID. 2)Your function can generate callback when some building dies and give order to nearest idle engineer to rebuild it.
|
|
| Top |
|
 |
|
Mithy
|
Posted: 20 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
|
1) Would work fine for any structure that it can rebuild now (that is any structure that belonged to you, that was ever selected). Actually, there is no good way to do this that is any better than simply giving a reclaim order, then holding alt and issuing a rebuild order on the same point while the wreck is still there, but being reclaimed. 2) Absolutely no way to do this without serious sim integration. Most orders (including build) can only be issued in sim.
And yeah, there is simply no good way to detect the presence of an already-taken deposit. Iterating the structs table and doing another full VDist2 on each would work for any mex/hydro that has been selected, but that's way too much work to do every time the mouse moves near a deposit, and still isn't foolproof.
|
|
| Top |
|
 |
|
conKORD
|
Posted: 20 Aug, 2010
|
|
Joined: 26 Jul, 2007 Posts: 139
|
Mithy wrote: 2) Absolutely no way to do this without serious sim integration. Most orders (including build) can only be issued in sim. Upgrade order can be issued from UI. Build order in factory too.
|
|
| Top |
|
 |
|
Mithy
|
Posted: 20 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
|
That's because they're not positional orders. BuildMobile is.
|
|
| Top |
|
 |
|
BulletMagnet
|
Posted: 20 Aug, 2010
|
|
Joined: 05 Oct, 2007 Posts: 16425 Location: camping near the biggest power-up
|
Mithy wrote: Looks good, much less of a hitch when it triggers on a deposit. Also, I had no idea tables could have an index of 0, but apparently they can. I made a small enhancement-- in controls/worldview.lua, substituting this: Code: --Holding alt builds the highest tech available mex instead of tech 1 if IsKeyDown('Menu') and depositCat == 'MASSEXTRACTION' then for i=3, 1, -1 do local buildableUnits = EntityCategoryGetUnitList(buildableCategories * ParseEntityCategory(depositCat) * ParseEntityCategory('TECH'..i)) if buildableUnits[1] then buildBP = buildableUnits[1] break end end else local buildableUnits = EntityCategoryGetUnitList(buildableCategories * ParseEntityCategory(depositCat) * categories.TECH1) buildBP = buildableUnits[1] end for the 'local buildableUnits = ' etc that appears here in the else block allows you to hold alt to one-click-build the highest tech available mex, instead of only T1. This shouldn't conflict with any of the other scenarios where alt can be held to change behaviour, except in the case of a rebuildable wreck very near an empty deposit (e.g. storage), in which case the rebuild functionality will obviously still take precedence. Building T1 mexes is almost always be best choice to make, it takes a rather long time for a T3 mex to pay for itself, even with rebuild bonuses. On the topics of selecting units, played around with that before release; it is too slow to use. I had a thought about polling the idle engineers, because IIRC there's something there that doesn't involve UI selection of them. I doubt I'll get much done on that this weekend as Today is voting day and I have a maths test on Monday to study for. FML.
_________________
Nephylim wrote: But, an FA army in an FA environment just looks... right. Does anyone know how to use air transports? I cant get them to pick up troops.
|
|
| Top |
|
 |
|
Mithy
|
Posted: 20 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
|
I'm aware, but there are times later in the game when I want at least T2. You don't have to include that code of course - the beauty of a UI mod is that anyone who wants that capability can just plug it in. It can also be changed to ignore T3 just by lowering the for loop starting point to i=2.
I gave some further thought to structure detection, and I really don't think there's a way short of some heavy-handed crap like the Supreme Economy snippet that conKORD posted (and there's a reason, and only one reason, that I don't use Supreme Economy). That's too bad, because I find the previously-helpful large snap distance really annoying once I've got mexes queued and I'm trying to assist them or something near them.
|
|
| Top |
|
 |
|
BulletMagnet
|
Posted: 21 Aug, 2010
|
|
Joined: 05 Oct, 2007 Posts: 16425 Location: camping near the biggest power-up
|
|
Anyone know if the mex/hydro snap is handled in the engine or not? I mean, build mode and the blueprint is handled in Lua.
[EDIT:] Holy Snap! GetMouseWorldPos() jumps to the deposit position! How can we abuse this?
_________________
Nephylim wrote: But, an FA army in an FA environment just looks... right. Does anyone know how to use air transports? I cant get them to pick up troops.
|
|
| Top |
|
 |
|
Mithy
|
Posted: 21 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
|
Oh, neat. Well, that should be easy enough? Just base your checks off of that position instead of the actual cursor position.
That still doesn't help with structure detection - at least not unless it doesn't snap if there's already a structure there, or something like that.
|
|
| Top |
|
 |
|
Veqryn
|
Posted: 24 Aug, 2010
|
|
Joined: 07 Dec, 2007 Posts: 122
|
BulletMagnet wrote: Hopefully this one works better. ok, just tried 0.2 version, and I have a major complaint (tho i still love it) *it does not detect when there Already is a mex on the spot. so in other words, even when there is a t1 mex, t2 mex, or t3 mex, the one click wonder still tries to put a mex on the spot. I find this annoying because often times I am trying to do something else, like assist an upgrading mex, or repair a damaged mex, and instead it keeps trying to give me a red box for building a new mex instead. (ps, i find the snap distance is just fine, and i don't want a t3 mex either, t1 mexes are the best, if i want a t3 i can click the menu)
|
|
| Top |
|
 |
|
BulletMagnet
|
Posted: 24 Aug, 2010
|
|
Joined: 05 Oct, 2007 Posts: 16425 Location: camping near the biggest power-up
|
|
It's basically impossible. There's nothing I have access to in UI-Land that would let me do that.
If you care to read the thread, you'll see that we've all come to a similar conclusion. I will be staying with T1 mexes.
_________________
Nephylim wrote: But, an FA army in an FA environment just looks... right. Does anyone know how to use air transports? I cant get them to pick up troops.
|
|
| Top |
|
 |
|
Mithy
|
Posted: 24 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
|
Well, you could implement half-assed sometimes mex-detection by adding any mexes selected to a separate, hash-keyed table from alive in commandmode.lua, likewise clearing them out when their ids are released (by also storing their hash in alive). Then, since GetMouseWorldPos() apparently drops right on the deposit, you can use hashes again to quickly get existing mex positions.
Of course this would only work for mexes/hydros that have been selected at one point or another, but it'd be an improvement of some sort.
|
|
| Top |
|
 |
|
BulletMagnet
|
Posted: 25 Aug, 2010
|
|
Joined: 05 Oct, 2007 Posts: 16425 Location: camping near the biggest power-up
|
Done - sort of. Put all structures on selection and order (why do I have them on order too? I'll have to select them first. lol) into a divided table like mex. markers, then check that region for a mex. that has the same coordinates are the mass marker. Not going to upload it yet because I have to select buildings for this to work, and this also affects rebuilding too. Three things I want to consider adding/changing before I'll release a new version; - Intercept construction orders and add things to the table of alive structures then, so players won't have to select buildings for them to work.
- Put mexes. and hydros. in their own table so I don't have to faff about around other buildings nearby.
- Making Tonight's additions key-based, so I don't have to walk large tables.
_________________
Nephylim wrote: But, an FA army in an FA environment just looks... right. Does anyone know how to use air transports? I cant get them to pick up troops.
|
|
| Top |
|
 |
|
Mithy
|
Posted: 25 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
BulletMagnet wrote: Done - sort of.
Put all structures on selection and order (why do I have them on order too? I'll have to select them first. lol) into a divided table like mex. markers, then check that region for a mex. that has the same coordinates are the mass marker.
Not going to upload it yet because I have to select buildings for this to work, and this also affects rebuilding too. How does it affect rebuilding? What I meant was to leave the rebuilding system as it was, and also route a copy of only mex/hydro entries into another table that's keyed only by coordinate hash. Add a new value to that structure's alive table with its key/hash in the other table, and use that to also remove that ref during releaseids. This should work flawlessly for any structure selected, without impacting rebuilding or requiring more distance checks, so long as you get the mouse coord hash in exactly the same way (e.g. math.floor) as the structure hash. BulletMagnet wrote: Three things I want to consider adding/changing before I'll release a new version; - Intercept construction orders and add things to the table of alive structures then, so players won't have to select buildings for them to work.
- Put mexes. and hydros. in their own table so I don't have to faff about around other buildings nearby.
- Making Tonight's additions key-based, so I don't have to walk large tables.
1) Good luck! I don't think there's any way to get the entityid of a buildmobile structure in the user layer other than by selecting it after it's totally finished building. 2) and 3) Oh. Yeah, this is what I was talking about above, soz. It would have been really cool if the UnitData table had actually contained the entityids of all units created. It would be incredibly trivial to make a sim-side mod that does this, and this is functionality that could be included in FuryoftheStars' bugfix mod, but then any UI mods dependent on that wouldn't work in a normal game.
|
|
| Top |
|
 |
|
Veqryn
|
Posted: 25 Aug, 2010
|
|
Joined: 07 Dec, 2007 Posts: 122
|
|
will this interfere with any other mods?
(like supreme economy?)
i noticed with 0.2 that supreme economy stopped showing my t3 mexes for some reason....
|
|
| Top |
|
 |
|
X-Cubed
|
Posted: 25 Aug, 2010
|
|
Joined: 24 Dec, 2008 Posts: 3184
|
|
It does. I believe there is a notice on the first post that says any other economy mods won't work with this.
_________________ My system: Intel Core i7-3770K @ 3.5 / 8 GB DDR3 RAM / EVGA GTX 670 FTW
"TA has been the role model of (sic) all Chris Taylor RTSes to come: always big, always complex, always innovative, always niche, and always in need of one more patch."
|
|
| Top |
|
 |
|
BulletMagnet
|
Posted: 25 Aug, 2010
|
|
Joined: 05 Oct, 2007 Posts: 16425 Location: camping near the biggest power-up
|
Mithy wrote: 2) and 3) Oh. Yeah, this is what I was talking about above, soz. LOL. Yeah, any structure that has been selected works fine, but I often don't select some structures (power for example). Those are the ones that won't rebuild, and the UserUnit has already been cleaned up so I couldn't check for position there. I just realised that OnCommandIssued has entity Id's given for orders like assist and repair, so I'll collect those too.
_________________
Nephylim wrote: But, an FA army in an FA environment just looks... right. Does anyone know how to use air transports? I cant get them to pick up troops.
|
|
| Top |
|
 |
|
BulletMagnet
|
Posted: 25 Aug, 2010
|
|
Joined: 05 Oct, 2007 Posts: 16425 Location: camping near the biggest power-up
|
http://code.google.com/p/healthandmana/ ... r%2003.zipSomething to play with. Also, in my sleep-deprived Wednesday-night (read:cheap alcohol night, lolol). I didn't realise that [3]'s additions were key-based. Whoops. Not going to implement [2] just yet; I want to see if it's actually worth the effort before proceeding. If anything is broken, I won't be home for the next 36 hours (but I will have Internet access) so fix any bugs yourself!
_________________
Nephylim wrote: But, an FA army in an FA environment just looks... right. Does anyone know how to use air transports? I cant get them to pick up troops.
|
|
| Top |
|
 |
|
Mr Pinguin
|
Posted: 29 Aug, 2010
|
|
Joined: 30 Aug, 2009 Posts: 2538
|
Wow, this is pretty cool. I don't really play FA anymore..  ..but some sort of 'smart' cursor functionality for building eco or rebuilding structures is definitely a great addition. That said, I think it would be better if you could set it so T2 engies defaulted to T2 Mexes and T3 engies went for T3. There are lots of situations where that is what you want to do (like rebuilding a destroyed Mex or quickly claiming Mex spots in a recently vacated/destroyed base). But it's fine either way. T1 mexes are the conservative choice, so that's a good place to start. They're just a big waste in the late game (if the area is secure) because you pay full price for the T2 and T3 upgrades..
_________________
|
|
| Top |
|
 |
|
Mithy
|
Posted: 29 Aug, 2010
|
|
Joined: 19 Jul, 2009 Posts: 2972
|
|
I already posted a code snippet halfway up the page that does just that (builds the highest tech available mex while alt is held). Also, for mex rebuilding, it could be very easily modified to prefer rebuilding over standard mex placement while holding ALT. It's a UI mod, and it's pretty well-commented, so there's nothing stopping anyone from making easy customizations like these.
|
|
| Top |
|
 |
|
Krapougnak
|
Posted: 13 Nov, 2010
|
|
Joined: 21 May, 2008 Posts: 706
|
Hi, I use OneClick Wonder 03 which I found a great addition to the game. I recently found though that this mod originates an error report in the log with the following message : Code: warning: Error running HandleEvent script in CScriptObject at 317c5900: ...iance\gamedata\lua.scd\lua\ui\controls\worldview.lua(653): attempt to call method `GetArmy' (a nil value) stack traceback: ...iance\gamedata\lua.scd\lua\ui\controls\worldview.lua(653): in function <...iance\gamedata\lua.scd\lua\ui\controls\worldview.lua:616>
No idea though how it affects the game outside from clogging the error log with error messages. Thought I had to report it.
|
|
| Top |
|
 |
 |
 |
|