Advertisement
Guest User

Untitled

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