Exemple #1
0
 protected void SetOnFire(bool onFire)
 {
     if (onFire && !IsDepleted)
     {
         //create the fire object
         GameObject newFireObject = gameObject.FindOrCreateChild("Fire").gameObject;
         FireObject        = newFireObject.AddComponent <Fire>();
         FireObject.Offset = FireObjectOffset;
         FireObject.FireScaleMultiplier = FireScaleMultiplier;
         FireObject.Type         = Type;
         FireObject.FuelSource   = this;
         FireObject.ThermalState = GooThermalState.Igniting;
         if (!string.IsNullOrEmpty(IgnitedState))
         {
             worlditem.State = IgnitedState;
         }
         OnIgnite.SafeInvoke();
         if (!State.HasCausedReputationPenalty)
         {
             if (WorldItems.IsOwnedBySomeoneOtherThanPlayer(worlditem, out mCheckOwner))
             {
                 //TODO tie reputation loss to item value
                 Profile.Get.CurrentGame.Character.Rep.LosePersonalReputation(mCheckOwner.worlditem.FileName, mCheckOwner.worlditem.DisplayName, 1);
                 State.HasCausedReputationPenalty = true;
             }
         }
         //if the player is carrying this item, we have to be dropped
         if (worlditem.Is(WIMode.Equipped))
         {
             Debug.Log("Force-carrying ignited item");
             Player.Local.ItemPlacement.ItemForceCarry(worlditem);
         }
     }
     else
     {
         //destroy the fire object
         if (FireObject != null)
         {
             FireObject.Extinguish();
             OnExtinguish.SafeInvoke();
         }
     }
 }
Exemple #2
0
        public virtual bool TakeDamage(WIMaterialType materialType, Vector3 damagePoint, float attemptedDamage, Vector3 attemptedForce, string sourceName, out float actualDamage, out bool isDead)
        {
            if (!mInitialized)
            {
                actualDamage = 0f;
                isDead       = false;
                return(false);
            }

            if (State.IsDead)
            {
                actualDamage = 0.0f;
                isDead       = true;
                worlditem.ApplyForce(attemptedForce, damagePoint);
                if (LastBodyPartHit != null)
                {
                    LastBodyPartHit.ForceOnConvertToRagdoll = attemptedForce;
                }
                return(false);
            }

            actualDamage = attemptedDamage;
            //this is where we apply body part modifiers and succeptibilities
            if (Flags.Check((uint)State.MaterialPenalties, (uint)materialType, Flags.CheckType.MatchAny))
            {
                actualDamage *= Globals.DamageMaterialBonusMultiplier;                //apply the bonus to this source
            }
            else if (Flags.Check((uint)State.MaterialBonuses, (uint)materialType, Flags.CheckType.MatchAny))
            {
                actualDamage *= Globals.DamageMaterialPenaltyMultiplier;                //apply the penalty to this source
            }

            if (State.SourcePenalties.Contains(sourceName))
            {
                actualDamage *= Globals.DamageMaterialBonusMultiplier;                //apply the bonus to this source
            }
            else if (State.SourceBonuses.Contains(sourceName))
            {
                actualDamage *= Globals.DamageMaterialPenaltyMultiplier;                //apply the penalty to this source
            }

            if (actualDamage > State.MinimumDamageThreshold)
            {
                //if we haven't taken a reputation penalty for damaging someone else's property
                //check and see if we're owned by someone else
                if (!State.HasCausedReputationPenalty)
                {
                    if (WorldItems.IsOwnedBySomeoneOtherThanPlayer(worlditem, out mCheckOwner))
                    {
                        //TODO tie reputation loss to item value
                        Profile.Get.CurrentGame.Character.Rep.LosePersonalReputation(mCheckOwner.worlditem.FileName, mCheckOwner.worlditem.DisplayName, 1);
                        State.HasCausedReputationPenalty = true;
                    }
                }

                State.LastDamagePoint    = damagePoint;
                State.LastDamageMaterial = materialType;
                State.LastDamageSource   = sourceName;
                State.LastDamageForce    = attemptedForce;

                State.LastDamageTaken = actualDamage;
                State.DamageTaken    += actualDamage;

                //see if the force exceeds our 'throw' threshold
                if (attemptedForce.magnitude > State.MinimumForceThreshold)
                {
                    if (ApplyForceAutomatically)
                    {
                        worlditem.ApplyForce(attemptedForce, damagePoint);
                    }
                    else
                    {
                        OnForceApplied.SafeInvoke();
                    }
                }
                if (LastBodyPartHit != null)
                {
                    LastBodyPartHit.ForceOnConvertToRagdoll = attemptedForce;
                }

                //now that we've set everything up, send the damage messages
                OnTakeDamage.SafeInvoke();

                if (actualDamage >= State.OverkillDamageThreshold)
                {
                    State.LastDamageTaken = actualDamage * State.OverkillDamageMultiplier;
                    State.DamageTaken    += actualDamage * State.OverkillDamageMultiplier;
                    OnTakeOverkillDamage.SafeInvoke();
                }
                else if (actualDamage >= State.CriticalDamageThreshold)
                {
                    State.LastDamageTaken = actualDamage * State.CriticalDamageMultiplier;
                    State.DamageTaken    += actualDamage * State.CriticalDamageMultiplier;
                    OnTakeCriticalDamage.SafeInvoke();
                }

                //now check to see if we're dead
                isDead = State.IsDead;

                if (isDead)
                {
                    OnDieResult();
                }
                return(true);
            }

            isDead = false;
            return(false);
        }