- float d = vlen(it.origin + (it.mins + it.maxs) * 0.5 - rocket.origin);
- d = bound(0, edgedamage + (coredamage - edgedamage) * sqrt(1 - d * recipricoledgeradius), 10000);
- // count potential damage according to type of target
- if(it == actor)
- selfdamage = selfdamage + d;
- else if(SAME_TEAM(it, actor))
- teamdamage = teamdamage + d;
- else if(bot_shouldattack(actor, it))
- enemydamage = enemydamage + d;
- });
- });
- float desirabledamage;
- desirabledamage = enemydamage;
- if(time > STAT(INVINCIBLE_FINISHED, actor) && time > actor.spawnshieldtime)
- desirabledamage = desirabledamage - selfdamage * autocvar_g_balance_selfdamagepercent;
- if(teamplay && actor.team)
- desirabledamage = desirabledamage - teamdamage;
-
- makevectors(actor.v_angle);
- IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket",
- {
- if(skill > 9) // normal players only do this for the target they are tracking
- {
- entity rocket = it;
- IL_EACH(g_bot_targets, it.bot_attack,
- {
- if((v_forward * normalize(rocket.origin - it.origin) < 0.1)
- && desirabledamage > 0.1 * coredamage
- ) PHYS_INPUT_BUTTON_ATCK2(actor) = true;
- });
- }
- else
- {
- //As the distance gets larger, a correct detonation gets near imposible
- //Bots are assumed to use the rocket spawnfunc_light to see if the rocket gets near a player
- if((v_forward * normalize(it.origin - actor.enemy.origin) < 0.1)
- && IS_PLAYER(actor.enemy)
- && (desirabledamage >= 0.1 * coredamage)
- )
+ // code to calculate damage is similar to the one used in RadiusDamageForSource with some simplifications
+ vector target_pos = it.origin + (it.maxs - it.mins) * 0.5;
+
+ float dist = vlen(target_pos - rocket.origin);
+ float dmg = 0;
+ if (dist <= edgeradius)
+ {
+ float f = (edgeradius > 0) ? max(0, 1 - (dist / edgeradius)) : 1;
+ dmg = coredamage * f + edgedamage * (1 - f);
+ }
+
+ float pred_dist = vlen(target_pos + it.velocity * pred_time - (rocket.origin + rocket.velocity * pred_time));
+ float pred_dmg = 0;
+ if (pred_dist <= edgeradius)