Skip to content

Commit

Permalink
Added Legion Fortifier
Browse files Browse the repository at this point in the history
  • Loading branch information
EnderRobo committed Dec 4, 2024
1 parent 29e13da commit 7f04e94
Show file tree
Hide file tree
Showing 20 changed files with 567 additions and 3 deletions.
1 change: 1 addition & 0 deletions gamedata/armordefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ local armorDefs = {
"legstone",
"dice",
"chip",
"legmohoconin",
},
crawlingbombs = {
"armvader",
Expand Down
6 changes: 6 additions & 0 deletions language/en/units.json
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,9 @@
"legmstor": "Metal Storage",
"legmoho": "Advanced Metal Extractor",
"legmohobp": "Fortifier",
"legmohocon": "Advanced Metal Fortifier",
"legmohoconct": "Advanced Metal Fortifier",
"legmohoconin": "Advanced Metal Fortifier",
"legmg": "Cacophony",
"legmh": "Salacia",
"legmineb": "Harbinger",
Expand Down Expand Up @@ -1611,6 +1614,9 @@
"legmstor": "Increases Metal Storage (3000)",
"legmoho": "Advanced Metal Extractor / Storage",
"legmohobp": "Advanced Metal Extractor / Build Drone Pad",
"legmohocon": "Advanced Metal Extractor and Construction Turret",
"legmohoconct": "Advanced Metal Extractor and Construction Turret",
"legmohoconin": "You aren't supposed to see this one",
"legmg": "Heavy Land & Air Defense",
"legmh": "Hovercraft Rocket Launcher",
"legmineb": "Deploys Clusters of Light Mines onto Target Area",
Expand Down
4 changes: 4 additions & 0 deletions luarules/configs/collisionvolumes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ pieceCollisionVolume['leginfestor'] = {
['0']={38,23,45,0,7,0,1,1},
['16']={12,10,20,2,0,1,1,2},
}
pieceCollisionVolume['legmohoconct'] = {
['0']={70,30,70,0,-3,0,1,1},
['1']={21,16,30,0,-3,-1,2,1},
}

for name, v in pairs(pieceCollisionVolume) do
for udid, ud in pairs(UnitDefs) do
Expand Down
100 changes: 100 additions & 0 deletions luarules/gadgets/unit_attached_con_turret_mex.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
function gadget:GetInfo()
return {
name = 'Legion Con Turret Metal Extractor',
desc = 'Allows the mex to function as a con turret by replacing it with a fake mex with a con turret attached',
author = 'EnderRobo',
version = 'v1',
date = 'September 2024',
license = 'GNU GPL, v2 or later',
layer = 12,
enabled = true
}
end

if not gadgetHandler:IsSyncedCode() then
return false
end

local SpGetUnitPosition = Spring.GetUnitPosition
local SpGetUnitDefID = Spring.GetUnitDefID
local SpGetUnitAllyTeam = Spring.GetUnitAllyTeam
local SpGetUnitHealth = Spring.GetUnitHealth
local SpGetUnitBuildFacing = Spring.GetUnitBuildFacing
local SpGetUnitIsDead = Spring.GetUnitIsDead
local SpGetUnitStates = Spring.GetUnitStates

function gadget:UnitFinished(unitID, unitDefID, unitTeam)

local unitDef = UnitDefs[unitDefID]
if unitDef.name == "legmohocon" then -- checks for mex
local nano_id
local imex_id
local health
local facing
local xx,yy,zz
xx,yy,zz = SpGetUnitPosition(unitID)
facing = SpGetUnitBuildFacing(unitID)
health = SpGetUnitHealth(unitID) -- saves location, rotation and health of mex
imex_id = Spring.CreateUnit("legmohoconin",xx,yy,zz,facing,Spring.GetUnitTeam(unitID) ) -- creates imex on mex
if not imex_id then
return
end
Spring.SetUnitBlocking(imex_id, true, false, false) -- makes imex non interactive
Spring.SetUnitNoSelect(imex_id,true)
nano_id = Spring.CreateUnit("legmohoconct",xx,yy,zz,facing,Spring.GetUnitTeam(imex_id) ) -- creates con on imex
if not nano_id then
return
end
Spring.UnitAttach(imex_id,nano_id,6) -- attaches con to imex
Spring.SetUnitHealth(nano_id, health) -- sets con health to be the same as mex
Spring.DestroyUnit(unitID, false, true) -- removes mex
end
end

function gadget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam)

