Building Animation

Building Animation

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

Moderator: Moderators

Post Reply
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Building Animation

Post by kalda341 »

How do you get one of those nice building animations they have in complete annihilation where the verticies appear in blue then the textures slowly come in?
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Building Animation

Post by oksnoop2 »

If i understand you right, the engine does that by default.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Building Animation

Post by knorke »

yes, that is the default building animation.
that can be changed though (via Lua scripting) atm I do not remember any game that does it...
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Building Animation

Post by kalda341 »

oksnoop2 wrote:If i understand you right, the engine does that by default.
It did do it by default, but has stopped.
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Building Animation

Post by oksnoop2 »

That's odd. Can I have a screenshot?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Building Animation

Post by AF »

Check your unitdefs, there are tags that disable the default animation, you may have set them by accident
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Building Animation

Post by kalda341 »

The unitdef is:

Code: Select all

local unitName = "mushroom1"

local unitDef =
{
-- Internal settings
	BuildPic = "infantry.pcx",
	Category = "BUILDING NOTSCOUT NOTHEAVY NOTAIR NOTEPIC NOTSHIP NOTSTEALTHY ALL",
	ObjectName = "mushroom 1.s3o",
	name = "Infantry Shroom",
	Side = "MACROBES",
	TEDClass = "PLANT",
	UnitName = "Infantry Shroom",
	script = "mushroom1script.lua",
	
-- Unit limitations and properties
	ActivateWhenBuilt = true,
	BuildTime = 1000,
    commander = true,
	Description = "Produces infantry",
	MaxDamage = 1500,
	Name = "Base",
	RadarDistance = 0,
	SightDistance = 400,
	SoundCategory = "BUILDING",
	Upright = 1,
	WorkerTime = 80,
	levelground = 1,
	
-- Energy and metal related
	BuildCostEnergy = 500,
	EnergyStorage = 0,
	EnergyUse = 0,
	MetalStorage = 0,
	EnergyMake = 0, 
	MakesMetal = 0, 
	MetalMake = 0,
	
-- Pathfinding and related
	FootprintX = 3,
	FootprintZ = 3,
	MaxSlope = 10,
	MaxWaterDepth = 0,
	YardMap = "cccc cccc cccc cccc",

-- Abilities
	Builder = 1,
    Reclaimable = 0,
	ShowNanoSpray = 1,
	CanBeAssisted = 0,
	buildoptions = 
	{
		"tank",
		"builder",
		"sphericalvirus",
	},
	
-- Abilities new to Spring
	
-- Weapons and related

	ExplodeAs = "BUILDINGLARGEDEATH",
	SelfDestructAs = "BUILDINGLARGEDEATH",
	SelfDestructCountdown = 5,
}

return lowerkeys({ [unitName] = unitDef })
Attachments
bad unitdef.jpg
(227.89 KiB) Downloaded 3 times
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Building Animation

Post by CarRepairer »

Also paste your gamedata/unitdefs_post.lua file here. It might be in there.
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Building Animation

Post by kalda341 »

CarRepairer wrote:Also paste your gamedata/unitdefs_post.lua file here. It might be in there.
I don't have a unitdefs_post.lua.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Building Animation

Post by knorke »

the teal selection is not the engines default.
default is a green square.
so it might be some other widget or gadget?
(probally not the selectin circle widget, but what else are you running)
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Building Animation

Post by kalda341 »

knorke wrote:the teal selection is not the engines default.
default is a green square.
so it might be some other widget or gadget?
(probally not the selectin circle widget, but what else are you running)
I temporarily removed all widgets, still no building animation.
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Building Animation

Post by SinbadEV »

I think you need to set this unitdef to true

showNanoFrame(false)
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Building Animation

Post by FLOZi »

SinbadEV wrote:I think you need to set this unitdef to true

showNanoFrame(false)
https://github.com/spring/spring/blob/0 ... f.cpp#L465

