do you have a post where all of this is put together just so if any of us want to implement it we can test the changes?
it would be nice if you included everything in the first post so we can see what all is changed so everyone dosent have to go through all of the posts.
you should make a new post in the mods section and put the updated code there and what each thing does just so there is not a huge long post with all of your data might be easier and link back to here for reference.
<!--quoteo(post=1893256:date=Jan 10 2012, 02:10 AM:name=Yuuki)--><div class='quotetop'>QUOTE (Yuuki @ Jan 10 2012, 02:10 AM) <a href="index.php?act=findpost&pid=1893256"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Hu, seems right, I check with the matlab version (just counting the points) and I get the same function :
Why are we doing this again ? ^^<!--QuoteEnd--></div><!--QuoteEEnd--> It'd be more useful to have it be hit-rate versus distance, because... (Why are we doing this?) We were going to use hit-rate with distance and multiply that by the raw damage with distance, to get the average damage with distance; so that we can balance damage with distance...
Here is the hit-rate versus distance. I used target radius of 0.2 and 6 degree spread. I have no idea if the scale is right, I don't really have an idea of the typical distance or life form size.
The function drops quite fast, but it depends on the different parameters of course.
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->what does uwe's graph look like on how they have that set? or is that the original params from vanilla ns2?<!--QuoteEnd--></div><!--QuoteEEnd-->
It's vanilla ns2, bullets/spikes have a bit of spread so if the target is far and small a fraction of the bullets will miss even if you aim perfectly. The graph is for 6 degree spread and guessed target size and distance (seems more or less right). I think it's correct but it's not so trivial to compute so I might have made a mistake.
Shotgun and spikes have an additional piece-wise linear damage drop with distance. I don't think rifle and pistol have any.
Additional drop function looks like some that Harimau did I think :
What's the equation for that graph, so I can plug it into excel?
Is it f = rt/rs [1 - ln(rt/rs) ] where rt = some constant, and rs = d*tan(spreadAngle), f = hitrate <strike>ugh, except that when d = 0, it's trying to divide by zero... Yeah, I'm definitely doing something wrong here.</strike> EDIT: Oh, forgot about the rt < rs thing. EDIT: Yep, got it working.
Also, this is one serious tangent we're on...
EDIT: So, with the assumption that a lerk has perfect aim and a marine's hitbox is a circle of radius = 0.302* (60cm in diameter), this is the 'raw' and 'average' damage with respect to distance for the live implementation (UWE's original) <img src="http://i.imgur.com/tU5JT.png" border="0" class="linked-image" /> *I've just said that a marine has height = 1.8, width = 0.5, therefore area = 0.9 = PI*r^2 => r = 0.302 With this implementation, the damage = 24 at distance = 0 and damage = 20 at distance >= 16, with the damage between being a straight line, and a spike cone of 8 degrees.
Btw, Fluid Core, what different final systems have we come up with now?
Well, I added the complete code for the sigmoid approach, the entirely physical approach where damage decrease on distance come from drag, and the approach that you at one point said you preferred. The codes should be linked to on dropbox on page 4 (?) I believe.
<!--quoteo(post=1893138:date=Jan 8 2012, 04:34 PM:name=Fluid Core)--><div class='quotetop'>QUOTE (Fluid Core @ Jan 8 2012, 04:34 PM) <a href="index.php?act=findpost&pid=1893138"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->The completely physical approach with drag. <a href="http://dl.dropbox.com/u/49503284/lerkSpikes/lua/Weapons/Alien/SpikesPhysical.lua" target="_blank">http://dl.dropbox.com/u/49503284/lerkSpike...kesPhysical.lua</a> The semi physical approach with drag for speed damage decrease, but linear damage decrease for range. <a href="http://dl.dropbox.com/u/49503284/lerkSpikes/lua/Weapons/Alien/SpikesSemiPhysical.lua" target="_blank">http://dl.dropbox.com/u/49503284/lerkSpike...emiPhysical.lua</a> The mathematical approach with a sigmoid shape. The one I tested against eggs/drifters/MAC:s <a href="http://dl.dropbox.com/u/49503284/lerkSpikes/lua/Weapons/Alien/SpikesSigmoid.lua" target="_blank">http://dl.dropbox.com/u/49503284/lerkSpike...ikesSigmoid.lua</a><!--QuoteEnd--></div><!--QuoteEEnd-->
<!--quoteo(post=1893267:date=Jan 9 2012, 09:42 PM:name=BJHBnade_spammer)--><div class='quotetop'>QUOTE (BJHBnade_spammer @ Jan 9 2012, 09:42 PM) <a href="index.php?act=findpost&pid=1893267"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->do you have a post where all of this is put together just so if any of us want to implement it we can test the changes?
it would be nice if you included everything in the first post so we can see what all is changed so everyone dosent have to go through all of the posts.
you should make a new post in the mods section and put the updated code there and what each thing does just so there is not a huge long post with all of your data might be easier and link back to here for reference.<!--QuoteEnd--></div><!--QuoteEEnd-->
A note on the lua files there: You have retained the following lines of code <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> local damageDistScalar = Clamp(1 - (distToTarget / kSpikeMinDamageRange), 0, 1) local damage = kSpikeMinDamage + damageDistScalar * (kSpikeMaxDamage - kSpikeMinDamage)<!--c2--></div><!--ec2--> even though damageDistScalar is not used in SpikesPhysical.lua and SpikesSigmoid.lua; and the initial value for damage above is not used in any of the scripts (wasted code).
So for the two lines above I would remove the first line from SpikesPhysical.lua and SpikesSigmoid.lua, and I would remove the second line from all three scripts, but instead where you have <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> damage = 20/47^2*(47+movement)^2*e^(-1.2047*distToTarget/(1390*0.04)) damage = static * (dragfactor*movement/35 + 1)^2 damage = 40/(1+math.exp(-(movement-1)/5))*(0.4*math.exp(-(distToTarget^2)/200)+0.6)<!--c2--></div><!--ec2--> change them to <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> local damage = 20/47^2*(47+movement)^2*e^(-1.2047*distToTarget/(1390*0.04)) local damage = static * (dragfactor*movement/35 + 1)^2 local damage = 40/(1+math.exp(-(movement-1)/5))*(0.4*math.exp(-(distToTarget^2)/200)+0.6)<!--c2--></div><!--ec2-->
There was also another, "physical approach with game numbers", that I proposed:
I've removed most of the comment clutter (like derivations and such). For the derivations, see <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=115786&view=findpost&p=1893114" target="_blank">this post</a>; and for a summary see <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=115786&view=findpost&p=1893177" target="_blank">this post</a>.
There are two flavours.
You can choose the most abstract version (balancing involves changing values in balance.lua): 5 lines <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> // Do max damage for short time and then fall off over time to encourage close quarters combat instead of // hanging back and sniping local damageScalar = ConditionalValue(player:GetHasUpgrade(kTechId.Piercing), kPiercingDamageScalar, 1) local distToTarget = (trace.endPoint - startPoint):GetLength()
// Make damage increase based on your speed and decrease based on your range:
local movement = player:GetVelocity():DotProduct(player:GetViewAngles():GetCoords().zAxis)
local spikeSpeed = 52 local distConstant = -math.ln(kSpikeMinDamage / kSpikeMaxDamage) / (kSpikeMinDamageRange - kSpikeMaxDamageRange) // !! need to check if natural logarithm function is in fact " math.ln "
local distLimited = Clamp(distToTarget - kSpikeMaxDamageRange, 0, kSpikeMinDamageRange - kSpikeMaxDamageRange) local damage = kSpikeMaxDamage*(movement/spikeSpeed+1)^2*math.exp(-distConstant*distLimited))<!--c2--></div><!--ec2-->
or you can choose the version with ALL the necessary values (including stuff ordinarily defined in balance.lua) already substituted (also uses different, possibly better values): 3 lines <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> // Do max damage for short time and then fall off over time to encourage close quarters combat instead of // hanging back and sniping local damageScalar = ConditionalValue(player:GetHasUpgrade(kTechId.Piercing), kPiercingDamageScalar, 1) local distToTarget = (trace.endPoint - startPoint):GetLength()
// Make damage increase based on your speed and decrease based on your range:
local movement = player:GetVelocity():DotProduct(player:GetViewAngles():GetCoords().zAxis)
local distLimited = Clamp(distToTarget - 2, 0, 16 - 2) local damage = 20*(movement/52+1)^2*math.exp(-0.020548719*distLimited))<!--c2--></div><!--ec2-->
Also, if we want to reduce the effect of extreme movement speeds, you add 1 line: <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> local movement = player:GetVelocity():DotProduct(player:GetViewAngles():GetCoords().zAxis) movement = math.sign(movement)*math.abs(movement)^0.9 // !! assuming there's a math.sign function (it returns -1 if -ve, 0 if zero, 1 if +ve), otherwise will have to use if statements<!--c2--></div><!--ec2--> (It doesn't have to be 0.9, it can be less or more, but less than 1 of course.) Basically, the size of movement is reduced and reduced proportionally to its own size, so increased movement does not lead to such an increased damage. Illustration: <img src="http://i.imgur.com/b9I32.png" border="0" class="linked-image" />
I'm slightly hessitant to remove original lines. I've got the feeling that it sometimes makes the game not start, with the "attempting to access function 'GetIsAlive', a nil value" error. It looks something like that. If you could test the code to make sure it works, that would be great. Another note is that it may be usefull to keep the old lines to be able to compare and see just what we changed. A final version would have the codes fully optimised though. I think adding a .txt file with the comments and such would be better also, to speed up the code :)
Well I think you should try just commenting those two lines out for now (and change "damage" to "local damage"), and see if it still works. I can't test it right now (or soon) since NS2 hasn't been installed on this PC. I'll probably wait until 190 so that I won't have to download it and then download a massive patch soon after (Australia, download limits, etc.)
Not going to test it now, preparing myself mentally for an upcomming exam :)
Forums is just the right kind of relaxed distraction, coding and testing is to much :P Just noticed you joined the forums one day before me! I would have guessed you were from there due to time too, and I noticed now that you've added location too :)
Verified the files for 192 and commented away the unused parts. Also made you able to hold secondary fire and not wait to the end of all times if you timed your primary release wrong.
Comments
<a href="http://sciencesoft.at/lpng/2861fe4a32bd614b4bce2a451344af40c267b8c.txt" target="_blank">http://sciencesoft.at/lpng/2861fe4a32bd614...af40c267b8c.txt</a>
<img src="http://i.imgur.com/64SIH.png" border="0" class="linked-image" />
Why are we doing this again ? ^^
it would be nice if you included everything in the first post so we can see what all is changed so everyone dosent have to go through all of the posts.
you should make a new post in the mods section and put the updated code there and what each thing does just so there is not a huge long post with all of your data might be easier and link back to here for reference.
<img src="http://i.imgur.com/64SIH.png" border="0" class="linked-image" />
Why are we doing this again ? ^^<!--QuoteEnd--></div><!--QuoteEEnd-->
It'd be more useful to have it be hit-rate versus distance, because...
(Why are we doing this?)
We were going to use hit-rate with distance and multiply that by the raw damage with distance, to get the average damage with distance; so that we can balance damage with distance...
The function drops quite fast, but it depends on the different parameters of course.
<img src="http://i.imgur.com/ufT2E.png" border="0" class="linked-image" />
As I understand it applies to all weapons in game.
or is that the original params from vanilla ns2?
or is that the original params from vanilla ns2?<!--QuoteEnd--></div><!--QuoteEEnd-->
It's vanilla ns2, bullets/spikes have a bit of spread so if the target is far and small a fraction of the bullets will miss even if you aim perfectly. The graph is for 6 degree spread and guessed target size and distance (seems more or less right). I think it's correct but it's not so trivial to compute so I might have made a mistake.
Shotgun and spikes have an additional piece-wise linear damage drop with distance. I don't think rifle and pistol have any.
Additional drop function looks like some that Harimau did I think :
<img src="http://i.imgur.com/cMciw.png" border="0" class="linked-image" />
Rifle has a 3 degree spread so the drop is less sever than in the graph bellow, and pistol has only 1 degree.
<img src="http://i.imgur.com/ufT2E.png" border="0" class="linked-image" />
Is it
f = rt/rs [1 - ln(rt/rs) ]
where rt = some constant, and rs = d*tan(spreadAngle), f = hitrate
<strike>ugh, except that when d = 0, it's trying to divide by zero...
Yeah, I'm definitely doing something wrong here.</strike>
EDIT: Oh, forgot about the rt < rs thing.
EDIT: Yep, got it working.
Also, this is one serious tangent we're on...
EDIT: So, with the assumption that a lerk has perfect aim and a marine's hitbox is a circle of radius = 0.302* (60cm in diameter), this is the 'raw' and 'average' damage with respect to distance for the live implementation (UWE's original)
<img src="http://i.imgur.com/tU5JT.png" border="0" class="linked-image" />
*I've just said that a marine has height = 1.8, width = 0.5, therefore area = 0.9 = PI*r^2 => r = 0.302
With this implementation, the damage = 24 at distance = 0 and damage = 20 at distance >= 16, with the damage between being a straight line, and a spike cone of 8 degrees.
Btw, Fluid Core, what different final systems have we come up with now?
<!--quoteo(post=1893138:date=Jan 8 2012, 04:34 PM:name=Fluid Core)--><div class='quotetop'>QUOTE (Fluid Core @ Jan 8 2012, 04:34 PM) <a href="index.php?act=findpost&pid=1893138"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->The completely physical approach with drag.
<a href="http://dl.dropbox.com/u/49503284/lerkSpikes/lua/Weapons/Alien/SpikesPhysical.lua" target="_blank">http://dl.dropbox.com/u/49503284/lerkSpike...kesPhysical.lua</a>
The semi physical approach with drag for speed damage decrease, but linear damage decrease for range.
<a href="http://dl.dropbox.com/u/49503284/lerkSpikes/lua/Weapons/Alien/SpikesSemiPhysical.lua" target="_blank">http://dl.dropbox.com/u/49503284/lerkSpike...emiPhysical.lua</a>
The mathematical approach with a sigmoid shape. The one I tested against eggs/drifters/MAC:s
<a href="http://dl.dropbox.com/u/49503284/lerkSpikes/lua/Weapons/Alien/SpikesSigmoid.lua" target="_blank">http://dl.dropbox.com/u/49503284/lerkSpike...ikesSigmoid.lua</a><!--QuoteEnd--></div><!--QuoteEEnd-->
it would be nice if you included everything in the first post so we can see what all is changed so everyone dosent have to go through all of the posts.
you should make a new post in the mods section and put the updated code there and what each thing does just so there is not a huge long post with all of your data might be easier and link back to here for reference.<!--QuoteEnd--></div><!--QuoteEEnd-->
As you wished, I have now updated the first post.
And here is the modding post:
<a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=115838" target="_blank">http://www.unknownworlds.com/ns2/forums/in...howtopic=115838</a>
You have retained the following lines of code
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> local damageDistScalar = Clamp(1 - (distToTarget / kSpikeMinDamageRange), 0, 1)
local damage = kSpikeMinDamage + damageDistScalar * (kSpikeMaxDamage - kSpikeMinDamage)<!--c2--></div><!--ec2-->
even though damageDistScalar is not used in SpikesPhysical.lua and SpikesSigmoid.lua; and the initial value for damage above is not used in any of the scripts (wasted code).
So for the two lines above I would remove the first line from SpikesPhysical.lua and SpikesSigmoid.lua, and I would remove the second line from all three scripts, but instead where you have
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> damage = 20/47^2*(47+movement)^2*e^(-1.2047*distToTarget/(1390*0.04))
damage = static * (dragfactor*movement/35 + 1)^2
damage = 40/(1+math.exp(-(movement-1)/5))*(0.4*math.exp(-(distToTarget^2)/200)+0.6)<!--c2--></div><!--ec2-->
change them to
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> local damage = 20/47^2*(47+movement)^2*e^(-1.2047*distToTarget/(1390*0.04))
local damage = static * (dragfactor*movement/35 + 1)^2
local damage = 40/(1+math.exp(-(movement-1)/5))*(0.4*math.exp(-(distToTarget^2)/200)+0.6)<!--c2--></div><!--ec2-->
There was also another, "physical approach with game numbers", that I proposed:
I've removed most of the comment clutter (like derivations and such). For the derivations, see <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=115786&view=findpost&p=1893114" target="_blank">this post</a>; and for a summary see <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=115786&view=findpost&p=1893177" target="_blank">this post</a>.
There are two flavours.
You can choose the most abstract version (balancing involves changing values in balance.lua):
5 lines
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> // Do max damage for short time and then fall off over time to encourage close quarters combat instead of
// hanging back and sniping
local damageScalar = ConditionalValue(player:GetHasUpgrade(kTechId.Piercing), kPiercingDamageScalar, 1)
local distToTarget = (trace.endPoint - startPoint):GetLength()
// Make damage increase based on your speed and decrease based on your range:
local movement = player:GetVelocity():DotProduct(player:GetViewAngles():GetCoords().zAxis)
// kSpikeMaxDamage 24 // [from balance.lua]
// kSpikeMinDamage 20 // [from balance.lua]
// kSpikeMaxDamageRange 2 // [from balance.lua]
// kSpikeMinDamageRange 16 // [from balance.lua]
// spikeSpeed 52 // (below, arbitrarily specified)
// distConstant 0.013022968 // (below, calculated)
local spikeSpeed = 52
local distConstant = -math.ln(kSpikeMinDamage / kSpikeMaxDamage) / (kSpikeMinDamageRange - kSpikeMaxDamageRange)
// !! need to check if natural logarithm function is in fact " math.ln "
local distLimited = Clamp(distToTarget - kSpikeMaxDamageRange, 0, kSpikeMinDamageRange - kSpikeMaxDamageRange)
local damage = kSpikeMaxDamage*(movement/spikeSpeed+1)^2*math.exp(-distConstant*distLimited))<!--c2--></div><!--ec2-->
or you can choose the version with ALL the necessary values (including stuff ordinarily defined in balance.lua) already substituted (also uses different, possibly better values):
3 lines
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> // Do max damage for short time and then fall off over time to encourage close quarters combat instead of
// hanging back and sniping
local damageScalar = ConditionalValue(player:GetHasUpgrade(kTechId.Piercing), kPiercingDamageScalar, 1)
local distToTarget = (trace.endPoint - startPoint):GetLength()
// Make damage increase based on your speed and decrease based on your range:
local movement = player:GetVelocity():DotProduct(player:GetViewAngles():GetCoords().zAxis)
// kSpikeMaxDamage 20 // (specified)
// kSpikeMinDamage 15 // (specified)
// kSpikeMaxDamageRange 2 // (specified)
// kSpikeMinDamageRange 16 // (specified)
// spikeSpeed 52 // (arbitrarily specified)
// distConstant 0.020548719 // (externally calculated)
// where distConstant = -ln(kSpikeMinDamage / kSpikeMaxDamage) / (kSpikeMinDamageRange - kSpikeMaxDamageRange)
local distLimited = Clamp(distToTarget - 2, 0, 16 - 2)
local damage = 20*(movement/52+1)^2*math.exp(-0.020548719*distLimited))<!--c2--></div><!--ec2-->
Also, if we want to reduce the effect of extreme movement speeds, you add 1 line:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> local movement = player:GetVelocity():DotProduct(player:GetViewAngles():GetCoords().zAxis)
movement = math.sign(movement)*math.abs(movement)^0.9
// !! assuming there's a math.sign function (it returns -1 if -ve, 0 if zero, 1 if +ve), otherwise will have to use if statements<!--c2--></div><!--ec2-->
(It doesn't have to be 0.9, it can be less or more, but less than 1 of course.)
Basically, the size of movement is reduced and reduced proportionally to its own size, so increased movement does not lead to such an increased damage.
Illustration:
<img src="http://i.imgur.com/b9I32.png" border="0" class="linked-image" />
<!--quoteo(post=1893514:date=Jan 11 2012, 11:08 AM:name=Harimau)--><div class='quotetop'>QUOTE (Harimau @ Jan 11 2012, 11:08 AM) <a href="index.php?act=findpost&pid=1893514"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec--><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->math.exp^(-distConstant*distLimited))<!--c2--></div><!--ec2--><!--QuoteEnd--></div><!--QuoteEEnd-->
Assuming the ^ is a typo? Since the math.exp function doesn't want it.
Well I think you should try just commenting those two lines out for now (and change "damage" to "local damage"), and see if it still works. I can't test it right now (or soon) since NS2 hasn't been installed on this PC. I'll probably wait until 190 so that I won't have to download it and then download a massive patch soon after (Australia, download limits, etc.)
Forums is just the right kind of relaxed distraction, coding and testing is to much :P
Just noticed you joined the forums one day before me! I would have guessed you were from there due to time too, and I noticed now that you've added location too :)