Skip to content

Commit

Permalink
Initial commit!
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximumADHD committed Nov 30, 2020
0 parents commit 0eb7a4a
Show file tree
Hide file tree
Showing 11 changed files with 1,665 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0.0",

"tasks":
[
{
"label": "build",
"type": "shell",
"command": "rojo build -o Realism.rbxm build.project.json",

"group":
{
"kind": "build",
"isDefault": true
}
}
]
}
373 changes: 373 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Character Realism

By: CloneTrooper1019
Made for Roblox!

## What is this?

*Realism* is a character enhancement system for Roblox designed to be adaptive and minimally invasive to existing game code. It allows players to see their avatar's body in first person and look around with their head in third person. It additionally override's Roblox's default walking sound with a set of material-based walking sounds.

## Features

- Compatible with real-time avatar scaling and HumanoidDescription changes.
- Interpolated 100% on the client, no snapping or lag.
- Supports both R6 and R15 avatars.

## Installation

This repository is setup as a [Rojo](https://rojo.space/) project! Syncing the `default.project.json` file of this project with your Studio session will automatically set it up.

Alternatively, you can drag and drop the `Realism.rbxm` file distributed in this project's [Releases](https://github.com/CloneTrooper1019/Character-Realism/releases) page into your game. Just make sure the `RealismServer` and `RealismClient` scripts are placed in their appropriate locations so they only execute once upon the game starting. I recommend placing `RealismServer` into the `ServerScriptService`, and `RealismClient` under `StarterPlayer/StarterPlayerScripts`!

## Licensing

*Realism* is licensed under v2.0 of the Mozilla Public License. The intent of using this license is to allow the system to be used commercially in Roblox games for free without requiring the entire source code of the game to be disclosed. However, any improvements that you make to the system itself which could benefit others using it should be publicly disclosed under the same conditions. You must also provide credit to me (CloneTrooper1019) somewhere in your game if you use this system. This can be either the description or an in-game credits feature. Whatever suits you best :)!
Binary file added Realism.rbxm
Binary file not shown.
53 changes: 53 additions & 0 deletions Realism.server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- CloneTrooper1019, 2020
-- Realism Server
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")

local setLookAngles = Instance.new("RemoteEvent")
setLookAngles.Archivable = false
setLookAngles.Name = "SetLookAngles"
setLookAngles.Parent = ReplicatedStorage

local function onReceiveLookAngles(player, pitch, yaw)
if typeof(pitch) ~= "number" or pitch ~= pitch then
return
end

if typeof(yaw) ~= "number" or yaw ~= yaw then
return
end

pitch = math.clamp(pitch, -1, 1)
yaw = math.clamp(yaw, -1, 1)

setLookAngles:FireAllClients(player, pitch, yaw)
end

local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid", 10)

if humanoid and humanoid:IsA("Humanoid") then
CollectionService:AddTag(humanoid, "RealismHook")
end
end

local function onPlayerAdded(player)
if player.Character then
onCharacterAdded(player.Character)
end

player.CharacterAdded:Connect(onCharacterAdded)
end

for _,player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end

Players.PlayerAdded:Connect(onPlayerAdded)
setLookAngles.OnServerEvent:Connect(onReceiveLookAngles)

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
138 changes: 138 additions & 0 deletions RealismClient/Config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- CloneTrooper1019, 2020
-- Realism Config
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

local REALISM_CONFIG =
{
-----------------------------------
-- A dictionary mapping materials
-- to walking sound ids.
-----------------------------------

Sounds =
{
Dirt = 178054124;
Wood = 177940988;
Concrete = 277067660;
Grass = 4776173570;
Metal = 4790537991;
Sand = 4777003964;
Fabric = 4776951843;
Gravel = 4776998555;
Marble = 4776962643;
};

---------------------------------------
-- A dictionary mapping materials to
-- names in the 'Sounds' table, for
-- any materials that don't have a
-- specific sound id.
---------------------------------------

MaterialMap =
{
Mud = "Dirt";
Pebble = "Dirt";
Ground = "Dirt";

Sand = "Sand";
Snow = "Sand";
Sandstone = "Sand";

Rock = "Gravel";
Basalt = "Gravel";
Asphalt = "Gravel";
Glacier = "Gravel";
Slate = "Gravel";

WoodPlanks = "Wood";
LeafyGrass = "Grass";

Ice = "Marble";
Salt = "Marble";
Marble = "Marble";
Pavement = "Marble";
Limestone = "Marble";

Foil = "Metal";
DiamondPlate = "Metal";
CorrodedMetal = "Metal";
};

---------------------------------------------
-- Multiplier values (in radians) for each
-- joint, based on the pitch/yaw look angles
---------------------------------------------

RotationFactors =
{
-------------------------------
-- Shared
-------------------------------

Head =
{
Pitch = 0.8;
Yaw = 0.75;
};

-------------------------------
-- R15
-------------------------------

UpperTorso =
{
Pitch = 0.5;
Yaw = 0.5;
};

LeftUpperArm =
{
Pitch = 0.0;
Yaw = -0.5;
};

RightUpperArm =
{
Pitch = 0.0;
Yaw = -0.5;
};

-------------------------------
-- R6
-------------------------------

Torso =
{
Pitch = 0.4;
Yaw = 0.2;
};

["Left Arm"] =
{
Pitch = 0.0;
Yaw = -0.5;
};

["Right Arm"] =
{
Pitch = 0.0;
Yaw = -0.5;
};

["Left Leg"] =
{
Pitch = 0.0;
Yaw = -0.2;
};

["Right Leg"] =
{
Pitch = 0.0;
Yaw = -0.2;
};
};
}

return REALISM_CONFIG
Loading

0 comments on commit 0eb7a4a

Please sign in to comment.