// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/plasma.c
// Function: plasma_spread_touch
void
plasma_spread_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;
	}

	// Don't collide with other plasma goops
	if (Q_stricmp(other->classname,"goop") == 0)
		return;
	
	//bat
	if(quadmeister)
		damage = PLASMA_SPREAD_DAMAGE * 4;
	else
		damage = PLASMA_SPREAD_DAMAGE;

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

	// If can damage, hurt it
	if( other->takedamage )
	{
		//T_Damage (other, self, self->owner, self->velocity,
		//          self->s.origin, plane->normal, self->dmg, 1,
		//	  DAMAGE_ENERGY, MOD_PLASMA);
		T_Damage(other, self, self->owner, self->velocity, self->s.origin, plane->normal, damage, 1, DAMAGE_ENERGY, MOD_PLASMA);
	}		  
	else	// otherwise, splash damage
	{
		//-bat
		//T_RadiusDamage(self,self->owner,self->dmg,NULL, self->dmg+PLASMA_SPLASH_RADIUS,MOD_PLASMA);
		//T_RadiusDamage(self,self->owner,32,NULL,32,MOD_PLASMA);
		
		//-bat added sparks to this too.
		// 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,damage,NULL, damage+PLASMA_SPLASH_RADIUS,MOD_PLASMA);
	}		  
	// play hit sound
	gi.sound( self,CHAN_BODY, gi.soundindex(PLASMA_SOUND_HIT), 1,
	          ATTN_IDLE,0 );	// idle static none

	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;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
testq %rcx, %rcx
je 0x2410c
testb $0x4, 0x10(%rcx)
jne 0x24197
movq 0x138(%r15), %rdi
leaq 0x30b5d(%rip), %rsi     # 0x54c77
callq 0x18690
testl %eax, %eax
je 0x242e1
movq 0x45542(%rip), %rax     # 0x69670
cmpl $0x0, (%rax)
movl $0x1c, %eax
movl $0x70, %r12d
cmovel %eax, %r12d
movq 0x110(%rbx), %rdi
cmpq $0x0, 0x58(%rdi)
je 0x2415c
leaq 0x4(%rbx), %rsi
movl $0x2, %edx
callq 0x18ef0
cmpl $0x0, 0x27c(%r15)
je 0x241a8
movq 0x110(%rbx), %rdx
leaq 0x1c0(%rbx), %rcx
leaq 0x4(%rbx), %r8
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %r9
pushq $0x22
pushq $0x4
pushq $0x1
pushq %r12
callq 0x190f0
addq $0x20, %rsp
jmp 0x2422a
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x19a60
movq 0x45451(%rip), %r13     # 0x69600
movl $0x3, %edi
callq *0xc8(%r13)
movl $0xf, %edi
callq *0xc8(%r13)
movl $0x20, %edi
callq *0xc8(%r13)
leaq 0x4(%rbx), %r15
movq %r15, %rdi
callq *0xf0(%r13)
movq %r14, %rdi
callq *0xf8(%r13)
movl $0xb0, %edi
callq *0xc8(%r13)
movq %r15, %rdi
movl $0x2, %esi
callq *0xb0(%r13)
movq 0x110(%rbx), %rsi
cvtsi2ss %r12d, %xmm0
addl $0x46, %r12d
cvtsi2ss %r12d, %xmm1
movq %rbx, %rdi
xorl %edx, %edx
movl $0x22, %ecx
callq 0x180c0
movq 0x453cf(%rip), %r14     # 0x69600
movq 0x20(%r14), %r15
leaq 0x309f4(%rip), %rdi     # 0x54c30
callq *0x48(%r14)
movss 0x2fce0(%rip), %xmm0    # 0x53f28
movss 0x30208(%rip), %xmm1    # 0x54458
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0x4, %esi
movl %eax, %edx
callq *%r15
xorl %r15d, %r15d
movl %r15d, 0x108(%rbx)
movq %r15, 0x220(%rbx)
leaq 0x4(%rbx), %rdi
leaq 0x1c0(%rbx), %rsi
movss 0x3097c(%rip), %xmm0    # 0x54c00
movq %rdi, %rdx
callq 0x19770
movl %r15d, 0x1c8(%rbx)
movq %r15, 0x1c0(%rbx)
leaq 0x309a6(%rip), %rdi     # 0x54c47
callq *0x40(%r14)
movl %eax, 0x28(%rbx)
movl %r15d, 0x38(%rbx)
movl %r15d, 0x4c(%rbx)
movq 0x45179(%rip), %rax     # 0x69430
movq %rax, 0x210(%rbx)
movq 0x45adb(%rip), %rax     # 0x69da0
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rax), %xmm0
addsd 0x30943(%rip), %xmm0    # 0x54c18
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x200(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq