// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_combat.c
// Function: T_RadiusDamage
void T_RadiusDamage (edict_t *inflictor, edict_t *attacker, float damage, edict_t *ignore, float radius, int mod)
{
	float	points;
	edict_t	*ent = NULL;
	vec3_t	v;
	vec3_t	dir;

#ifdef WEAP_BALANCE_OK	
	float vlength, adjuster; //surt weaponbalance
#endif

	while ((ent = findradius(ent, inflictor->s.origin, radius)) != NULL)
	{
		if (ent == ignore)
			continue;
		if (!ent->takedamage)
			continue;

		VectorAdd (ent->mins, ent->maxs, v);
		VectorMA (ent->s.origin, 0.5, v, v);
		VectorSubtract (inflictor->s.origin, v, v);

#ifdef WEAP_BALANCE_OK	
		if ((int)ctfflags->value & CTF_WEAP_BALANCE)
		{
			vlength = VectorLength(v); //hopefully in id-units
			//'corrected' radius damage formula
			if (vlength < 1)
				vlength = 0; //no negatives
			if (radius < 1)
				radius = 1; //no divide by zero, no negatives
			adjuster = 1 - (vlength / radius);
			//as vlength approaches radius, adjuster approaches zero
			//we then multiply this value into the damage, so that
			//damage approaches zero at the radius of the explosion
			points = damage * adjuster;
			//assuming id calculated the vector length correctly, then
			//this should be a drop off of r over the radius, making
			//it worst to be very close to the center of an explosion,
			//but also allowing you to 'feel' a big explosion nearby
		}
		else //original id code
			points = damage - 0.5 * VectorLength (v);
#else
		points = damage - 0.5 * VectorLength (v);
#endif

		if (ent == attacker)
			points = points * 0.5;
		if (points > 0)
		{
			if (CanDamage (ent, inflictor))
			{
				VectorSubtract (ent->s.origin, inflictor->s.origin, dir);
				T_Damage (ent, inflictor, attacker, dir, inflictor->s.origin, vec3_origin, (int)points, (int)points, DAMAGE_RADIUS, mod);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x30(%rsp)
movq %rdx, %r14
movss %xmm0, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %r12
leaq 0x4(%rdi), %r13
xorl %edi, %edi
movq %r13, %rsi
movss %xmm1, 0x20(%rsp)
movaps %xmm1, %xmm0
callq 0x19880
testq %rax, %rax
je 0x2c380
movq %rax, %rbp
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movss 0x29200(%rip), %xmm0    # 0x55404
leaq 0x4(%rsp), %rbx
cmpq %r14, %rbp
je 0x2c35b
cmpl $0x0, 0x27c(%rbp)
je 0x2c35b
movss 0xcc(%rbp), %xmm1
addss 0xd8(%rbp), %xmm1
movss %xmm1, 0x4(%rsp)
movss 0xd0(%rbp), %xmm1
addss 0xdc(%rbp), %xmm1
movss %xmm1, 0x8(%rsp)
movss 0xd4(%rbp), %xmm1
addss 0xe0(%rbp), %xmm1
movss %xmm1, 0xc(%rsp)
leaq 0x4(%rbp), %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x19770
movss 0x4(%r12), %xmm0
subss 0x4(%rsp), %xmm0
movss %xmm0, 0x4(%rsp)
movss 0x8(%r12), %xmm0
subss 0x8(%rsp), %xmm0
movss %xmm0, 0x8(%rsp)
movss 0xc(%r12), %xmm0
subss 0xc(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movq %rbx, %rdi
callq 0x192e0
cvtss2sd %xmm0, %xmm0
mulsd 0x2a8f3(%rip), %xmm0    # 0x56bb0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
cmpq %r15, %rbp
jne 0x2c2d4
mulss 0x29130(%rip), %xmm0    # 0x55404
ucomiss 0x28685(%rip), %xmm0    # 0x54960
jbe 0x2c35b
movq %rbp, %rdi
movq %r12, %rsi
movss %xmm0, 0x1c(%rsp)
callq 0x18930
movss 0x1c(%rsp), %xmm1
testl %eax, %eax
je 0x2c35b
movss 0x4(%rbp), %xmm0
subss 0x4(%r12), %xmm0
movss %xmm0, 0x24(%rsp)
movss 0x8(%rbp), %xmm0
subss 0x8(%r12), %xmm0
movss %xmm0, 0x28(%rsp)
movss 0xc(%rbp), %xmm0
subss 0xc(%r12), %xmm0
movss %xmm0, 0x2c(%rsp)
cvttss2si %xmm1, %eax
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
leaq 0x24(%rsp), %rcx
movq %r13, %r8
movq 0x3d41e(%rip), %r9      # 0x69768
pushq 0x30(%rsp)
pushq $0x1
pushq %rax
pushq %rax
callq 0x190f0
addq $0x20, %rsp
movq %rbp, %rdi
movq %r13, %rsi
movss 0x20(%rsp), %xmm0
callq 0x19880
movss 0x29090(%rip), %xmm0    # 0x55404
movq %rax, %rbp
testq %rax, %rax
jne 0x2c209
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop