local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
local simUnit = import('/lua/sim/Unit.lua')
local oldUnit = simUnit.Unit
local TERRAIN_SAND_NAME = 'Sand01'
------ GENERAL
function OnPopulate ()
ScenarioUtils.InitializeArmies()
ScenarioFramework.SetPlayableArea('AREA_1' , false)
end
function OnStart (scenario)
ForkThread(showmessage)
ForkThread(gatherFeedback)
end
------ Startmessage
function gatherFeedback()
WaitSeconds(10)
BroadcastMSG('The -- INSERT TERRAIN OR AREA HERE -- will slow your GROUND units down -- HOVER units are affected less', -- message
40, -- fontsize
'd0d0d0', -- color
10, -- duration
'center') -- position
end
-- Change message colour to stand out against terrain colour codes are; Yellow - ffff00, Orange - ffa500, Red - ff0000, Purple - 9370db Blue - 0000ff,
-- Light Blue - 00bfff, Green - 7cfc00, Black - 000000, White - d0d0d0
function showmessage()
local message = ''
local sendmessage = false
end
function BroadcastMSG(message, fontsize, RGBColor, duration, location)
-- broadcast a text message to players
-- possible locations = lefttop, leftcenter, leftbottom, righttop, rightcenter, rightbottom, rightbottom, centertop, center, centerbottom
PrintText(message, fontsize, 'ff' .. RGBColor, duration , location) ;
end
----- SLOW ON SAND
simUnit.Unit = Class(oldUnit) {
OnTerrainTypeChange = function(self, new, old)
oldUnit.OnTerrainTypeChange(self, new, old)
if (new and new.Name == TERRAIN_SAND_NAME) then
if (isLandUnit(self)) then
if (isCommanderUnit(self)) then
self:SetSpeedMult(0.9)
elseif (isHoveringUnit(self)) then
self:SetSpeedMult(0.8)
else
self:SetSpeedMult(0.6)
end
end
elseif (old and old.Name == TERRAIN_SAND_NAME) then
if (isLandUnit(self)) then
self:SetSpeedMult(1)
end
end
end,
}
function isLandUnit (unit)
if (EntityCategoryContains(categories.MOBILE * categories.LAND, unit)) then
return true
else
return false
end
end
function isHoveringUnit (unit)
if (EntityCategoryContains(categories.HOVER, unit)) then
return true
else
return false
end
end
function isCommanderUnit (unit)
if (EntityCategoryContains(categories.COMMAND + categories.SUBCOMMANDER, unit)) then
return true
else
return false
end
end
local simUnit = import('/lua/sim/Unit.lua')
local oldUnit = simUnit.Unit
local TERRAIN_SAND_NAME = 'Sand01'
----- SLOW ON SAND
simUnit.Unit = Class(oldUnit) {
OnTerrainTypeChange = function(self, new, old)
oldUnit.OnTerrainTypeChange(self, new, old)
if (new and new.Name == TERRAIN_SAND_NAME) then
if (isLandUnit(self)) then
if (isCommanderUnit(self)) then
self:SetSpeedMult(0.9)
elseif (isHoveringUnit(self)) then
self:SetSpeedMult(0.8)
else
self:SetSpeedMult(0.6)
end
end
elseif (old and old.Name == TERRAIN_SAND_NAME) then
if (isLandUnit(self)) then
self:SetSpeedMult(1)
end
end
end,
}
function isLandUnit (unit)
if (EntityCategoryContains(categories.MOBILE * categories.LAND, unit)) then
return true
else
return false
end
end
function isHoveringUnit (unit)
if (EntityCategoryContains(categories.HOVER, unit)) then
return true
else
return false
end
end
function isCommanderUnit (unit)
if (EntityCategoryContains(categories.COMMAND + categories.SUBCOMMANDER, unit)) then
return true
else
return false
end
end
--Startmessageslow
function gatherFeedback()
WaitSeconds(0)
BroadcastMSG('The -- INSERT TERRAIN OR AREA HERE -- will slow your GROUND units down -- HOVER units are affected less', -- message
40, -- fontsize
'ff0000', -- color
10, -- duration
'center') -- position
end
-- Change message colour to stand out against terrain colour codes are; Yellow - ffff00, Orange - ffa500, Red - ff0000, Purple - 9370db Blue - 0000ff,
-- Light Blue - 00bfff, Green - 7cfc00, Black - 000000, White - d0d0d0
if (new and new.Name == TERRAIN_SAND_NAME) then
if (isLandUnit(self)) then
if (isCommanderUnit(unit)) then
unit:SetSpeedMult(0.9)
elseif (isHoveringUnit(unit)) then
unit:SetSpeedMult(0.8)
else
unit:SetSpeedMult(0.6)
end
if (isCommanderUnit(unit)) then
unit:SetSpeedMult(0.9)
elseif (isHoveringUnit(unit)) then
unit:SetSpeedMult(0.8)
else
unit:SetSpeedMult(0.6)
Statistics: Posted by MadMax — 02 May 2020, 18:57