* For your fragging desire, damage enabled land works, but watch out!, life does not regenerate until you're dead!

0.6.0-stable
Teravus Ovares 2008-05-03 15:39:40 +00:00
parent 07167c9a3f
commit e8acb49fef
9 changed files with 173 additions and 5 deletions

View File

@ -259,6 +259,19 @@ namespace OpenSim.Framework.Communications
}
}
}
public string UUIDNameRequestString(LLUUID uuid)
{
UserProfileData profileData = m_userService.GetUserProfile(uuid);
if (profileData != null)
{
//LLUUID profileId = profileData.ID;
string firstname = profileData.FirstName;
string lastname = profileData.SurName;
return firstname + " " + lastname;
}
return "(hippos)";
}
public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
{

View File

@ -729,6 +729,7 @@ namespace OpenSim.Framework
uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID);
void SendScriptQuestion(LLUUID taskID, string taskName, string ownerName, LLUUID itemID, int question);
void SendHealth(float health);
byte[] GetThrottlesPacked(float multiplier);

View File

@ -4849,6 +4849,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(logReply, ThrottleOutPacketType.Task);
}
public void SendHealth(float health)
{
HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
healthpacket.HealthData.Health = health;
OutPacket(healthpacket, ThrottleOutPacketType.Task);
}
public ClientInfo GetClientInfo()
{

View File

@ -186,6 +186,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
scene.EventManager.OnClientClosed += ClientLoggedOut;
scene.EventManager.OnValidateLandBuy += ValidateLandBuy;
scene.EventManager.OnLandBuy += processLandBuy;
scene.EventManager.OnAvatarKilled += KillAvatar;
}
}
@ -1390,7 +1391,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
{
if (avatar.Scene.RegionInfo.originRegionID != m_rootAgents[avatar.UUID])
{
m_rootAgents[avatar.UUID] = avatar.Scene.RegionInfo.originRegionID;
//m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
// Claim User! my user! Mine mine mine!
if (m_MoneyAddress.Length > 0)
@ -1400,12 +1405,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
{
Hashtable hresult =
claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
if ((bool) hresult["success"] == true)
if ((bool)hresult["success"] == true)
{
int funds = 0;
try
{
funds = (Int32) hresult["funds"];
funds = (Int32)hresult["funds"];
}
catch (InvalidCastException)
{
@ -1414,11 +1419,23 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
}
else
{
avatar.ControllingClient.SendAgentAlertMessage((string) hresult["errorMessage"], true);
avatar.ControllingClient.SendAgentAlertMessage((string)hresult["errorMessage"], true);
}
}
}
}
else
{
ILandObject obj = avatar.Scene.LandChannel.getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
if ((obj.landData.landFlags & (uint)Parcel.ParcelFlags.AllowDamage) != 0)
{
avatar.Invulnerable = false;
}
else
{
avatar.Invulnerable = true;
}
}
}
else
{
@ -1457,6 +1474,60 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
//m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
}
private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar)
{
if (killerObjectLocalID == 0)
DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true);
else
{
bool foundResult = false;
string resultstring = "";
List<ScenePresence> allav = DeadAvatar.Scene.GetScenePresences();
try
{
foreach (ScenePresence av in allav)
{
if (av.LocalId == killerObjectLocalID)
{
av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname);
resultstring = av.Firstname + " " + av.Lastname;
foundResult = true;
}
}
} catch (System.InvalidOperationException)
{
}
if (!foundResult)
{
SceneObjectPart part = DeadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID);
if (part != null)
{
ScenePresence av = DeadAvatar.Scene.GetScenePresence(part.OwnerID);
if (av != null)
{
av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname);
resultstring = av.Firstname + " " + av.Lastname;
DeadAvatar.ControllingClient.SendAgentAlertMessage("You got killed by " + resultstring + "!", true);
}
else
{
string killer = DeadAvatar.Scene.CommsManager.UUIDNameRequestString(part.OwnerID);
DeadAvatar.ControllingClient.SendAgentAlertMessage("You impailed yourself on " + part.Name + " owned by " + killer +"!", true);
}
//DeadAvatar.Scene. part.ObjectOwner
}
else
{
DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true);
}
}
}
DeadAvatar.Health = 100;
DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient);
}
#endregion
}

View File

@ -336,6 +336,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{
if (over.landData.localID == landData.localID)
{
if ((over.landData.landFlags & (uint)Parcel.ParcelFlags.AllowDamage) != 0)
avatars[i].Invulnerable = false;
else
avatars[i].Invulnerable = true;
sendLandUpdateToClient(avatars[i].ControllingClient);
}
}

