2022-08-01 11:09:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Whoami
|
|
|
|
ScriptFullname="$(readlink -e "$0")"
|
|
|
|
ScriptName="$(basename "$0")"
|
|
|
|
ScriptDir="$(dirname "$ScriptFullname")"
|
|
|
|
|
|
|
|
# Dirs
|
|
|
|
PawnsDir="$ScriptDir/Pawns"
|
|
|
|
ProxiesDir="$ScriptDir/Classes"
|
|
|
|
|
|
|
|
# Gen params
|
|
|
|
PercentStart=10
|
2022-08-16 23:07:11 +00:00
|
|
|
PercentEnd=200
|
2022-08-01 11:09:38 +00:00
|
|
|
PercentInc=10
|
|
|
|
|
|
|
|
function modded_xp () # $1: XP, $2: Percent
|
|
|
|
{
|
|
|
|
local Scale=$(echo "scale=2; 1.0 + ${2}/100" | bc)
|
|
|
|
printf "%.0f" $(echo "${1}*${Scale}" | bc)
|
|
|
|
}
|
|
|
|
|
|
|
|
function main ()
|
|
|
|
{
|
|
|
|
local TmpDir
|
2022-08-17 07:53:13 +00:00
|
|
|
local Index
|
|
|
|
local DefProps
|
2022-08-01 11:09:38 +00:00
|
|
|
|
|
|
|
if ! command -v bc &> /dev/null; then
|
|
|
|
echo "Error: bc not found"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [[ -d "$ProxiesDir" ]]; then mkdir "$ProxiesDir"; fi
|
|
|
|
|
|
|
|
TmpDir=$(mktemp -d)
|
|
|
|
for ((Percent = PercentStart; Percent <= PercentEnd; Percent += PercentInc ))
|
|
|
|
do
|
2022-08-17 07:53:13 +00:00
|
|
|
(
|
2022-08-01 11:09:38 +00:00
|
|
|
PercentStr=$(printf "%03d" $Percent)
|
2022-08-17 07:53:13 +00:00
|
|
|
DefProps="$TmpDir/DefProps_${PercentStr}.dp"
|
|
|
|
echo -e -n "\tXPBoosts.Add({(\n\t\tBoostValue=${Percent}" > "$DefProps"
|
|
|
|
Index=0
|
|
|
|
for Zed in $(find "$PawnsDir" -type f -iname '*.uc' -printf "%f\n" | grep -oP '.*(?=[.])' | sort)
|
2022-08-01 11:09:38 +00:00
|
|
|
do
|
|
|
|
ProxyZed="Proxy_${Zed}_${PercentStr}"
|
|
|
|
TmpZed="$TmpDir/$ProxyZed.uc"
|
|
|
|
cp "$PawnsDir/$Zed.uc" "$TmpZed"
|
2022-08-16 06:59:16 +00:00
|
|
|
sed -i -r "s|class.+extends (.+);|class $ProxyZed extends \1;|g" "$TmpZed"
|
2022-08-01 11:09:38 +00:00
|
|
|
grep -Po 'XPValues\(\d\)=(\d+)' "$TmpZed" | \
|
|
|
|
while read XPValue
|
|
|
|
do
|
|
|
|
CurrentExp=$(echo "$XPValue" | sed -r 's|.+=([0-9]+)|\1|g')
|
|
|
|
CurrentDiff=$(echo "$XPValue" | sed -r 's|.+\(([0-9])\).+|\1|g')
|
|
|
|
ModdedXP=$(modded_xp "$CurrentExp" "$Percent")
|
|
|
|
sed -i "s|$XPValue|XPValues($CurrentDiff)=$ModdedXP // $CurrentExp|g" "$TmpZed"
|
|
|
|
done
|
2022-08-17 07:53:13 +00:00
|
|
|
echo -e -n ",\n\t\tZeds[${Index}]={(ZedName=${Zed},Proxy=class'${ProxyZed}')}" >> "$DefProps"
|
|
|
|
((Index+=1))
|
2022-08-01 11:09:38 +00:00
|
|
|
mv -f "$TmpZed" "$ProxiesDir"
|
2022-08-17 07:53:13 +00:00
|
|
|
echo "$ProxyZed"
|
2022-08-01 11:09:38 +00:00
|
|
|
done
|
2022-08-17 07:53:13 +00:00
|
|
|
echo -e -n "\n\t)})\n" >> "$DefProps"
|
|
|
|
) &
|
2022-08-01 11:09:38 +00:00
|
|
|
done
|
2022-08-17 07:53:13 +00:00
|
|
|
wait
|
|
|
|
|
|
|
|
echo -e -n 'defaultproperties\n{\n' > "$ScriptDir/ProxiesDefProps.uc"
|
|
|
|
find "$TmpDir" -type f -iname '*.dp' -exec cat {} \; >> "$ScriptDir/ProxiesDefProps.uc"
|
|
|
|
echo -e -n '}\n' >> "$ScriptDir/ProxiesDefProps.uc"
|
|
|
|
|
2022-08-01 11:09:38 +00:00
|
|
|
rm -rf "$TmpDir"
|
|
|
|
echo "Done"
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|