Shadowy's Micro Scripts - Tomb-Raider-Level-Editor/Tutorials GitHub Wiki
Originally by Shadowy (or ShadowXJaw) on TEN Discord Server
As the title says- I'll post small scripts that can be used that are based off TRNG's tutorials, starting with the screaming on fire:
LevelFuncs.OnLoad = function() end
LevelFuncs.OnSave = function() end
LevelFuncs.OnStart = function() end
LevelFuncs.OnLoop = function() LevelFuncs.MakeLaraScreamOnFire() end
LevelFuncs.OnEnd = function() end
LevelFuncs.MakeLaraScreamOnFire = function()
if not IsSoundPlaying(30) and Lara:GetEffect() == EffectID.FIRE then
PlaySound(30, Lara:GetPosition())
end
end
When lara's on fire and NOT already screaming, then scream : D
Roblox inspired Wait() function
local StartWaitFunc = false
local WaitVar = 0
LevelFuncs.OnLoop = function()
if StartWaitFunc then
WaitVar = WaitVar + 1
if WaitVar == 300 then
Lara:Explode()
end
else
WaitVar = 0
end
end
LevelFuncs.TriggerExample = function()
StartWaitFunc = true
end
A porting of a raw Wait() system from Roblox. It's so raw and dry it's really up to you where you expand it.
Expanded Ammo Counter Script
-- OG Tutorial by DaviDM
-- I made this for my mercenaries mode but ported it for general use
local COLOR_VAR = Color.new(255,255,255)
local AmmoStringPosX, AmmoStringPosY = PercentToScreen(5, 90)
local AmmoCounter = DisplayString("", AmmoStringPosX, AmmoStringPosY)
AmmoCounter:SetColor(COLOR_VAR)
-- Editing the scale fucks with the positioning of the string.
local AmmoCounterWriting = {
"Pistols:",
"Revolver:",
"Uzi:",
"Shotgun:",
"HK",
"Crossbow",
"Flare",
"Torch",
"Grenade Launcher",
"Harpoon Gun",
"RPG"
}
LevelFuncs.AmmoCounter = function()
if Lara:GetHandStatus() == 4 and Lara:GetWeaponType() ~= 0 and Lara:GetWeaponType() ~= 7 and Lara:GetWeaponType() ~= 8 then
ShowString(AmmoCounter)
AmmoCounter:SetKey(tostring(AmmoCounterWriting[Lara:GetWeaponType()]) .. " " .. Lara:GetAmmoCount())
if Lara:GetAmmoCount() == -1 then
AmmoCounter:SetKey(tostring(AmmoCounterWriting[Lara:GetWeaponType()]) .. " " .. "Infinite")
end
else
HideString(AmmoCounter)
end
end
LevelFuncs.OnLoop = function()
LevelFuncs.AmmoCounter()
end
An expanded ammo counter for all of lara's guns- it does not show for flares and torches.
Enemy Randomizer
LevelFuncs.OnLoad = function() end
LevelFuncs.OnSave = function() end
LevelFuncs.OnLoop = function() end
LevelFuncs.OnEnd = function() end
LevelFuncs.OnStart = function()
LevelFuncs.ListEnemyPositions(4)
end
local EnemyPositionList = {}
local EnemyCountList = {}
local EnemyIndex = 1
local EnemyTierPool = {}
local EnemyTierPoolHP = {}
-- For EnemyTierPool, go into your WAD and insert into the table the number ID for the enemy slot you want to use. ObjID will NOT work as a string.
-- HP you can have whatever, just make sure your table structure is correct.
LevelFuncs.ListEnemyPositions = function(enemy_spawn_amount)
for i=1, enemy_spawn_amount do
EnemyPositionList[i] = "EnemySpawnPoint" .. i
end
end
-- Builder note- you need to replicate the above set-up, as in name your desired object's LUA name ( take CAMERA_TARGET ) for example as EnemySpawnPoint1, EnemySpawnPoint2 and so on.
-- Then run LevelFuncs.ListEnemyPositions() and insert into the brackets how many of the spawn points you have set around the level.
LevelFuncs.SpawnEnemyFunction = function(ENEMY_SPAWN_COUNT) -- A function to spawn a random enemy count in random locations, with HP values from a table -- WIP
for w=1, ENEMY_SPAWN_COUNT do
local EnemySlot = math.random(1, #EnemyTierPool)
local EnemyData = GetMoveableByName(EnemyPositionList[math.random(1, #EnemyPositionList)]) -- choose one out 4 enemies at random
local EnemySetHP = math.floor(math.random(-4,4) + EnemyTierPoolHP[EnemySlot])
local EnemySpawnPos = EnemyData:GetPosition()
local EnemySpawnRot = EnemyData:GetRotation()
local EnemySpawnRoom = EnemyData:GetRoomNumber()
EnemyCountList[EnemyIndex] = Moveable(EnemyTierPool[EnemySlot], "ENEMY".. tostring(EnemyIndex), EnemySpawnPos, EnemySpawnRot, EnemySpawnRoom, 0, 0, EnemySetHP)
EnemyCountList[EnemyIndex]:Enable()
EnemyIndex = EnemyIndex + 1
end
end
LevelFuncs.TestFunction = function()
LevelFuncs.SpawnEnemyFunction(5)
end
This function explains how you can have a random spawn function for enemies
Give Item conditions
LevelFuncs.OnLoad = function() end
LevelFuncs.OnSave = function() end
LevelFuncs.OnEnd = function() end
LevelFuncs.OnStart = function() end
function GiveItemConditions()
if Lara:GetAnim() == 464 and Lara:GetFrame() == 180 then LevelFuncs.GiveRandomItem("AmmoAndHeal") end
if Lara:GetAnim() == 465 and Lara:GetFrame() == 100 then LevelFuncs.GiveRandomItem("Ammo") end
if Lara:GetAnim() == 466 and Lara:GetFrame() == 160 then LevelFuncs.GiveRandomItem("Heal") end
if Lara:GetAnim() == 472 and Lara:GetFrame() == 88 then LevelFuncs.GiveRandomItem("AmmoAndHeal") end
end
local randomItemVar = 0
local ItemList = { -- Big Medi, Small Medi, and AMMO - Uzi, Shotgun, Revolver, Crossbow, HK, Grenade Gun, RPG, Harpoon
978, 979, 953, 955, 956, 958, 960, 961, 962, 965, 967, 968, 969, 972, 975
}
local ItemListAmount = {
1, 1, 30, 6, 6, 6, 10, 10, 10, 30, 10, 10, 10, 1, 4
}
local ItemSearchObjectString = {
"You found a Big Medi!",
"You found a Small Medi!",
"You found Uzi Clips!",
"You found regular shotgun shells!",
"You found wideshot shotgun shells!",
"You found revolver bullets!",
"You found normal crossbow bolts!",
"You found poisonous crossbow bolts!",
"You found explosive crossbow bolts!",
"You found a HK clip!",
"You found normal grenades!",
"You found enhanced grenades!",
"You found flash grenades!",
"You found a rocket!",
"You found a bundle of harpoons!"
}
-- We have to use the ID numbers, and not the names themselves as if we do "Obj" for anything, it breaks and counts as a string which won't work.
LevelFuncs.GiveRandomItem = function(SEARCH_OBJECT)
if SEARCH_OBJECT == "AmmoAndHeal" then
randomItemVar = math.random(1, 15)
elseif SEARCH_OBJECT == "Heal" then
randomItemVar = math.random(1, 2)
elseif SEARCH_OBJECT == "Ammo" then
randomItemVar = math.random(3, 15)
end
local ItemNotifX, ItemNotifY = PercentToScreen(5, 85)
local ItemNotif = DisplayString(ItemSearchObjectString[randomItemVar], ItemNotifX, ItemNotifY)
local COLOR_VAR = Color.new(255,255,255)
ItemNotif:SetColor(COLOR_VAR)
ShowString(ItemNotif, 2)
local Item = ItemList[randomItemVar]
local ItemAmount = ItemListAmount[randomItemVar]
GiveItem(ItemList[randomItemVar], ItemAmount, true)
end
LevelFuncs.OnLoop = function()
GiveItemConditions()
end
Take this one with a grain of salt, because it's abusable
Diary System (WIP)
C_WHITE = Color.new(255,255,255)
C_RADIO = Color.new(36, 22, 69)
C_INST1 = Color.new(44, 69, 79)
C_INST2 = Color.new(44, 69, 126)
local Title_image = DisplaySprite(1356, 1, Vec2(50,50), 0, Vec2(100,100), Color(255,255,255))
IN_DIARY = false
Option_Choice_Increment = 1
Available_Options = 3
FFSXPos, FFSYPos = PercentToScreen(10, 48)
FunFactString = DisplayString("", FFSXPos, FFSYPos, C_WHITE)
LevelFuncs.OnRadio = function()
if KeyIsHit(ActionID.SPRINT) and Lara:GetAnim() == 103 and Lara:GetHandStatus() == 0 then
Lara:SetAnim(467)
IN_DIARY = true
end
if KeyIsHit(ActionID.SPRINT) and Lara:GetAnim() == 468 then
Lara:SetAnim(469)
IN_DIARY = false
end
if IN_DIARY then
Title_image:Draw(0, View.AlignMode.CENTER, View.ScaleMode.FILL, Effects.BlendID.ALPHABLEND)
if KeyIsHit(ActionID.LEFT) then
if Option_Choice_Increment ~= 0 then
PlaySound(644, Lara:GetPosition())
Option_Choice_Increment = Option_Choice_Increment - 1
Title_image = DisplaySprite(1356, Option_Choice_Increment, Vec2(50,50), 0, Vec2(100,100), Color(255,255,255))
end
end
if KeyIsHit(ActionID.RIGHT) then
if Option_Choice_Increment ~= Available_Options then
PlaySound(644, Lara:GetPosition())
Option_Choice_Increment = Option_Choice_Increment + 1
Title_image = DisplaySprite(1356, Option_Choice_Increment, Vec2(50,50), 0, Vec2(100,100), Color(255,255,255))
end
end
end
end
LevelFuncs.OnLoad = function() end
LevelFuncs.OnSave = function() end
LevelFuncs.OnStart = function() end
LevelFuncs.OnEnd = function() end
LevelFuncs.OnLoop = function() LevelFuncs.OnRadio() end
WIP Diary System A lot of cleaning and sorting needs to be done