예제 #1
0
 public EventEngine(MapleCharacter starter, string script, int recreateMap = -1, bool skipSpawn = false)
 {
     Starter   = starter;
     ChannelId = Starter.Client.Channel;
     if (!(DataBuffer.EventScripts.TryGetValue(script, out EventType) && EventType != null))
     {
         return;
     }
     EventInstance = ScriptActivator.CreateScriptInstance(EventType, script, starter) as EventScript;
     if (EventInstance == null)
     {
         string error = string.Format("Error loading {0} {1}", "EventScript", script);
         ServerConsole.Error(error);
         FileLogging.Log("Event scripts", error);
         return;
     }
     RecreatedMap                     = recreateMap != -1;
     EventInstance.OnFinish          += new Action(FinishEvent);
     EventInstance.OnSpawnMobs       += new Action <int, int, int, int>(SpawnMobs);
     EventInstance.OnRandomSpawnMobs += new Action <int, int, Point, Point>(RandomSpawnMobs);
     if (RecreatedMap)
     {
         EventMap = new MapleEvent(recreateMap, DataBuffer.GetMapById(recreateMap), skipSpawn);
         EventId  = Program.RegisterEvent(EventMap);
         if (Starter != null)
         {
             AddCharacter(Starter);
         }
     }
 }
예제 #2
0
        public NpcEngine(MapleClient c, int id)
        {
            Client = c;
            NpcId  = id;
            Type npcT;

            if (DataBuffer.NpcScripts.TryGetValue(NpcId, out npcT) && npcT != null)
            {
                ScriptInstance = ScriptActivator.CreateScriptInstance(npcT, npcT.ToString(), c.Account.Character) as NpcScript;
                if (ScriptInstance == null)
                {
                    string error = string.Format("Error loading {0} {1}", "NpcScript", npcT.ToString());
                    ServerConsole.Error(error);
                    FileLogging.Log("Npc scripts", error);
                    return;
                }
                if (ScriptInstance.IsShop)
                {
                    IsShop = true;
                }
                else
                {
                    ScriptInstance.SendOk       = new Action <string>(SendOk);
                    ScriptInstance.SendNext     = new Action <string>(SendNext);
                    ScriptInstance.SendPrev     = new Action <string>(SendPrev);
                    ScriptInstance.SendNextPrev = new Action <string>(SendNextPrev);
                    ScriptInstance.SendSimple   = new Action <string>(SendSimple);
                    ScriptInstance.EndChat      = new Action(Dispose);
                    ScriptInstance.SendYesNo    = new Action <string>(SendYesNo);
                    ScriptInstance.SendAskText  = new Action <string, int, int, string>(SendAskText);
                }
            }
            else
            {
                SendOk(string.Format(@"An error has occured in my script. Please report this as a bug\r\nNpcId: {0}", NpcId));
                ServerConsole.Debug(string.Format(@"Missing script for NPC: {0}", NpcId));
                ScriptInstance = null;
                c.Account.Character.EnableActions();
            }
        }