// File: /workspace/github_cpp_makefile_star2_O1/MichaelXanth[P]RPG_Game/Living/Monsters/Monster.cpp
// Function: Monster::HitBySpell(Spell*)
void Monster::HitBySpell(Spell* hitSpell)
{
    unsigned int rounds;

    switch(hitSpell->ReduceStat(rounds))//gets the rounds of the effect
    {
        case 1:
            avoidanceAffectedForRounds += rounds;//adds the rounds of the effect

            if(((100 - (double)hitSpell ->GetAvoidanceReduction()) / 100) * avoidance < 0)//if the new avoidance is below 0 then it is set to 0
                avoidance = 0.0;
            else
            {
                oldAvoidance += avoidance;//stores the old avoidance so that it can be restored after the end of the effect
                avoidance = ((100 - (double)hitSpell ->GetAvoidanceReduction()) / 100) * avoidance;//reduces the avoidance
            }
            break;
        case 2:
            damageAffectedForRounds += rounds;//adds the rounds of the effect

            if(minDamage - hitSpell ->GetDamageReduction() < 0)//if the new damage is below 0 then it is set to 0
                minDamage = 0;
            else
            {
                oldMinDamage += minDamage;//stores the old damage so that it can be restored after the end of the effect
                minDamage = minDamage - hitSpell ->GetDamageReduction();//reduces the damage
            }

            if(maxDamage - hitSpell ->GetDamageReduction() < 0)
                maxDamage = 0;
            else
            {
                oldMaxDamage += maxDamage;
                maxDamage = maxDamage - hitSpell ->GetDamageReduction();
            }
            break;
        case 3:
            defenceAffectedForRounds += rounds;//adds the rounds of the effect

            if(defence - hitSpell ->GetDefenceReduction() < 0)//if the new damage is below 0 then it is set to 0
                defence = 0;
            else
            {
                oldDefence += defence;//stores the old damage so that it can be restored after the end of the effect
                defence = defence - hitSpell ->GetDefenceReduction();//reduces the damage
            }
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
leaq -0x1c(%rbp), %rsi
movq %r14, %rdi
callq *(%rax)
cmpw $0x3, %ax
je 0x18eed
movzwl %ax, %eax
cmpl $0x2, %eax
je 0x18ea3
cmpl $0x1, %eax
jne 0x18f5c
movl -0x1c(%rbp), %eax
addl %eax, 0x50(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0xe1d7(%rip), %xmm2     # 0x27048
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
divsd %xmm2, %xmm1
movss 0x60(%rbx), %xmm0
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
mulsd %xmm1, %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm2, %xmm1
jbe 0x18f16
movl $0x0, 0x60(%rbx)
jmp 0x18f5c
movl -0x1c(%rbp), %eax
addl %eax, 0x48(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movl 0x54(%rbx), %r15d
addl %r15d, 0x38(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
subl %eax, %r15d
movl %r15d, 0x54(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movl 0x58(%rbx), %r15d
addl %r15d, 0x3c(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
subl %eax, %r15d
movl %r15d, 0x58(%rbx)
jmp 0x18f5c
movl -0x1c(%rbp), %eax
addl %eax, 0x4c(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movl 0x5c(%rbx), %r15d
addl %r15d, 0x40(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
subl %eax, %r15d
movl %r15d, 0x5c(%rbx)
jmp 0x18f5c
addss 0x44(%rbx), %xmm0
movss %xmm0, 0x44(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0xe10d(%rip), %xmm2     # 0x27048
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
divsd %xmm2, %xmm1
xorps %xmm0, %xmm0
cvtss2sd 0x60(%rbx), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x60(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop