diff options
author | Teravus Ovares | 2008-05-03 15:39:40 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-03 15:39:40 +0000 |
commit | e8acb49fefc0e567510b4058b6571599a0158b62 (patch) | |
tree | d87243f8d596b6df07db190ba30bf2da4d608c18 /OpenSim/Region | |
parent | * Committing some collision stuffs that I'm working on. (diff) | |
download | opensim-SC-e8acb49fefc0e567510b4058b6571599a0158b62.zip opensim-SC-e8acb49fefc0e567510b4058b6571599a0158b62.tar.gz opensim-SC-e8acb49fefc0e567510b4058b6571599a0158b62.tar.bz2 opensim-SC-e8acb49fefc0e567510b4058b6571599a0158b62.tar.xz |
* For your fragging desire, damage enabled land works, but watch out!, life does not regenerate until you're dead!
Diffstat (limited to '')
7 files changed, 159 insertions, 5 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 9d77a14..c890b31 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -4849,6 +4849,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4849 | 4849 | ||
4850 | OutPacket(logReply, ThrottleOutPacketType.Task); | 4850 | OutPacket(logReply, ThrottleOutPacketType.Task); |
4851 | } | 4851 | } |
4852 | public void SendHealth(float health) | ||
4853 | { | ||
4854 | HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage); | ||
4855 | healthpacket.HealthData.Health = health; | ||
4856 | OutPacket(healthpacket, ThrottleOutPacketType.Task); | ||
4857 | } | ||
4852 | 4858 | ||
4853 | public ClientInfo GetClientInfo() | 4859 | public ClientInfo GetClientInfo() |
4854 | { | 4860 | { |
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs index 966c5e2..aa7e690 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs | |||
@@ -186,6 +186,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney | |||
186 | scene.EventManager.OnClientClosed += ClientLoggedOut; | 186 | scene.EventManager.OnClientClosed += ClientLoggedOut; |
187 | scene.EventManager.OnValidateLandBuy += ValidateLandBuy; | 187 | scene.EventManager.OnValidateLandBuy += ValidateLandBuy; |
188 | scene.EventManager.OnLandBuy += processLandBuy; | 188 | scene.EventManager.OnLandBuy += processLandBuy; |
189 | scene.EventManager.OnAvatarKilled += KillAvatar; | ||
189 | } | 190 | } |
190 | } | 191 | } |
191 | 192 | ||
@@ -1390,7 +1391,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney | |||
1390 | { | 1391 | { |
1391 | if (avatar.Scene.RegionInfo.originRegionID != m_rootAgents[avatar.UUID]) | 1392 | if (avatar.Scene.RegionInfo.originRegionID != m_rootAgents[avatar.UUID]) |
1392 | { | 1393 | { |
1394 | |||
1395 | |||
1393 | m_rootAgents[avatar.UUID] = avatar.Scene.RegionInfo.originRegionID; | 1396 | m_rootAgents[avatar.UUID] = avatar.Scene.RegionInfo.originRegionID; |
1397 | |||
1398 | |||
1394 | //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + "."); | 1399 | //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + "."); |
1395 | // Claim User! my user! Mine mine mine! | 1400 | // Claim User! my user! Mine mine mine! |
1396 | if (m_MoneyAddress.Length > 0) | 1401 | if (m_MoneyAddress.Length > 0) |
@@ -1400,12 +1405,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney | |||
1400 | { | 1405 | { |
1401 | Hashtable hresult = | 1406 | Hashtable hresult = |
1402 | claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret); | 1407 | claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret); |
1403 | if ((bool) hresult["success"] == true) | 1408 | if ((bool)hresult["success"] == true) |
1404 | { | 1409 | { |
1405 | int funds = 0; | 1410 | int funds = 0; |
1406 | try | 1411 | try |
1407 | { | 1412 | { |
1408 | funds = (Int32) hresult["funds"]; | 1413 | funds = (Int32)hresult["funds"]; |
1409 | } | 1414 | } |
1410 | catch (InvalidCastException) | 1415 | catch (InvalidCastException) |
1411 | { | 1416 | { |
@@ -1414,11 +1419,23 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney | |||
1414 | } | 1419 | } |
1415 | else | 1420 | else |
1416 | { | 1421 | { |
1417 | avatar.ControllingClient.SendAgentAlertMessage((string) hresult["errorMessage"], true); | 1422 | avatar.ControllingClient.SendAgentAlertMessage((string)hresult["errorMessage"], true); |
1418 | } | 1423 | } |
1419 | } | 1424 | } |
1420 | } | 1425 | } |
1421 | } | 1426 | } |
1427 | else | ||
1428 | { | ||
1429 | ILandObject obj = avatar.Scene.LandChannel.getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
1430 | if ((obj.landData.landFlags & (uint)Parcel.ParcelFlags.AllowDamage) != 0) | ||
1431 | { | ||
1432 | avatar.Invulnerable = false; | ||
1433 | } | ||
1434 | else | ||
1435 | { | ||
1436 | avatar.Invulnerable = true; | ||
1437 | } | ||
1438 | } | ||
1422 | } | 1439 | } |
1423 | else | 1440 | else |
1424 | { | 1441 | { |
@@ -1457,6 +1474,60 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney | |||
1457 | //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); | 1474 | //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); |
1458 | } | 1475 | } |
1459 | 1476 | ||
1477 | private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar) | ||
1478 | { | ||
1479 | if (killerObjectLocalID == 0) | ||
1480 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true); | ||
1481 | else | ||
1482 | { | ||
1483 | bool foundResult = false; | ||
1484 | string resultstring = ""; | ||
1485 | List<ScenePresence> allav = DeadAvatar.Scene.GetScenePresences(); | ||
1486 | try | ||
1487 | { | ||
1488 | foreach (ScenePresence av in allav) | ||
1489 | { | ||
1490 | if (av.LocalId == killerObjectLocalID) | ||
1491 | { | ||
1492 | av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); | ||
1493 | resultstring = av.Firstname + " " + av.Lastname; | ||
1494 | foundResult = true; | ||
1495 | } | ||
1496 | } | ||
1497 | } catch (System.InvalidOperationException) | ||
1498 | { | ||
1499 | |||
1500 | } | ||
1501 | |||
1502 | if (!foundResult) | ||
1503 | { | ||
1504 | SceneObjectPart part = DeadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID); | ||
1505 | if (part != null) | ||
1506 | { | ||
1507 | ScenePresence av = DeadAvatar.Scene.GetScenePresence(part.OwnerID); | ||
1508 | if (av != null) | ||
1509 | { | ||
1510 | av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); | ||
1511 | resultstring = av.Firstname + " " + av.Lastname; | ||
1512 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You got killed by " + resultstring + "!", true); | ||
1513 | } | ||
1514 | else | ||
1515 | { | ||
1516 | string killer = DeadAvatar.Scene.CommsManager.UUIDNameRequestString(part.OwnerID); | ||
1517 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You impailed yourself on " + part.Name + " owned by " + killer +"!", true); | ||
1518 | } | ||
1519 | //DeadAvatar.Scene. part.ObjectOwner | ||
1520 | } | ||
1521 | else | ||
1522 | { | ||
1523 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true); | ||
1524 | } | ||
1525 | } | ||
1526 | } | ||
1527 | DeadAvatar.Health = 100; | ||
1528 | DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient); | ||
1529 | } | ||
1530 | |||
1460 | #endregion | 1531 | #endregion |
1461 | } | 1532 | } |
1462 | 1533 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs index e297b10..628ea04 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs | |||
@@ -336,6 +336,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
336 | { | 336 | { |
337 | if (over.landData.localID == landData.localID) | 337 | if (over.landData.localID == landData.localID) |
338 | { | 338 | { |
339 | if ((over.landData.landFlags & (uint)Parcel.ParcelFlags.AllowDamage) != 0) | ||
340 | avatars[i].Invulnerable = false; | ||
341 | else | ||
342 | avatars[i].Invulnerable = true; | ||
343 | |||
339 | sendLandUpdateToClient(avatars[i].ControllingClient); | 344 | sendLandUpdateToClient(avatars[i].ControllingClient); |
340 | } | 345 | } |
341 | } | 346 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 002fc5d..53a8d0f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs | |||
@@ -151,6 +151,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
151 | 151 | ||
152 | public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete; | 152 | public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete; |
153 | 153 | ||
154 | public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar); | ||
155 | |||
156 | public event AvatarKillData OnAvatarKilled; | ||
157 | |||
154 | /// <summary> | 158 | /// <summary> |
155 | /// RegisterCapsEvent is called by Scene after the Caps object | 159 | /// RegisterCapsEvent is called by Scene after the Caps object |
156 | /// has been instantiated and before it is return to the | 160 | /// has been instantiated and before it is return to the |
@@ -267,6 +271,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
267 | private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null; | 271 | private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null; |
268 | private LandBuy handlerLandBuy = null; | 272 | private LandBuy handlerLandBuy = null; |
269 | private LandBuy handlerValidateLandBuy = null; | 273 | private LandBuy handlerValidateLandBuy = null; |
274 | private AvatarKillData handlerAvatarKill = null; | ||
270 | 275 | ||
271 | public void TriggerOnScriptChangedEvent(uint localID, uint change) | 276 | public void TriggerOnScriptChangedEvent(uint localID, uint change) |
272 | { | 277 | { |
@@ -574,5 +579,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
574 | handlerScriptNotAtTargetEvent(localID); | 579 | handlerScriptNotAtTargetEvent(localID); |
575 | } | 580 | } |
576 | } | 581 | } |
582 | public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar) | ||
583 | { | ||
584 | handlerAvatarKill = OnAvatarKilled; | ||
585 | if (handlerAvatarKill != null) | ||
586 | { | ||
587 | handlerAvatarKill(KillerObjectLocalID, DeadAvatar); | ||
588 | } | ||
589 | } | ||
577 | } | 590 | } |
578 | } | 591 | } |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 6a50336..453c18f 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -67,6 +67,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
67 | private LLVector3 m_requestedSitOffset = new LLVector3(); | 67 | private LLVector3 m_requestedSitOffset = new LLVector3(); |
68 | private float m_sitAvatarHeight = 2.0f; | 68 | private float m_sitAvatarHeight = 2.0f; |
69 | private float m_godlevel = 0; | 69 | private float m_godlevel = 0; |
70 | |||
71 | private bool m_invulnerable = true; | ||
72 | |||
70 | private LLVector3 m_LastChildAgentUpdatePosition = new LLVector3(); | 73 | private LLVector3 m_LastChildAgentUpdatePosition = new LLVector3(); |
71 | 74 | ||
72 | private int m_perfMonMS = 0; | 75 | private int m_perfMonMS = 0; |
@@ -83,6 +86,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
83 | private bool m_newForce = false; | 86 | private bool m_newForce = false; |
84 | private bool m_newCoarseLocations = true; | 87 | private bool m_newCoarseLocations = true; |
85 | private bool m_gotAllObjectsInScene = false; | 88 | private bool m_gotAllObjectsInScene = false; |
89 | private float m_health = 100f; | ||
86 | 90 | ||
87 | private LLVector3 m_lastVelocity = LLVector3.Zero; | 91 | private LLVector3 m_lastVelocity = LLVector3.Zero; |
88 | 92 | ||
@@ -183,6 +187,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
183 | set { m_updateflag = value; } | 187 | set { m_updateflag = value; } |
184 | get { return m_updateflag; } | 188 | get { return m_updateflag; } |
185 | } | 189 | } |
190 | public bool Invulnerable | ||
191 | { | ||
192 | set { m_invulnerable = value; } | ||
193 | get { return m_invulnerable; } | ||
194 | } | ||
186 | 195 | ||
187 | private readonly ulong m_regionHandle; | 196 | private readonly ulong m_regionHandle; |
188 | 197 | ||
@@ -334,6 +343,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
334 | get { return m_parentID; } | 343 | get { return m_parentID; } |
335 | set { m_parentID = value; } | 344 | set { m_parentID = value; } |
336 | } | 345 | } |
346 | public float Health | ||
347 | { | ||
348 | get { return m_health; } | ||
349 | set { m_health = value; } | ||
350 | } | ||
337 | 351 | ||
338 | /// <summary> | 352 | /// <summary> |
339 | /// These are the region handles known by the avatar. | 353 | /// These are the region handles known by the avatar. |
@@ -602,6 +616,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
602 | { | 616 | { |
603 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | 617 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); |
604 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 618 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
619 | m_physicsActor.UnSubscribeEvents(); | ||
605 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 620 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
606 | PhysicsActor = null; | 621 | PhysicsActor = null; |
607 | } | 622 | } |
@@ -1894,16 +1909,55 @@ namespace OpenSim.Region.Environment.Scenes | |||
1894 | } | 1909 | } |
1895 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 1910 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
1896 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 1911 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
1912 | m_physicsActor.SubscribeEvents(1000); | ||
1897 | m_physicsActor.LocalID = LocalId; | 1913 | m_physicsActor.LocalID = LocalId; |
1898 | } | 1914 | } |
1899 | 1915 | ||
1900 | // Event called by the physics plugin to tell the avatar about a collision. | 1916 | // Event called by the physics plugin to tell the avatar about a collision. |
1901 | private void PhysicsCollisionUpdate(EventArgs e) | 1917 | private void PhysicsCollisionUpdate(EventArgs e) |
1902 | { | 1918 | { |
1919 | if (e == null) | ||
1920 | return; | ||
1921 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | ||
1922 | Dictionary<uint, float> coldata = collisionData.m_objCollisionList; | ||
1923 | float starthealth = Health; | ||
1924 | uint killerObj = 0; | ||
1925 | foreach (uint localid in coldata.Keys) | ||
1926 | { | ||
1927 | if (coldata[localid] <= 0.10f || m_invulnerable) | ||
1928 | continue; | ||
1929 | //if (localid == 0) | ||
1930 | //continue; | ||
1931 | |||
1932 | Health -= coldata[localid] * 5; | ||
1933 | |||
1934 | if (Health <= 0) | ||
1935 | { | ||
1936 | if (localid != 0) | ||
1937 | killerObj = localid; | ||
1938 | } | ||
1939 | //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); | ||
1940 | } | ||
1941 | //Health = 100; | ||
1942 | if (!m_invulnerable) | ||
1943 | { | ||
1944 | if (starthealth != Health) | ||
1945 | { | ||
1946 | ControllingClient.SendHealth(Health); | ||
1947 | } | ||
1948 | if (m_health <= 0) | ||
1949 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | ||
1950 | } | ||
1951 | |||
1952 | |||
1903 | bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0; | 1953 | bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0; |
1904 | UpdateMovementAnimations(isUserMoving); | 1954 | UpdateMovementAnimations(isUserMoving); |
1905 | } | 1955 | } |
1906 | 1956 | public void setHealthWithUpdate(float health) | |
1957 | { | ||
1958 | Health = health; | ||
1959 | ControllingClient.SendHealth(Health); | ||
1960 | } | ||
1907 | internal void Close() | 1961 | internal void Close() |
1908 | { | 1962 | { |
1909 | lock (m_attachments) | 1963 | lock (m_attachments) |
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index a227d82..25c9093 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs | |||
@@ -615,5 +615,8 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
615 | public void SendScriptQuestion(LLUUID objectID, string taskName, string ownerName, LLUUID itemID, int question) | 615 | public void SendScriptQuestion(LLUUID objectID, string taskName, string ownerName, LLUUID itemID, int question) |
616 | { | 616 | { |
617 | } | 617 | } |
618 | public void SendHealth(float health) | ||
619 | { | ||
620 | } | ||
618 | } | 621 | } |
619 | } | 622 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 39f94cb..3d0855f 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -113,7 +113,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
113 | public bool collidelock = false; | 113 | public bool collidelock = false; |
114 | 114 | ||
115 | public int m_eventsubscription = 0; | 115 | public int m_eventsubscription = 0; |
116 | private CollisionEventUpdate CollisionEventsThisFrame = null; | 116 | private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); |
117 | 117 | ||
118 | public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size) | 118 | public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size) |
119 | { | 119 | { |
@@ -869,9 +869,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
869 | public override void SubscribeEvents(int ms) | 869 | public override void SubscribeEvents(int ms) |
870 | { | 870 | { |
871 | m_eventsubscription = ms; | 871 | m_eventsubscription = ms; |
872 | _parent_scene.addCollisionEventReporting(this); | ||
872 | } | 873 | } |
873 | public override void UnSubscribeEvents() | 874 | public override void UnSubscribeEvents() |
874 | { | 875 | { |
876 | _parent_scene.remCollisionEventReporting(this); | ||
875 | m_eventsubscription = 0; | 877 | m_eventsubscription = 0; |
876 | } | 878 | } |
877 | public void AddCollisionEvent(uint CollidedWith, float depth) | 879 | public void AddCollisionEvent(uint CollidedWith, float depth) |