Wyrmgus Merge

Post Reply
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Wyrmgus Merge

Post by Andrettin »

Now that Stratagus is on GitHub, I've begun to merge some elements from Wyrmgus into Stratagus.

Units can now have individual upgrades with Stratagus like they do with Wyrmgus :)
User avatar
Yukiko
Posts: 63
Joined: Sun May 24, 2015 6:52 pm

Re: Wyrmgus Merge

Post by Yukiko »

Why are you so sexy, Andrettin?
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Wyrmgus Merge

Post by Andrettin »

Yukiko wrote:Why are you so sexy, Andrettin?
Hehehe :P
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Wyrmgus Merge

Post by Andrettin »

A couple of new additions:

- It is now possible to specify different melee and ranged attack animations for a unit. Use "RangedAttack" to specify the ranged attack animation; if it is present, then "Attack" will be used for the melee attack
- The AI now uses for its attack waves and etc. only units which have their AI set to active; the editor now properly saves when a unit's AI is active or not; use SetUnitVariable through Lua to change whether a unit's AI is active or not; example:
SetUnitVariable(unit, "Active", false)
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Wyrmgus Merge

Post by Andrettin »

A unit type's Supply and Demand can now be changed through upgrades.
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Wyrmgus Merge

Post by Andrettin »

It is now possible to make map-specific changes to the stats and sounds of unit types. To make this feature available to the editor by right-clicking a unit-type, add the following Lua code (in a /menus/editor.lua file or wherever you see fit):

Code: Select all

--
--  Function to edit unit type properties in the editor
--
function EditUnitTypeProperties(unit_type)

	if (unit_type == "" or unit_type == nil) then
		return;
	end
	local menu = WarGameMenu(panel(5))
	local sizeX = 352
	local sizeY = 352

	menu:resize(sizeX, sizeY)
	menu:addLabel(_(GetUnitTypeName(unit_type)) .. " " .. _("Properties"), sizeX / 2, 11)

	menu:addFullButton(_("S~!tats"), "t", (sizeX / 2) - (224 / 2), sizeY - 40 - (36 * 6),
		function()
			EditUnitTypePropertiesStats(unit_type)
		end
	)
		
	menu:addFullButton(_("~!Resource Stats"), "r", (sizeX / 2) - (224 / 2), sizeY - 40 - (36 * 5),
		function()
			EditUnitTypePropertiesResourceStats(unit_type)
		end
	)
		
	menu:addFullButton(_("~!Sounds"), "s", (sizeX / 2) - (224 / 2), sizeY - 40 - (36 * 4),
		function()
			EditUnitTypePropertiesSounds(unit_type)
		end
	)
		
	menu:addFullButton(_("~!OK"), "o", (sizeX / 2) - (224 / 2), sizeY - 40 - (36 * 3),
		function()
			menu:stop()
		end
	)

	menu:run(false)
end

