Awesome, changed it to the snippet below and it works perfectly.
Thank you so much for your explanation!
I feel a bit silly for what I did with the AddVectors part - I started with a velocity vector, used it to get the next position, and then used the two positions to just get the same velocity vector back
PHP Code:
float GetDamageVelocityModifier(int attacker, int victim)
{
float attackerPos[3], victimPos[3], unitVec[3], attackerVel[3];
GetClientAbsOrigin(attacker, attackerPos);
GetClientAbsOrigin(victim, victimPos);
MakeVectorFromPoints(attackerPos, victimPos, unitVec);
GetEntPropVector(attacker, Prop_Data, "m_vecVelocity", attackerVel);
NormalizeVector(unitVec, unitVec);
NormalizeVector(attackerVel, attackerVel);
float dp = GetVectorDotProduct(unitVec, attackerVel);
PrintToChatAll("dot product: %f", dp);
return 1 + 0.5 * dp;
}
If anyone reading is curious, here's a video of what I'm doing:
(note that the damage in chat is wrong because armor appears to eat 50% of damage).