Damage calculator

#60
FYI: I've attached a demo to this post (\<span> site blocked, contact your administrator/bbs2/index.php?topic=142.msg1196#msg1196) but I haven't yet announced it in the thread. I'll do that tomorrow after getting some sleep.

If your numbers have a syntax error you'll get a game over popup box. It's better than nothing for now. The error is not described. But the expression is in the popup's title bar.

Also. I went and changed handicap_quantifier to hit_handicap_quantifier...

The following mentioned extensions are not implemented and odds are good they won't be in the next release.

hit_point_mode
hit_point_model
hit_penalty_quantifier

The damage loop looks like this:

Code:
    DWORD ebp = dst; *out = 0;
    for(esi=0;esi<8;esi++,ebp+=2)
    {
        /*
        0040459E 33 F6            xor         esi,esi
        004045A0 33 C0            xor         eax,eax
        004045A2 8A 44 33 04      mov         al,byte ptr [ebx+esi+4]
        004045A6 84 C0            test        al,al
        004045A8 74 77            je          00404621
        004045AA 0F BF 4D 00      movsx       ecx,word ptr [ebp]
        004045AE 25 FF 00 00 00   and         eax,0FFh
        004045B3 83 FE 03         cmp         esi,3
        004045B6 89 44 24 28      mov         dword ptr [esp+28h],eax
        004045BA DB 44 24 28      fild        dword ptr [esp+28h]
        004045BE 89 4C 24 28      mov         dword ptr [esp+28h],ecx
        004045C2 DB 44 24 28      fild        dword ptr [esp+28h]
        004045C6 D8 44 24 10      fadd        dword ptr [esp+10h]
        004045CA D9 5C 24 28      fstp        dword ptr [esp+28h]
        */
        float offset = *(SHORT*)(ebp);        
        float rating = *(BYTE*)(ebx+esi+4);
        
        if(!rating) continue; //todo: extension to bypass this?
        /*        
        004045CE 7D 0E            jge         004045DE
        004045D0 D8 44 24 14      fadd        dword ptr [esp+14h]
        004045D4 D9 44 24 28      fld         dword ptr [esp+28h]
        004045D8 D8 44 24 1C      fadd        dword ptr [esp+1Ch]
        004045DC EB 0C            jmp         004045EA
        004045DE D8 44 24 18      fadd        dword ptr [esp+18h]
        004045E2 D9 44 24 28      fld         dword ptr [esp+28h]
        004045E6 D8 44 24 20      fadd        dword ptr [esp+20h]
        */        
        if(&hp->hit_point_quantifier)
        {
            SOM::L.pcstatus = srcStatus;

            if(esi<3||!&hp->hit_point_quantifier2)
            {
                rating = hp->hit_point_quantifier(rating,0,esi);
            }
            else rating = hp->hit_point_quantifier2(rating,0,esi);
        }
        else rating+=srcBase[esi>=3];

        if(&hp->hit_offset_quantifier)
        {
            SOM::L.pcstatus = dstStatus;

            if(esi<3||!&hp->hit_offset_quantifier2)
            {
                offset = hp->hit_offset_quantifier(offset,evasion,esi);
            }
            else offset = hp->hit_offset_quantifier2(offset,evasion,esi);
        }
        else offset+=dstBase[esi>=3]+evasion;
        /*
        004045EA D9 C1            fld         st(1)
        004045EC D8 D9            fcomp       st(1)
        004045EE DF E0            fnstsw      ax   
        004045F0 F6 C4 41         test        ah,41h
        004045F3 75 0D            jne         00404602
        004045F5 D9 C1            fld         st(1)
        004045F7 D8 E1            fsub        st,st(1)         
        004045F9 E8 3A B3 04 00   call        0044F938
        004045FE 8B F8            mov         edi,eax
        00404600 EB 02            jmp         00404604
        00404602 33 FF            xor         edi,edi
        */                        Â   
        LONG edi = 0; //max(0,rating-offset);
        /*                                Â 
        00404604 D9 C1            fld         st(1)
        00404606 D8 CA            fmul        st,st(2)
        00404608 D9 C9            fxch        st(1)
        0040460A DC C0            fadd        st(0),st
        0040460C DE F9            fdivp       st(1),st
        //not sure what this does but INF becomes 0//
        0040460E E8 25 B3 04 00   call        0044F938
        00404613 DD D8            fstp        st(0)
        00404615 03 F8            add         edi,eax
        */
        if(&hp->hit_outcome_quantifier)
        {
            SOM::L.pcstatus = 0; //NaN

            *out = //custom formula
            hp->hit_outcome_quantifier(rating,offset,esi);
        }
        else if(!bf||bf->do_fix_damage_calculus)
        {    
            if(offset>0) //default formula
            {
                edi = rating-
                max(0,offset-(rating*rating/(offset*2)));
                if(edi<0) edi = 0;
            }
            else edi = rating;
        }
        else //classic formula with bugs
        {
            edi = max(0,rating-offset);

            rating*=rating; offset+=offset;

            if(offset) edi+=rating/offset;
        }
        /*
        00404617 85 FF            test        edi,edi
        00404619 7E 06            jle         00404621
        0040461B 8B 44 24 30      mov         eax,dword ptr [esp+30h]
        0040461F 01 38            add         dword ptr [eax],edi
        00404621 46               inc         esi
        00404622 83 C5 02         add         ebp,2
        00404625 83 FE 08         cmp         esi,8
        00404628 0F 8C 72 FF FF FF jl          004045A0
        */
        *out+=edi; //why jle and not je???
    }
    /*
    0040462E 8B 43 14         mov         eax,dword ptr [ebx+14h]
    00404631 BF 18 1A 9C 01   mov         edi,19C1A18h
    00404636 3B C7            cmp         eax,edi
    00404638 75 1B            jne         00404655
    */
    DWORD edi = 0x19C1A18;
    if(*(DWORD*)(ebx+0x14)==edi) //0x19C1A18
    {
        //player power gauge
        /*
        0040463A 8B 4C 24 30      mov         ecx,dword ptr [esp+30h]
        0040463E 33 D2            xor         edx,edx
        00404640 66 8B 53 0E      mov         dx,word ptr [ebx+0Eh]
        00404644 B8 59 17 B7 D1   mov         eax,0D1B71759h
        00404649 0F AF 11         imul        edx,dword ptr [ecx]
        0040464C F7 E2            mul         eax,edx
        0040464E C1 EA 0C         shr         edx,0Ch
        00404651 89 11            mov         dword ptr [ecx],edx
        00404653 EB 04            jmp         00404659
        */

        LONG edx = *out**(WORD*)(ebx+0xE);

        edx = (0xD1B71759ULL*edx)>>32; //mul edx
        
        *out = edx>>0xC;
    }
    SOM::L.pcstatus = pcstatus;
    /*
    00404655 8B 4C 24 30      mov         ecx,dword ptr [esp+30h]
    00404659 83 39 00         cmp         dword ptr [ecx],0
    0040465C 75 06            jne         00404664
    0040465E C7 01 01 00 00 00 mov         dword ptr [ecx],1
    */
    if(&hp->hit_handicap_quantifier)
    {
        SOM::L.pcstatus = dstStatus;
        *out = hp->hit_handicap_quantifier(*out);
        SOM::L.pcstatus = pcstatus;
    }
    else if(*out==0) *out = 1;

