-
Notifications
You must be signed in to change notification settings - Fork 4
/
weapondefs_post.lua
206 lines (185 loc) · 5.76 KB
/
weapondefs_post.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- file: weapondefs_post.lua
-- brief: weaponDef post processing
-- author: Dave Rodgers
--
-- Copyright (C) 2008.
-- Licensed under the terms of the GNU GPL, v2 or later.
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local function isbool(x) return (type(x) == 'boolean') end
local function istable(x) return (type(x) == 'table') end
local function isnumber(x) return (type(x) == 'number') end
local function isstring(x) return (type(x) == 'string') end
local function tobool(val)
local t = type(val)
if (t == 'nil') then
return false
elseif (t == 'boolean') then
return val
elseif (t == 'number') then
return (val ~= 0)
elseif (t == 'string') then
return ((val ~= '0') and (val ~= 'false'))
end
return false
end
local noVerticalRangeBoostWeapons = {
gear_u1commander_flamethrower = true,
gear_pyro_flamethrower = true,
gear_heater_flamethrower = true,
gear_burner_flamethrower = true,
gear_cube_flamethrower = true,
claw_sword_laser = true,
claw_u6commander_laser = true,
claw_knife_laser = true
}
local function processSoundDefaults(wd)
local forceSetVolume = (not wd.soundstartvolume) or (not wd.soundhitvolume)
if not forceSetVolume then
return
end
local defaultDamage = wd.damage and wd.damage.default
if (not defaultDamage) then
wd.soundstartvolume = 1
wd.soundhitvolume = 1
return
end
local soundVolume = 1.4 + math.sqrt(defaultDamage * 0.1) * 0.1
if (not wd.soundstartvolume) then
wd.soundstartvolume = soundVolume
end
if (not wd.soundhitvolume) then
wd.soundhitvolume = soundVolume
end
end
-- weapondef tweaking
-- NOTE : property names are lower case
for wdName, wd in pairs(WeaponDefs) do
-- auto detect ota weapontypes
if (wd.weapontype==nil) then
local rendertype = tonumber(wd.rendertype) or 0
if (tobool(wd.dropped)) then
wd.weapontype = "AircraftBomb"
elseif (tobool(wd.vlaunch)) then
wd.weapontype = "StarburstLauncher"
elseif (tobool(wd.beamlaser)) then
wd.weapontype = "BeamLaser"
elseif (tobool(wd.isshield)) then
wd.weapontype = "Shield"
elseif (tobool(wd.waterweapon)) then
wd.weapontype = "TorpedoLauncher"
elseif (wdName:lower():find("disintegrator",1,true)) then
wd.weapontype = "DGun"
elseif (tobool(wd.lineofsight)) then
if (rendertype==7) then
wd.weapontype = "LightningCannon"
elseif (wd.model and wd.model:lower():find("laser",1,true)) then
wd.weapontype = "LaserCannon"
elseif (tobool(wd.beamweapon)) then
wd.weapontype = "LaserCannon"
elseif (tobool(wd.smoketrail)) then
wd.weapontype = "MissileLauncher"
elseif (rendertype==4 and tonumber(wd.color)==2) then
wd.weapontype = "EmgCannon"
elseif (rendertype==5) then
wd.weapontype = "Flame"
--elseif(rendertype==1) then
-- wd.weapontype = "MissileLauncher"
else
wd.weapontype = "Cannon"
end
else
wd.weapontype = "Cannon"
end
end
-- reduce cratering
if (not wd.cratermult) then
wd.cratermult = 0.1
end
if (wdName ~= "sphere_magnetar_blast") then
-- change visual intensity for EMG cannons, change weaponType
if wd.weapontype == "EmgCannon" then
wd.intensity = 0.1
wd.weapontype = "Cannon"
end
if (noVerticalRangeBoostWeapons[wdName]) then
wd.heightmod = 1
wd.heightboostfactor = 0
elseif (wd.weapontype == "BeamLaser") then
wd.heightmod = 1.0 -- default was 1.0
-- fading effect for beams proportional to damage
if wd.damage and wd.damage.default then
local defaultDamage = tonumber(wd.damage.default)
wd.beamttl = 4 + defaultDamage / 130
if not wd.beamdecay then
wd.beamdecay = 0.8
end
if not wd.laserflaresize then
wd.laserflaresize = 9
end
end
elseif (wd.weapontype == "LaserCannon") then
wd.heightmod = 1.0 -- default was 1.0
elseif (wd.weapontype == "Cannon" or wd.weapontype == "EmgCannon" ) then
if wd.range and tonumber(wd.range) > 380 then
wd.heightmod = 0.5 -- default was 0.8
end
wd.heightboostfactor = 0.0 -- default was -1.0
elseif (wd.weapontype == "MissileLauncher" ) then
wd.heightmod = 0.5 -- default was 0.8
elseif (wd.weapontype == "StarburstLauncher" ) then
wd.cylindertargeting = 2
end
-- override mygravity for cannons if not specified
if (wd.weapontype == "Cannon") then
if (not wd.mygravity) then
wd.mygravity = 0.1
end
end
-- range compensation for lasercannons due to engine bug
-- https://springrts.com/mantis/view.php?id=6384
if (wd.weapontype == "LaserCannon") then
local oRange = tonumber(wd.range)
if oRange > 0 then
wd.range = oRange + 20
end
end
end
-- force unit to retry the aim animation more often
-- without this it would only run twice per second (?)
-- wd.allownonblockingaim = 1
if (wd.tolerance ~= nil and wd.range ~= nil) then
wd.firetolerance = 32000 -- wd.tolerance * 0.5
end
if not (wd.customparams) then
wd.customparams = {}
end
if not (wd.customparams.reaimtime) then
wd.customparams.reaimtime = 10
end
if wd.areaofeffect then
local aoe = tonumber(wd.areaofeffect)
local edge = tonumber(wd.edgeeffectiveness) or 0
-- set minimum aoe to 12
if aoe < 10 then
wd.areaofeffect = 12
end
-- increase edge effectiveness by 0.2
if edge < 0.8 then
wd.edgeeffectiveness = edge + 0.2
end
-- set explosion speed
-- defaults are about 3-4 for most cases
if (not wd.explosionspeed) then
wd.explosionspeed = 7 + aoe*0.02
end
end
-- TODO disabled for now because it'd make walls untargetable
--wd.avoidNeutral = 1
-- make weapon sounds relatively louder
processSoundDefaults(wd)
end