function EditUnitTypePropertiesStats(unit_type)

	if (unit_type == "" or unit_type == nil) then
		return;
	end
	local menu = WarGameMenu(panel(5))
	local sizeX = 352
	local sizeY = 352

	menu:resize(sizeX, sizeY)
	menu:addLabel(_(GetUnitTypeName(unit_type)) .. " " .. _("Properties"), sizeX / 2, 11)

	menu:addLabel(_("Hit Points:"), 10, 12 + 36 * 1, Fonts["game"], false)
	local hp_value = menu:addTextInputField(GetUnitTypeData(unit_type, "HitPoints"), (sizeX / 2) - 60 - 10, 11 + 36 * 1, 60)

	menu:addLabel(_("Speed:"), (sizeX / 2) + 10, 12 + 36 * 1, Fonts["game"], false)
	local speed_value = menu:addTextInputField(GetUnitTypeData(unit_type, "Speed"), sizeX - 60 - 10, 11 + 36 * 1, 60)

	menu:addLabel(_("B. Damage:"), 10, 12 + 36 * 2, Fonts["game"], false)
	local basic_damage_value = menu:addTextInputField(GetUnitTypeData(unit_type, "BasicDamage"), (sizeX / 2) - 60 - 10, 11 + 36 * 2, 60)

	menu:addLabel(_("Armor:"), (sizeX / 2) + 10, 12 + 36 * 2, Fonts["game"], false)
	local armor_value = menu:addTextInputField(GetUnitTypeData(unit_type, "Armor"), sizeX - 60 - 10, 11 + 36 * 2, 60)

	menu:addLabel(_("Range:"), 10, 12 + 36 * 3, Fonts["game"], false)
	local range_value = menu:addTextInputField(GetUnitTypeData(unit_type, "AttackRange"), (sizeX / 2) - 60 - 10, 11 + 36 * 4, 60)

	menu:addLabel(_("Sight:"), (sizeX / 2) + 10, 12 + 36 * 3, Fonts["game"], false)
	local sight_value = menu:addTextInputField(GetUnitTypeData(unit_type, "SightRange"), sizeX - 60 - 10, 11 + 36 * 4, 60)

	menu:addHalfButton(_("~!OK"), "o", 20 + 48, sizeY - 40,
		function()
			if (hp_value:getText() ~= GetUnitTypeData(unit_type, "HitPoints")) then
				SetMapStat(unit_type, "HitPoints", hp_value:getText(), "Value")
				SetMapStat(unit_type, "HitPoints", hp_value:getText(), "Max")
				SetMapStat(unit_type, "HitPoints", 1, "Enable")
			end
			if (basic_damage_value:getText() ~= GetUnitTypeData(unit_type, "BasicDamage")) then
				SetMapStat(unit_type, "BasicDamage", basic_damage_value:getText(), "Value")
				SetMapStat(unit_type, "BasicDamage", basic_damage_value:getText(), "Max")
				SetMapStat(unit_type, "BasicDamage", 1, "Enable")
			end
			if (armor_value:getText() ~= GetUnitTypeData(unit_type, "Armor")) then
				SetMapStat(unit_type, "Armor", armor_value:getText(), "Value")
				SetMapStat(unit_type, "Armor", armor_value:getText(), "Max")
				SetMapStat(unit_type, "Armor", 1, "Enable")
			end
			if (range_value:getText() ~= GetUnitTypeData(unit_type, "AttackRange")) then
				SetMapStat(unit_type, "AttackRange", range_value:getText(), "Value")
				SetMapStat(unit_type, "AttackRange", range_value:getText(), "Max")
				SetMapStat(unit_type, "AttackRange", 1, "Enable")
			end
			if (sight_value:getText() ~= GetUnitTypeData(unit_type, "SightRange")) then
				SetMapStat(unit_type, "SightRange", sight_value:getText(), "Value")
				SetMapStat(unit_type, "SightRange", sight_value:getText(), "Max")
				SetMapStat(unit_type, "SightRange", 1, "Enable")
			end
			if (speed_value:getText() ~= GetUnitTypeData(unit_type, "Speed")) then
				SetMapStat(unit_type, "Speed", speed_value:getText(), "Value")
				SetMapStat(unit_type, "Speed", speed_value:getText(), "Max")
				SetMapStat(unit_type, "Speed", 1, "Enable")
			end
			menu:stop()
		end
	)

	menu:addHalfButton(_("~!Cancel"), "c", 130 + 48, sizeY - 40,
		function() menu:stop() end)

	menu:run(false)
end

