Page 1 of 1

play for me® widget!

Posted: 15 Jun 2013, 00:29
by BrainDamage
people always complained widgets could replace a player, and i'm going to demonstrate it's possible, the following widget reimplements the playing style of various players, callable with some chat commands
WARNING: this widget is completely untested, it won't necessarily work, use at your own risk

Code: Select all

function widget:GetInfo()
  return {
    name      = "commands",
    desc      = "Adds useful commands for play",
    author    = "BD",
    date      = "-",
    license   = "WTFPL",
    layer     = 0,
    enabled   = true  --  loaded by default?
  }
end

--ctrl+a ctrl+d
function JeenodeCmd()
	for _,unitID in ipairs(Spring.GetAllUnits()) do
		Spring.GiveOrderToUnit(unitID, CMD.SELFD, {}, {})
	end
end

--kamikaze all units to first found enemy com
function MurtagonCmd()
	local coms = {[UnitDefNames.armcom.id]=true,[UnitDefNames.corcom.id]=true}
	local enemycom
	for _,unitID in ipairs(Spring.GetAllUnits()) do
		if not Spring.IsUnitAllied(unitID) and coms[Spring.GetUnitDefID(unitID)] then 
			enemycom = unitID
			break
		end
	end
	if enemycom then
		for _,unitID in ipairs(Spring.GetAllUnits()) do
			Spring.GiveOrderToUnit(unitID, CMD.ATTACK, {enemycom}, {})
		end
	end
end
 
--spam whole map with fus
function FightlessCmd()
	for _,unitDefID in ipairs({UnitDefNames.aafus.id,UnitDefNames.cafus.id,UnitDefNames.armfus.id,UnitDefNames.corfus.id}) do
		for _,unitID in ipairs(Spring.GetAllUnits()) do
			for x=0, Game.mapSizeX, UnitDefs[unitDefID].xsize do
				for z=0, Game.mapSizeZ, UnitDefs[unitDefID].zsize do
					Spring.GiveOrderToUnit(unitID, -unitDefID,{x,0,z}, {})
				end
			end
		end
	end
end

--all in guard to air lab with fighters on repeat
function FlorisCmd()
	local airlabs = {UnitDefNames.armaap.id,UnitDefNames.armap.id,UnitDefNames.coraap.id,UnitDefNames.corap.id}
	local airlab
	for _,unitID in ipairs(Spring.GetAllUnits()) do
		if Spring.IsUnitAllied(unitID) and airlabs[Spring.GetUnitDefID(unitID)] then 
			airlab = unitID
			break
		end
	end
	if airlab then
		for _,unitID in ipairs(Spring.GetAllUnits()) do
			Spring.GiveOrderToUnit(unitID, CMD.GUARD, {airlab}, {})
		end
		Spring.GiveOrderToUnit(airlab,-UnitDefNames.corveng.id, {}, {})
		Spring.GiveOrderToUnit(airlab, -UnitDefNames.armfig.id, {}, {})
		Spring.GiveOrderToUnit(airlab, -UnitDefNames.armhawk.id, {}, {})
		Spring.GiveOrderToUnit(airlab, -UnitDefNames.corvamp.id, {}, {})
		Spring.GiveOrderToUnit(airlab,CMD.REPEAT,{1},{})
	end
end


--split map in half with HLT wall
function BobbelCmd()
	for _,unitDefID in ipairs({UnitDefNames.corgaat.id,UnitDefNames.armhlt.id}) do
		for _,unitID in ipairs(Spring.GetAllUnits()) do
			for x=0, Game.mapSizeX, UnitDefs[unitDefID].xsize do
				Spring.GiveOrderToUnit(unitID, -unitDefID,{x,0,Game.mapSizeZ/2}, {})
			end
			for z=0, Game.mapSizeZ, UnitDefs[unitDefID].zsize do
				Spring.GiveOrderToUnit(unitID, -unitDefID,{Game.mapSizeX/2,0,z}, {})
			end
		end
	end
end

--combomb first enemy com
function GasmaskCmd()
	local coms = {[UnitDefNames.armcom.id]=true,[UnitDefNames.corcom.id]=true}
	local enemycom
	local allycom
	for _,unitID in ipairs(Spring.GetAllUnits()) do
		if not Spring.IsUnitAllied(unitID) and coms[Spring.GetUnitDefID(unitID)] then 
			enemycom = unitID
		end
		if Spring.IsUnitAllied(unitID) and coms[Spring.GetUnitDefID(unitID)] then
			allycom = unitID 
		end
	end
	if enemycom and allycom then
		Spring.GiveOrderToUnit(allycom, CMD.MANUALFIRE, {enemycom}, {})
	end
