[SDK]How to count First Strikes

phungus420

Deity
Joined
Mar 1, 2003
Messages
6,296
Say I have two units, pAttacker and pDeffender, and I want to count the first strikes of the units... Any ideas as to how I can go about this?
Overall, I'm just interesed in just getting the average, so I need to be able to seperate First Strike Chances and First Strikes, then I can write up a math function to give me the Statistically expected outcome of the # of first strikes. So at the end of the day I'd have something like:

Net First Strikes = first strikes(Att) + First Strike Chances(Att)/2 - First Strike(Def) - First Strike Chances(Def)/3

Anyway, the math isn't that important, I can write up that code easily. The hang up I'm having is:

Code:
int iFSAtt = 0;
    iFSAtt = ????pAttacker???

I was shown this code when I asked in the relevant thread. I have tried breaking it down into it's consituent parts, and create a useful function. Anyway, the code below will compile, even if broken down to it's various pieces, but when I test it in game, all I ever get is 0 (For instance iFSAtt = (pAttacker->FirstStrikes()); Just returns 0):
Code:
AttFSnet = ( (pDefender->immuneToFirstStrikes()) ? 0 : pAttacker->firstStrikes() ) - ((pAttacker->immuneToFirstStrikes()) ? 0 : pDefender->firstStrikes());
    AttFSC = (pDefender->immuneToFirstStrikes()) ? 0 : (pAttacker->chanceFirstStrikes());
    DefFSC = (pAttacker->immuneToFirstStrikes()) ? 0 : (pDefender->chanceFirstStrikes());
 
I'm not sure why it would be not working for you.

I entered the following code at the end of ACO in GameTxtMgr...

Code:
int DefFS = ((pAttacker->immuneToFirstStrikes()) ? 0 : pDefender->firstStrikes());
int AttFS = ((pDefender->immuneToFirstStrikes()) ? 0 : pAttacker->firstStrikes());
int AttFSC = ((pDefender->immuneToFirstStrikes()) ? 0 : (pAttacker->chanceFirstStrikes()));
int DefFSC = ((pAttacker->immuneToFirstStrikes()) ? 0 : (pDefender->chanceFirstStrikes()));
                szTempBuffer.Format(L"Attacker FS: %d-%d\n",
                                    AttFS,AttFS+AttFSC);
                ;szString.append(szTempBuffer.GetCString());
                szTempBuffer.Format(L"Defender FS: %d-%d\n",
                                    DefFS,DefFS+DefFSC);
                ;szString.append(szTempBuffer.GetCString());

And got this...
Note there is currently a bug in the odds display (ignore it) but look at the end of the help text.

attachment.php
 

Attachments

  • first strikes.GIF
    first strikes.GIF
    139.2 KB · Views: 147
Back
Top Bottom