showNanoFrame defaults to true. (It's only initialized to false)
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Building Animation

Post by kalda341 »

SinbadEV wrote:I think you need to set this unitdef to true

showNanoFrame(false)
Adding

Code: Select all

	showNanoFrame = 1,
Doesn't make it appear.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Building Animation

Post by FLOZi »

Protip: showNanoFrame is a boolean. But it defaults to true anyway, as I already said.
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Building Animation

Post by kalda341 »

When I add:

Code: Select all

	showNanoFrame = false,
The unit looks completed straight away, so this is not the problem.
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Building Animation

Post by kalda341 »

So it's not this variable causing the problem.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Building Animation

Post by FLOZi »

You say you disabled all the widgets and still have the same problem, what gadgets do you have?
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Building Animation

Post by kalda341 »

I have disabled all but game_spawn.lua which contains this:

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--  file:    game_spawn.lua
--  brief:   spawns start unit and sets storage levels
--  author:  Tobi Vollebregt
--
--  Copyright (C) 2010.
--  Licensed under the terms of the GNU GPL, v2 or later.
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function gadget:GetInfo()
	return {
		name      = "Spawn",
		desc      = "spawns start unit and sets storage levels",
		author    = "Tobi Vollebregt",
		date      = "January, 2010",
		license   = "GNU GPL, v2 or later",
		layer     = 0,
		enabled   = true  --  loaded by default?
	}
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

-- synced only
if (not gadgetHandler:IsSyncedCode()) then
	return false
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local modOptions = Spring.GetModOptions()


local function GetStartUnit(teamID)
	-- get the team startup info
	local side = select(5, Spring.GetTeamInfo(teamID))
	local startUnit
	if (side == "") then
		-- startscript didn't specify a side for this team
		local sidedata = Spring.GetSideData()
		if (sidedata and #sidedata > 0) then
			startUnit = sidedata[1 + teamID % #sidedata].startUnit
		end
	else
		startUnit = Spring.GetSideData(side)
	end
	return startUnit
end

local function SpawnStartUnit(teamID)
	local startUnit = GetStartUnit(teamID)
	if (startUnit and startUnit ~= "") then
		-- spawn the specified start unit
		local x,y,z = Spring.GetTeamStartPosition(teamID)
		-- snap to 16x16 grid
		x, z = 16*math.floor((x+8)/16), 16*math.floor((z+8)/16)
		y = Spring.GetGroundHeight(x, z)
		-- facing toward map center
		local facing=math.abs(Game.mapSizeX/2 - x) > math.abs(Game.mapSizeZ/2 - z)
			and ((x>Game.mapSizeX/2) and "west" or "east")
			or ((z>Game.mapSizeZ/2) and "north" or "south")
		local unitID = Spring.CreateUnit(startUnit, x, y, z, facing, teamID)
	end

	-- set start resources, either from mod options or custom team keys
	local teamOptions = select(7, Spring.GetTeamInfo(teamID))
	local m = teamOptions.startmetal  or modOptions.startmetal  or 1000
	local e = teamOptions.startenergy or modOptions.startenergy or 1000

	-- using SetTeamResource to get rid of any existing resource without affecting stats
	-- using AddTeamResource to add starting resource and counting it as income
	if (m and tonumber(m) ~= 0) then
		-- remove the pre-existing storage
		--   must be done after the start unit is spawned,
		--   otherwise the starting resources are lost!
		Spring.SetTeamResource(teamID, "ms", tonumber(m))
		Spring.SetTeamResource(teamID, "m", 0)
		Spring.AddTeamResource(teamID, "m", tonumber(m))
	end
	if (e and tonumber(e) ~= 0) then
		-- remove the pre-existing storage
		--   must be done after the start unit is spawned,
		--   otherwise the starting resources are lost!
		Spring.SetTeamResource(teamID, "es", tonumber(e))
		Spring.SetTeamResource(teamID, "e", 0)
		Spring.AddTeamResource(teamID, "e", tonumber(e))
	end
end


function gadget:GameStart()
	-- only activate if engine didn't already spawn units (compatibility)
	if (#Spring.GetAllUnits() > 0) then
		return
	end

	-- spawn start units
	local gaiaTeamID = Spring.GetGaiaTeamID()
	local teams = Spring.GetTeamList()
	for i = 1,#teams do
		local teamID = teams[i]
		-- don't spawn a start unit for the Gaia team
		if (teamID ~= gaiaTeamID) then
			SpawnStartUnit(teamID)
		end
	end
end
Post Reply

Return to “Lua Scripts”