// File: /workspace/github_c_makefile_star2_O3/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 0x24044
testb $0x4, 0x10(%rcx)
jne 0x240cf
movq 0x138(%r15), %rdi
leaq 0x2fc65(%rip), %rsi     # 0x53cb7
callq 0x18690
testl %eax, %eax
je 0x24219
movq 0x4460a(%rip), %rax     # 0x68670
cmpl $0x0, (%rax)
movl $0x1c, %eax
movl $0x70, %r12d
cmovel %eax, %r12d
movq 0x110(%rbx), %rdi
cmpq $0x0, 0x58(%rdi)
je 0x24094
leaq 0x4(%rbx), %rsi
movl $0x2, %edx
callq 0x18ef0
cmpl $0x0, 0x27c(%r15)
je 0x240e0
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 0x24162
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x19a50
movq 0x44519(%rip), %r13     # 0x68600
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 0x44497(%rip), %r14     # 0x68600
movq 0x20(%r14), %r15
leaq 0x2fafc(%rip), %rdi     # 0x53c70
callq *0x48(%r14)
movss 0x2eda8(%rip), %xmm0    # 0x52f28
movss 0x2f2e4(%rip), %xmm1    # 0x5346c
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 0x2fa74(%rip), %xmm0    # 0x53c30
movq %rdi, %rdx
callq 0x19760
movl %r15d, 0x1c8(%rbx)
movq %r15, 0x1c0(%rbx)
leaq 0x2faae(%rip), %rdi     # 0x53c87
callq *0x40(%r14)
movl %eax, 0x28(%rbx)
movl %r15d, 0x38(%rbx)
movl %r15d, 0x4c(%rbx)
movq 0x44241(%rip), %rax     # 0x68430
movq %rax, 0x210(%rbx)
movq 0x44ba3(%rip), %rax     # 0x68da0
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rax), %xmm0
addsd 0x2fa3b(%rip), %xmm0    # 0x53c48
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x200(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq