Compare commits
No commits in common. "master" and "v0.5-beta" have entirely different histories.
|
@ -1,8 +1,6 @@
|
||||||
Disguiser SWEP
|
Disguiser SWEP
|
||||||
==============
|
==============
|
||||||
|
|
||||||
[![YouTube: [gmod] Derping around with the Disguiser ](http://img.youtube.com/vi/IvMkNIm4Ro0/0.jpg)](http://www.youtube.com/watch?v=IvMkNIm4Ro0&feature=github)
|
|
||||||
|
|
||||||
So you always wanted to be able to disguise as another item on the map in Sandbox or
|
So you always wanted to be able to disguise as another item on the map in Sandbox or
|
||||||
any other game mode than Prop Hunt? You were always annoyed by how you were able to
|
any other game mode than Prop Hunt? You were always annoyed by how you were able to
|
||||||
see yourself being able to rotate but without knowing you were still standing all the
|
see yourself being able to rotate but without knowing you were still standing all the
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
"ignore" :
|
"ignore" :
|
||||||
[
|
[
|
||||||
"*.git*",
|
"*.git*",
|
||||||
"*.svn*",
|
"*.svn*"
|
||||||
"builds*",
|
|
||||||
"tools*",
|
|
||||||
"*.bat",
|
|
||||||
"*.sh",
|
|
||||||
"*.md",
|
|
||||||
"LICENSE.txt"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
40
build.bat
40
build.bat
|
@ -5,44 +5,6 @@ path %programfiles(x86)%\lua\5.1\;%path%;%programfiles(x86)%\Steam\SteamApps\com
|
||||||
if not exist builds mkdir builds
|
if not exist builds mkdir builds
|
||||||
mkdir tmp
|
mkdir tmp
|
||||||
|
|
||||||
:: Root path
|
|
||||||
set workspace=%cd%
|
|
||||||
set workspacelentmp=%workspace%
|
|
||||||
set workspacelen=1
|
|
||||||
:workspacelencalc
|
|
||||||
set /a workspacelen=!workspacelen!+1
|
|
||||||
set workspace=!workspace:~1!
|
|
||||||
if "%workspace%"=="" goto compile
|
|
||||||
goto workspacelencalc
|
|
||||||
|
|
||||||
:compileerr
|
|
||||||
echo ERROR: Compilation failed.
|
|
||||||
exit /B -1
|
|
||||||
|
|
||||||
:compile
|
|
||||||
echo Workspace: %workspace% (%workspacelen%)
|
|
||||||
:: Compile LUA files
|
|
||||||
pushd lua
|
|
||||||
for /r %%i in (.) do (
|
|
||||||
set absdir=%%i
|
|
||||||
set directory=!absdir:~%workspacelen%,-2!
|
|
||||||
|
|
||||||
echo Creating !directory!...
|
|
||||||
mkdir "..\tmp\!directory!"
|
|
||||||
)
|
|
||||||
for /r %%i in (*.lua) do (
|
|
||||||
set absfile=%%i
|
|
||||||
set file=!absfile:~%workspacelen%!
|
|
||||||
|
|
||||||
echo Compiling !file!...
|
|
||||||
luac52 -o "..\tmp\!file!" "!absfile!"
|
|
||||||
if %errorlevel% NEQ 0 (
|
|
||||||
echo Could not compile !file!, only copying...
|
|
||||||
copy !absfile! "..\tmp\!file!"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
popd
|
|
||||||
|
|
||||||
:: Optimize LUA files
|
:: Optimize LUA files
|
||||||
::set cutofflen=
|
::set cutofflen=
|
||||||
::set foo=%~dp0
|
::set foo=%~dp0
|
||||||
|
@ -72,4 +34,4 @@ gmad create -folder "tmp" -out "builds\disguiser_swep.gma"
|
||||||
|
|
||||||
:: Clean up
|
:: Clean up
|
||||||
rmdir /q /s tmp
|
rmdir /q /s tmp
|
||||||
::pause
|
pause
|
||||||
|
|
99
build.sh
99
build.sh
|
@ -1,99 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
reldir() {
|
|
||||||
# both $1 and $2 are absolute paths beginning with /
|
|
||||||
# returns relative path to $2/$target from $1/$source
|
|
||||||
source=$1
|
|
||||||
target=$2
|
|
||||||
|
|
||||||
common_part=$source # for now
|
|
||||||
result="" # for now
|
|
||||||
|
|
||||||
while [[ "${target#$common_part}" == "${target}" ]]; do
|
|
||||||
# no match, means that candidate common part is not correct
|
|
||||||
# go up one level (reduce common part)
|
|
||||||
common_part="$(dirname $common_part)"
|
|
||||||
# and record that we went back, with correct / handling
|
|
||||||
if [[ -z $result ]]; then
|
|
||||||
result=".."
|
|
||||||
else
|
|
||||||
result="../$result"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $common_part == "/" ]]; then
|
|
||||||
# special case for root (no common path)
|
|
||||||
result="$result/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# since we now have identified the common part,
|
|
||||||
# compute the non-common part
|
|
||||||
forward_part="${target#$common_part}"
|
|
||||||
|
|
||||||
# and now stick all parts together
|
|
||||||
if [[ -n $result ]] && [[ -n $forward_part ]]; then
|
|
||||||
result="$result$forward_part"
|
|
||||||
elif [[ -n $forward_part ]]; then
|
|
||||||
# extra slash removal
|
|
||||||
result="${forward_part:1}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $result
|
|
||||||
}
|
|
||||||
|
|
||||||
copy_flt() {
|
|
||||||
filter="$3"
|
|
||||||
source="$1"
|
|
||||||
target="$2"
|
|
||||||
|
|
||||||
find "$source" -type "d" -not -path "$target" | while read i; do
|
|
||||||
mkdir -p "$target/$(reldir $source $i)"
|
|
||||||
done
|
|
||||||
find "$source" -name "$filter" -type "f" -not -path "$target" | while read i; do
|
|
||||||
cp "$i" "$target/$(reldir $source $i)"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir -p builds
|
|
||||||
|
|
||||||
if [ -e tmp ]; then
|
|
||||||
rm -rf tmp
|
|
||||||
fi
|
|
||||||
mkdir -p tmp
|
|
||||||
|
|
||||||
# Root path
|
|
||||||
workspace=$(pwd)
|
|
||||||
|
|
||||||
echo Workspace: $workspace
|
|
||||||
|
|
||||||
# Copy over
|
|
||||||
copy_flt "." "tmp" "*.json"
|
|
||||||
copy_flt "." "tmp" "*.wav"
|
|
||||||
copy_flt "." "tmp" "*.lua"
|
|
||||||
copy_flt "." "tmp" "*.mp3"
|
|
||||||
copy_flt "." "tmp" "*.jpg"
|
|
||||||
copy_flt "." "tmp" "*.png"
|
|
||||||
copy_flt "." "tmp" "*.txt"
|
|
||||||
|
|
||||||
find tmp
|
|
||||||
|
|
||||||
# Compile LUA files
|
|
||||||
pushd lua
|
|
||||||
mkdir -p ../tmp/lua
|
|
||||||
find . -type f -name '*.lua' | while read absfile; do
|
|
||||||
file="lua/$absfile"
|
|
||||||
echo "Compiling $file..."
|
|
||||||
luac5.2 -o "../tmp/$file.luac" "$absfile" && (
|
|
||||||
rm "/tmp/$file"
|
|
||||||
mv "/tmp/$file.luac" "/tmp/$file"
|
|
||||||
) || (
|
|
||||||
echo "Could not compile $file, leaving as is."
|
|
||||||
)
|
|
||||||
done
|
|
||||||
popd
|
|
||||||
|
|
||||||
# Create the GMA file
|
|
||||||
gmad create -warninvalid -folder "tmp" -out "builds/disguiser_swep.gma"
|
|
||||||
|
|
||||||
# Clean up
|
|
||||||
rm -rf tmp
|
|
|
@ -1,47 +1,48 @@
|
||||||
--
|
/**
|
||||||
-- Disguiser SWEP - Lets you disguise as any prop on a map.
|
* Disguiser SWEP - Lets you disguise as any prop on a map.
|
||||||
--
|
*
|
||||||
-- File:
|
* File:
|
||||||
-- patch_createfont.lua
|
* patch_createfont.lua
|
||||||
--
|
*
|
||||||
-- Purpose:
|
* Purpose:
|
||||||
-- This code will allow any font to be checked for existence. I hope it works
|
* This code will allow any font to be checked for existence. I hope it works
|
||||||
-- as it is only a function patch which should be loaded right at the beginning.
|
* as it is only a function patch which should be loaded right at the beginning.
|
||||||
-- Can't guarantee that it loads right at the beginning though.
|
* Can't guarantee that it loads right at the beginning though.
|
||||||
--
|
*
|
||||||
-- Copyright (C) 2013 Carl Kittelberger (Icedream)
|
* Copyright (C) 2013 Carl Kittelberger (Icedream)
|
||||||
--
|
*
|
||||||
-- This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
-- it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
-- published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
-- License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
--
|
*
|
||||||
-- This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
-- GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
--
|
*
|
||||||
-- You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
print("[Disguiser] Loading compatibility layer for surface.CreateFont...")
|
print("[Disguiser] Loading compatibility layer for surface.CreateFont...")
|
||||||
|
|
||||||
local registered_fonts = {}
|
local registered_fonts = {}
|
||||||
|
|
||||||
-- Function already patched by us?
|
// Function already patched by us?
|
||||||
if not surface.__createFont == nil then
|
if !!surface.__createFont then
|
||||||
MsgC(Color(255, 255, 0), "[Fontpatch] Can't patch surface.CreateFont, already patched. Skipping patch.\n")
|
MsgC(Color(255, 255, 0), "[Fontpatch] Can't patch surface.CreateFont, already patched. Skipping patch.\n")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Original function
|
// Original function
|
||||||
surface.__createFont = surface.CreateFont
|
surface.__createFont = surface.CreateFont
|
||||||
|
|
||||||
-- Patch function
|
// Patch function
|
||||||
function surface.CreateFont(name, data)
|
function surface.CreateFont(name, data)
|
||||||
if not name or not data then return false end
|
if !name || !data then return false end
|
||||||
|
|
||||||
if registered_fonts[name] then
|
if !!registered_fonts[name] then
|
||||||
MsgN("[Fontpatch] Skipping font " .. name .. ", already registered")
|
MsgN("[Fontpatch] Skipping font " .. name .. ", already registered")
|
||||||
else
|
else
|
||||||
MsgN("[Fontpatch] Registering font " .. name .. "...")
|
MsgN("[Fontpatch] Registering font " .. name .. "...")
|
||||||
|
@ -50,7 +51,7 @@ function surface.CreateFont(name, data)
|
||||||
surface.__createFont(name, data)
|
surface.__createFont(name, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if a font exists
|
// Check if a font exists
|
||||||
function surface.FontExists(name)
|
function surface.FontExists(name)
|
||||||
return not not registered_fonts[name]
|
return !!registered_fonts[name] // I love how all those peeps on the internet still don't use the !! thingie
|
||||||
end
|
end
|
|
@ -86,7 +86,7 @@ hook.Add("CalcView", "Disguiser.ThirdPersonCalcView", function(ply, pos, angles,
|
||||||
end
|
end
|
||||||
|
|
||||||
// Smoothing FOV change
|
// Smoothing FOV change
|
||||||
fov = targetfov -- comment or remove this to enable smoothing
|
fov = targetfov
|
||||||
fov = math.Approach(fov, targetfov, math.abs(targetfov - fov) * smoothscale)
|
fov = math.Approach(fov, targetfov, math.abs(targetfov - fov) * smoothscale)
|
||||||
|
|
||||||
return GAMEMODE:CalcView(ply, pos, angles, fov)
|
return GAMEMODE:CalcView(ply, pos, angles, fov)
|
||||||
|
|
|
@ -316,7 +316,6 @@ function SWEP:EnableThirdPerson(player)
|
||||||
entity:SetModel(player:GetModel())
|
entity:SetModel(player:GetModel())
|
||||||
entity:Spawn()
|
entity:Spawn()
|
||||||
entity:SetAngles(player:GetAngles())
|
entity:SetAngles(player:GetAngles())
|
||||||
entity:SetVelocity(player:GetVelocity())
|
|
||||||
entity:SetMoveType(MOVETYPE_NONE)
|
entity:SetMoveType(MOVETYPE_NONE)
|
||||||
entity:SetParent(player)
|
entity:SetParent(player)
|
||||||
entity:SetOwner(player)
|
entity:SetOwner(player)
|
||||||
|
|
Loading…
Reference in New Issue