// File: /workspace/github_c_makefile_star2_O2/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 0x222f8
testb $0x4, 0x10(%rcx)
jne 0x2237d
movq 0x138(%r15), %rdi
leaq 0x2d9b1(%rip), %rsi     # 0x4fcb7
callq 0x186d0
testl %eax, %eax
je 0x224b7
movq 0x44356(%rip), %rax     # 0x66670
cmpl $0x0, (%rax)
pushq $0x1c
popq %rax
pushq $0x70
popq %r12
cmovel %eax, %r12d
movq 0x110(%rbx), %rdi
cmpq $0x0, 0x58(%rdi)
je 0x22342
leaq 0x4(%rbx), %rsi
pushq $0x2
popq %rdx
callq 0x19010
cmpl $0x0, 0x27c(%r15)
je 0x2238e
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 0x19260
addq $0x20, %rsp
jmp 0x22406
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x19c50
movq 0x4426b(%rip), %r13     # 0x66600
pushq $0x3
popq %rdi
callq *0xc8(%r13)
pushq $0xf
popq %rdi
callq *0xc8(%r13)
pushq $0x20
popq %rdi
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)
pushq $0x2
popq %rsi
movq %r15, %rdi
callq *0xb0(%r13)
movq 0x110(%rbx), %rsi
cvtsi2ss %r12d, %xmm0
addl $0x46, %r12d
cvtsi2ss %r12d, %xmm1
pushq $0x22
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x180c0
movq 0x441f3(%rip), %r14     # 0x66600
movq 0x20(%r14), %r15
leaq 0x2d858(%rip), %rdi     # 0x4fc70
callq *0x48(%r14)
pushq $0x4
popq %rsi
movss 0x2cb01(%rip), %xmm0    # 0x4ef28
movss 0x2d03d(%rip), %xmm1    # 0x4f46c
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
callq *%r15
andl $0x0, 0x108(%rbx)
andq $0x0, 0x220(%rbx)
leaq 0x4(%rbx), %rdi
leaq 0x1c0(%rbx), %rsi
movss 0x2d7d4(%rip), %xmm0    # 0x4fc30
movq %rdi, %rdx
callq 0x19940
andl $0x0, 0x1c8(%rbx)
andq $0x0, 0x1c0(%rbx)
leaq 0x2d80d(%rip), %rdi     # 0x4fc87
callq *0x40(%r14)
movl %eax, 0x28(%rbx)
andl $0x0, 0x38(%rbx)
andl $0x0, 0x4c(%rbx)
movq 0x43fa0(%rip), %rax     # 0x66430
movq %rax, 0x210(%rbx)
movq 0x44902(%rip), %rax     # 0x66da0
cvtss2sd 0x4(%rax), %xmm0
addsd 0x2d79d(%rip), %xmm0    # 0x4fc48
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x200(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq