// File: /workspace/github_c_makefile_star2_O2/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 0x220df
testb $0x4, 0x10(%rcx)
jne 0x22208
movq 0x4458a(%rip), %rax     # 0x66670
cmpl $0x0, (%rax)
pushq $0x27
popq %rax
movl $0x9c, %ebp
cmovel %eax, %ebp
movq 0x110(%rbx), %rdi
cmpq $0x0, 0x58(%rdi)
je 0x2210e
leaq 0x4(%rbx), %rsi
pushq $0x2
popq %rdx
callq 0x19010
cmpl $0x0, 0x27c(%r13)
je 0x2221e
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 0x19260
addq $0x20, %rsp
movq 0x444ac(%rip), %r14     # 0x66600
movq 0x20(%r14), %r13
leaq 0x2db11(%rip), %rdi     # 0x4fc70
callq *0x48(%r14)
pushq $0x4
popq %rsi
movss 0x2cdba(%rip), %xmm0    # 0x4ef28
movss 0x2d2f6(%rip), %xmm1    # 0x4f46c
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
callq *%r13
andl $0x0, 0x108(%rbx)
andq $0x0, 0x220(%rbx)
movss 0x2da98(%rip), %xmm0    # 0x4fc30
movq %r12, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x19940
andl $0x0, 0x1c8(%rbx)
andq $0x0, 0x1c0(%rbx)
leaq 0x2dacb(%rip), %rdi     # 0x4fc87
callq *0x40(%r14)
movl %eax, 0x28(%rbx)
andl $0x0, 0x38(%rbx)
andl $0x0, 0x4c(%rbx)
movq 0x4425e(%rip), %rax     # 0x66430
movq %rax, 0x210(%rbx)
movq 0x44bc0(%rip), %rax     # 0x66da0
cvtss2sd 0x4(%rax), %xmm0
addsd 0x2da5b(%rip), %xmm0    # 0x4fc48
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 0x19c50
movq 0x443db(%rip), %r12     # 0x66600
movq 0x20(%r12), %r15
leaq 0x2da6c(%rip), %rdi     # 0x4fc9d
callq *0x48(%r12)
pushq $0x4
popq %rsi
movss 0x2cce7(%rip), %xmm0    # 0x4ef28
movss 0x2ccc3(%rip), %xmm1    # 0x4ef0c
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
callq *%r15
pushq $0x3
popq %rdi
callq *0xc8(%r12)
pushq $0xf
popq %rdi
callq *0xc8(%r12)
pushq $0x20
popq %rdi
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)
pushq $0x2
popq %rsi
movq %r15, %rdi
callq *0xb0(%r12)
cvtsi2ss %ebp, %xmm0
addl $0x46, %ebp
cvtsi2ss %ebp, %xmm1
movq 0x110(%rbx), %rsi
pushq $0x22
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x180c0