Shade Posted March 30, 2014 Group: Members Topic Count: 48 Topics Per Day: 0.01 Content Count: 123 Reputation: 29 Joined: 04/09/12 Last Seen: February 10, 2021 Share Posted March 30, 2014 Hi, I'm trying to reduce the limit of poison damage from 25% to 10% but I couldn't get myself to understand what is going on the status.c: case SC_DPOISON: // Lose 10/15% of your life as long as it doesn't brings life below 25% if (status->hp > status->max_hp>>2) { int diff = status->max_hp*(bl->type==BL_PC?10:15)/100; if (status->hp - diff < status->max_hp>>2) diff = status->hp - (status->max_hp>>2); if( val2 && bl->type == BL_MOB ) { struct block_list* src = map_id2bl(val2); if( src ) mob_log_damage((TBL_MOB*)bl,src,diff); } status_zap(bl, diff, 0); } case SC_POISON: // Fall through val3 = tick/1000; // Damage iterations if(val3 < 1) val3 = 1; tick_time = 1000; // [GodLesZ] tick time // val4: HP damage if (bl->type == BL_PC) val4 = (type == SC_DPOISON) ? 2 + status->max_hp/50 : 2 + status->max_hp*3/200; else val4 = (type == SC_DPOISON) ? 2 + status->max_hp/100 : 2 + status->max_hp/200; break; I don't get what the if condition means: if (status->hp > status->max_hp>>2) { Shouldn't it be: if (status->hp > status->max_hp*1/4) { Looking forward to gain a better understanding of this. Thanks, Shade Quote Link to comment Share on other sites More sharing options...
nanakiwurtz Posted March 30, 2014 Group: Members Topic Count: 81 Topics Per Day: 0.02 Content Count: 1654 Reputation: 583 Joined: 08/09/12 Last Seen: January 14, 2020 Share Posted March 30, 2014 (edited) Hello Shade! The source code sometimes is easier to work with binary. To make you understand better, I have an example for you: Let's say that a player's Max HP is 10000, in binary it's 100111000100. Then we want to make it to 25%, so we just shift it right, twice, so: 100111000100 will becomes 1001110001 which is 2500. And 2500 is 25% of 10000 right? But then again, you may ask, "Why do I have to shift it twice? (>>2)" Well it's because 2500/10000=0.25 (25% from 10000) --> 1 / 0.25 = 4 --> 4 is 2^2 It would work too just like what you have said earlier "max_hp*1/4". But, what if your player's Max HP is 9999? A --> Decimal calculation: 9999*1/4 = 2499.75 B --> Binary calculation: 10011100001111 -> 100111000011 = 2499 Since our rA engine doesn't work with floating numbers, then it'll take another steps to omits the decimals from calculation A, but what happened with calculation B? It automatically omits the decimals isn't it? That's why I said that working with binary is easier... But in this case what you want is "status->max_hp/10" since you want 10% of the Max HP ^^ Edited March 30, 2014 by nanakiwurtz 2 Quote Link to comment Share on other sites More sharing options...
Shade Posted March 30, 2014 Group: Members Topic Count: 48 Topics Per Day: 0.01 Content Count: 123 Reputation: 29 Joined: 04/09/12 Last Seen: February 10, 2021 Author Share Posted March 30, 2014 @nanakiwurtz Now that made more sense. Haha. Thank you. But surprisingly, no matter what condition I put into it will always stop at 25% HP. I'm not sure why. Quote Link to comment Share on other sites More sharing options...
nanakiwurtz Posted March 30, 2014 Group: Members Topic Count: 81 Topics Per Day: 0.02 Content Count: 1654 Reputation: 583 Joined: 08/09/12 Last Seen: January 14, 2020 Share Posted March 30, 2014 @nanakiwurtz Now that made more sense. Haha. Thank you. But surprisingly, no matter what condition I put into it will always stop at 25% HP. I'm not sure why. To put new code into effect, you have to recompile your server Quote Link to comment Share on other sites More sharing options...
Shade Posted March 30, 2014 Group: Members Topic Count: 48 Topics Per Day: 0.01 Content Count: 123 Reputation: 29 Joined: 04/09/12 Last Seen: February 10, 2021 Author Share Posted March 30, 2014 Well, yes I always recompile servers after doing SRC edits. I've been doing a lot of SRC edit for skills to gain better understanding and so far most of it works like a charm except this poison status. Quote Link to comment Share on other sites More sharing options...
Kichi Posted April 8, 2014 Group: Members Topic Count: 25 Topics Per Day: 0.01 Content Count: 509 Reputation: 80 Joined: 11/20/11 Last Seen: October 3, 2020 Share Posted April 8, 2014 Find this: status.c map_freeblock_lock(); if(status->hp >= max(status->max_hp>>2, sce->val4)) //Stop damaging after 25% HP left. status_zap(bl, sce->val4, 0); Change to map_freeblock_lock(); if(status->hp >= max(status->max_hp/10, sce->val4)) //Stop damaging after 10% HP left. status_zap(bl, sce->val4, 0); Quote Link to comment Share on other sites More sharing options...
Shade Posted April 8, 2014 Group: Members Topic Count: 48 Topics Per Day: 0.01 Content Count: 123 Reputation: 29 Joined: 04/09/12 Last Seen: February 10, 2021 Author Share Posted April 8, 2014 Find this: status.c map_freeblock_lock(); if(status->hp >= max(status->max_hp>>2, sce->val4)) //Stop damaging after 25% HP left. status_zap(bl, sce->val4, 0); Change to map_freeblock_lock(); if(status->hp >= max(status->max_hp/10, sce->val4)) //Stop damaging after 10% HP left. status_zap(bl, sce->val4, 0); I did that, recompiled, still stays @ 25% max hp. Quote Link to comment Share on other sites More sharing options...
Question
Shade
Hi,
I'm trying to reduce the limit of poison damage from 25% to 10% but I couldn't get myself to understand what is going on the status.c:
I don't get what the if condition means:
Shouldn't it be:
Looking forward to gain a better understanding of this.
Thanks,
Shade
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.