Advertisement
Guest User

Untitled

a guest
Jan 17th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.13 KB | None | 0 0
  1. public OnPlayerSpawn(playerid)
  2. {
  3.     SetPlayerHealth(playerid, 9999999);
  4.     SetPlayerTeam(playerid, 0);
  5.     return 1;
  6. }
  7.  
  8. forward SetPlayerHealthEx(playerid,Float:hp,reason = 0,Float:amount = 0.0);
  9. stock SetPlayerHealthEx(playerid,Float:hp,reason = 0,Float:amount = 0.0)
  10. {
  11.     new Float:oldhp = GetPlayerHealthEx(playerid);
  12.  
  13.     if(hp <= 0.0)
  14.     {
  15.         SetPlayerHealth(playerid,0);
  16.         hp = 0.0;
  17.     }
  18.  
  19.     if(reason != 18 && reason != 37)
  20.         hp = float(floatround(hp,floatround_floor));
  21.  
  22.     SetPVarFloat(playerid,"ScriptHealth",hp);
  23.     //insert here any hud function you have to update player HP
  24.     return 1;
  25. }
  26.  
  27. forward SetPlayerArmourEx(playerid,Float:armour,reason = 0);
  28. stock SetPlayerArmourEx(playerid,Float:armour,reason = 0)
  29. {
  30.         if(armour < 0.0)
  31.         armour = 0.0;
  32.  
  33.         if(reason != 18 && reason != 37)
  34.             armour = float(floatround(armour,floatround_floor));
  35.  
  36.     SetPlayerArmour(playerid,armour);
  37.     SetPVarFloat(playerid,"ScriptArmour",armour);
  38.     // insert here any hud function you have to update player's armor
  39.     return 1;
  40. }
  41.  
  42. forward Float:GetPlayerHealthEx(playerid);
  43. stock Float:GetPlayerHealthEx(playerid)
  44. {
  45.     return GetPVarFloat(playerid, "ScriptHealth");
  46. }
  47.  
  48. forward Float:GetPlayerArmourEx(playerid);
  49. stock Float:GetPlayerArmourEx(playerid)
  50. {
  51.     return GetPVarFloat(playerid, "ScriptArmour");
  52. }
  53.  
  54.  
  55. // function example taken from my TF2 (removed specific mode parts) Gamemode
  56. // This does not include armor calculations as armor is not in the GM but they are easily done
  57.  
  58. forward DamagePlayer(playerid, Float:amount, weaponid, Float:hp, Float:armour, issuerid);
  59. public DamagePlayer(playerid, Float:amount, weaponid, Float:hp, Float:armour, issuerid)
  60. {
  61.         //33% Less damage from explosions to Demos & Soldiers
  62.     //25% resistance for rockets to Soldiers
  63.     //66% Fall damage reduced for Scouts
  64.     //100% Fire damage reduced for Pyros
  65.     //100% damage resistance while round warmup
  66.     //10% fire resistance to medic
  67.  
  68.         //100% - amount
  69.     //toremove%  - x
  70.     //formula: (toremove * amount) / 100
  71.  
  72.     if(amount == 0.0)
  73.         return 1;
  74.  
  75.     if( (weaponid == 18 || weaponid == 37) && GetPlayerClassEx(playerid) == PYRO)
  76.         return 1; // This means fire damage wont affect you if you're a PYRO
  77.    
  78.     if(GetPVarInt(playerid,"OnSpawn") == 1 || GetPlayerTeamEx(playerid) == GetPlayerTeamEx(issuerid))
  79.             return 1; //ignore all damage if on spawn or same team
  80.         if(MissionInfo[Mission_Warming] != 999)
  81.             return 1; //ignore all damage if mission hasn't started
  82.        
  83.    
  84.     if(weaponid == 5 || weaponid == 8 || weaponid == 6 || weaponid == 2 || weaponid == 1)
  85.             amount = amount+40.0; //Melees damage +40
  86.     if(weaponid == 22) // Pistol
  87.             amount = amount-((50.0*amount)/100.0); //pistol damage reduced by 50%
  88.     if(weaponid == 24) // Deagle
  89.             amount = amount-((50.0*amount)/100.0); //deagle damage reduced by 50%
  90.     if(weaponid == 25) // Shotgun
  91.             amount = amount+((25.0*amount)/100.0); //shotgun damage increased 25%
  92.     if(weaponid == 38 && GetPlayerClassEx(issuerid) != MEDIC) // Minigun
  93.             amount = amount-((95.0*amount)/100.0); //minigun damage decreased 95%
  94.     if(weaponid == 35 || weaponid == 51) //RPG/Explosion
  95.             amount = amount+((20.0*amount)/100.0); //Explosions damage increased 20%
  96.     if(weaponid == 26) //Sawnoff
  97.             amount = amount-((5.0*amount)/100.0); // Sawnoff damage decreased 5%
  98.     if(weaponid == 34) //Sniper rifle
  99.             amount = amount+((110.0*amount)/100.0); //sniper damage increased 110%
  100.     if(weaponid == 23) //Silenced
  101.             amount = 35; // Silenced damage to 35hp
  102.     if(weaponid == 37) //Flame
  103.             amount =  amount+((5.0*amount)/100.0); // flame thrower initial damage +5%
  104.         if(weaponid == 18) //Mooltovs
  105.             amount =  amount-((90.0*amount)/100.0); // molotov damage -90%
  106.         if(weaponid == 31) //M4
  107.             amount =  amount+((25.0*amount)/100.0); //m4 damage +25%
  108.         if(weaponid == 42) //Fire ex
  109.             amount =  amount-((40.0*amount)/100.0); //fire ex damage -40%
  110.         if(weaponid == 8 && GetPlayerClassEx(issuerid) == DEMOMAN) //Demoman
  111.             amount =  amount*2; //Double damage for demoman & katana
  112.  
  113.         if( (weaponid == 18 || weaponid == 37) && GetPlayerClassEx(playerid) == MEDIC)
  114.             amount =  amount-((10.0*amount)/100.0); //10% Fire Resistance for medics
  115.         if( (weaponid == 51 || weaponid == 35 || weaponid == 16 || weaponid == 39))
  116.             if(GetPlayerClassEx(playerid) == SOLDIER || GetPlayerClassEx(playerid) == DEMOMAN)
  117.             amount =  amount-((66.0*amount)/100.0); //Blast Resistance for soldier & demoman
  118.         if( weaponid == 54 && GetPlayerClassEx(playerid) == SCOUT)
  119.             amount =  amount-((66.0*amount)/100.0); //-66% fall damage for scouts
  120.        
  121.  
  122.    
  123.     hp = hp-amount;
  124.         SetPlayerHealthEx(playerid, hp, weaponid, amount);
  125.     return 1;
  126. }
  127.  
  128.  
  129. // another damageplayer example without reductions but armour calculations
  130.  
  131. //playerid, amount of damage, weaponid of damage, current player HP, current player armor
  132. forward DamagePlayer(playerid, Float:amount, weaponid, Float:hp, Float:armour);
  133. public DamagePlayer(playerid, Float:amount, weaponid, Float:hp, Float:armour)
  134. {
  135.         if(weaponid == 41 || weaponid == 42) //spray
  136.         amount = amount-((25.0*amount)/100.0);
  137.  
  138.     if(weaponid != 54 && weaponid != 53)
  139.     {
  140.         if(armour > 0.0)
  141.         {
  142.                 new Float:tmp = armour;
  143.             tmp = tmp-amount;
  144.                 if(tmp < 0.0)
  145.                 {
  146.                     amount = amount - armour;
  147.                     armour = 0.0;
  148.             }
  149.             else
  150.             {
  151.                     armour = tmp;
  152.                     amount = 0;
  153.             }
  154.             if(armour > GetPlayerArmourEx(playerid))
  155.                 armour = 0.0;
  156.                    
  157.             SetPlayerArmourEx(playerid, armour,weaponid);
  158.         }
  159.         hp = (hp - amount);
  160.         if(hp > GetPlayerHealthEx(playerid))
  161.             hp = 0.0;
  162.                
  163.         SetPlayerHealthEx(playerid, hp, weaponid);
  164.     }
  165.     else
  166.     {
  167.         hp = (hp - amount);
  168.         if(hp > GetPlayerHealthEx(playerid))
  169.             hp = 0.0;
  170.             SetPlayerHealthEx(playerid, hp, weaponid);
  171.     }
  172.     return 1;
  173. }
  174.  
  175.  
  176. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  177. {
  178.     if(weaponid == 34)
  179.         if(bodypart == 9) //sniper headshoot 2.5x damage
  180.             amount = amount*2.5;
  181.                
  182.     DamagePlayer(playerid, amount, weaponid, GetPlayerHealthEx(playerid), GetPlayerArmourEx(playerid), issuerid);
  183.  
  184.     return 1;
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement