Skip to content

Commit

Permalink
Merge pull request #2805 from TheSilverHornet/critterupdate
Browse files Browse the repository at this point in the history
Critter update
  • Loading branch information
Damgam authored Mar 31, 2024
2 parents 4a3b104 + 3b33fcc commit 0380830
Show file tree
Hide file tree
Showing 11 changed files with 477 additions and 25 deletions.
26 changes: 14 additions & 12 deletions luarules/gadgets/gaia_critters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,20 @@ local function randomPatrolInCircle(unitID, circle, minWaterDepth) -- only defin
end

local function setGaiaUnitSpecifics(unitID)
Spring.SetUnitNeutral(unitID, true)
Spring.SetUnitNoSelect(unitID, true)
Spring.SetUnitStealth(unitID, true)
Spring.SetUnitNoMinimap(unitID, true)
Spring.SetUnitMaxHealth(unitID, 2)
Spring.SetUnitBlocking(unitID, false)
Spring.SetUnitSensorRadius(unitID, 'los', 0)
Spring.SetUnitSensorRadius(unitID, 'airLos', 0)
Spring.SetUnitSensorRadius(unitID, 'radar', 0)
Spring.SetUnitSensorRadius(unitID, 'sonar', 0)
for weaponID, _ in pairs(UnitDefs[GetUnitDefID(unitID)].weapons) do
Spring.UnitWeaponHoldFire(unitID, weaponID) -- doesnt seem to work :S (maybe because they still patrol)
if false then
Spring.SetUnitNeutral(unitID, true)
Spring.SetUnitNoSelect(unitID, true)
Spring.SetUnitStealth(unitID, true)
Spring.SetUnitNoMinimap(unitID, true)
Spring.SetUnitMaxHealth(unitID, 2)
Spring.SetUnitBlocking(unitID, false)
Spring.SetUnitSensorRadius(unitID, 'los', 0)
Spring.SetUnitSensorRadius(unitID, 'airLos', 0)
Spring.SetUnitSensorRadius(unitID, 'radar', 0)
Spring.SetUnitSensorRadius(unitID, 'sonar', 0)
for weaponID, _ in pairs(UnitDefs[GetUnitDefID(unitID)].weapons) do
Spring.UnitWeaponHoldFire(unitID, weaponID) -- doesnt seem to work :S (maybe because they still patrol)
end
end
end

Expand Down
112 changes: 112 additions & 0 deletions luarules/gadgets/game_critter_spawner.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
function gadget:GetInfo()
return {
name = "Critter Spawner",
desc = "Spawns critters when trees are reclaimed, at semi random",
author = "Hornet",
date = "2024",
license = "GNU GPL, v2 or later",
layer = 0,
enabled = true
}
end


local initialUnits = {}
local crittersPresent = {}
local critterNames = {}
local gaiaID = Spring.GetGaiaTeamID()
local currentCritter = 442

if not gadgetHandler:IsSyncedCode() then
return
end

for unitDefID, defs in pairs(UnitDefs) do
if string.find(defs.name, "critter_") then
critterNames[unitDefID] = defs.name
end
end


-- 437 = critter_ant
-- 438 = critter_crab
-- 439 = critter_duck
-- 440 = critter_goldfish
-- 441 = critter_gull
-- 442 = critter_penguin
-- 443 = critter_penguinbro
-- 444 = critter_penguinking

function gadget:GameFrame(frame)
if frame == 15 then
--clean critters list of irrelevants, if empty add penguins

for id, unit in pairs(initialUnits) do
if id==437 or id==438 or id==439 or id==442 then ---ant crab duck penguin
table.insert(crittersPresent, id)
end
end


if #crittersPresent == 0 then
table.insert(crittersPresent, 442)--add penwins
end

