# force based damage

i was looking around and i found a person that made a script that calculates force… i was just wondering how you use it because i already asked like 23 time on the thread and nobody answered…

heres the script:

import GameLogic as g
import math
from math import sqrt
c = g.getCurrentController()
o = c.getOwner()
mass = o.getMass()
iv = o.iv
(vx,vy,vz) = o.getVelocity()
fv = sqrt(vx**2 + vy**2 + vz**2)
o.iv = fv
a = abs(fv-iv)*60
f = a * mass

hope you can help
:RocknRoll:Steve:RocknRoll:

I know almost nothing in regards to python and properties and stuff like that, so correct me if I’m wrong. It may involve an int. property with a specific value, and when the value is reached, then it triggers the depletion of the health bar or whatever you are using…yah…

I don’t know how much python you know but I’ll try to explain as much of it as I understand myself.

import GameLogic as g
import math <– import some math that isn’t normally included
from math import sqrt <– import the squar root calculating from math (isn’t it already imported?)
c = g.getCurrentController()
o = c.getOwner()
mass = o.getMass() <– a variable for the mass of the object (found in the logic brick section)
iv = o.iv <– a variable loads the value of the property iv (whatever that is)
(vx,vy,vz) = o.getVelocity() <– I don’t get this something stores the velocity of the object
fv = sqrt(vx2 + vy2 + vz**2) <– calculating the total velocity for all directions combined I think
o.iv = fv <– store that in the propery iv
a = abs(fv-iv)*60 <– the absolute value of fv-iv (if it’s negative it gets multiplied by -1) then multiplied by 60. iv seems to be the “old” fv
f = a * mass <– guessing f is for force…

to use it you would need an object with the property iv, possibly an integer… Maybe this is meant to be triggered by an always sensor, since I think it’s referring to it previous numbers…

what do you want to use it for? because right now it calculates the force (if that’s what the calculation does) and then trow away the number…

ok… i sorta get it now… just now i gotta try and figure out how to get the script to work and all… and how to get damage stuff done…