// File: XxAdi101xX[P]ChamberCrawler/Character/Character.cc
// Function: Character::attack(Character&, Generator&)
void Character::attack(Character& defender, Generator& rng) {
	int damage = ceil((100.0/(100.0 + defender.getTotalDefence()))
		* this->getTotalAttack());

	bool firstRollForHit = this->dealDamageTo(defender, damage, rng);
	bool secondRollForHit = defender.defend(*this, damage, rng);

	if (firstRollForHit && secondRollForHit) {
		// reports hit
		this->addAction(makeMsg(this->name, WORD_DEAL_PAST_TENSE + " "
			+ to_string(damage) + " " + WORD_DAMAGE_NOUN + " "
			+ WORD_TO_PREPOSITION, defender.getName() + " ("
			+ to_string(defender.getHP()) + ")"));

	}

	else {
		// reports miss
		this->addAction(makeMsg(this->name, WORD_MISS_PAST_TENSE + " ("
		+ to_string(damage) + " " + WORD_DAMAGE_NOUN + ")",
		defender.getName()));
	}

	this->postAttackRoutine(defender, firstRollForHit && secondRollForHit, rng);

	// checks for defender's death
	if (defender.getHP() <= 0) {
		this->addGold(defender.getWallet());

		defender.deathRoutine();

		// removes character from floor
		(defender.getCurrentCell())->setOccupant(nullptr);

		this->addAction(
				makeMsg(this->name, WORD_KILL_PAST_TENSE, defender.getName()));

		defender.addAction(makeMsg(defender.getName(), WORD_IS_PAST_TENSE + " "
			+ WORD_KILL_PAST_TENSE + " " + WORD_BY_PREPOSITION, this->name));
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x498(%rbp)
movq -0x10(%rbp), %rdi
callq 0x30160
movq -0x498(%rbp), %rdi
cvtsi2sd %eax, %xmm0
movsd 0x14b52(%rip), %xmm1    # 0x45090
addsd %xmm0, %xmm1
movsd 0x14b46(%rip), %xmm0    # 0x45090
divsd %xmm1, %xmm0
movsd %xmm0, -0x4a0(%rbp)
callq 0x30130
movsd -0x4a0(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
mulsd %xmm1, %xmm0
callq 0x60a0
movq -0x498(%rbp), %rdi
cvttsd2si %xmm0, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rcx
movq (%rdi), %rax
leaq -0x1c(%rbp), %rdx
callq *0x38(%rax)
movq -0x498(%rbp), %rsi
andb $0x1, %al
movb %al, -0x1d(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
leaq -0x1c(%rbp), %rdx
callq 0x2ebe0
andb $0x1, %al
movb %al, -0x1e(%rbp)
testb $0x1, -0x1d(%rbp)
je 0x309c3
testb $0x1, -0x1e(%rbp)
je 0x309c3
movq -0x498(%rbp), %rsi
addq $0x88, %rsi
leaq -0x60(%rbp), %rdi
callq 0x6160
leaq 0x38cd4(%rip), %rsi     # 0x692b8
leaq 0x14594(%rip), %rdx     # 0x44b7f
leaq -0x120(%rbp), %rdi
callq 0x31710
jmp 0x305f9
movl -0x1c(%rbp), %esi
leaq -0x150(%rbp), %rdi
callq 0x31790
jmp 0x3060a
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x150(%rbp), %rdx
callq 0x31640
jmp 0x30626
leaq 0x14552(%rip), %rdx     # 0x44b7f
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x19360
jmp 0x30642
leaq 0x38c4f(%rip), %rdx     # 0x69298
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x315f0
jmp 0x3065e
leaq 0x1451a(%rip), %rdx     # 0x44b7f
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x19360
jmp 0x3067a
leaq 0x38db7(%rip), %rdx     # 0x69438
leaq -0x80(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x315f0
jmp 0x30693
movq -0x10(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x2f310
jmp 0x306a5
leaq 0x149ec(%rip), %rdx     # 0x45098
leaq -0x1b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x19360
jmp 0x306c1
movq -0x10(%rbp), %rdi
callq 0x2eb40
movl %eax, -0x4a4(%rbp)
jmp 0x306d2
movl -0x4a4(%rbp), %esi
leaq -0x1f0(%rbp), %rdi
callq 0x31790
jmp 0x306e6
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
leaq -0x1f0(%rbp), %rdx
callq 0x31640
jmp 0x30702
leaq 0x144d6(%rip), %rdx     # 0x44bdf
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x19360
jmp 0x3071e
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x80(%rbp), %rdx
leaq -0x170(%rbp), %rcx
callq 0x343f0
jmp 0x30738
movq -0x498(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x2eb60
jmp 0x3074a
leaq -0x40(%rbp), %rdi
callq 0x65e8
leaq -0x170(%rbp), %rdi
callq 0x65e8
leaq -0x190(%rbp), %rdi
callq 0x65e8
leaq -0x1f0(%rbp), %rdi
callq 0x65e8
leaq -0x1b0(%rbp), %rdi
callq 0x65e8
leaq -0x1d0(%rbp), %rdi
callq 0x65e8
leaq -0x80(%rbp), %rdi
callq 0x65e8
leaq -0xa0(%rbp), %rdi
callq 0x65e8
leaq -0xc0(%rbp), %rdi
callq 0x65e8
leaq -0xe0(%rbp), %rdi
callq 0x65e8
leaq -0x100(%rbp), %rdi
callq 0x65e8
leaq -0x150(%rbp), %rdi
callq 0x65e8
leaq -0x120(%rbp), %rdi
callq 0x65e8
leaq -0x60(%rbp), %rdi
callq 0x65e8
jmp 0x30c64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x309b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x309a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x3099d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30991
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30985
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30979
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x3096d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30964
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30958
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x3094c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30940
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30934
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30928
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x65e8
leaq -0x170(%rbp), %rdi
callq 0x65e8
leaq -0x190(%rbp), %rdi
callq 0x65e8
leaq -0x1f0(%rbp), %rdi
callq 0x65e8
leaq -0x1b0(%rbp), %rdi
callq 0x65e8
leaq -0x1d0(%rbp), %rdi
callq 0x65e8
leaq -0x80(%rbp), %rdi
callq 0x65e8
leaq -0xa0(%rbp), %rdi
callq 0x65e8
leaq -0xc0(%rbp), %rdi
callq 0x65e8
leaq -0xe0(%rbp), %rdi
callq 0x65e8
leaq -0x100(%rbp), %rdi
callq 0x65e8
leaq -0x150(%rbp), %rdi
callq 0x65e8
leaq -0x120(%rbp), %rdi
callq 0x65e8
leaq -0x60(%rbp), %rdi
callq 0x65e8
jmp 0x310cf
movq -0x498(%rbp), %rsi
addq $0x88, %rsi
leaq -0x230(%rbp), %rdi
callq 0x6160
leaq 0x389d4(%rip), %rsi     # 0x693b8
leaq 0x146ad(%rip), %rdx     # 0x45098
leaq -0x2d0(%rbp), %rdi
callq 0x31710
jmp 0x309f9
movl -0x1c(%rbp), %esi
leaq -0x2f0(%rbp), %rdi
callq 0x31790
jmp 0x30a0a
leaq -0x2b0(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
leaq -0x2f0(%rbp), %rdx
callq 0x31640
jmp 0x30a26
leaq 0x14152(%rip), %rdx     # 0x44b7f
leaq -0x290(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x19360
jmp 0x30a42
leaq 0x3884f(%rip), %rdx     # 0x69298
leaq -0x270(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x315f0
jmp 0x30a5e
leaq 0x1417a(%rip), %rdx     # 0x44bdf
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x19360
jmp 0x30a7a
movq -0x10(%rbp), %rsi
leaq -0x310(%rbp), %rdi
callq 0x2f310
jmp 0x30a8c
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
leaq -0x250(%rbp), %rdx
leaq -0x310(%rbp), %rcx
callq 0x343f0
jmp 0x30aaf
movq -0x498(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x2eb60
jmp 0x30ac4
leaq -0x210(%rbp), %rdi
callq 0x65e8
leaq -0x310(%rbp), %rdi
callq 0x65e8
leaq -0x250(%rbp), %rdi
callq 0x65e8
leaq -0x270(%rbp), %rdi
callq 0x65e8
leaq -0x290(%rbp), %rdi
callq 0x65e8
leaq -0x2b0(%rbp), %rdi
callq 0x65e8
leaq -0x2f0(%rbp), %rdi
callq 0x65e8
leaq -0x2d0(%rbp), %rdi
callq 0x65e8
leaq -0x230(%rbp), %rdi
callq 0x65e8
jmp 0x30c64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30c53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30c47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30c3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30c2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30c23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30c17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30c0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30bff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x65e8
leaq -0x310(%rbp), %rdi
callq 0x65e8
leaq -0x250(%rbp), %rdi
callq 0x65e8
leaq -0x270(%rbp), %rdi
callq 0x65e8
leaq -0x290(%rbp), %rdi
callq 0x65e8
leaq -0x2b0(%rbp), %rdi
callq 0x65e8
leaq -0x2f0(%rbp), %rdi
callq 0x65e8
leaq -0x2d0(%rbp), %rdi
callq 0x65e8
leaq -0x230(%rbp), %rdi
callq 0x65e8
jmp 0x310cf
movq -0x10(%rbp), %rax
movq %rax, -0x4b0(%rbp)
xorl %eax, %eax
testb $0x1, -0x1d(%rbp)
movb %al, -0x4a5(%rbp)
je 0x30c86
movb -0x1e(%rbp), %al
movb %al, -0x4a5(%rbp)
movq -0x4b0(%rbp), %rsi
movq -0x498(%rbp), %rdi
movb -0x4a5(%rbp), %dl
movq -0x18(%rbp), %rcx
movq (%rdi), %rax
movq 0x20(%rax), %rax
movzbl %dl, %edx
andl $0x1, %edx
callq *%rax
movq -0x10(%rbp), %rdi
callq 0x2eb40
cmpl $0x0, %eax
jg 0x310c6
movq -0x10(%rbp), %rdi
callq 0x310e0
movq -0x498(%rbp), %rdi
movl %eax, %esi
callq 0x301e0
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movq -0x10(%rbp), %rsi
leaq -0x320(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
callq 0x2ff40
movq -0x4c8(%rbp), %rdi
callq 0x19df0
movq %rax, -0x4c0(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x330(%rbp), %rdi
movq %rdi, -0x4b8(%rbp)
callq 0x194e0
movq -0x4c0(%rbp), %rdi
movq -0x4b8(%rbp), %rsi
callq 0x2cc10
jmp 0x30d39
leaq -0x330(%rbp), %rdi
callq 0x19530
leaq -0x320(%rbp), %rdi
callq 0x199a0
movq -0x498(%rbp), %rsi
addq $0x88, %rsi
leaq -0x370(%rbp), %rdi
callq 0x6160
leaq 0x38606(%rip), %rsi     # 0x69378
leaq -0x390(%rbp), %rdi
callq 0x6160
jmp 0x30d80
movq -0x10(%rbp), %rsi
leaq -0x3b0(%rbp), %rdi
callq 0x2f310
jmp 0x30d92
leaq -0x350(%rbp), %rdi
leaq -0x370(%rbp), %rsi
leaq -0x390(%rbp), %rdx
leaq -0x3b0(%rbp), %rcx
callq 0x343f0
jmp 0x30db5
movq -0x498(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x2eb60
jmp 0x30dca
leaq -0x350(%rbp), %rdi
callq 0x65e8
leaq -0x3b0(%rbp), %rdi
callq 0x65e8
leaq -0x390(%rbp), %rdi
callq 0x65e8
leaq -0x370(%rbp), %rdi
callq 0x65e8
movq -0x10(%rbp), %rsi
movq %rsi, -0x4d0(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x2f310
leaq 0x38540(%rip), %rsi     # 0x69358
leaq 0x13d60(%rip), %rdx     # 0x44b7f
leaq -0x470(%rbp), %rdi
callq 0x31710
jmp 0x30e2d
leaq 0x38544(%rip), %rdx     # 0x69378
leaq -0x450(%rbp), %rdi
leaq -0x470(%rbp), %rsi
callq 0x315f0
jmp 0x30e49
leaq 0x13d2f(%rip), %rdx     # 0x44b7f
leaq -0x430(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x19360
jmp 0x30e65
leaq 0x3840c(%rip), %rdx     # 0x69278
leaq -0x410(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x315f0
jmp 0x30e81
movq -0x498(%rbp), %rsi
addq $0x88, %rsi
leaq -0x490(%rbp), %rdi
callq 0x6160
jmp 0x30e9d
leaq -0x3d0(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
leaq -0x410(%rbp), %rdx
leaq -0x490(%rbp), %rcx
callq 0x343f0
jmp 0x30ec0
movq -0x4d0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x2eb60
jmp 0x30ed5
leaq -0x3d0(%rbp), %rdi
callq 0x65e8
leaq -0x490(%rbp), %rdi
callq 0x65e8
leaq -0x410(%rbp), %rdi
callq 0x65e8
leaq -0x430(%rbp), %rdi
callq 0x65e8
leaq -0x450(%rbp), %rdi
callq 0x65e8
leaq -0x470(%rbp), %rdi
callq 0x65e8
leaq -0x3f0(%rbp), %rdi
callq 0x65e8
jmp 0x310c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x330(%rbp), %rdi
callq 0x19530
leaq -0x320(%rbp), %rdi
callq 0x199a0
jmp 0x310cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30fcf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30fc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x30fb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x65e8
leaq -0x3b0(%rbp), %rdi
callq 0x65e8
leaq -0x390(%rbp), %rdi
callq 0x65e8
leaq -0x370(%rbp), %rdi
callq 0x65e8
jmp 0x310cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x310b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x310ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x310a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x31094
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x31088
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
jmp 0x3107c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x128(%rbp)
movl %eax, -0x12c(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x65e8
leaq -0x490(%rbp), %rdi
callq 0x65e8
leaq -0x410(%rbp), %rdi
callq 0x65e8
leaq -0x430(%rbp), %rdi
callq 0x65e8
leaq -0x450(%rbp), %rdi
callq 0x65e8
leaq -0x470(%rbp), %rdi
callq 0x65e8
leaq -0x3f0(%rbp), %rdi
callq 0x65e8
jmp 0x310cf
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
movq -0x128(%rbp), %rdi
callq 0x6550
nopl (%rax,%rax)