--Spring.Echo('hornet cp', #crittersPresent)


end
end

function gadget:UnitCreated(unitID, unitDefID, teamID, builderID)
local frame = Spring.GetGameFrame ()
if frame < 10 then

--scan for critters present
if teamID == gaiaID and unitDefID > 430 and unitDefID < 450 then --rough double check, this should be only critters anyway
initialUnits[unitDefID] = unitDefID
end


end
end



--Spring.Echo('hornet critters here')


function gadget:FeatureDestroyed(featureID, allyTeamID)
--Spring.Echo('hornet fd')
if allyTeamID==2 then
--10% 1, 3.333% 2, ~1% 3

if math.random(1,10) == 1 then
currentCritter = crittersPresent[math.random(1, #crittersPresent)]
--currentCritter = 442 --testing force; ant 437, crab 438, duck 439, penguin 442
local posx, posy, posz = Spring.GetFeaturePosition(featureID)
local critterID = Spring.CreateUnit(currentCritter, posx, posy, posz, "north", Spring.GetGaiaTeamID())
Spring.SetUnitBlocking(critterID, false)

if math.random(1,3) == 1 then
local critterID = Spring.CreateUnit(currentCritter, posx, posy, posz, "north", Spring.GetGaiaTeamID())
Spring.SetUnitBlocking(critterID, false)
end

if math.random(1,3) == 1 then
local critterID = Spring.CreateUnit(currentCritter, posx, posy, posz, "north", Spring.GetGaiaTeamID())
Spring.SetUnitBlocking(critterID, false)
end

end

--seperate gull roll
if math.random(1,20) == 1 then
local posx, posy, posz = Spring.GetFeaturePosition(featureID)
local critterID = Spring.CreateUnit(441, posx, posy, posz+5, "north", Spring.GetGaiaTeamID())
end



end
end
Binary file modified objects3d/Critters/critter_crab.s3o
Binary file not shown.
Binary file modified objects3d/Critters/critter_gull.s3o
Binary file not shown.
23 changes: 22 additions & 1 deletion scripts/Critters/critter_crab.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
--just copy from duck
local flare = piece "flare"


function walk()
end
Expand All @@ -13,6 +14,26 @@ function script.StopMoving()
end



function script.AimFromWeapon1()
return flare
end

function script.QueryWeapon1()
return flare
end
function script.AimWeapon1(heading, pitch)
return true
end

function script.FireWeapon1()
return true
end

function script.Shot1()
end


--[[
function script.Killed(recentDamage, maxHealth)
local snd
Expand Down
36 changes: 36 additions & 0 deletions scripts/Critters/critter_gull.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local wingr = piece "rwing"
local base = piece "base"
local flare = piece "flare"
local wingl = piece "lwing"
local flapSpeed = math.rad(360)
local volume = 0.5
Expand Down Expand Up @@ -48,3 +50,37 @@ function flapWings()
end]]--
end
end


function script.AimFromWeapon1()
return flare
end
function script.AimFromWeapon2()
return flare
end

function script.QueryWeapon1()
return flare
end

function script.QueryWeapon2()
return flare
end


function script.AimWeapon1(heading, pitch)
return true
end
function script.AimWeapon2(heading, pitch)
return true
end

function script.FireWeapon1()
return true
end
function script.FireWeapon2()
return true
end

function script.Shot1()
end
60 changes: 60 additions & 0 deletions units/other/critters/critter_ant.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,65 @@ return {
nohealthbars = true,
subfolder = "other/critters",
},





weapondefs = {
eyelaser = {
areaofeffect = 8,
avoidfeature = false,
beamtime = 0.7,
corethickness = 0.2,
craterareaofeffect = 0,
craterboost = 0,
cratermult = 0,
edgeeffectiveness = 0.3,
energypershot = 0,
explosiongenerator = "custom:laserhit-tiny-red",
firestarter = 5,
impactonly = 1,
impulseboost = 0,
impulsefactor = 0,
laserflaresize = 3.146,
name = "LightLaser",
noselfdamage = true,
proximitypriority = 2,
range = 266,
reloadtime = 2,
rgbcolor = "1 0 0",
soundhitdry = "",
soundhitwet = "sizzle",
soundstart = "penbray1",
soundtrigger = 1,
targetborder = 0.75,
targetmoveerror = 0.1,
thickness = 1.25,
tolerance = 7000,
turret = false,
weapontype = "BeamLaser",
weaponvelocity = 2250,
customparams = {
nohealthbars = true,
},
damage = {
default = 25,
vtol = 2,
},
},
},
weapons = {
[1] = {
badtargetcategory = "VTOL",
def = "EYELASER",
onlytargetcategory = "",
},
},





},
}
52 changes: 52 additions & 0 deletions units/other/critters/critter_crab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,57 @@ return {
nohealthbars = true,
subfolder = "other/critters",
},

weapondefs = {
eyelaser = {
areaofeffect = 8,
avoidfeature = false,
beamtime = 0.2,
corethickness = 0.2,
craterareaofeffect = 0,
craterboost = 0,
cratermult = 0,
edgeeffectiveness = 0.3,
energypershot = 0,
explosiongenerator = "custom:laserhit-tiny-red",
firestarter = 100,
impactonly = 1,
impulseboost = 0,
impulsefactor = 0,
laserflaresize = 3.146,
name = "LightLaser",
noselfdamage = true,
proximitypriority = 2,
range = 266,
reloadtime = 0.2,
rgbcolor = "1 0 0",
soundhitdry = "",
soundhitwet = "sizzle",
soundstart = "penbray1",
soundtrigger = 1,
targetborder = 0.75,
targetmoveerror = 0.1,
thickness = 1.25,
tolerance = 7000,
turret = false,
weapontype = "BeamLaser",
weaponvelocity = 2250,
customparams = {
nohealthbars = true,
},
damage = {
default = 4,
vtol = 2,
},
},
},
weapons = {
[1] = {
badtargetcategory = "VTOL",
def = "EYELASER",
onlytargetcategory = "",
},
},

},
}
Loading

0 comments on commit 0380830

Please sign in to comment.