]> git.jsancho.org Git - lugaru.git/commitdiff
SolidHitBonus simplification
authorAlexander Monakov <amonakov@gmail.com>
Sun, 26 Dec 2010 23:41:12 +0000 (02:41 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Sun, 26 Dec 2010 23:41:12 +0000 (02:41 +0300)
Source/Bonuses.def
Source/Person.cpp

index 91b2b5ca47716b01a1106cf1109e7e19383a8e2c..1604f240cdda5e2f41c423f1326c014564b7aad5 100644 (file)
@@ -32,6 +32,7 @@ DECLARE_BONUS(touchofdeath, "Touch of Death!", 150)
 DECLARE_BONUS(swordreversebonus, "Sword Disarm!", 100)
 DECLARE_BONUS(staffreversebonus, "Staff Disarm!", 100)
 DECLARE_BONUS(reverseko, "Reversal KO!", 100)
+// The following five should be kept in that order
 DECLARE_BONUS(solidhit, "Solid Hit!", 10)
 DECLARE_BONUS(twoxcombo, "2X Combo!", 20)
 DECLARE_BONUS(threexcombo, "3X Combo!", 40)
index a6eba852ea039de0375dc6be403964593e5bbbdb..d3fb16a437fa51d09b89965e68e641c45bd17409 100644 (file)
@@ -357,22 +357,13 @@ bool Person::isWallJump(){
        else return 0;
 }
 
-void SolidHitBonus(){
-       if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
-         award_bonus(0, megacombo);
-       }
-       else if(bonustime<1.5&&bonus==threexcombo){
-         award_bonus(0, fourxcombo);
-       }
-       else if(bonustime<1.5&&bonus==twoxcombo){
-         award_bonus(0, threexcombo);
-       }
-       else if(bonustime<1.5&&bonus==solidhit){
-         award_bonus(0, twoxcombo);
-       }
-       else {
-         award_bonus(0, solidhit);
-       }
+static void
+SolidHitBonus(int playerid)
+{
+  if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo)
+    award_bonus(playerid, bonus == megacombo ? bonus : bonus + 1);
+  else
+    award_bonus(playerid, solidhit);
 }
 
 void Person::DoBlood(float howmuch,int which){
@@ -2295,9 +2286,7 @@ void      Person::DoAnimations(){
                                                                                victim->Puff(head);
                                                                                victim->DoDamage(damagemult*100/victim->protectionhead);
 
-                                                                               if(id==0){
-                                                                                       SolidHitBonus();
-                                                                               }
+                                                                               SolidHitBonus(id);
                                                                        }
                                                                }
 
@@ -2389,12 +2378,10 @@ void    Person::DoAnimations(){
                                                                                victim->Puff(head);
                                                                                victim->DoDamage(damagemult*150/victim->protectionhead);
 
-                                                                               if(victim->damage>victim->damagetolerance){
+                                                                               if(victim->damage>victim->damagetolerance)
                                                                                  award_bonus(id, style);
-                                                                               }
-                                                                               else if(id==0){
-                                                                                       SolidHitBonus();
-                                                                               }
+                                                                               else
+                                                                                 SolidHitBonus(id);
                                                                        }
                                                                }
 
@@ -2440,12 +2427,10 @@ void    Person::DoAnimations(){
                                                                                victim->Puff(head);
                                                                                victim->DoDamage(damagemult*150/victim->protectionhead);
 
-                                                                               if(victim->damage>victim->damagetolerance){
+                                                                               if(victim->damage>victim->damagetolerance)
                                                                                  award_bonus(id, style);
-                                                                               }
-                                                                               else if(id==0){
-                                                                                       SolidHitBonus();
-                                                                               }
+                                                                               else
+                                                                                 SolidHitBonus(id);
                                                                        }
                                                                }
 
@@ -2605,9 +2590,8 @@ void      Person::DoAnimations(){
                                                                                for(i=0;i<victim->skeleton.num_joints;i++){
                                                                                        victim->skeleton.joints[i].velocity+=relative*damagemult*20;
                                                                                }
-                                                                               if(id==0&&!victim->dead){
-                                                                                       SolidHitBonus();
-                                                                               }
+                                                                               if(!victim->dead)
+                                                                                 SolidHitBonus(id);
 
                                                                                victim->Puff(abdomen);
                                                                                victim->DoDamage(damagemult*20/victim->protectionhigh);
@@ -2885,9 +2869,7 @@ void      Person::DoAnimations(){
                                                                                victim->Puff(abdomen);
                                                                                victim->DoDamage(damagemult*60/victim->protectionhigh);
 
-                                                                               if(id==0){
-                                                                                       SolidHitBonus();
-                                                                               }
+                                                                               SolidHitBonus(id);
                                                                        }
                                                                }
 
@@ -2952,9 +2934,7 @@ void      Person::DoAnimations(){
                                                                                victim->Puff(abdomen);
                                                                                victim->DoDamage(damagemult*60/victim->protectionhigh);
 
-                                                                               if(id==0){
-                                                                                       SolidHitBonus();
-                                                                               }
+                                                                               SolidHitBonus(id);
                                                                        }
                                                                }
 
@@ -3396,9 +3376,7 @@ void      Person::DoAnimations(){
                                                                                relative.y=0;
                                                                                Normalise(&relative);
 
-                                                                               if(id==0){
-                                                                                       SolidHitBonus();
-                                                                               }
+                                                                               SolidHitBonus(id);
 
                                                                                if(animation[victim->targetanimation].height==lowheight){
                                                                                        if(Random()%2){
@@ -3523,9 +3501,7 @@ void      Person::DoAnimations(){
                                                                                        victim->DoDamage(damagemult*30/victim->protectionlow);
                                                                                }
 
-                                                                               if(id==0){
-                                                                                       SolidHitBonus();
-                                                                               }
+                                                                               SolidHitBonus(id);
 
                                                                        }
                                                                }
@@ -4485,7 +4461,7 @@ void      Person::DoAnimations(){
                                                                                //DoDamage(100);
                                                                                RagDoll(0);
                                                                                skeleton.spinny=0;
-                                                                               if(id!=0)SolidHitBonus();
+                                                                               SolidHitBonus(!id); // FIXME: tricky id
                                                                        }
                                                                        if(feint){
                                                                                escapednum++;
@@ -4508,7 +4484,7 @@ void      Person::DoAnimations(){
                                                                                //DoDamage(100);
                                                                                RagDoll(0);
                                                                                skeleton.spinny=0;
-                                                                               if(id!=0)SolidHitBonus();
+                                                                               SolidHitBonus(!id); // FIXME: tricky id
                                                                        }
                                                                        if(feint){
                                                                                escapednum++;