Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //========================================================================================================
- //Class
- //========================================================================================================
- public class PlayerData {
- public IPlayer player = null;
- public bool IsBleeding = false;
- public float LastHealth = 100f;
- public float BleedCounter = 0f;
- public PlayerData (IPlayer ply){
- this.player = ply;
- }
- }
- //========================================================================================================
- //Vars
- //========================================================================================================
- List<PlayerData> DataList = new List<PlayerData>();
- Random rnd = new Random();
- //========================================================================================================
- //Const
- //========================================================================================================
- const float MINDAMAGE = 2f; //Damage you need to take to have a chance to bleed
- const float MAXDAMAGE = 50f; //Damage that grant 100% of bleeding
- const float DAMAGEBLEEDING = 2f; // Damage per bleeding per tick
- const float BLEEDTIME = 6f; //Time needed to heal (*500ms)
- //========================================================================================================
- //methods
- //========================================================================================================
- public void OnStartup(){
- foreach (IPlayer ply in Game.GetPlayers()){
- DataList.Add(new PlayerData(ply));
- }
- Game.ShowPopupMessage("Bleeding mode activated\nCrouch to heal your wounds", new Color(0,100,150));
- IObjectTimerTrigger timerTriger = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
- timerTriger.SetIntervalTime(500);
- timerTriger.SetRepeatCount(0);
- timerTriger.SetScriptMethod("Script_BleedCheck");
- timerTriger.Trigger();
- }
- public void Script_BleedCheck(TriggerArgs args){
- foreach (PlayerData data in DataList){
- IPlayer ply = data.player;
- float health = ply.GetHealth();
- if (health < data.LastHealth - MINDAMAGE && !ply.IsBurning){
- float dmg = data.LastHealth - health - MINDAMAGE;
- if (!data.IsBleeding){
- data.IsBleeding = true;
- Game.PlayEffect("CFTXT",ply.GetWorldPosition(),"Bleeding !");
- data.BleedCounter = BLEEDTIME;
- }
- }
- else if (data.LastHealth < health){
- if (data.IsBleeding){
- data.IsBleeding = false;
- Game.PlayEffect("CFTXT",ply.GetWorldPosition(),"Healed !");
- }
- }
- if (data.IsBleeding && !ply.IsDead){
- if (ply.IsCrouching){
- data.BleedCounter -= 1f;
- if (data.BleedCounter < 0f){
- data.IsBleeding = false;
- Game.PlayEffect("CFTXT",ply.GetWorldPosition(),"Healed !");
- }
- }
- if (ply.IsBurning){
- data.IsBleeding = false;
- Game.PlayEffect("CFTXT",ply.GetWorldPosition(),"Cauterized !");
- }
- if (rnd.Next(5) == 0)
- for (int i = 5; i>0; i--)
- Game.PlayEffect("BLD",ply.GetWorldPosition()+ new Vector2(rnd.Next(-5,6),rnd.Next(-5,6)));
- ply.SetHealth(health - DAMAGEBLEEDING);
- if (health < DAMAGEBLEEDING) ply.Kill();
- }
- data.LastHealth = ply.GetHealth();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement