// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x273bc
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x273bc
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x2769f
movq 0x5b2ad(%rip), %rax     # 0x82670
cmpl $0x0, (%rax)
je 0x273d1
movl $0x9c, -0x24(%rbp)
jmp 0x273d8
movl $0x27, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rax
cmpq $0x0, 0x58(%rax)
je 0x27407
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rdi
movq -0x8(%rbp), %rsi
addq $0x4, %rsi
movl $0x2, %edx
callq 0x19080
movq -0x10(%rbp), %rax
cmpl $0x0, 0x27c(%rax)
je 0x27596
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rdx
movq -0x8(%rbp), %rcx
addq $0x1c0, %rcx            # imm = 0x1C0
movq -0x8(%rbp), %r8
addq $0x4, %r8
movq -0x18(%rbp), %r9
movl -0x24(%rbp), %eax
movl %eax, (%rsp)
movl $0x1, 0x8(%rsp)
movl $0x4, 0x10(%rsp)
movl $0x22, 0x18(%rsp)
callq 0x192c0
movq 0x5b194(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x497ad(%rip), %rdi     # 0x70c30
movq 0x5b176(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x38(%rbp), %rdi
movl %eax, %edx
movq -0x30(%rbp), %rax
movl $0x4, %esi
movss 0x48a48(%rip), %xmm0    # 0x6feec
movss 0x48a3c(%rip), %xmm1    # 0x6fee8
xorps %xmm2, %xmm2
callq *%rax
movq -0x8(%rbp), %rax
movl $0x0, 0x108(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x220(%rax)
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movq -0x8(%rbp), %rsi
addq $0x1c0, %rsi            # imm = 0x1C0
movq -0x8(%rbp), %rdx
addq $0x4, %rdx
movss 0x49717(%rip), %xmm0    # 0x70c08
callq 0x199c0
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x1c8(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x1c4(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x1c0(%rax)
leaq 0x4971d(%rip), %rdi     # 0x70c47
movq 0x5b0cf(%rip), %rax     # 0x82600
callq *0x40(%rax)
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x4c(%rax)
movq -0x8(%rbp), %rax
movq 0x5aed2(%rip), %rcx     # 0x82430
movq %rcx, 0x210(%rax)
movq 0x5b834(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x4969b(%rip), %xmm1    # 0x70c18
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x200(%rax)
jmp 0x2769f
movq 0x5b063(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x496a9(%rip), %rdi     # 0x70c5d
movq 0x5b045(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x48(%rbp), %rdi
movl %eax, %edx
movq -0x40(%rbp), %rax
movl $0x4, %esi
movss 0x48917(%rip), %xmm0    # 0x6feec
movss 0x48933(%rip), %xmm1    # 0x6ff10
xorps %xmm2, %xmm2
callq *%rax
movl $0x3, %edi
movq 0x5b012(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movl $0xf, %edi
movq 0x5b000(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movl $0x20, %edi
movq 0x5afee(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x5afe1(%rip), %rax     # 0x82600
movq 0xf0(%rax), %rax
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
callq *%rax
movq 0x5afc9(%rip), %rax     # 0x82600
movq 0xf8(%rax), %rax
movq -0x18(%rbp), %rdi
callq *%rax
movl $0xb0, %edi
movq 0x5afb0(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x5afa3(%rip), %rax     # 0x82600
movq 0xb0(%rax), %rax
movq -0x8(%rbp), %rdi
addq $0x4, %rdi
movl $0x2, %esi
callq *%rax
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rsi
cvtsi2ssl -0x24(%rbp), %xmm0
movl -0x24(%rbp), %eax
addl $0x46, %eax
cvtsi2ss %eax, %xmm1
xorl %eax, %eax
movl %eax, %edx
movl $0x22, %ecx
callq 0x180c0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)