// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/plasma.c
// Function: plasma_reflect_touch
void
plasma_reflect_touch
(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) 
{
int damage;
	
	// If hit the sky, remove from world
	if (surf && (surf->flags & SURF_SKY)) {
		G_FreeEdict(self);
		return;
	}

	// Damage Decay
	// determine damage (max 3.0s * 7 = max 21 damage)
	// if time is adjusted, must also adjust the constant
	
	//bat.  This think stuff is messing me up, so I am taking it out.
	//self->dmg= 7 + (self->nextthink - level.time) * 7 * PLASMA_DAMAGE_MULTIPLIER;

	//bat
	if(quadmeister)
		damage = PLASMA_BOUNCE_DAMAGE * 4;
	else
		damage = PLASMA_BOUNCE_DAMAGE;

	if( self->owner->client )
		PlayerNoise(self->owner,self->s.origin,PNOISE_IMPACT);

	if( other->takedamage ) 
	{
		T_Damage(other, self, self->owner, self->velocity, self->s.origin, plane->normal, damage, 1, DAMAGE_ENERGY, MOD_PLASMA);
			
		///T_Damage (other, self, self->owner, self->velocity,
		 //         self->s.origin, plane->normal, self->dmg, 1,
		 //	  DAMAGE_ENERGY, MOD_PLASMA);
			  
		// play hit sound
		gi.sound( self,CHAN_BODY, gi.soundindex(PLASMA_SOUND_HIT), 1,
		          ATTN_IDLE,0 );

		self->solid=	SOLID_NOT;
		self->touch=	NULL;
		VectorMA (self->s.origin,-1*FRAMETIME,self->velocity,self->s.origin);
		VectorClear (self->velocity);

		// Run Plasma Hit Animation
		self->s.modelindex= 	gi.modelindex (PLASMA_SPRITE_HIT);
		self->s.frame= 		0;
		self->s.sound=		0;
		self->think=		G_FreeEdict;
		self->nextthink=	level.time + 0.1;
	}
	else {	// fx to do when it bounces off something
		// play reflection sound
		gi.sound( self,CHAN_BODY, gi.soundindex(PLASMA_SOUND_BOUNCE), 1,
		          ATTN_STATIC,0 );

		// Draw blue sparks
		gi.WriteByte (svc_temp_entity);
		gi.WriteByte (TE_LASER_SPARKS);
		gi.WriteByte (32);		// ammount
		gi.WritePosition (self->s.origin);
		gi.WriteDir (plane->normal);
		gi.WriteByte (176);		// stecki's choice of id's blue
		gi.multicast (self->s.origin, MULTICAST_PVS);

		//T_RadiusDamage(self,self->owner,32,NULL,32,MOD_PLASMA);
		//-bat
		T_RadiusDamage(self,self->owner,damage,NULL, damage+PLASMA_SPLASH_RADIUS,MOD_PLASMA);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbx
testq %rcx, %rcx
je 0x23e0f
testb $0x4, 0x10(%rcx)
jne 0x23f42
movq 0x4485a(%rip), %rax     # 0x68670
cmpl $0x0, (%rax)
movl $0x27, %eax
movl $0x9c, %ebp
cmovel %eax, %ebp
movq 0x110(%rbx), %rdi
cmpq $0x0, 0x58(%rdi)
je 0x23e42
leaq 0x4(%rbx), %rsi
movl $0x2, %edx
callq 0x18ef0
cmpl $0x0, 0x27c(%r13)
je 0x23f58
movq 0x110(%rbx), %rdx
leaq 0x1c0(%rbx), %r15
leaq 0x4(%rbx), %r12
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rcx
movq %r12, %r8
movq %r14, %r9
pushq $0x22
pushq $0x4
pushq $0x1
pushq %rbp
callq 0x190f0
addq $0x20, %rsp
movq 0x44778(%rip), %r14     # 0x68600
movq 0x20(%r14), %r13
leaq 0x2fddd(%rip), %rdi     # 0x53c70
callq *0x48(%r14)
movss 0x2f089(%rip), %xmm0    # 0x52f28
movss 0x2f5c5(%rip), %xmm1    # 0x5346c
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0x4, %esi
movl %eax, %edx
callq *%r13
xorl %r13d, %r13d
movl %r13d, 0x108(%rbx)
movq %r13, 0x220(%rbx)
movss 0x2fd60(%rip), %xmm0    # 0x53c30
movq %r12, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x19760
movl %r13d, 0x1c8(%rbx)
movq %r13, 0x1c0(%rbx)
leaq 0x2fd94(%rip), %rdi     # 0x53c87
callq *0x40(%r14)
movl %eax, 0x28(%rbx)
movl %r13d, 0x38(%rbx)
movl %r13d, 0x4c(%rbx)
movq 0x44527(%rip), %rax     # 0x68430
movq %rax, 0x210(%rbx)
movq 0x44e89(%rip), %rax     # 0x68da0
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rax), %xmm0
addsd 0x2fd21(%rip), %xmm0    # 0x53c48
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x200(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x19a50
movq 0x446a1(%rip), %r12     # 0x68600
movq 0x20(%r12), %r15
leaq 0x2fd32(%rip), %rdi     # 0x53c9d
callq *0x48(%r12)
movss 0x2efb0(%rip), %xmm0    # 0x52f28
movss 0x2ef90(%rip), %xmm1    # 0x52f10
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0x4, %esi
movl %eax, %edx
callq *%r15
movl $0x3, %edi
callq *0xc8(%r12)
movl $0xf, %edi
callq *0xc8(%r12)
movl $0x20, %edi
callq *0xc8(%r12)
leaq 0x4(%rbx), %r15
movq %r15, %rdi
callq *0xf0(%r12)
movq %r14, %rdi
callq *0xf8(%r12)
movl $0xb0, %edi
callq *0xc8(%r12)
movq %r15, %rdi
movl $0x2, %esi
callq *0xb0(%r12)
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
addl $0x46, %ebp
xorps %xmm1, %xmm1
cvtsi2ss %ebp, %xmm1
movq 0x110(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
movl $0x22, %ecx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x180c0