local unitDef = UnitDefs[unitDefID]
if unitDef.name == "legmohoconct" then
local health
local maxHealth
health, maxHealth = SpGetUnitHealth(unitID)
if not (health > 0) then -- when damaged and killed
local xx,yy,zz
local facing
xx,yy,zz = SpGetUnitPosition(unitID)
facing = SpGetUnitBuildFacing(unitID)
if damage < (maxHealth / 3) then -- if damage is <33% of max health spawn wreck
local featureID
featureID = Spring.CreateFeature("legmohocon_dead", xx, yy, zz, facing, unitTeam)
Spring.SetFeatureResurrect(featureID, "legmohocon", facing, 0)
end
if damage > (maxHealth / 3) and damage < ((maxHealth / 3) * 2) then -- if damage is >33% and <66% of max health spawn heap
Spring.CreateFeature("legmohocon_heap", xx, yy, zz, facing, unitTeam)
end
end
end
end

function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam) -- if con dies remove imex

local unitDef = UnitDefs[unitDefID]
if unitDef.name == "legmohoconct" then
Spring.DestroyUnit(Spring.GetUnitTransporter(unitID), false, true)
end
end



--[[
mex built done
place imex on mex done
attach con turret to imex done
copy mex health to con Turret done
remove mex done
on turret death remove imex done
make it spawn wrecks and heaps done
To do:
if damaged during construction cons continue to repair
on off switch for mex via turret
make turret display metal income and energy upkeep of mex
1 change: 1 addition & 0 deletions luaui/configs/buildmenu_sorting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ local unitOrderTable = {
['legmoho'] = 100260,
['armshockwave'] = 100290,
['cormexp'] = 100300,
['legmohocon'] = 100310,

--ECO ENERGY CONVERTERS
['armmakr'] = 100500,
Expand Down
Binary file added objects3d/Units/legmohocon.s3o
Binary file not shown.
Binary file added objects3d/Units/legmohocon_dead.s3o
Binary file not shown.
8 changes: 8 additions & 0 deletions scripts/Units/legmohocon.bos
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#include "../recoil_common_includes.h"

piece base, aim, nano1, nano2, rotor, attach;

#define BASEPIECE base
#define MAXTILT 0
#include "../unit_hitbyweaponid_and_smoke.h"
Binary file added scripts/Units/legmohocon.cob
Binary file not shown.
109 changes: 109 additions & 0 deletions scripts/Units/legmohoconct.bos
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

#include "sfxtype.h"
#include "exptype.h"

piece base, aim, nano1, nano2, rotor, attach;

static-var Stunned, spray, BuildHeading;

#define BASEPIECE base
#define HITSPEED <55.0>
//how 'heavy' the unit is, on a scale of 1-10
#define UNITSIZE 2
#define MAXTILT 100

#include "unit_hitbyweaponid_and_smoke.h"

static-var Stunned;
ExecuteRestoreAfterDelay()
{
if (Stunned) {
return (1);
}
turn aim to y-axis <0.000000> speed <100.000000>;
}

RestoreAfterDelay()
{
sleep 5000;
start-script ExecuteRestoreAfterDelay();
}

Create()
{
hide nano1;
hide nano2;
BuildHeading = 0;
spin rotor around y-axis speed <180> accelerate <0.5>;
return (0);
}

SetStunned(State)
{
Stunned = State;
if (!Stunned) {
start-script ExecuteRestoreAfterDelay();
}
}

StartBuilding(heading)
{
signal 1; // stop the restore delay stuff
BuildHeading = heading;
show nano1;
show nano2;
turn aim to y-axis BuildHeading speed <320.000000>;
wait-for-turn aim around y-axis;
set INBUILDSTANCE to 1;
}

StopBuilding()
{
hide nano1;
hide nano2;
set INBUILDSTANCE to 0;
signal 1; // we must signal here, instead of in RestoreAfterDelay(), as that only gets called 1 frame later, so startbuilding wont terminate it
set-signal-mask 1; // make child threads inherit signal mask of 1
start-script RestoreAfterDelay();
}

QueryNanoPiece(piecenum)
{
spray = (spray + 1) % 2;
piecenum = nano1 + spray;
}

SweetSpot(piecenum)
{
piecenum = aim;
}


Killed(severity, corpsetype)
{
if( severity <= 25 )
{
corpsetype = 1 ;
explode base type BITMAPONLY | NOHEATCLOUD;
explode rotor type FIRE | SMOKE | FALL | BITMAPONLY | NOHEATCLOUD;
return(corpsetype);
}
if( severity <= 50 )
{
corpsetype = 2 ;
explode base type BITMAPONLY | NOHEATCLOUD;
explode rotor type FIRE | SMOKE | FALL | NOHEATCLOUD;
return(corpsetype);
}
if( severity <= 99 )
{
corpsetype = 3 ;
explode base type BITMAPONLY | NOHEATCLOUD;
explode rotor type FIRE | SMOKE | FALL | NOHEATCLOUD;
return(corpsetype);
}
corpsetype = 3 ;
explode base type BITMAPONLY | NOHEATCLOUD;
explode rotor type EXPLODE_ON_HIT | FIRE | FALL | NOHEATCLOUD;
return corpsetype;
}
Binary file added scripts/Units/legmohoconct.cob
Binary file not shown.
58 changes: 58 additions & 0 deletions scripts/Units/legmohoconin.bos
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

#include "../recoil_common_includes.h"

piece base, aim, nano1, nano2, rotor, attach;

Create()
{
hide base;
hide aim;
hide nano1;
hide nano2;
hide rotor;
hide attach;
return (0);
}


#define BASEPIECE base
#define MAXTILT 0
#include "../unit_hitbyweaponid_and_smoke.h"

Activate()
{
}

Deactivate()
{
}


Killed(severity, corpsetype)
{
if( severity <= 25 )
{
corpsetype = 1 ;
explode base type BITMAPONLY | NOHEATCLOUD;
explode rotor type FIRE | SMOKE | FALL | BITMAPONLY | NOHEATCLOUD;
return(corpsetype);
}
if( severity <= 50 )
{
corpsetype = 2 ;
explode base type BITMAPONLY | NOHEATCLOUD;
explode rotor type FIRE | SMOKE | FALL | NOHEATCLOUD;
return(corpsetype);
}
if( severity <= 99 )
{
corpsetype = 3 ;
explode base type BITMAPONLY | NOHEATCLOUD;
explode rotor type FIRE | SMOKE | FALL | NOHEATCLOUD;
return(corpsetype);
}
corpsetype = 3 ;
explode base type BITMAPONLY | NOHEATCLOUD;
explode rotor type EXPLODE_ON_HIT | FIRE | FALL | NOHEATCLOUD;
return corpsetype;
}
Binary file added scripts/Units/legmohoconin.cob
Binary file not shown.
Binary file added unitpics/legmohocon.dds
Binary file not shown.
2 changes: 1 addition & 1 deletion units/Legion/Constructors/legaca.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ return {
"coruwageo",
"legrampart",
"legmoho",
"cormexp",
"legmohocon",
"cormmkr",
"coruwadves",
"legamstor",
Expand Down
2 changes: 1 addition & 1 deletion units/Legion/Constructors/legack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ return {
"legageo",
"legrampart",
"legmoho",
"cormexp",
"legmohocon",
"cormmkr",
"coruwadves",
"legamstor",
Expand Down
2 changes: 1 addition & 1 deletion units/Legion/Constructors/legacv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ return {
[3] = "legageo",
[4] = "legrampart",
[5] = "legmoho",
[6] = "cormexp",
[6] = "legmohocon",
[7] = "cormmkr",
[8] = "coruwadves",
[9] = "legamstor",
Expand Down
Loading

0 comments on commit 7f04e94

Please sign in to comment.