예제 #1
0
            public void IncurHealing(double healing, UUID OwnerID)
            {
                if (healing < 0)
                {
                    return;
                }
                IScenePresence SP = m_SP.Scene.GetScenePresence(OwnerID);

                if (SP == null)
                {
                    return;
                }
                ICombatPresence cp = SP.RequestModuleInterface <ICombatPresence>();

                if (!cp.HasLeftCombat || !m_combatModule.ForceRequireCombatPermission)
                {
                    float health = Health;
                    health += (float)healing;
                    if (health >= MaximumHealth)
                    {
                        health = MaximumHealth;
                    }

                    m_SP.ControllingClient.SendHealth(health);
                }
            }
예제 #2
0
        void AvatarEnteringParcel(IScenePresence avatar, ILandObject oldParcel)
        {
            ILandObject             obj = null;
            IParcelManagementModule parcelManagement = avatar.Scene.RequestModuleInterface <IParcelManagementModule> ();

            if (parcelManagement != null)
            {
                obj = parcelManagement.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
            }
            if (obj == null)
            {
                return;
            }

            try {
                if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0)
                {
                    ICombatPresence CP = avatar.RequestModuleInterface <ICombatPresence> ();
                    CP.Health           = MaximumHealth;
                    avatar.Invulnerable = false;
                }
                else
                {
                    avatar.Invulnerable = true;
                }
            } catch (Exception) {
            }
        }
예제 #3
0
            public void IncurDamage(uint localID, double damage, UUID OwnerID)
            {
                if (damage < 0)
                {
                    return;
                }

                IScenePresence SP = m_SP.Scene.GetScenePresence(OwnerID);

                if (SP == null)
                {
                    return;
                }
                ICombatPresence cp = SP.RequestModuleInterface <ICombatPresence>();

                if (!cp.HasLeftCombat || !m_combatModule.ForceRequireCombatPermission)
                {
                    if (damage > MaximumDamageToInflict)
                    {
                        damage = MaximumDamageToInflict;
                    }
                    float health = Health;
                    health -= (float)damage;
                    m_SP.ControllingClient.SendHealth(health);
                    if (health <= 0)
                    {
                        KillAvatar(localID, true);
                    }
                }
            }
예제 #4
0
        public void aaJoinCombatTeam(LSL_Key uuid, LSL_String team)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "AAJoinCombatTeam", m_host, "AA", m_itemID))
            {
                return;
            }
            UUID avID;

            if (UUID.TryParse(uuid, out avID))
            {
                IScenePresence SP = World.GetScenePresence(avID);
                if (SP != null)
                {
                    ICombatPresence CP = SP.RequestModuleInterface <ICombatPresence>();
                    if (CP != null)
                    {
                        if (team.m_string == "No Team")
                        {
                            SP.ControllingClient.SendAlertMessage("You cannot join this team.");
                            return;
                        }
                        CP.Team = team.m_string;
                    }
                }
            }
        }
예제 #5
0
        public void aaSetCharacterStat(string UUIDofAv, string StatName, float statValue)
        {
            ScriptProtection.CheckThreatLevel(ThreatLevel.None, "AASetCharacterStat", m_host, "AA");
            UUID           avatarId = new UUID(UUIDofAv);
            IScenePresence presence = World.GetScenePresence(avatarId);

            if (presence != null)
            {
                ICombatPresence cp = presence.RequestModuleInterface <ICombatPresence>();
                cp.SetStat(StatName, statValue);
            }
        }
예제 #6
0
        public LSL_Float aaGetHealth(LSL_Key uuid)
        {
            ScriptProtection.CheckThreatLevel(ThreatLevel.None, "AAGetHealth", m_host, "AA");
            UUID avID;

            if (UUID.TryParse(uuid, out avID))
            {
                IScenePresence SP = World.GetScenePresence(avID);
                if (SP != null)
                {
                    ICombatPresence cp = SP.RequestModuleInterface <ICombatPresence>();
                    return(new LSL_Float(cp.Health));
                }
            }
            return(new LSL_Float(-1));
        }
예제 #7
0
 public void botCauseDamage(string sBotName, float fdamage)
 {
     m_host.ParentEntity.Scene.ForEachScenePresence(delegate(IScenePresence sp)
     {
         // this should be the correct bot by name
         if (sp.Name == sBotName)
         {
             ICombatPresence cp = sp.RequestModuleInterface <ICombatPresence>();
             if (cp.Health > 0)
             {
                 cp.Health = cp.Health - fdamage;
                 cp.IncurDamage(1, fdamage, sp.UUID);
             }
         }
     });
 }
예제 #8
0
        public void aaJoinCombat(LSL_Key uuid)
        {
            ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "AAJoinCombat", m_host, "AA");
            UUID avID;

            if (UUID.TryParse(uuid, out avID))
            {
                IScenePresence SP = World.GetScenePresence(avID);
                if (SP != null)
                {
                    ICombatPresence CP = SP.RequestModuleInterface <ICombatPresence>();
                    if (CP != null)
                    {
                        CP.JoinCombat();
                    }
                }
            }
        }
