forked from entertainment-dog/Anomaly-Research-Center-ARC
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 21f570a
Showing
7 changed files
with
304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Xalalau Xubilozo and Anomaly Research Center (A.R.C.) Community | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Anomaly Research Center (A.R.C.) | ||
|
||
This repository is under construction. | ||
|
||
[gm_construct_13 beta](https://steamcommunity.com/sharedfiles/filedetails/?id=2553727051). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
-- Break vehicles (By Zaurzo) | ||
|
||
function CGM13.Vehicle:Break(vehicle, value) | ||
if not (IsValid(vehicle) and vehicle:IsValid() and vehicle:IsVehicle() and vehicle.StartEngine) then return end | ||
|
||
vehicle:StartEngine(false) | ||
vehicle:SetNWBool("cgm13_burned_engine", true) | ||
vehicle:SetSequence("idle") | ||
GM13.Ent:SetMute(vehicle, true) | ||
end | ||
|
||
function CGM13.Vehicle:IsBroken(vehicle) | ||
return vehicle:GetNWBool("cgm13_burned_engine") | ||
end | ||
|
||
local ENT = FindMetaTable("Entity") | ||
local SetNWBool = ENT.SetNWBool | ||
ENT.SetNWBool = function(self, value, ...) | ||
if CGM13.Vehicle:IsBroken(self) then return end | ||
return SetNWBool(self, value, ...) | ||
end | ||
|
||
hook.Add("VehicleMove", "cgm13_vehicle_control", function(ply, vehicle) | ||
if CGM13.Vehicle:IsBroken(vehicle) then | ||
vehicle:StartEngine(false) | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
-- This is a reference file for creating events. Several features of this addon are not listed here. | ||
|
||
--[[ | ||
The first thing to notice is the way the SandEv loads scripts. Events are located in "lua/gm13/events/tierX", | ||
where X is an integer starting from 1, and they can even be added by external addons. Subfolders are supported | ||
The filenames have this pattern of prefixes: | ||
sh_ = shared | ||
sv_ = server | ||
cl_ = client | ||
The filenames have this pattern of suffixes: | ||
_g = global. Will load the event on any map | ||
_t = tier. Will load the event only when the correct tier is loaded | ||
_gt = global and tier. | ||
This means that a file called sv_myevent_g.lua will be loaded server-side and on all maps while the addon | ||
is active. | ||
If you are interested in creating libraries inside SandEv, consider that the load order is alphabetical. It | ||
starts with files and goes to folders, so sub-libraries must be in sub-folders. | ||
]] | ||
|
||
-- Now, about creating the event itself: | ||
|
||
-- Always set a unique event name | ||
local eventName = "myEvent" | ||
|
||
-- Set some variables that are kept when the map is cleared | ||
local saved = false | ||
|
||
-- Set some memory dependencies. An event can provide or request memories | ||
-- When a memory is provided, events that require this memory are automatically loaded | ||
GM13.Event.Memory.Dependency:SetProvider(eventName, "myMemory1", "myMemory2", ...) | ||
GM13.Event.Memory.Dependency:SetDependent(eventName, "iNeedMemoryX", "iNeedMemoryY", ...) | ||
|
||
-- It's also possible to declare a memory incompatibility and force the event to terminate | ||
-- automatically when this memory is provided. | ||
GM13.Event.Memory.Incompatibility:Set(eventName, "anyMemoryIDontLike", ...) | ||
|
||
-- Create your own stuff with as many functions as you need | ||
local function SomeAuxFunc() | ||
-- Do something | ||
end | ||
|
||
-- Create the event main function | ||
local function CreateEvent() | ||
-- Create custom GM13 entities | ||
-- The purpose of GM13 entities is to mark areas, make triggers and create sents | ||
-- Marked areas and triggers can be rendered on the clientside to facilitate development | ||
local someEnt = ents.Create("gm13_some_ent") | ||
someEnt:Setup(eventName, "entName", Vector(x,y,z), otherVars) | ||
|
||
-- Create entities and connect them to the event so that they are automatically cleared if the it ends | ||
local citizen = ents.Create("npc_citizen") | ||
citizen:Spawn() | ||
GM13.Event:SetGameEntity(eventName, citizen) | ||
|
||
-- Use SandEv libs to set custom behaviours, such as | ||
GM13.Ent:BlockPhysgun(ent, value) | ||
GM13.Ent:BlockTools(ent, ...) | ||
GM13.Ent:SetInvulnerable(ent, value, callback, ...) | ||
GM13.Ent:SetReflectDamage(ent, value, callback, ...) | ||
GM13.Ent:SetMute(ent, value) | ||
GM13.Ent:FadeIn(ent, fadingTime, callback, ...) | ||
GM13.Ent:FadeOut(ent, fadingTime, callback, ...) | ||
GM13.Ent:Dissolve(ent, dissolveType) | ||
GM13.Ent:CallOnCondition(ent, condition, callback, ...) | ||
GM13.Ent:BlockContextMenu(ent, value) | ||
GM13.Ent:SetFakeInvalid(ent, value) | ||
GM13.Ent:HideClassName(ent, value) | ||
GM13.Light:SetBurnResistant(ent, value) | ||
GM13.Light:Burn(ent) | ||
GM13.Light:FadeOut(ent, callback) | ||
GM13.Light:FadeIn(ent, callback) | ||
GM13.Light:Blink(ent, maxTime, finalState, callbackOn, callbackOff, callbackEnd) | ||
GM13.Map:BlockCleanup(value) | ||
GM13.NPC:AttackClosestPlayer(npc, duration) | ||
GM13.NPC:PlaySequences(npc, ...) | ||
GM13.NPC:CallOnKilled(npc, id, callback, ...) | ||
GM13.Prop:CallOnBreak(ent, id, callback, ...) | ||
GM13.Ply:GetClosestPlayer(pos) | ||
GM13.Ply:BlockNoclip(ply, value) | ||
GM13.Ply:CallOnSpawn(ply, isOnce, callback, ...) | ||
CGM13.Vehicle:Break(vehicle, value) | ||
-- And many more | ||
|
||
-- A common thing in events are triggers, so create and populate them here. E.G. | ||
local someTrigger = ents.Create("gm13_trigger") | ||
someTrigger:Setup(eventName, "someTrigger", Vector(-100, -100, 25), Vector(100, 100, 125)) | ||
|
||
function someTrigger:StartTouch(ent) | ||
-- In this case, only accept players | ||
if not ent:IsPlayer() then return end | ||
|
||
-- Let's set a random chance of activating the event | ||
if (math.random(1, 100) <= 20) then -- 20% | ||
ply:Kill() -- Oh no, the player is dead | ||
|
||
-- Now I'm going to set some memories to remember this. We can store any information we | ||
-- want as long as GMod can save it in JSON and retrieve the values correctly afterwards. | ||
-- Beware of this conversion, it can be problematic! Documentation: | ||
-- https://wiki.facepunch.com/gmod/util.TableToJSON | ||
-- https://github.com/Facepunch/garrysmod-issues/issues/3561 | ||
-- But fear not, it usually works. | ||
GM13.Event.Memory:Set("firstDeath", anyVariable) | ||
end | ||
|
||
-- Call any extra | ||
SomeAuxFunc() | ||
end | ||
|
||
-- More touch functions... | ||
function someTrigger:EndTouch(ent) | ||
-- Do something | ||
end | ||
|
||
function someTrigger:Touch(ent) | ||
-- Do something | ||
end | ||
|
||
-- Besides these things, there's a still unused system that allows for complete integrations | ||
-- Every time an event is added, removed or started, a GMod hook is fired. This allows other events to react | ||
-- immediately without needing to fully reload. But be careful! These reactions must ensure consistency of memory | ||
-- checks or generate momentary situations that don't interfere with the current event's operation. NEVER use these | ||
-- hooks to create new event parts!! ONLY memories can guarantee correct continuation experiences. | ||
|
||
-- Loaded event | ||
hook.Add("gm13_add_OtherEvent", "MyHookName1", function() | ||
-- Adjust memory checks or do something unusual and momentary | ||
end) | ||
|
||
-- Ran event | ||
hook.Add("gm13_run_OtherEvent", "MyHookName2", function() | ||
-- Adjust memory checks or do something unusual and momentary | ||
end) | ||
|
||
-- Unloaded event | ||
hook.Add("gm13_remove_OtherEvent", "MyHookName3", function() | ||
-- Adjust memory checks or do something unusual and momentary | ||
end) | ||
|
||
-- Note: these hooks also work during game startup | ||
|
||
-- We must return true when this function is successful | ||
return true | ||
end | ||
|
||
-- When removing the event it may be necessary to do some cleaning | ||
local function RemoveEvent() | ||
-- Remove hooks and timers for example | ||
timer.Remove("identifier") | ||
hook.Remove("eventName", "hookName") | ||
|
||
-- We must return true when this function is successful | ||
return true | ||
end | ||
|
||
-- If the event is blocked by missing or incompatible memories, we can also run a callback | ||
local function IgnoreEvent() | ||
-- Do something | ||
|
||
-- We must return true when this function is successful | ||
return true | ||
end | ||
|
||
-- Link functions to the event system | ||
GM13.Event:SetCall(eventName, CreateEvent) | ||
GM13.Event:SetDisableCall(eventName, RemoveEvent) | ||
GM13.Event:SetBlockedByMemoryCall(eventName, IgnoreEvent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
local eventName = "bigBreakVehicles" | ||
|
||
GM13.Event.Memory.Dependency:SetDependent(eventName, "openThePortal", "showBigDarkRoom") | ||
|
||
local function CreateEvent() | ||
local breakVehiclesBigDarkroom = ents.Create("gm13_trigger") | ||
breakVehiclesBigDarkroom:Setup(eventName, "breakVehiclesBigDarkroom", Vector(2542.8, 4078.5, -7081.9), Vector(-11247.8, -7663.7, -2176)) | ||
|
||
function breakVehiclesBigDarkroom:StartTouch(ent) | ||
if not ent:IsVehicle() then return end | ||
|
||
timer.Simple(math.random(2, 6), function() | ||
if not ent:IsValid() then return end | ||
|
||
CGM13.Vehicle:Break(ent, true) | ||
|
||
if math.random(1, 100) <= 50 then | ||
local explo = ents.Create("env_explosion") | ||
explo:SetPos(ent:GetPos()) | ||
explo:Spawn() | ||
explo:Fire("Explode") | ||
explo:SetKeyValue("IMagnitude", 20) | ||
|
||
ent:Ignite(15, 30) | ||
end | ||
end) | ||
end | ||
|
||
return true | ||
end | ||
|
||
GM13.Event:SetCall(eventName, CreateEvent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
local eventName = "breakVehicles" | ||
|
||
local function CreateEvent() | ||
local function StartTouch(ent, chance) | ||
if not ent:IsVehicle() then return end | ||
|
||
if math.random(1, 100) <= chance then | ||
timer.Simple(math.random(2, 6), function() | ||
if not ent:IsValid() then return end | ||
|
||
CGM13.Vehicle:Break(ent, true) | ||
|
||
if math.random(1, 100) <= 50 then | ||
local explo = ents.Create("env_explosion") | ||
explo:SetPos(ent:GetPos()) | ||
explo:Spawn() | ||
explo:Fire("Explode") | ||
explo:SetKeyValue("IMagnitude", 20) | ||
|
||
ent:Ignite(15, 30) | ||
end | ||
end) | ||
end | ||
end | ||
|
||
local breakVehiclesGarage = ents.Create("gm13_trigger") | ||
breakVehiclesGarage:Setup(eventName, "breakVehiclesGarage", Vector(-2809.4, -1064.7, 207.9), Vector(-1056.9, -1919, -143.9)) | ||
|
||
local breakVehiclesDarkroom = ents.Create("gm13_trigger") | ||
breakVehiclesDarkroom:Setup(eventName, "breakVehiclesDarkroom", Vector(-5245.2, -1057.2, 159.9), Vector(-5247.3, -1056.7, -143.9)) | ||
|
||
function breakVehiclesGarage:StartTouch(ent) | ||
StartTouch(ent, 40) | ||
end | ||
|
||
function breakVehiclesDarkroom:StartTouch(ent) | ||
StartTouch(ent, 75) | ||
end | ||
|
||
return true | ||
end | ||
|
||
GM13.Event:SetCall(eventName, CreateEvent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--[[ | ||
Anomaly Research Center (A.R.C.) Exploration | ||
Revealing and exposing curses. | ||
https://github.com/Xalalau/Anomaly-Research-Center-ARC | ||
https://discord.gg/97UpY3D7XB | ||
Created by Xalalau and ARC community, 2022 | ||
MIT License | ||
]] | ||
|
||
CGM13 = { -- Community GM13 | ||
Vehicle = {} | ||
} | ||
|
||
hook.Add("Initialize", "arc_int", function() | ||
GM13:AddBase("arc") | ||
end) |