play for me® widget!

play for me® widget!

Classic game design, maintained to please you...

Moderator: Content Developer

Post Reply
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

play for me® widget!

Post 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
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: play for me® widget!

Post by Jazcash »

Code: Select all

Spring.SendCommands({"say .D"})
Tare was a bot all along!
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: play for me® widget!

Post by Beherith »

ROFL!

Love the bobbel AI :)

Never thought I would live the day where I am bent over laughing at lua code...
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: play for me® widget!

Post 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.
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: play for me® widget!

Post by REVENGE »

Is this patented?
User avatar
Sabutai
Posts: 413
Joined: 18 Dec 2005, 05:55

Re: play for me® widget!

Post by Sabutai »

Is it good or bad to not find myself on this list? Well done!
User avatar
marciolino
Posts: 268
Joined: 06 Sep 2010, 22:59

Re: play for me® widget!

Post by marciolino »

Beherith wrote:ROFL!

Never thought I would live the day where I am bent over laughing at lua code...
That!
User avatar
jamerlan
Balanced Annihilation Developer
Posts: 683
Joined: 20 Oct 2009, 13:04

Re: play for me® widget!

Post 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
Last edited by jamerlan on 24 Jun 2013, 16:01, edited 1 time in total.
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: play for me® widget!

Post 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
klapmongool
Posts: 843
Joined: 13 Aug 2007, 13:19

Re: play for me® widget!

Post 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.
Post Reply

Return to “Balanced Annihilation”