function EditUnitTypePropertiesResourceStats(unit_type)

	if (unit_type == "" or unit_type == nil) then
		return;
	end
	local menu = WarGameMenu(panel(5))
	local sizeX = 352
	local sizeY = 352

	menu:resize(sizeX, sizeY)
	menu:addLabel(_(GetUnitTypeName(unit_type)) .. " " .. _("Properties"), sizeX / 2, 11)

	menu:addLabel(_("Time Cost:"), 10, 12 + 36 * 1, Fonts["game"], false)
	local time_cost_value = menu:addTextInputField(GetUnitTypeData(unit_type, "Costs", "time"), (sizeX / 2) - 60 - 10, 11 + 36 * 1, 60)

	menu:addLabel(_("Gold Cost:"), (sizeX / 2) + 10, 12 + 36 * 1, Fonts["game"], false)
	local gold_cost_value = menu:addTextInputField(GetUnitTypeData(unit_type, "Costs", "gold"), sizeX - 60 - 10, 11 + 36 * 1, 60)

	menu:addLabel(_("Lumber Cost:"), 10, 12 + 36 * 2, Fonts["game"], false)
	local lumber_cost_value = menu:addTextInputField(GetUnitTypeData(unit_type, "Costs", "lumber"), (sizeX / 2) - 60 - 10, 11 + 36 * 2, 60)

	menu:addLabel(_("Gold Proc.:"), 10, 12 + 36 * 3, Fonts["game"], false)
	local gold_processing_value = menu:addTextInputField(GetUnitTypeData(unit_type, "ImproveProduction", "gold"), (sizeX / 2) - 60 - 10, 11 + 36 * 3, 60)

	menu:addLabel(_("Lumber Proc.:"), (sizeX / 2) + 10, 12 + 36 * 3, Fonts["game"], false)
	local lumber_processing_value = menu:addTextInputField(GetUnitTypeData(unit_type, "ImproveProduction", "lumber"),  sizeX - 60 - 10, 11 + 36 * 3, 60)

	menu:addHalfButton(_("~!OK"), "o", 20 + 48, sizeY - 40,
		function()
			if (time_cost_value:getText() ~= GetUnitTypeData(unit_type, "Costs", "time")) then
				SetMapStat(unit_type, "Costs", time_cost_value:getText(), "time")
			end
			if (gold_cost_value:getText() ~= GetUnitTypeData(unit_type, "Costs", "gold")) then
				SetMapStat(unit_type, "Costs", gold_cost_value:getText(), "gold")
			end
			if (lumber_cost_value:getText() ~= GetUnitTypeData(unit_type, "Costs", "lumber")) then
				SetMapStat(unit_type, "Costs", lumber_cost_value:getText(), "lumber")
			end
			if (gold_processing_value:getText() ~= GetUnitTypeData(unit_type, "ImproveProduction", "gold")) then
				SetMapStat(unit_type, "ImproveProduction", gold_processing_value:getText(), "gold")
			end
			if (lumber_processing_value:getText() ~= GetUnitTypeData(unit_type, "ImproveProduction", "lumber")) then
				SetMapStat(unit_type, "ImproveProduction", lumber_processing_value:getText(), "lumber")
			end
			menu:stop()
		end
	)

	menu:addHalfButton(_("~!Cancel"), "c", 130 + 48, sizeY - 40,
		function() menu:stop() end)

	menu:run(false)
end

