public static void Register(string name, MapScriptFunction scriptFunction) { Handlers[name] = new MapScriptHandler(name, scriptFunction); }
public void ProccessMovement(IMobile mobile, Point3D location) { if (mapData[location.X, location.Y].Length < location.Z) { return; } MapData md = mapData[location.X, location.Y][location.Z]; if (!string.IsNullOrEmpty(md.Script)) { MapScriptHandler handler = MapScriptManager.GetScriptHandler(md.Script); if (handler == null) { Console.WriteLine("Unhandled Script {0}", md.Script); } else { try { handler.ProcessScript(mobile); } catch { Console.WriteLine("Error processing Script {0} for {1}", md.Script, mobile); } } } if (!string.IsNullOrEmpty(md.MapCommand)) { string mapCommand = md.MapCommand; if (mapCommand.StartsWith("W")) { string[] newLocation = mapCommand.Replace("W", "").Trim().Split(' '); int X = byte.Parse(newLocation[0]) + ((byte.Parse(newLocation[1])) * 256); int Y = byte.Parse(newLocation[2]) + ((byte.Parse(newLocation[3])) * 256); byte M = byte.Parse(newLocation[4]); byte Z = byte.Parse(newLocation[5]); IMap targetMap = MapManager.GetMap(M); Point3D targetLocation = new Point3D(X, Y, Z); mobile.WarpToLocation(targetMap, targetLocation); return; } if (mapCommand.StartsWith("B")) { mobile.OpenBank(); return; } if (mapCommand.StartsWith("!")) { return; //additional map info } if (mapCommand.StartsWith("x")) { return; //additional map info } if (mapCommand.StartsWith("z")) { return; //additional map info } if (mapCommand.StartsWith("G")) { return; //additional map info } Console.WriteLine(String.Format("Map Command \"{0}\" Not Implemented...", mapCommand)); } }