예제 #9
0
        public LSL_String aaGetTeam(LSL_Key uuid)
        {
            UUID avID;

            if (UUID.TryParse(uuid, out avID))
            {
                ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "AAGetTeam", m_host, "AA");
                IScenePresence SP = World.GetScenePresence(avID);
                if (SP != null)
                {
                    ICombatPresence CP = SP.RequestModuleInterface <ICombatPresence>();
                    if (CP != null)
                    {
                        return(CP.Team);
                    }
                }
            }
            return("No Team");
        }
예제 #10
0
            public void IncurDamage(uint localID, double damage, string RegionName, Vector3 pos, Vector3 lookat, UUID OwnerID)
            {
                if (damage < 0)
                {
                    return;
                }

                IScenePresence SP = m_SP.Scene.GetScenePresence(OwnerID);

                if (SP == null)
                {
                    return;
                }
                ICombatPresence cp = SP.RequestModuleInterface <ICombatPresence>();

                if (!cp.HasLeftCombat || !m_combatModule.ForceRequireCombatPermission)
                {
                    if (damage > MaximumDamageToInflict)
                    {
                        damage = MaximumDamageToInflict;
                    }
                    float health = Health;
                    health -= (float)damage;
                    m_SP.ControllingClient.SendHealth(health);
                    if (health <= 0)
                    {
                        KillAvatar(localID, false);
                        m_SP.ControllingClient.SendTeleportStart((uint)TeleportFlags.ViaHome);
                        IEntityTransferModule entityTransfer = m_SP.Scene.RequestModuleInterface <IEntityTransferModule>();
                        if (entityTransfer != null)
                        {
                            entityTransfer.RequestTeleportLocation(m_SP.ControllingClient, RegionName, pos, lookat, (uint)TeleportFlags.ViaHome);
                        }
                    }
                }
            }
예제 #11
0
            public void PhysicsActor_OnCollisionUpdate(EventArgs e)
            {
                if (m_SP == null || m_SP.Scene == null || m_SP.Invulnerable || HasLeftCombat || e == null)
                {
                    return;
                }

                CollisionEventUpdate            collisionData = (CollisionEventUpdate)e;
                Dictionary <uint, ContactPoint> coldata       = collisionData.GetCollisionEvents();

                float          starthealth   = Health;
                IScenePresence killingAvatar = null;

                foreach (uint localid in coldata.Keys)
                {
                    ISceneChildEntity part        = m_SP.Scene.GetSceneObjectPart(localid);
                    IScenePresence    otherAvatar = null;
                    if (part != null && part.ParentEntity.Damage > 0)
                    {
                        otherAvatar = m_SP.Scene.GetScenePresence(part.OwnerID);
                        ICombatPresence OtherAvatarCP = otherAvatar == null
                                                            ? null
                                                            : otherAvatar.RequestModuleInterface <ICombatPresence> ();
                        if (OtherAvatarCP != null && OtherAvatarCP.HasLeftCombat)
                        {
                            // If the avatar is null, the person is not inworld, and not on a team
                            //If they have left combat, do not let them cause any damage.
                            continue;
                        }

                        //Check max damage to inflict
                        if (part.ParentEntity.Damage > m_combatModule.MaximumDamageToInflict)
                        {
                            part.ParentEntity.Damage = m_combatModule.MaximumDamageToInflict;
                        }

                        // If the avatar is null, the person is not inworld, and not on a team
                        if (m_combatModule.AllowTeams && OtherAvatarCP != null && otherAvatar.UUID != m_SP.UUID &&
                            OtherAvatarCP.Team == Team)
                        {
                            float Hits = 0;
                            if (!TeamHits.TryGetValue(otherAvatar.UUID, out Hits))
                            {
                                Hits = 0;
                            }
                            Hits++;
                            if (m_combatModule.SendTeamKillerInfo && Hits == m_combatModule.TeamHitsBeforeSend)
                            {
                                otherAvatar.ControllingClient.SendAlertMessage("You have shot too many teammates and " +
                                                                               m_combatModule.DamageToTeamKillers +
                                                                               " health has been taken from you!");
                                OtherAvatarCP.IncurDamage(null, m_combatModule.DamageToTeamKillers);
                                Hits = 0;
                            }
                            TeamHits [otherAvatar.UUID] = Hits;

                            if (m_combatModule.AllowTeamKilling) //Green light on team killing
                            {
                                Health -= part.ParentEntity.Damage;
                            }
                        }
                        else   //Object, hit em
                        {
                            Health -= part.ParentEntity.Damage;
                        }
                    }
                    else
                    {
                        float Z = m_SP.Velocity.Length();
                        if (coldata [localid].PenetrationDepth >= 0.05f && m_SP.Velocity.Z < -3 &&
                            !m_SP.PhysicsActor.Flying && !m_SP.PhysicsActor.IsJumping)
                        {
                            Z = Math.Max(Z, 1.5f) * 10;
                            float damage = Math.Min(coldata [localid].PenetrationDepth, 15f);
                            Health -= damage * Z;
                        }
                    }

                    if (Health > m_combatModule.MaximumHealth)
                    {
                        Health = m_combatModule.MaximumHealth;
                    }

                    if (Health <= 0 && killingAvatar == null)
                    {
                        killingAvatar = otherAvatar;
                    }
                    //MainConsole.Instance.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString());
                }

                if (starthealth != Health)
                {
                    m_SP.ControllingClient.SendHealth(Health);
                }

                if (Health <= 0)
                {
                    KillAvatar(killingAvatar, "You killed " + m_SP.Name, "You died!", true, true);
                }
            }