function EditUnitTypePropertiesSounds(unit_type)

	if (unit_type == "" or unit_type == nil) then
		return;
	end
	local menu = WarGameMenu(panel(5))
	local sizeX = 352
	local sizeY = 352

	menu:resize(sizeX, sizeY)
	menu:addLabel(_(GetUnitTypeName(unit_type)) .. " " .. _("Properties"), sizeX / 2, 11)

	local sound_list = GetSounds()
	table.insert(sound_list, "") -- for instances where the unit does not have a sound of a particular type
  
	menu:addLabel(_("Selected:"), 10, 14 + 36 * 1, Fonts["game"], false)
	local selected_sound = menu:addDropDown(sound_list, (sizeX / 2) - 60 - 10, 11 + 36 * 1, function(dd) end)
	selected_sound:setSize(236, 20)
	selected_sound:setSelected(GetElementIndexFromArray(sound_list, GetUnitTypeData(unit_type, "Sounds", "selected")) - 1)
	
	menu:addLabel(_("Acknowledge:"), 10, 14 + 36 * 2, Fonts["game"], false)
	local acknowledge_sound = menu:addDropDown(sound_list, (sizeX / 2) - 60 - 10, 11 + 36 * 2, function(dd) end)
	acknowledge_sound:setSize(236, 20)
	acknowledge_sound:setSelected(GetElementIndexFromArray(sound_list, GetUnitTypeData(unit_type, "Sounds", "acknowledge")) - 1)
	
	menu:addLabel(_("Attack:"), 10, 14 + 36 * 3, Fonts["game"], false)
	local attack_sound = menu:addDropDown(sound_list, (sizeX / 2) - 60 - 10, 11 + 36 * 3, function(dd) end)
	attack_sound:setSize(236, 20)
	attack_sound:setSelected(GetElementIndexFromArray(sound_list, GetUnitTypeData(unit_type, "Sounds", "attack")) - 1)
	
	menu:addLabel(_("Ready:"), 10, 14 + 36 * 4, Fonts["game"], false)
	local ready_sound = menu:addDropDown(sound_list, (sizeX / 2) - 60 - 10, 11 + 36 * 4, function(dd) end)
	ready_sound:setSize(236, 20)
	ready_sound:setSelected(GetElementIndexFromArray(sound_list, GetUnitTypeData(unit_type, "Sounds", "ready")) - 1)
	
	menu:addLabel(_("Help:"), 10, 14 + 36 * 5, Fonts["game"], false)
	local help_sound = menu:addDropDown(sound_list, (sizeX / 2) - 60 - 10, 11 + 36 * 5, function(dd) end)
	help_sound:setSize(236, 20)
	help_sound:setSelected(GetElementIndexFromArray(sound_list, GetUnitTypeData(unit_type, "Sounds", "help")) - 1)
	
	menu:addLabel(_("Dead:"), 10, 14 + 36 * 6, Fonts["game"], false)
	local dead_sound = menu:addDropDown(sound_list, (sizeX / 2) - 60 - 10, 11 + 36 * 6, function(dd) end)
	dead_sound:setSize(236, 20)
	dead_sound:setSelected(GetElementIndexFromArray(sound_list, GetUnitTypeData(unit_type, "Sounds", "dead")) - 1)
	
	menu:addHalfButton("~!OK", "o", 20 + 48, sizeY - 40,
		function()
			if (sound_list[selected_sound:getSelected() + 1] ~= GetUnitTypeData(unit_type, "Sounds", "selected")) then
				SetMapSound(unit_type, sound_list[selected_sound:getSelected() + 1], "selected")
			end
			if (sound_list[acknowledge_sound:getSelected() + 1] ~= GetUnitTypeData(unit_type, "Sounds", "acknowledge")) then
				SetMapSound(unit_type, sound_list[acknowledge_sound:getSelected() + 1], "acknowledge")
			end
			if (sound_list[attack_sound:getSelected() + 1] ~= GetUnitTypeData(unit_type, "Sounds", "attack")) then
				SetMapSound(unit_type, sound_list[attack_sound:getSelected() + 1], "attack")
			end
			if (sound_list[ready_sound:getSelected() + 1] ~= GetUnitTypeData(unit_type, "Sounds", "ready")) then
				SetMapSound(unit_type, sound_list[ready_sound:getSelected() + 1], "ready")
			end
			if (sound_list[help_sound:getSelected() + 1] ~= GetUnitTypeData(unit_type, "Sounds", "help")) then
				SetMapSound(unit_type, sound_list[help_sound:getSelected() + 1], "help")
			end
			if (sound_list[dead_sound:getSelected() + 1] ~= GetUnitTypeData(unit_type, "Sounds", "dead")) then
				SetMapSound(unit_type, sound_list[dead_sound:getSelected() + 1], "dead")
			end
			menu:stop()
		end
	)

	menu:addHalfButton(_("~!Cancel"), "c", 130 + 48, sizeY - 40,
		function() menu:stop() end)

	menu:run(false)
end
The editor interface doesn't include all possible variables to be edited, but you can add the ones you want relatively easily based on this Lua code.
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Wyrmgus Merge

Post by Andrettin »

I've now added support for autosaving from Wyrmguns into Stratagus. By default the game autosaves a game every 5 minutes (9000 cycles).
User avatar
Big Daddy
Posts: 118
Joined: Sun Jan 08, 2012 11:23 pm

Re: Wyrmgus Merge

Post by Big Daddy »

Good work old chum!
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Wyrmgus Merge

Post by Andrettin »

Big Daddy wrote:Good work old chum!
Thank you!
Post Reply