Esempio n. 1
0
		public static void OnServerStarted() {
			// Spawn test
			ServerConsole.DebugLine("Spawn a mob");
			Location location = new Location(1, new Point2D(157, 183));
			Monster.SpawnOnce(null, location, "Rovolution Poring", 1002, 1);

			ServerConsole.DebugLine("Spawn a npc");
			location = new Location(1, new Point2D(155, 183));
			NpcScript.Spawn("Test NPC", 46, location);
		}
Esempio n. 2
0
		public static void Spawn(string name, int viewID, Location loc) {
			// Search free cell to spawn, if not given
			if (loc.Map.SearchSpawnCell(ref loc) == false) {
				// No spot on the map.. maybe a bug or something else
				ServerConsole.ErrorLine("SpawnSub: Failed to locate spawn pos on map " + loc.Map.Name);
				return;
			}

			NpcScript npc = new NpcScript(new DatabaseID(viewID, EDatabaseType.Npc));
			npc.Location = loc;
			npc.Name = name;
			npc.Class = (short)viewID;
			npc.NpcType = ENpcScriptType.Script;

			// TODO: ontouch area

			npc.StatusChange = new WorldObjectStatusChangeList();
			npc.StatusChange.Clear();

			npc.Spawn();

			return;
		}
Esempio n. 3
0
		private static Monster SpawnOnceSub(Character character, Location loc, string name, int mobID) {
			// Create new world object based on mobID
			Monster mob = new Monster(new DatabaseID(mobID, EDatabaseType.Mob));
			// Search free cell to spawn, if no given
			Point2D spawnPoint = loc.Point;
			if (character != null && (spawnPoint.X < 0 || spawnPoint.Y < 0)) {
				// if none found, pick random position on map
				if (loc.Map.SearchFreeCell(character, ref spawnPoint, 1, 1, 0) == false) {
					if (spawnPoint.X <= 0 || spawnPoint.Y <= 0 || loc.Map.CheckCell(spawnPoint, ECollisionType.Reachable) == false) {
						// Failed to fetch random spot on the whole map?
						if (loc.Map.SearchFreeCell(null, ref spawnPoint, -1, -1, 1) == false) {
							ServerConsole.ErrorLine("SpawnSub: Failed to locate spawn pos on map " + loc.Map.Name);
							return null;
						}
					}
				}
			}

			mob.Location = new Location(loc.Map.ID, spawnPoint);
			mob.Name = name;
			mob.Class = (short)mobID;

			// mob_parse_dataset here; check for tiny/large, event and so on

			// TODO: takeover of special_state AI ect; need mob_parse_dataset before
			//		 and place in Monster class to store it (look @ eA mob_data)

			mob.ViewData = WorldObjectViewData.GetViewData(mob.Database, mobID);
			mob.Status = new WorldObjectStatus(mob);
			mob.BaseStatus = new WorldObjectStatus(mob);
			mob.StatusChange.Clear();

			return mob;
		}
Esempio n. 4
0
		public static void SpawnOnce(NetState state, Location loc, string name, int mobID, int amount) {
			// TODO: calllback/event
			Character character = (state != null && state.Account != null && state.Account.ActiveChar != null ? state.Account.ActiveChar : null);
			int lv = (int)(character != null ? character.Status.LevelBase : 255);
			mobID = (mobID >= 0 ? mobID : GetRandomMobID(state.Account.ActiveChar, -mobID - 1, 3, lv));

			amount = Math.Min(amount, 1000);
			for (int i = 0; i < amount; i++) {
				Monster mob = SpawnOnceSub(character, loc, name, mobID);
				if (mob == null) {
					continue;
				}

				// TODO: check for emperium, add guardian & castle data
				mob.Spawn();

				// TODO: check for negative mobID (Dead branch) and mode changes
			}
		}