예제 #12
0
            public void PhysicsActor_OnCollisionUpdate(EventArgs e)
            {
                if (m_SP == null || m_SP.Invulnerable)
                {
                    return;
                }

                if (HasLeftCombat)
                {
                    return;
                }

                if (e == null)
                {
                    return;
                }

                CollisionEventUpdate            collisionData = (CollisionEventUpdate)e;
                Dictionary <uint, ContactPoint> coldata       = collisionData.m_objCollisionList;

                float starthealth = Health;
                uint  killerObj   = 0;

                foreach (uint localid in coldata.Keys)
                {
                    ISceneChildEntity part = m_SP.Scene.GetSceneObjectPart(localid);
                    if (part != null)
                    {
                        if (part.ParentEntity.Damage != -1.0f)
                        {
                            continue;
                        }
                        IScenePresence otherAvatar = m_SP.Scene.GetScenePresence(part.OwnerID);
                        if (otherAvatar != null) // If the avatar is null, the person is not inworld, and not on a team
                        {
                            if (otherAvatar.RequestModuleInterface <ICombatPresence>().HasLeftCombat)
                            {
                                //If they have left combat, do not let them cause any damage.
                                continue;
                            }
                        }
                        if (part.ParentEntity.Damage > MaximumDamageToInflict)
                        {
                            part.ParentEntity.Damage = MaximumDamageToInflict;
                        }

                        if (AllowTeams)
                        {
                            if (otherAvatar != null) // If the avatar is null, the person is not inworld, and not on a team
                            {
                                ICombatPresence OtherAvatarCP = otherAvatar.RequestModuleInterface <ICombatPresence>();
                                if (OtherAvatarCP.Team == Team)
                                {
                                    float Hits = 0;
                                    if (!TeamHits.TryGetValue(otherAvatar.UUID, out Hits))
                                    {
                                        Hits = 0;
                                    }
                                    Hits++;
                                    if (SendTeamKillerInfo && Hits == TeamHitsBeforeSend)
                                    {
                                        otherAvatar.ControllingClient.SendAlertMessage("You have shot too many teammates and " + DamageToTeamKillers + " health has been taken from you!");
                                        OtherAvatarCP.Health -= DamageToTeamKillers;
                                        otherAvatar.ControllingClient.SendHealth(OtherAvatarCP.Health);
                                        if (OtherAvatarCP.Health <= 0)
                                        {
                                            KillAvatar(otherAvatar.LocalId, true);
                                        }
                                        Hits = 0;
                                    }
                                    TeamHits[otherAvatar.UUID] = Hits;

                                    if (AllowTeamKilling) //Green light on team killing
                                    {
                                        Health -= part.ParentEntity.Damage;
                                    }
                                }
                                else //Object, hit em
                                {
                                    Health -= part.ParentEntity.Damage;
                                }
                            }
                            else //Other team, hit em
                            {
                                Health -= part.ParentEntity.Damage;
                            }
                        }
                        else //Free for all, hit em
                        {
                            Health -= part.ParentEntity.Damage;
                        }
                    }
                    else
                    {
                        float Z = m_SP.Velocity.Length() / 20;
                        if (coldata[localid].PenetrationDepth >= 0.05f && Math.Abs(m_SP.Velocity.X) < 1 && Math.Abs(m_SP.Velocity.Y) < 1)
                        {
                            Z = Math.Min(Z, 1.5f);
                            float damage = Math.Min(coldata[localid].PenetrationDepth, 15f);
                            Health -= damage * Z;
                        }
                    }

                    if (Health > m_combatModule.MaximumHealth)
                    {
                        Health = m_combatModule.MaximumHealth;
                    }

                    if (Health <= 0.0f)
                    {
                        if (localid != 0)
                        {
                            killerObj = localid;
                        }
                    }
                    //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString());
                }

                if (starthealth != Health)
                {
                    m_SP.ControllingClient.SendHealth(Health);
                }
                if (Health <= 0)
                {
                    KillAvatar(killerObj, true);
                }
            }