D-Gun unstall widget - Page 2

D-Gun unstall widget

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Firstly:

Yes you can pause builders but you cant pause construction. If I pause a builder after a few seconds the building half done starts loosing health as if it has no builder. So its not true pause.

And this widget could help AIs in some mods by being converted into an AI unit only gadget.
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Post by LordMatt »

Masure wrote:
LordMatt wrote:Hmm dunno how I feel about this widget, but I'll try it out anyways. :P Does it stop things from building even if you have a lot of e though?
Yeah there is no smart E excess control.

I think D-Gun unstall is an emergency behaviour, no matter if you waste E for 10s.

That would be great to control E smarter but, harder to dev.
So, to clarify because I am potentially dumb: It stops all your building for 10s every time you dgun? That doesn't seem terribly useful to me.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post by lurker »

LordMatt wrote:So, to clarify because I am potentially dumb: It stops all your building for 10s every time you dgun? That doesn't seem terribly useful to me.
And turns off all metalmakers. And you can set it to something like 2-3 seconds.
Masure
Posts: 581
Joined: 30 Jan 2007, 15:23

Post by Masure »

You can turn this off by setting 0 to hysteresis parameter.
User avatar
1v0ry_k1ng
Posts: 4656
Joined: 10 Mar 2006, 10:24

Post by 1v0ry_k1ng »

LordMatt wrote: That doesn't seem terribly useful to me.
are you nuts?
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Post by LordMatt »

I don't really want all my construction stopped every time I dgun. I don't stall while dgunning very often (and often stop factories anyway if I'm in danger of stalling when I see the units coming).
Satirik
Lobby Developer
Posts: 1688
Joined: 16 Mar 2007, 18:27

Post by Satirik »

it stops construction if you don't have 600e to dgun ... and it stops 10s but if you get 600e before it reactivates the cons

when the dgun unstall detect a dgun it does the same as the metal makers but try to always have more than 600e and stop everything that use e
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Does it use hardcoded values?
Masure
Posts: 581
Joined: 30 Jan 2007, 15:23

Post by Masure »

No you can edit he lua script with the value you want (hysteresis, energyaim)
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

So it is hardcoded, it doesn't calculate the value.
Masure
Posts: 581
Joined: 30 Jan 2007, 15:23

Post by Masure »

D-Gun energy cost is a known value so there is no need to make it in a different way.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

So each mod uses 600 energy for their D-Gun, it they happen to have one?
Masure
Posts: 581
Joined: 30 Jan 2007, 15:23

Post by Masure »

I'll try to use the weapondef to dynamically read the dgun energy cost.
User avatar
FrOzEnTaCo
Posts: 81
Joined: 02 Jul 2008, 05:52

Re: D-Gun unstall widget

Post by FrOzEnTaCo »

lurker wrote:
Masure wrote:sets builders and factories to wait
You can do whatnow? :shock:

press the ''w'' key to make a factory or building ''wait''. it will pause everything. press the ''w'' key again to unpause it. if you hold shift, you will see a ''wait'' icon indicating that the building or builder is paused
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: D-Gun unstall widget

Post by Beherith »

I hate necroing threads, but currently the dgun unstall widget only works if you do a /luaui reload or an f11+remove+add widget. I was trying to find a workaround to this by making it look for the commander, but the widget still fails unless reloaded:

Code: Select all

	for _, comID in ipairs(coms) do
		Spring.Echo("parsing for dgun order")
		bDgunOrder = findCmdId(comID, CMD.DGUN)
		
		if bDgunOrder then
			break
		end 
	end
I have added in game (after 5 secs of ingame time) commander detection, then it manages to detect a comm, but the parsing line never gets called unless the widget is reloaded.
Masure
Posts: 581
Joined: 30 Jan 2007, 15:23

Re: D-Gun unstall widget

Post by Masure »

Hi Beherith,

I haven't used/modified this widget since its release (which version of Spring and BA > I don't know). Shame on me cause it wasn't far from being fully operational.

However I'm surprised cause as far as I remember, I never had issues with Com detection. The only issue I remember was the "de-waiting" of a unit type (metal maker I think).

Maybe the issue you're talking about appeared in our current releases of Spring and BA. I'll give it a look.

No matter you necroed that thread, It's cool indeed.
Masure
Posts: 581
Joined: 30 Jan 2007, 15:23

Re: D-Gun unstall widget

Post by Masure »

Code: Select all

function widget:Initialize()
  local _, _, spec = Spring.GetPlayerInfo(MyTeamId)
  if spec then
    widgetHandler:RemoveWidget()
    return false
  end
  local units = Spring.GetTeamUnits(MyTeamId)
  for _,UID in ipairs(units) do
  
    local UDID = Spring.GetUnitDefID(UID)
    local UD = UnitDefs[UDID]
	
	if (UD == nil) then break end
    if (UD.TEDClass == "COMMANDER") then
	  table.insert(coms,UID)
    end
  end

end


function widget:UnitCreated(unitID, unitDefID, unitTeam)
  local UD
  UD = UnitDefs[unitDefID]
  if (UD.TEDClass == "COMMANDER") then
	table.insert(coms,UID)
  end
end

function widget:UnitGiven(unitID, unitDefID, unitTeam)
  local UD
  UD = UnitDefs[unitDefID]
  if (UD.TEDClass == "COMMANDER") then
	table.insert(coms,UID)
  end
end

function widget:UnitDestroyed(unitID, unitDefID, unitTeam)
	for comIndex,comID in ipairs(coms) do
      if (unitID == comID) then
        table.remove(coms,comIndex)
        break
      end
    end
end

function widget:UnitTaken(unitID, unitDefID, unitTeam)
	for comIndex,comID in ipairs(coms) do
      if (unitID == comID) then
        table.remove(coms,comIndex)
        break
      end
    end
end
Here is the code that should keep the coms array updated. As I said, this worked at the time of the widget release. I won't have time this evening but I'll have some in the week end.

Stay tuned :D
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: D-Gun unstall widget

Post by REVENGE »

I used this widget for a little bit, but I have some ideas for seriously improving it.

Allow players to set a minimum energy level that economic units will simply not violate. I'll illustrate this with an example:

I drag a slider on my energy bar (similar to the one that autoshares) up to 500. As soon as my energy decreases to that point, my buildings and units currently under construction would "stall" like they do normally, but I will still have that 500 energy below my slider left untouched. That 500 e can only be accessed by weapons fire, and e will be prioritized to charge up to 500 before construction can resume.

So, it's sortof like setting a new bottom line for your stall point. Everything having to do with construction and metal maker usage will use that point as the bottom line, while your weapons and such can still dip into your reserves in order to fire. This way, even early ingame, I can ensure that my dgun will be able to fire at least once upon command, and I won't have to wait for energy to charge up.
Post Reply

Return to “Lua Scripts”