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); } } }); }
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); } }