// File: /workspace/github_cpp_makefile_star2_O2/lotuskip[P]yuxtapa/server/chores.cpp
// Function: (anonymous namespace)::missile_hit_PC(std::_List_iterator<Player>, OwnedEnt*, bool)
void missile_hit_PC(const list<Player>::iterator pit, OwnedEnt* mis,
	const bool should_void_zap)
{
	list<Player>::iterator shooter = mis->get_owner();
	if(dynamic_cast<Arrow*>(mis)) // it's an arrow
	{
		if(pit->team != shooter->team) // shooting teammates don't count as hit
			shooter->stats_i->arch_hits++;

		if(test_hit(pit, 7, 1, 7, 0)) // arrows: 1d7+0 damage, +7 to hit
		{
			if(pit->cl_props.hp <= 0) // (check if died)
			{
				string msg = " was shot by ";
				if(pit->team == shooter->team)
				{
					msg += teammate_str;
					shooter->stats_i->tks++;
				}
				else // shot enemy, count kill
					record_kill(shooter, WTK_ARROW);
				player_death(pit, msg + shooter->nick + '.', true);
			}
			else
				pit->needs_state_upd = true;
		}
		mis->makevoid(); // occupied flag is unset in kill_player if necessary
	}
	else // a mm or a zap
	{
		bool is_zap = dynamic_cast<Zap*>(mis);
		if(is_zap && shooter->team != pit->team)
			shooter->stats_i->cm_hits++;
		if(pit->nomagicres())
		{
			add_action_ind(pit->own_pc->getpos(), A_HIT);

			char dam = 1 + random()%5; // 1d5
			if(is_zap)
				dam += 1 + random()%5; // 2d5 for zaps
			pit->cl_props.hp -= dam;
			if(pit->cl_props.hp <= 0) // died
			{
				string msg = spell_kill_msg[is_zap][0];
				if(pit == shooter)
					msg += spell_kill_msg[is_zap][1];
				else
				{
					if(pit->team == shooter->team)
					{
						msg += teammate_str;
						shooter->stats_i->tks++;
					}
					else
						record_kill(shooter, is_zap ? WTK_ZAP : WTK_MM);
					msg += shooter->nick;
					if(!is_zap)
						msg += "\'s ";
				}
				msg += spell_kill_msg[is_zap][2];
				player_death(pit, msg, true);
			}
			else
				pit->needs_state_upd = true;
		} // no magic resistance
		else
			add_action_ind(pit->own_pc->getpos(), A_MISS);
		// mms voided always, zaps only if we are allowed to do so here:
		if(should_void_zap || !is_zap)
			mis->makevoid(); // occupied flag is unset in kill_player if necessary
	} // mm or zap
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movq 0x10(%rsi), %r12
leaq 0x1bd00(%rip), %rsi     # 0x3cd58
leaq 0x1bcb1(%rip), %rdx     # 0x3cd10
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x4450
testq %rax, %rax
je 0x210c4
movl 0xbc(%r14), %eax
cmpl 0xbc(%r12), %eax
je 0x2108e
movq 0x90(%r12), %rax
incq 0x118(%rax)
pushq $0x1
popq %rdx
pushq $0x7
popq %rcx
movq %r14, %rdi
movl %ecx, %esi
xorl %r8d, %r8d
callq 0x20b21
testb %al, %al
je 0x2136a
cmpb $0x0, 0x153(%r14)
jle 0x2118b
movb $0x1, 0x15d(%r14)
jmp 0x2136a
leaq 0x1bc8d(%rip), %rsi     # 0x3cd58
leaq 0x1bc6e(%rip), %rdx     # 0x3cd40
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x4450
movq %rax, %r13
testq %rax, %rax
je 0x21104
movl 0xbc(%r12), %eax
cmpl 0xbc(%r14), %eax
je 0x21104
movq 0x90(%r12), %rax
incq 0x128(%rax)
leaq 0x10(%r14), %rdi
callq 0xe7be
testb %al, %al
je 0x21165
movl %r15d, -0x2c(%rbp)
movq 0x148(%r14), %rax
movl 0x8(%rax), %eax
leaq -0x50(%rbp), %rdi
movl %eax, (%rdi)
pushq $0x4
popq %rsi
callq 0x1b103
leaq -0x50(%rbp), %rdi
callq 0x24d9e
callq 0x41e0
pushq $0x5
popq %rcx
cqto
idivq %rcx
movq %rdx, %r15
testq %r13, %r13
je 0x211d8
callq 0x41e0
cqto
pushq $0x5
popq %rcx
idivq %rcx
addb %dl, %r15b
addb $0x2, %r15b
jmp 0x211db
movq 0x148(%r14), %rax
movl 0x8(%rax), %eax
leaq -0x50(%rbp), %rdi
movl %eax, (%rdi)
pushq $0x5
popq %rsi
callq 0x1b103
leaq -0x50(%rbp), %rdi
callq 0x24d9e
jmp 0x2135d
leaq 0xe53b(%rip), %rsi      # 0x2f6cd
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0xb292
movl 0xbc(%r14), %eax
cmpl 0xbc(%r12), %eax
jne 0x21275
leaq 0x22d8d(%rip), %rsi     # 0x43f48
leaq -0x50(%rbp), %rdi
callq 0x4790
movq 0x90(%r12), %rax
incq 0xa0(%rax)
jmp 0x21280
incb %r15b
movb 0x153(%r14), %al
subb %r15b, %al
movb %al, 0x153(%r14)
testb %al, %al
jle 0x21201
movb $0x1, 0x15d(%r14)
movl -0x2c(%rbp), %r15d
jmp 0x2135d
xorl %eax, %eax
movq %r13, -0x58(%rbp)
testq %r13, %r13
setne %al
imulq $0x60, %rax, %rax
leaq 0x22d58(%rip), %r13     # 0x43f70
addq %rax, %r13
leaq -0x50(%rbp), %rdi
movq %r13, %rsi
callq 0x4590
cmpq %r14, %r12
movl -0x2c(%rbp), %r15d
movq %r13, -0x60(%rbp)
je 0x212df
movl 0xbc(%r14), %eax
cmpl 0xbc(%r12), %eax
jne 0x212f2
leaq 0x22cf4(%rip), %rsi     # 0x43f48
leaq -0x50(%rbp), %rdi
callq 0x4790
movq -0x58(%rbp), %r13
movq 0x90(%r12), %rax
incq 0xa0(%rax)
jmp 0x2130c
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x1f544
addq $0x98, %r12
leaq -0xa0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %r12, %rdx
callq 0xfe1f
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
pushq $0x2e
popq %rdx
callq 0x17d8b
leaq -0x80(%rbp), %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x1f393
leaq -0x80(%rbp), %rdi
callq 0x47e8
leaq -0xa0(%rbp), %rdi
callq 0x47e8
leaq -0x50(%rbp), %rdi
callq 0x47e8
jmp 0x2136a
leaq 0x20(%r13), %rsi
leaq -0x50(%rbp), %rdi
callq 0x4790
movq -0x58(%rbp), %r13
jmp 0x21334
xorl %eax, %eax
movq -0x58(%rbp), %r13
testq %r13, %r13
sete %al
leal (%rax,%rax,2), %esi
addl $0x3, %esi
movq %r12, %rdi
callq 0x1f544
addq $0x98, %r12
leaq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x4790
testq %r13, %r13
jne 0x21334
leaq 0xe3b0(%rip), %rsi      # 0x2f6db
leaq -0x50(%rbp), %rdi
callq 0x4770
movq -0x60(%rbp), %rsi
addq $0x40, %rsi
leaq -0x50(%rbp), %rdi
callq 0x4790
leaq -0x50(%rbp), %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x1f393
leaq -0x50(%rbp), %rdi
callq 0x47e8
testq %r13, %r13
sete %al
orb %r15b, %al
cmpb $0x1, %al
jne 0x2136e
movb $0x1, 0xe(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x47e8
jmp 0x2138e
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x47e8
jmp 0x213b8
jmp 0x213b5
jmp 0x213b5
movq %rax, %rbx
jmp 0x213c1
jmp 0x213a7
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x24d9e
jmp 0x213c1
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x47e8
movq %rbx, %rdi
callq 0x4710