29 using System.Collections.Generic;
31 using OpenSim.Framework;
32 using OpenSim.Region.Framework.Interfaces;
33 using OpenSim.Region.Framework.Scenes;
34 using OpenSim.Services.Interfaces;
41 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"CombatModule")]
54 private Dictionary<ulong, Scene> m_scenel =
new Dictionary<ulong, Scene>();
71 m_scenel[scene.RegionInfo.RegionHandle] = scene;
75 m_scenel.Add(scene.RegionInfo.RegionHandle, scene);
79 scene.EventManager.OnAvatarKilled += KillAvatar;
80 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
88 scene.EventManager.OnAvatarKilled -= KillAvatar;
89 scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
106 get {
return "CombatModule"; }
109 public Type ReplaceableInterface
115 private void KillAvatar(uint killerObjectLocalID,
ScenePresence deadAvatar)
117 string deadAvatarMessage;
128 if (killerObjectLocalID == 0)
129 deadAvatarMessage =
"You committed suicide!";
133 killingAvatar = deadAvatar.Scene.GetScenePresence(killerObjectLocalID);
134 if (killingAvatar == null)
137 SceneObjectPart part = deadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID);
141 deadAvatarMessage =
"You died!";
146 killingAvatar = deadAvatar.Scene.GetScenePresence(part.OwnerID);
147 if (killingAvatar == null)
150 string userName =
"Unkown User";
151 if (userManager != null)
152 userName = userManager.GetUserName(part.OwnerID);
153 deadAvatarMessage = String.Format(
"You impaled yourself on {0} owned by {1}!", part.Name, userName);
158 deadAvatarMessage = String.Format(
"You got killed by {0}!", killingAvatar.Name);
165 deadAvatarMessage = String.Format(
"You got killed by {0}!", killingAvatar.Name);
170 deadAvatar.ControllingClient.SendAgentAlertMessage(deadAvatarMessage,
true);
171 if (killingAvatar != null)
172 killingAvatar.ControllingClient.SendAlertMessage(
"You fragged " + deadAvatar.Firstname +
" " + deadAvatar.Lastname);
174 catch (InvalidOperationException)
177 deadAvatar.setHealthWithUpdate(100.0f);
178 deadAvatar.Scene.TeleportClientHome(deadAvatar.UUID, deadAvatar.ControllingClient);
181 private void AvatarEnteringParcel(
ScenePresence avatar,
int localLandID, UUID regionID)
185 ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
188 if ((obj.
LandData.
Flags & (uint)ParcelFlags.AllowDamage) != 0
189 || avatar.Scene.RegionInfo.RegionSettings.AllowDamage)
191 avatar.Invulnerable =
false;
195 avatar.Invulnerable =
true;
196 if (avatar.
Health < 100.0f)
198 avatar.setHealthWithUpdate(100.0f);
bool DeleteNPC(UUID agentID, Scene scene)
Delete an NPC.
Scene Scene
The scene to which this entity belongs
void Initialise(IConfigSource config)
Startup
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
Interactive OpenSim region server
uint Flags
Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags ...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
virtual RegionInfo RegionInfo
This maintains the relationship between a UUID and a user name.
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...