private void Update_UCE_Friendship() { if (Time.time < _cacheFriendship) { return; } for (int i = 0; i < UCE_Friends.Count; i++) { UCE_Friend frnd = UCE_Friends[i]; Player plyr = UCE_Tools.FindOnlinePlayerByName(frnd.name); if (plyr != null) { frnd.online = true; frnd.inParty = plyr.InParty(); frnd.level = plyr.level; frnd._class = plyr.className; frnd.guild = plyr.guild.name; } else { frnd.online = false; } UCE_Friends[i] = frnd; } _cacheFriendship = Time.time + 4.0f; }
// ----------------------------------------------------------------------------------- // Apply // ----------------------------------------------------------------------------------- public override void Use(Player player, int inventoryIndex) { ItemSlot slot = player.inventory[inventoryIndex]; // -- Only activate if enough charges left if (decreaseAmount == 0 || slot.amount >= decreaseAmount) { if (player.InParty()) { // always call base function too base.Use(player, inventoryIndex); foreach (string member in (player.party.members)) { Player plyr = UCE_Tools.FindOnlinePlayerByName(member); // -- Teleport everybody but not the caster if (plyr != null && plyr != player) { // -- Check Distance if (maxDistanceToCaster <= 0 || Utils.ClosestDistance(player.collider, plyr.collider) <= maxDistanceToCaster || member == player.party.master) { // -- Determine Teleportation Target if (teleportToClosestSpawnpoint) { Transform target = NetworkManagerMMO.GetNearestStartPosition(plyr.transform.position); plyr.UCE_Warp(target.position); } else { teleportationTarget.OnTeleport(plyr); } } plyr = null; } } // decrease amount slot.DecreaseAmount(decreaseAmount); player.inventory[inventoryIndex] = slot; // -- Teleport the caster now if (teleportToClosestSpawnpoint) { Transform target = NetworkManagerMMO.GetNearestStartPosition(player.transform.position); player.UCE_Warp(target.position); } else { teleportationTarget.OnTeleport(player); } } } }
// ----------------------------------------------------------------------------------- // UCE_AddFriend // @Server // ----------------------------------------------------------------------------------- public void UCE_AddFriend(string name) { if (string.IsNullOrWhiteSpace(name)) { return; } if (UCE_Friends.Count >= friendshipTemplate.maxFriends) { UCE_TargetAddMessage(friendshipTemplate.msgMaxFriends); return; } if (name != this.name) { if (Database.singleton.CharacterExists(name)) { if (onlinePlayers.ContainsKey(name)) { if (UCE_Friends.FindIndex(x => x.name == name) == -1) { Player pl = UCE_Tools.FindOnlinePlayerByName(name); DateTime time = DateTime.UtcNow; #if _iMMOHONORSHOP int hours = friendshipTemplate.timespanHours * -1; time = time.AddHours(hours); #endif UCE_Friend frnd = new UCE_Friend(pl.name, time.ToString("s")); UCE_Friends.Add(frnd); UCE_TargetAddMessage(string.Format(friendshipTemplate.msgIsNowFriend, name)); } else { UCE_TargetAddMessage(string.Format(friendshipTemplate.msgIsAlreadyFriend, name)); } } else { UCE_TargetAddMessage(string.Format(friendshipTemplate.msgTargetOffline, name)); } } else { UCE_TargetAddMessage(string.Format(friendshipTemplate.msgTargetNotExist, name)); } } else { UCE_TargetAddMessage(friendshipTemplate.msgCannotFriendSelf); } }
// ----------------------------------------------------------------------------------- // Apply // ----------------------------------------------------------------------------------- public override void Apply(Entity caster, int skillLevel) { foreach (string member in ((Player)caster).party.members) { Player player = UCE_Tools.FindOnlinePlayerByName(member); // -- Teleport everybody but not the caster if (player != null && player != (Player)caster) { // -- Check Distance if (maxDistanceToCaster <= 0 || Utils.ClosestDistance(caster, caster.target) <= maxDistanceToCaster || member == ((Player)caster).party.master) { // -- Determine Teleportation Target if (teleportToClosestSpawnpoint) { Transform target = NetworkManagerMMO.GetNearestStartPosition(player.transform.position); player.UCE_Warp(target.position); } else { teleportationTarget.OnTeleport(player); } } player = null; } } // -- Teleport the caster now if (teleportToClosestSpawnpoint) { Transform target = NetworkManagerMMO.GetNearestStartPosition(((Player)caster).transform.position); ((Player)caster).UCE_Warp(target.position); } else { teleportationTarget.OnTeleport(((Player)caster)); } }
public void Cmd_UCE_HugFriend(string name) { if (string.IsNullOrWhiteSpace(name)) { return; } int idx = UCE_Friends.FindIndex(x => x.name == name); if (idx != -1) { Player plyr = UCE_Tools.FindOnlinePlayerByName(name); UCE_Friend frnd = UCE_Friends[idx]; if (UCE_CanHug(frnd.lastGifted)) { // -- Other player gains Honor Currency when online if (plyr && friendshipTemplate.friendHonorCurrency && friendshipTemplate.friendAmount > 0) { plyr.UCE_AddHonorCurrency(friendshipTemplate.friendHonorCurrency, friendshipTemplate.friendAmount); } frnd.lastGifted = DateTime.UtcNow.ToString("s"); UCE_Friends[idx] = frnd; // -- Hugging Player gains Honor Currency if (friendshipTemplate.honorCurrency && friendshipTemplate.amount > 0) { UCE_AddHonorCurrency(friendshipTemplate.honorCurrency, friendshipTemplate.amount); } UCE_TargetAddMessage(string.Format(friendshipTemplate.msgTargetHugged, name, friendshipTemplate.amount.ToString(), friendshipTemplate.honorCurrency.name)); } } }