View File

@ -151,6 +151,10 @@ namespace OpenSim.Region.Environment.Scenes
public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete;
public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar);
public event AvatarKillData OnAvatarKilled;
/// <summary>
/// RegisterCapsEvent is called by Scene after the Caps object
/// has been instantiated and before it is return to the
@ -267,6 +271,7 @@ namespace OpenSim.Region.Environment.Scenes
private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null;
private LandBuy handlerLandBuy = null;
private LandBuy handlerValidateLandBuy = null;
private AvatarKillData handlerAvatarKill = null;
public void TriggerOnScriptChangedEvent(uint localID, uint change)
{
@ -574,5 +579,13 @@ namespace OpenSim.Region.Environment.Scenes
handlerScriptNotAtTargetEvent(localID);
}
}
public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar)
{
handlerAvatarKill = OnAvatarKilled;
if (handlerAvatarKill != null)
{
handlerAvatarKill(KillerObjectLocalID, DeadAvatar);
}
}
}
}

View File

@ -67,6 +67,9 @@ namespace OpenSim.Region.Environment.Scenes
private LLVector3 m_requestedSitOffset = new LLVector3();
private float m_sitAvatarHeight = 2.0f;
private float m_godlevel = 0;
private bool m_invulnerable = true;
private LLVector3 m_LastChildAgentUpdatePosition = new LLVector3();
private int m_perfMonMS = 0;
@ -83,6 +86,7 @@ namespace OpenSim.Region.Environment.Scenes
private bool m_newForce = false;
private bool m_newCoarseLocations = true;
private bool m_gotAllObjectsInScene = false;
private float m_health = 100f;
private LLVector3 m_lastVelocity = LLVector3.Zero;
@ -183,6 +187,11 @@ namespace OpenSim.Region.Environment.Scenes
set { m_updateflag = value; }
get { return m_updateflag; }
}
public bool Invulnerable
{
set { m_invulnerable = value; }
get { return m_invulnerable; }
}
private readonly ulong m_regionHandle;
@ -334,6 +343,11 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_parentID; }
set { m_parentID = value; }
}
public float Health
{
get { return m_health; }
set { m_health = value; }
}
/// <summary>
/// These are the region handles known by the avatar.
@ -602,6 +616,7 @@ namespace OpenSim.Region.Environment.Scenes
{
m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients;
m_physicsActor.UnSubscribeEvents();
m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate;
PhysicsActor = null;
}
@ -1894,16 +1909,55 @@ namespace OpenSim.Region.Environment.Scenes
}
//m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
m_physicsActor.SubscribeEvents(1000);
m_physicsActor.LocalID = LocalId;
}
// Event called by the physics plugin to tell the avatar about a collision.
private void PhysicsCollisionUpdate(EventArgs e)
{
if (e == null)
return;
CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
Dictionary<uint, float> coldata = collisionData.m_objCollisionList;
float starthealth = Health;
uint killerObj = 0;
foreach (uint localid in coldata.Keys)
{
if (coldata[localid] <= 0.10f || m_invulnerable)
continue;
//if (localid == 0)
//continue;
Health -= coldata[localid] * 5;
if (Health <= 0)
{
if (localid != 0)
killerObj = localid;
}
//m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString());
}
//Health = 100;
if (!m_invulnerable)
{
if (starthealth != Health)
{
ControllingClient.SendHealth(Health);
}
if (m_health <= 0)
m_scene.EventManager.TriggerAvatarKill(killerObj, this);
}
bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0;
UpdateMovementAnimations(isUserMoving);
}
public void setHealthWithUpdate(float health)
{
Health = health;
ControllingClient.SendHealth(Health);
}
internal void Close()
{
lock (m_attachments)

View File

@ -615,5 +615,8 @@ namespace OpenSim.Region.Examples.SimpleModule
public void SendScriptQuestion(LLUUID objectID, string taskName, string ownerName, LLUUID itemID, int question)
{
}
public void SendHealth(float health)
{
}
}
}

View File

@ -113,7 +113,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public bool collidelock = false;
public int m_eventsubscription = 0;
private CollisionEventUpdate CollisionEventsThisFrame = null;
private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size)
{
@ -869,9 +869,11 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void SubscribeEvents(int ms)
{
m_eventsubscription = ms;
_parent_scene.addCollisionEventReporting(this);
}
public override void UnSubscribeEvents()
{
_parent_scene.remCollisionEventReporting(this);
m_eventsubscription = 0;
}
public void AddCollisionEvent(uint CollidedWith, float depth)