Comments (7)
[REDACTED] I'm checking the code and will edit this with what I find.
Please replace the code inside the else if
with:
uint8 playerRotation = PAttacker->loc.p.rotation;
uint8 mobRotation = PDefender->loc.p.rotation;
if (mobRotation > (232)) //255-23
{
if (playerRotation > 0)
{
if (abs(PDefender->loc.p.rotation - (PAttacker->loc.p.rotation + 256)) < 23 || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))
{
crithitrate = 100;
}
}
else
{
if (abs(PDefender->loc.p.rotation - PAttacker->loc.p.rotation) < 23 || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))
{
crithitrate = 100;
}
}
}
else if (mobRotation < 23)
{
if (playerRotation > (232))
{
if (abs((PDefender->loc.p.rotation+256) - PAttacker->loc.p.rotation) < 23 || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))
{
crithitrate = 100;
}
}
else
{
if (abs(PDefender->loc.p.rotation - PAttacker->loc.p.rotation) < 23 || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))
{
crithitrate = 100;
}
}
}
else
{
if (abs(PDefender->loc.p.rotation - PAttacker->loc.p.rotation) < 23 || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))
{
crithitrate = 100;
}
}
and see if that fixes you. I just threw it together real quick, so if it's a "messy" fix I apologize, this is the best way I could see to fix it.
Edit2: Didn't realize this till much later but this is indeed a value going from 0 - 255. (loc.p.rotation is a uint8 which is why I used that for my variables.)
Edit 3: Seems git didn't get any of my later edits, this was to fix that, and remove references to 360 degree math.
from darkstar.
Need someone on retail to confirm the rotation range to see if its 0-360(or 0-2π) or 0-255.
This is what I added to my server. I was just hoping that someone had something more elegant.
if (abs(PDefender->loc.p.rotation - PAttacker->loc.p.rotation) < 23
|| (PDefender->loc.p.rotation < 64 && PAttacker->loc.p.rotation > 192 && abs(PAttacker->loc.p.rotation - 256 - PDefender->loc.p.rotation) < 23)
|| (PDefender->loc.p.rotation > 192 && PAttacker->loc.p.rotation < 64 && abs(PDefender->loc.p.rotation - 256 - PAttacker->loc.p.rotation) < 23)
|| PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))
{
crithitrate = 100;
}
Also, I think that the ASSASSIN+TRICK_ATTACK Crit Rate check shouldn't be an else if condition, but needs retail verification. I think if you have both SA and Assassin+TA on, only one of the conditions needs to be satisfied for a crit.
from darkstar.
packet has an 8 bit value with different things in the byte son both sides of it, so unless we missed some bit-packing, pretty sure its 0-255 and not 1-360 or 0-359
from darkstar.
Need someone on retail to confirm the rotation range to see if its 0-360(or 0-2π) or 0-255.
This is what I added to my server. I was just hoping that someone had something more elegant.
if (abs(PDefender->loc.p.rotation - PAttacker->loc.p.rotation) < 23 || (PDefender->loc.p.rotation < 64 && PAttacker->loc.p.rotation > 192 && abs(PAttacker->loc.p.rotation - 256 - PDefender->loc.p.rotation) < 23) || (PDefender->loc.p.rotation > 192 && PAttacker->loc.p.rotation < 64 && abs(PDefender->loc.p.rotation - 256 - PAttacker->loc.p.rotation) < 23) || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE)) { crithitrate = 100; }
Also, I think that the ASSASSIN+TRICK_ATTACK Crit Rate check shouldn't be an else if condition, but needs retail verification. I think if you have both SA and Assassin+TA on, only one of the conditions needs to be satisfied for a crit.
I already confirmed it this morning since I couldn't sleep. Retail does indeed send 1 byte for rotation, which would be a uint8.
Edit: check your math, your numbers are way off. Also, there's no point in switching around PDefender and PAttacker, thats partially why abs() is used. Finally, if you're gonna reference a value that many times, it's usually better to create a temp variable like I did in mine, it saves some time.
You could also save some time by doing the check for hide exclusive to everything else, since having hide just sets the critrate to 100, i'd do:
if(PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))
{
crithitrate = 100;
}
else
{
//do the mess of checking rotations and such here.
}
this will actually speed up these checks in instances where hide is in effect, because it will skip every other check if hide is active. Your || chain will go through everything and check hide last.
from darkstar.
My math was dependent on which quadrant the attacker and defender are rotated toward. I'm reducing values greater than 192(quadrant 4) to be a negative angle from the 0 axis. This can be directly mathed with the positive value in quadrant 1 to come up with a sensical difference between the two. I think the order would matter with what I was doing.
abs(251 - 256 - 5) = 10
abs(5 - 256 - 251) = 502
I can probably do something like this if this would be better??? Would eliminate the swapping.
256 - abs(attacker - defender)
And pulling out the hide check might be a good idea, but I'm not sure. If we are going for efficiency, I'd suggest that people will rarely ever use Hide+SA. It happens, but in normal game play with party mechanics hide is just rarely used. We'd be moving a rarely used check to ALWAYS happen first.
from darkstar.
Sorry to be so chatty. This is what I ended up with.
uint8 playerRotation = PAttacker->loc.p.rotation;
uint8 mobRotation = PDefender->loc.p.rotation;
if (abs(mobRotation - playerRotation) < 23
|| (abs(mobRotation - playerRotation) >= 233 && 256 - abs(mobRotation - playerRotation) < 23)
|| PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE))
{
crithitrate = 100;
}
if the difference between the rotations was greater than 233 (256 - 23), then we can assume this is math between quadrant 1 and 4... and we really only care about math that is within 23 of 0.
from darkstar.
Sorry to be so chatty. This is what I ended up with.
uint8 playerRotation = PAttacker->loc.p.rotation; uint8 mobRotation = PDefender->loc.p.rotation; if (abs(mobRotation - playerRotation) < 23 || (abs(mobRotation - playerRotation) >= 233 && 256 - abs(mobRotation - playerRotation) < 23) || PAttacker->StatusEffectContainer->HasStatusEffect(EFFECT_HIDE)) { crithitrate = 100; }
if the difference between the rotations was greater than 233 (256 - 23), then we can assume this is math between quadrant 1 and 4... and we really only care about math that is within 23 of 0.
I'd still change this like I mentioned above, since Hide pretty much guarantees Sneak Attack will work, it shouldn't be dependent on check everything else first (or at all, unless its not active). But this looks a lot better than my version. I had an extra case that I now realize wasn't necessary (mob's facing 0+ and player is in the 200s) in my original post. If you don't want to if..else it then you can just move the check for hide to being the first check.
from darkstar.
Related Issues (20)
- Dragon-Moogle terrorized Mission CS event HOT 2
- Prowess not kept at log off log in
- Sandoria mission 3-3 Last cutscene does not finish the mission.
- Battlefield cleans up before cut scene finishes - THE CELESTIAL NEXUS HOT 3
- Windurst Mission 8-1 VAIN CS event missing parameters (needs !release to get out)
- Sanitize user input during the login flow. HOT 1
- Rename "email2" to something more descriptive in `accounts` SQL table
- Attempt to index local 'rainbow' (a nil value) HOT 4
- Cannot equip a gear HOT 4
- Killing a mob at the same time as the attacking player dies triggers a silent crash HOT 1
- MapServer error: la theine plateau 'rainbow' is nil value HOT 1
- [Easy Fix] Aquaveil incorrect functionality HOT 8
- Undead not despawning after Day/Night Change in multiple zones. HOT 1
- SMall non retail artifact of "the goblin tailor" quest
- Promathia fight - 2nd form caps at level 85 HOT 1
- Artisan Moogle in Rulude Garden has wrong name HOT 2
- continuous-integration/travis-ci seems struck on all recent PRs
- Linux compile failing HOT 1
- Wrong Mobs Spawning in Instances HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from darkstar.