I would like to change the default bonus if I don't forget. I'd like to hear any suggestions.


EDITED: I don't think I am going to do anymore work with this. The one thing I may do is better error messages for number syntax errors. Especially if anyone has problems. Of course there is a lot of documentation to do. And also. Very important. The damage extensions only work with som_db.exe. So until this release is done, they will only be in effect for project trials.
Reply



Messages In This Thread
Damage calculator - by HolyDiver - 2013-03-28, 08:10 PM
Re: Damage calculator - by Verdite - 2013-03-28, 09:18 PM
Re: Damage calculator - by HolyDiver - 2013-03-28, 10:30 PM
Re: Damage calculator - by Verdite - 2013-03-29, 12:02 AM
Re: Damage calculator - by HwitVlf - 2013-03-29, 12:18 AM
Re: Damage calculator - by HolyDiver - 2013-03-29, 02:21 AM
Re: Damage calculator - by HolyDiver - 2013-03-29, 03:05 PM
Re: Damage calculator - by HolyDiver - 2013-03-29, 04:52 PM
Re: Damage calculator - by HwitVlf - 2013-03-29, 05:35 PM
Re: Damage calculator - by HolyDiver - 2013-03-29, 07:53 PM
Re: Damage calculator - by HolyDiver - 2013-03-29, 09:08 PM
Re: Damage calculator - by HolyDiver - 2013-04-01, 03:12 AM
Re: Damage calculator - by Verdite - 2013-04-01, 03:33 PM
Re: Damage calculator - by HolyDiver - 2013-04-01, 10:16 PM
Re: Damage calculator - by HolyDiver - 2013-04-01, 10:27 PM
Re: Damage calculator - by HolyDiver - 2013-04-02, 12:17 AM
Re: Damage calculator - by HolyDiver - 2013-04-11, 04:15 AM
Re: Damage calculator - by HolyDiver - 2013-04-11, 04:30 AM
Re: Damage calculator - by HolyDiver - 2013-06-13, 02:15 PM
Re: Damage calculator - by HwitVlf - 2013-06-13, 07:54 PM
Re: Damage calculator - by HolyDiver - 2013-06-13, 10:50 PM
Re: Damage calculator - by HwitVlf - 2013-06-14, 07:23 PM
Re: Damage calculator - by HolyDiver - 2013-06-14, 10:25 PM
Re: Damage calculator - by HwitVlf - 2013-06-14, 11:51 PM
Re: Damage calculator - by HolyDiver - 2013-06-15, 02:26 AM
Re: Damage calculator - by HwitVlf - 2013-06-15, 03:13 AM
Re: Damage calculator - by HolyDiver - 2013-06-15, 03:58 AM
Re: Damage calculator - by HolyDiver - 2013-06-15, 04:59 AM
Re: Damage calculator - by HolyDiver - 2013-06-23, 01:15 AM
Re: Damage calculator - by HolyDiver - 2013-06-24, 12:52 AM
Re: Damage calculator - by HolyDiver - 2013-07-02, 05:19 PM
Re: Damage calculator - by HwitVlf - 2013-07-02, 07:49 PM
Re: Damage calculator - by HolyDiver - 2013-07-03, 06:52 AM
Re: Damage calculator - by HwitVlf - 2013-07-04, 07:41 PM
Re: Damage calculator - by HolyDiver - 2013-07-05, 09:25 AM
Re: Damage calculator - by HwitVlf - 2013-07-05, 10:51 AM
Re: Damage calculator - by HolyDiver - 2013-07-05, 11:15 AM
Re: Damage calculator - by HolyDiver - 2013-07-05, 02:05 PM
Re: Damage calculator - by HwitVlf - 2013-07-05, 07:00 PM
Re: Damage calculator - by HolyDiver - 2013-07-05, 08:59 PM
Re: Damage calculator - by HwitVlf - 2013-07-05, 10:11 PM
Re: Damage calculator - by HolyDiver - 2013-07-06, 10:17 AM
Re: Damage calculator - by HolyDiver - 2013-07-06, 10:41 AM
Re: Damage calculator - by HolyDiver - 2013-07-06, 10:52 AM
Re: Damage calculator - by HolyDiver - 2013-07-06, 11:05 AM
Re: Damage calculator - by HolyDiver - 2013-07-06, 11:36 AM
Re: Damage calculator - by HolyDiver - 2013-07-06, 06:45 PM
Re: Damage calculator - by HwitVlf - 2013-07-06, 09:50 PM
Re: Damage calculator - by HolyDiver - 2013-07-07, 08:10 AM
Re: Damage calculator - by HolyDiver - 2013-07-07, 12:34 PM
Re: Damage calculator - by HolyDiver - 2013-07-07, 02:49 PM
Re: Damage calculator - by HolyDiver - 2013-07-07, 05:38 PM
Re: Damage calculator - by HwitVlf - 2013-07-07, 10:41 PM
Re: Damage calculator - by HolyDiver - 2013-07-08, 04:50 AM
Re: Damage calculator - by HolyDiver - 2013-07-08, 08:34 AM
Re: Damage calculator - by HolyDiver - 2013-07-08, 11:07 AM
Re: Damage calculator - by HolyDiver - 2013-07-08, 11:49 AM
Re: Damage calculator - by HolyDiver - 2013-07-08, 12:11 PM
Re: Damage calculator - by HolyDiver - 2013-07-08, 04:56 PM
Re: Damage calculator - by HolyDiver - 2013-07-08, 07:14 PM
Re: Damage calculator - by HwitVlf - 2013-07-08, 09:25 PM
Re: Damage calculator - by HolyDiver - 2013-07-09, 11:27 AM
Re: Damage calculator - by HolyDiver - 2013-07-09, 01:46 PM



Users browsing this thread:
6 Guest(s)