Hi
I've shortly downloaded the Bomber Control widget.
What it does is basicly turning the Weapon cooldown time to 0 as far as I can see.
Therefore the Bombers can turn instandly after they began to drop the first bomb. Which can be very useful. The Problem is, that a Bombers dropping Bombs while turning is drawing a circle with it's bombs.
There is an easy way of stopping them to do that: queue a Wait command after the attack command. 
Then almost all the Bombs dropp quite exacty on the place, where normally the second Bomb would have struk.
Now the question/request. How can I
1) Let the Bomber fly until it has dropped all it's Bombs and then turn After that?
2) Let the Bomber get an wait command for about 0,5/1 secs?
I know that there is no such thong as a wait command in lua. So it's a bit harder I guess. Since the "getTicked" and "os.clock" commands do not work out (for me at least)
Any Ideas?
			
			
									
						
										
						Request: Improval of the Bomber Widget
Moderator: Moderators
Re: Request: Improval of the Bomber Widget
Find this code in the widget: 
And change value to true instead of false.
			
			
									
						
										
						Code: Select all
	release_all = {
		name   = 'Wait for all bombs',
		desc   = '',
		type   = 'bool',
		value  = false
	}Re: Request: Improval of the Bomber Widget
edit:
I haven't found the code in my version. Where have you downloaded your file?
I got mine from the download widget in the springlobby.
date = "2010-02-04",
You are my hero
 
That helps a lot!
And if there was something like the waiting command it would be just perfect.
Because it inflicts a nice amount of extra "spot-damage" for a hurrican on a heavy Laser Tower ~1600 insted of ~1100 for example ~+50% is a nice thing to have
			
			
									
						
										
						I haven't found the code in my version. Where have you downloaded your file?
I got mine from the download widget in the springlobby.
date = "2010-02-04",
You are my hero
That helps a lot!
And if there was something like the waiting command it would be just perfect.
Because it inflicts a nice amount of extra "spot-damage" for a hurrican on a heavy Laser Tower ~1600 insted of ~1100 for example ~+50% is a nice thing to have
Re: Request: Improval of the Bomber Widget
I got mine from Mr Dizekat himself, probably about a year ago, can't remember if I've updated it since, but it still works fine for me. Here's the full thing:
			
			
									
						
										
						Code: Select all
function widget:GetInfo()
	return {
		name	= "Bomber control",
		desc	= "Makes bombers execute queue properly",
		author	= "dizekat",
		date	= "2010-02-04",
		license	= "GPL v2 or later",
		layer	= 5,
		enabled	= true
	}
end
options={
	hoverbomb = {
		name   = 'Hover the bomber above target',
		desc   = '',
		type   = 'bool',
		value  = true
	},
	release_all = {
		name   = 'Wait for all bombs',
		desc   = '',
		type   = 'bool',
		value  = false
	}
}
local bombers={armpnix=true, armcybr=true, corgripn=true, armthund=true, armsb=true, corhurc=true, corsb=true, corshad=true, cortitan=true}
local bomber_uds={}
local GetUnitWeaponState   = Spring.GetUnitWeaponState
local GetUnitDefID         = Spring.GetUnitDefID
local GiveOrderToUnit      = Spring.GiveOrderToUnit
local GetGameFrame         = Spring.GetGameFrame
local GetMyTeamID          = Spring.GetMyTeamID
local GetUnitTeam          = Spring.GetUnitTeam
local GetGameFrame         = Spring.GetGameFrame
local GetCommandQueue      = Spring.GetCommandQueue
local GetUnitStates        = Spring.GetUnitStates
local my_bombers={}
local function AddUnit(unit_id, unit_udid_)
	local unit_udid=unit_udid_
	if GetUnitTeam(unit_id)==GetMyTeamID() then --my unit
		if unit_udid==nil then
			unit_udid=GetUnitDefID(unit_id)
		end
		local ud=UnitDefs[unit_udid]
		if ud and bomber_uds[unit_udid] then
			if  ud.primaryWeapon then
				local _,reloaded_,reloadFrame = GetUnitWeaponState(unit_id,ud.primaryWeapon-1)		
				my_bombers[unit_id]={reloaded=reloaded_, reload_frame=0}
				--Spring.Echo("bomber added")
			end
		end
	end	
end
function widget:UnitCreated(unit_id, unit_udid, unit_tid)
	if unit_tid==Spring.GetMyTeamID() then
		AddUnit(unit_id,unit_udid)
	end
end
local function RemoveUnit(unit_id)
	my_bombers[unit_id]=nil
end
function widget:UnitDestroyed(unit_id, unit_udid, unit_tid)
	RemoveUnit(unit_id)
end
function widget:UnitGiven(unit_id, unit_udid, old_team, new_team)
	RemoveUnit(unit_id)
	if new_team==GetMyTeamID() then
		AddUnit(unit_id,unit_udid)
	end	