end

--omg .D
function TarellinaCmd()
	for i=1,10 do
		local rand = math.rand()
		if rand < 0.3 then
			Spring.SendCommands({"say omg"})
		elseif rand > 0.3 and rand < 0.6 then
			Spring.SendCommands({"say .D"})
		else
			Spring.SendCommands({"say omg .D"})
		end
	end
end

--this command does absolutely nothing
function 7777zCmd()
end


--random commands to random units!
function AgilityCmd()
	for _,unitID in ipairs(Spring.GetAllUnits()) do
		Spring.GiveOrderToUnit(unitID, math.rand()*800-400, {math.rand()*Game.mapSizeZ,0,math.rand()*Game.mapSizeZ}, {})
	end
end


function widget:Initialize()
	widgetHandler:AddAction("jeenode",  JeenodeCmd)
	widgetHandler:AddAction("murtagon",  MurtagonCmd)
	widgetHandler:AddAction("fightless",  FightlessCmd)
	widgetHandler:AddAction("floris",  FlorisCmd)
	widgetHandler:AddAction("bobbel",  BobbelCmd)
	widgetHandler:AddAction("gasmask",  GasmaskCmd)
	widgetHandler:AddAction("tarellina",  TarellinaCmd)
	widgetHandler:AddAction("7777z",  7777zCmd)
	widgetHandler:AddAction("agility",  AgilityCmd)
end

Re: play for me® widget!

Posted: 15 Jun 2013, 00:35
by Jazcash

Code: Select all

Spring.SendCommands({"say .D"})
Tare was a bot all along!

Re: play for me® widget!

Posted: 15 Jun 2013, 00:55
by Beherith
ROFL!

Love the bobbel AI :)

Never thought I would live the day where I am bent over laughing at lua code...

Re: play for me® widget!

Posted: 15 Jun 2013, 01:50
by Jools
Very funny indeed. Can you make a command that self-d:s all your units when 10% of them are lost? Actually not self-d either, but just resigns to abandonded units.

Re: play for me® widget!

Posted: 18 Jun 2013, 10:53
by REVENGE
Is this patented?

Re: play for me® widget!

Posted: 23 Jun 2013, 12:22
by Sabutai
Is it good or bad to not find myself on this list? Well done!

Re: play for me® widget!

Posted: 24 Jun 2013, 11:10
by marciolino
Beherith wrote:ROFL!

Never thought I would live the day where I am bent over laughing at lua code...
That!

Re: play for me® widget!

Posted: 24 Jun 2013, 12:13
by jamerlan
I am not sure that gasmask combombs so often.

Just for fun:
Pako style: I was just the best. Others failed! My team sux!!
rzbx style: damn @#$!@#$ $!@#$#!@ !@$!@#$! not lucky @#$@#$
masu style: choose bottom back spot, build some samsons, self-d com, spam 2 core afus then spam air
xanax style: self-d com(at front), build arm t2 kbot lab, spam fidos
Tarelina style: start at north, tech to nuke
Paste style: start air at north, comdrop at enemy techers
Bunny style: start air, ask: how to rotate buildings, fly to enemy and try to dgun enemy lab, gift enemy 2500m

Re: play for me® widget!

Posted: 24 Jun 2013, 15:28
by Jazcash
jamerlan wrote: Pako style: I was just the best. Others failed! My team sux!!
xanax style: self-d com(at front), build arm t2 kbot lab, spam fidos
lol'd irl

Re: play for me® widget!

Posted: 24 Jun 2013, 21:04
by klapmongool
jamerlan wrote:I am not sure that gasmask combombs so often.

Just for fun:
Pako style: I was just the best. Others failed! My team sux!!
rzbx style: damn @#$!@#$ $!@#$#!@ !@$!@#$! not lucky @#$@#$
masu style: choose bottom back spot, build some samsons, self-d com, spam 2 core afus then spam air
xanax style: self-d com(at front), build arm t2 kbot lab, spam fidos
Tarelina style: start at north, tech to nuke
Paste style: start air at north, comdrop at enemy techers
Bunny style: start air, ask: how to rotate buildings, fly to enemy and try to dgun enemy lab, gift enemy 2500m
Pretty close.

But the sad thing about this post is that it implies DSD.