public override void OnUserEnterPortal(Character c, string sPortalName) { var portal = Portals.FindPortal(sPortalName); if (TryProceed(c, portal?.nIdx ?? 0)) { WarpMap(NextFieldID(), nInstanceID, (byte)NextPortalID(), 0); } else { c.Action.Enable(); } }
public override CPortal GetStartPoint(Character c) { var bottomCharCount = aaCharacterID[0].Count; var topCharCount = aaCharacterID[1].Count; string sPortalName; if (bottomCharCount > topCharCount) { sPortalName = "st01"; aaCharacterID[1].Add(c.dwId); } else { sPortalName = "st00"; aaCharacterID[0].Add(c.dwId); } return(Portals.FindPortal(sPortalName)); }
/// <summary> /// Warps player to the map associated with the given portal. /// No positional validation is done; if the portal exists, the player will be warped through it. /// Has extra handling in child classes. /// </summary> /// <param name="user"></param> /// <param name="sPortalName"></param> public virtual void OnUserEnterPortal(Character user, string sPortalName) { var portal = Portals.FindPortal(sPortalName); if (portal == null) { user.Action.Enable(); Log.WarnFormat("Client tried to enter non existant portal {0}", sPortalName); return; } var nFieldID = portal.nTMap; if (portal.nTMap != 999999999 || CFieldMan.IsFieldValid(nFieldID)) { var newField = user.Socket.Server.CFieldMan.GetField(nFieldID); var spawn = newField.Portals.FindPortal(portal.sTName) ?? newField.Portals.FindPortal(0); var foothold = newField.Footholds.FindBelow(spawn.nX, (short)(spawn.nY - 25)); if (nInstanceID != 0) { user.Action.SetFieldInstance(nFieldID, nInstanceID, (byte)spawn.nIdx, foothold?.Id ?? 0); } else { user.Action.SetField(nFieldID, (byte)spawn.nIdx, foothold?.Id ?? 0); } } else { user.Action.Enable(); Log.WarnFormat("Client tried to enter portal {0} with bad dest {1}", sPortalName, nFieldID); } }