Beispiel #1
0
        public PlayerCharacter ApplyHungerPenalties(PlayerCharacter entity, NWPlayer pc)
        {
            int penalty = 0;

            if (entity.CurrentHunger >= 40 && entity.CurrentHunger <= 50)
            {
                pc.FloatingText("You are starving! You should eat soon.");
            }
            else if (entity.CurrentHunger >= 30 && entity.CurrentHunger < 40)
            {
                penalty = 1;
                pc.FloatingText("You are starving! You are suffering from starvation penalties.");
            }
            else if (entity.CurrentHunger >= 20 && entity.CurrentHunger < 30)
            {
                penalty = 2;
                pc.FloatingText("You are starving! You are suffering from starvation penalties.");
            }
            else if (entity.CurrentHunger >= 10 && entity.CurrentHunger < 20)
            {
                penalty = 3;
                pc.FloatingText("You are starving! You are suffering from starvation penalties.");
            }
            else if (entity.CurrentHunger < 10)
            {
                penalty = 4;
                pc.FloatingText(_color.Red("You are starving! You are about to starve to death!"));
            }

            var effects = pc.Effects;

            foreach (Effect effect in effects)
            {
                if (_.GetEffectTag(effect) == "EFFECT_HUNGER_PENALTIES")
                {
                    _.RemoveEffect(pc.Object, effect);
                }
            }

            if (penalty > 0)
            {
                Effect effect = _.EffectAbilityDecrease(ABILITY_STRENGTH, penalty);
                effect = _.EffectLinkEffects(effect, _.EffectAbilityDecrease(ABILITY_DEXTERITY, penalty));
                effect = _.EffectLinkEffects(effect, _.EffectAbilityDecrease(ABILITY_CONSTITUTION, penalty));

                effect = _.TagEffect(effect, "EFFECT_HUNGER_PENALTIES");
                _.ApplyEffectToObject(DURATION_TYPE_PERMANENT, effect, pc.Object);
            }

            if (entity.CurrentHunger <= 0)
            {
                _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectDeath(), pc.Object);
                entity.CurrentHunger = 20;
                pc.FloatingText("You starved to death!");
            }

            return(entity);
        }
Beispiel #2
0
        private void DeathFunction(NWPlayer oPC, int nDC)
        {
            if (!oPC.IsValid)
            {
                return;
            }
            int iHP = oPC.CurrentHP;

            //Player Rolls a random number between 1 and 20+ConMod
            int iRoll = 20 + oPC.ConstitutionModifier;

            iRoll = _random.Random(iRoll) + 1;

            //Sanity Check
            if (nDC > 30)
            {
                nDC = 30;
            }
            else if (nDC < 4)
            {
                nDC = 4;
            }

            if (iHP <= 0)
            {
                if (iRoll >= nDC) //Stabilize
                {
                    nDC -= 2;
                    _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(1), oPC.Object);
                    oPC.DelayCommand(() =>
                    {
                        DeathFunction(oPC, nDC);
                    }, 3.0f);
                }
                else  //Failed!
                {
                    if (_random.Random(2) + 1 == 1)
                    {
                        nDC++;
                    }
                    Effect eResult = _.EffectDamage(1);

                    //Death!
                    if (iHP <= -9)
                    {
                        _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_IMP_DEATH), oPC.Object);
                        _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectDeath(), oPC.Object);
                        return;
                    }
                    else
                    {
                        oPC.SendMessage(_color.Orange("You failed to stabilize this round."));
                    }
                    _.ApplyEffectToObject(DURATION_TYPE_INSTANT, eResult, oPC.Object);

                    oPC.DelayCommand(() =>
                    {
                        DeathFunction(oPC, nDC);
                    }, 3.0f);
                }
            }
        }