Esempio n. 5
0
		protected override bool LoadFromDatabase(DataRow row) {
			// Load serials
			base.Serial = new DatabaseID(row.Field<uint>("charID"), EDatabaseType.Char);
			if (row.Field<uint>("partyID") > 0) {
				PartyID = new WorldID(row.Field<uint>("partyID"), EDatabaseType.Party);
			}
			if (row.Field<uint>("guildID") > 0) {
				GuildID = new WorldID(row.Field<uint>("guildID"), EDatabaseType.Guild);
			}
			if (row.Field<uint>("petID") > 0) {
				PetID = new WorldID(row.Field<uint>("petID"), EDatabaseType.Pet);
			}
			if (row.Field<uint>("homunID") > 0) {
				HomID = new WorldID(row.Field<uint>("homunID"), EDatabaseType.Homunculus);
			}
			if (row.Field<uint>("partnerID") > 0) {
				PartnerID = new WorldID(row.Field<uint>("partnerID"), EDatabaseType.Char);
			}
			if (row.Field<uint>("fatherID") > 0) {
				FatherID = new WorldID(row.Field<uint>("fatherID"), EDatabaseType.Char);
			}
			if (row.Field<uint>("motherID") > 0) {
				MotherID = new WorldID(row.Field<uint>("motherID"), EDatabaseType.Char);
			}
			if (row.Field<uint>("childID") > 0) {
				ChildrenID = new WorldID(row.Field<uint>("childID"), EDatabaseType.Char);
			}
			if (row.Field<uint>("childID") > 0) {
				MercenaryID = new WorldID(row.Field<uint>("mercID"), EDatabaseType.Mercenary);
			}

			Name = row.Field<string>("name");
			LevelBase = row.Field<ushort>("levelBase");
			LevelJob = row.Field<ushort>("levelJob");
			// TODO: rework all datatypes..
			Str = (short)row.Field<ushort>("str");
			Agi = (short)row.Field<ushort>("agi");
			Vit = (short)row.Field<ushort>("vit");
			Int = (short)row.Field<ushort>("int");
			Dex = (short)row.Field<ushort>("dex");
			Luk = (short)row.Field<ushort>("luk");
			Slot = (byte)row.Field<short>("slot");
			//Sex = (EAccountSex)row.Field<int>("sex");
			ExpBase = (uint)row.Field<ulong>("expBase");
			ExpJob = (uint)row.Field<ulong>("expJob");
			Zeny = (int)row.Field<uint>("zeny");
			Class = (EClientClass)row.Field<ushort>("class");
			StatusPoints = row.Field<uint>("statusPoint");
			SkillPoints = row.Field<uint>("skillPoint");
			HP = (int)row.Field<uint>("hp");
			HPMax = (int)row.Field<uint>("hpMax");
			SP = (int)row.Field<uint>("sp");
			SPMax = (int)row.Field<uint>("spMax");
			Option = (EStatusOption)row.Field<int>("option");
			Manner = row.Field<short>("manner");
			Karma = (byte)row.Field<sbyte>("karma");
			HairStyle = row.Field<byte>("hair");
			HairColor = (short)row.Field<ushort>("hairColor");
			ClothColor = (short)row.Field<ushort>("clothesColor");
			IsOnline = (row.Field<sbyte>("isOnline") > 0? true : false);
			Fame = (int)row.Field<uint>("fame");

			// Mercenary Guilds Rank
			/*
			int arch_faith, arch_calls;
			int spear_faith, spear_calls;
			int sword_faith, sword_calls;
			*/

			Weapon = (EWeaponType)row.Field<ushort>("weapon");
			Shield = (short)row.Field<ushort>("shield");
			HeadTop = (short)row.Field<ushort>("headTop");
			HeadMid = (short)row.Field<ushort>("headMid");
			HeadBottom = (short)row.Field<ushort>("headBottom");
			Rename = (short)row.Field<ushort>("rename");


			// Load locations
			Location = new Location(Mapcache.GetID(row.Field<string>("lastMap")), row.Field<ushort>("lastX"), row.Field<ushort>("lastY"));
			SavePoint = new Location(Mapcache.GetID(row.Field<string>("saveMap")), row.Field<ushort>("saveX"), row.Field<ushort>("saveY"));

			// Other crap
			DeleteDate = row.FieldDateTime("deleteDate");

			return true;
		}
Esempio n. 6
0
		public NpcWarpScript(DatabaseID id, Point2D point, Location loc)
			: this(id, new NpcWarpData(point, loc)) {
		}
Esempio n. 7
0
		public MapBlock this[Location loc] {
			get { return GetBlock(loc.Point); }
		}
Esempio n. 8
0
		public bool SearchSpawnCell(ref Location loc) {
			Point2D spawnPoint = loc.Point;
			if (spawnPoint.X < 0 || spawnPoint.Y < 0) {
				// No free cell found?
				if (loc.Map.SearchFreeCell(ref spawnPoint, 1, 1, 0) == false) {
					// The may have a position like (X, -1), means we only need to find a valid Y
					// If nothing found, we end up here & check if Y is still not valid
					if (spawnPoint.X <= 0 || spawnPoint.Y <= 0 || loc.Map.CheckCell(spawnPoint, ECollisionType.Reachable) == false) {
						// No spot arround bases position fond, search on the whole map
						if (loc.Map.SearchFreeCell(null, ref spawnPoint, -1, -1, 1) == false) {
							// No spot on the map.. maybe a bug or something else
							return false;
						}
					}
				}
			}

			return true;
		}
Esempio n. 9
0
		public NpcWarpData(Point2D area, Location loc) {
			TouchArea = area;
			Destination = loc;
		}
Esempio n. 10
0
		public void Write(Location loc) {
			Writer.Write(loc);
		}
Esempio n. 11
0
		public void Write(Location loc) {
			byte[] buf = new byte[3] {
				(byte)(loc.X >> 2),
				(byte)((loc.X << 6) | (loc.Y >> 4) & 0x3f),
				(byte)((loc.X << 4) | (int)loc.Direction & 0xf)
			};

			mWriter.Write(buf, 0, buf.Length);
		}