end
local function UpdateUnitsList()
	local my_team=GetMyTeamID()
	my_bombers={}
	for _,unit_id in ipairs(Spring.GetTeamUnits(my_team)) do
		AddUnit(unit_id,nil)
	end
end
function widget:Initialize()
	for i,ud in pairs(UnitDefs) do
		if bombers[ud.name] then
			bomber_uds[i]=ud
			--bomber_uds[i]=true
			ud.reloadTime    = 0
			ud.primaryWeapon = 0
			ud.shieldPower   = 0
			for i=1,ud.weapons.n do
				local WeaponDefID = ud.weapons[i].weaponDef;
				local WeaponDef   = WeaponDefs[ WeaponDefID ];
				if (WeaponDef.reload>ud.reloadTime) then
					ud.reloadTime    = WeaponDef.reload;
					ud.primaryWeapon = i;
				end
			end
		end
	end
	UpdateUnitsList()
end
local current_team=1234567
function widget:CommandNotify(id, params, options)
	local selected_units = Spring.GetSelectedUnits()
	for i,unit_id in ipairs(selected_units) do
		local bomber_data=my_bombers[unit_id]
		if bomber_data then
			bomber_data.on_reloaded=nil
			if bomber_data.must_clear_wait then
				bomber_data.must_clear_wait=nil
				GiveOrderToUnit(unit_id, CMD.WAIT,{},{})
			end
		end
	end
end
function widget:Update(dt)
	local hoverbomb=options.hoverbomb.value
	local gameFrame = GetGameFrame()
    if ((gameFrame%15)<1) then
		local my_team=GetMyTeamID()
		if my_team~=current_team then
			current_team=my_team
			UpdateUnitsList()
		end
    end
	if ((gameFrame%3)<1) then
		for bomber_id,bomber_data in pairs(my_bombers) do
		    local udid = GetUnitDefID(bomber_id)
			local ud = UnitDefs[udid or -1]
			if ud and ud.primaryWeapon then
				local _,reloaded,reload_frame,salvo_left = GetUnitWeaponState(bomber_id, ud.primaryWeapon-1)
				local vx,vy,vz=Spring.GetUnitVelocity(bomber_id)
				local speed_sq=vx*vx+vz*vz
				--Spring.Echo(salvo_left)
				bomber_data.did_shot=bomber_data.did_shot or (bomber_data.reloaded and not reloaded) or (bomber_data.reload_frame~=reload_frame)
				bomber_data.reloaded=reloaded
				bomber_data.reload_frame=reload_frame
				if reloaded and bomber_data.on_reloaded then
					GiveOrderToUnit(bomber_id, bomber_data.on_reloaded.id, bomber_data.on_reloaded.params, {})
				end
				if bomber_data.did_shot and (salvo_left==0 or (not options.release_all.value) or (speed_sq<9)) then
					bomber_data.did_shot=false
					local commands=GetCommandQueue(bomber_id)
					local set_wait=false
					if commands and commands[1] and commands[1].id==CMD.ATTACK then
						local got_next_orders=false
						for i=2,#commands do
							if commands[i].id ~= CMD.SET_WANTED_MAX_SPEED then
								got_next_orders=true
								break
							end
						end
						--Spring.Echo(CMD[commands[2].id])
						local states=GetUnitStates(bomber_id)
						if got_next_orders then
							bomber_data.on_reloaded=nil
							GiveOrderToUnit(bomber_id, CMD.REMOVE,{commands[1].tag},{})
							if states and (states['repeat']) then
								GiveOrderToUnit(bomber_id, commands[1].id,commands[1].params,{'shift'})
							end
						elseif hoverbomb and (not (states and (states['repeat']))) then
							bomber_data.on_reloaded=commands[1]
							set_wait=true
							bomber_data.must_clear_wait=true
						end
						--- two waits in sequence:
						--- workaround for mantis 1823
						if not set_wait then
							GiveOrderToUnit(bomber_id, CMD.WAIT,{},{})
						end
						GiveOrderToUnit(bomber_id, CMD.WAIT,{},{})
					end
				end
			end
		end
	end	
end
Re: Request: Improval of the Bomber Widget
It surely looks as if you have modified it since we both have the same " date   = "2010-02-04".
Thx alot
			
			
									
						
										
						Thx alot
Re: Request: Improval of the Bomber Widget
I were checking my widgets that got included in BA (making sure the included ones are the right versions)... this one, the version I have is indeed the one posted here, newer than the one included BA, it but doesn't seem to work correctly any more (need to do more testing).
Should I try to merge the changes or it doesn't really matter? The hoverbomb is a fairly silly one which tries to make the bomber hover above the target and bomb it like this. Wait for all bombs is potentially useful but not in all circumstances.
			
			
									
						
										
						Should I try to merge the changes or it doesn't really matter? The hoverbomb is a fairly silly one which tries to make the bomber hover above the target and bomb it like this. Wait for all bombs is potentially useful but not in all circumstances.
