本文整理汇总了C#中IMap.SpawnNpc方法的典型用法代码示例。如果您正苦于以下问题:C# IMap.SpawnNpc方法的具体用法?C# IMap.SpawnNpc怎么用?C# IMap.SpawnNpc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMap
的用法示例。
在下文中一共展示了IMap.SpawnNpc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpawnNpcsBad
public static void SpawnNpcsBad(Client client, IMap imap)
{
//super-hack-ish code, just making it work
int rand, n;
int[] npcs = new int[] { 558, 559, 560, 571, 572, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863 };
if (imap.MaxX == 19) {
rand = Server.Math.Rand(0, 20);
if (rand == 0) { //no NPCs
n = 0;
} else if (rand > 0 && rand <= 3) { //1 NPC
n = 1;
} else if (rand > 3 && rand <= 9) { //2 NPCs
n = 2;
} else if (rand > 9 && rand <= 15) { //3 NPCs
n = 3;
} else if (rand > 15 && rand <= 18) { //4 NPCs
n = 4;
} else { //rand == 19, 5 NPCs
n = 5;
}
}
else {
rand = Server.Math.Rand(0,25);
if (rand == 0) { //no NPCs
n = 0;
} else if (rand > 0 && rand <= 2) { //1 NPC
n = 1;
} else if (rand > 2 && rand <= 5) { //2 NPCs
n = 2;
} else if (rand > 5 && rand <= 9) { //3 NPCs
n = 3;
} else if (rand > 9 && rand <= 14) { //4 NPCs
n = 4;
} else if (rand > 14 && rand <= 18) { //5 NPCs
n = 5;
} else if (rand > 18 && rand <= 21) { //6 NPCs
n = 6;
} else if (rand > 21 && rand <= 23) { //7 NPCs
n = 7;
} else { //rand == 24, 8 NPCs
n = 8;
}
}
for (int i = 1; i <= n; i++) {
MapNpcPreset npc = new MapNpcPreset();
rand = Server.Math.Rand(0, npcs.Length);
npc.NpcNum = npcs[rand];
if (npcs[rand] == 859) {
npc.MinLevel = 10;
npc.MaxLevel = 10;
} else {
npc.MinLevel = 50;
npc.MaxLevel = 80;
}
//npc.AppearanceRate = 100;
imap.SpawnNpc(npc);
}
}
示例2: SpawnNpcInRange
public static void SpawnNpcInRange(IMap map, int x, int y, int range, PacketHitList hitlist)
{
if (map.Npc.Count == 0) return;
if (map.SpawnMarker >= map.Npc.Count) map.SpawnMarker = map.Npc.Count - 1;
for (int i = 0; i < 100; i++) {
if (Server.Math.Rand(0, 100) < map.Npc[map.SpawnMarker].AppearanceRate && map.WillSpawnNow(map.Npc[map.SpawnMarker])) {
break;
}
map.SpawnMarker++;
if (map.SpawnMarker >= map.Npc.Count) map.SpawnMarker = 0;
}
MapNpcPreset spawningNpc = new MapNpcPreset();
spawningNpc.NpcNum = map.Npc[map.SpawnMarker].NpcNum;
spawningNpc.MinLevel = map.Npc[map.SpawnMarker].MinLevel;
spawningNpc.MaxLevel = map.Npc[map.SpawnMarker].MaxLevel;
spawningNpc.StartStatus = Enums.StatusAilment.OK;
for (int i = 1; i <= 500; i++) {
int X = Server.Math.Rand(x - range, x + range + 1);
int Y = Server.Math.Rand(y - range, y + range + 1);
// Check if the tile is walkable
if (X >= 0 && X <= map.MaxX && Y >= 0 && Y <= map.MaxY && map.Tile[X, Y].Type == Enums.TileType.Walkable) {
spawningNpc.SpawnX = X;
spawningNpc.SpawnY = Y;
break;
}
}
if (spawningNpc.SpawnX > -1) map.SpawnNpc(spawningNpc);
map.SpawnMarker++;
if (map.SpawnMarker >= map.Npc.Count) map.SpawnMarker = 0;
}
示例3: ActivateTrap
//.........这里部分代码省略.........
case 43: {//slow
hitlist.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic180.wav"), x, y, 10);
hitlist.AddPacketToMap(map, PacketBuilder.CreateSpellAnim(559, x, y));
targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Room, 0, map, null, x, y, Enums.Direction.Up, true, true, false);
for (int i = 0; i < targets.Count; i++) {
ExtraStatus status = targets[i].VolatileStatus.GetStatus("MovementSpeed");
if (status != null) {
AddExtraStatus(targets[i], MapManager.RetrieveActiveMap(targets[i].MapID), "MovementSpeed", status.Counter - 1, null, "", hitlist);
} else {
AddExtraStatus(targets[i], MapManager.RetrieveActiveMap(targets[i].MapID), "MovementSpeed", -1, null, "", hitlist);
}
//AddExtraStatus(i, MapManager.RetrieveActiveMap(i.MapID), "MovementSpeed", (int)GetSpeedLimit(i) - 1, null, hitlist);
}
}
break;
case 44: {//spin
hitlist.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic198.wav"), x, y, 10);
hitlist.AddPacketToMap(map, PacketBuilder.CreateSpellAnim(560, x, y));
targets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Room, 0, map, null, x, y, Enums.Direction.Up, true, true, false);
for (int i = 0; i < targets.Count; i++) {
hitlist.AddPacketToMap(MapManager.RetrieveActiveMap(targets[i].MapID), PacketBuilder.CreateBattleMsg(targets[i].Name + " spun around and around...", Text.BrightRed), x, y, 10);
AddExtraStatus(targets[i], MapManager.RetrieveActiveMap(targets[i].MapID), "Confusion", 15, null, "", hitlist);
//Confuse(i, MapManager.RetrieveActiveMap(i.MapID), 15, hitlist);
}
}
break;
case 49: {//summon
hitlist.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic197.wav"), x, y, 10);
hitlist.AddPacketToMap(map, PacketBuilder.CreateSpellAnim(561, x, y));
//hitlist.AddPacketToMap(map, PacketBuilder.CreateSpellAnim(492, x, y));
hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("A sweet scent wafted out from the ground!", Text.BrightRed), x, y, 10);
for (int i = 0; i < Constants.MAX_MAP_NPCS / 4; i++) {
if (Server.Math.Rand(0,2) == 0) {
SpawnNpcInRange(map, x, y, 2, hitlist);
} else {
map.SpawnNpc();
}
}
hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("Wild Pokémon were attracted to the scent!", Text.BrightRed), x, y, 10);
}
break;
case 50: {//grudge
hitlist.AddPacketToMap(map, PacketBuilder.CreateSoundPacket("Magic468.wav"), x, y, 10);
hitlist.AddPacketToMap(map, PacketBuilder.CreateSpellAnim(562, x, y));
//hitlist.AddPacketToMap(mapID, PacketBuilder.CreateSpellAnim(492, x, y));
for (int i = 0; i < Constants.MAX_MAP_NPCS / 4; i++) {
SpawnNpcInRange(map, x, y, 2, hitlist);
}
for (int i = 0; i < Constants.MAX_MAP_NPCS; i++) {
if (map.ActiveNpc[i].Num > 0) {
AddExtraStatus(map.ActiveNpc[i], map, "Grudge", 0, null, "", hitlist);
}
}
hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg("All Pokémon on the floor now hold a grudge!", Text.BrightRed), x, y, 10);
}
break;
case 51: {//selfdestruct
bool explode = true;
TargetCollection checkedTargets = MoveProcessor.GetTargetsInRange(Enums.MoveRange.Floor, 0, map, null, x, y, Enums.Direction.Up, true, true, false);
for (int i = 0; i < checkedTargets.Count; i++) {
if (HasAbility(checkedTargets[i], "Damp")) {
explode = false;
}
}
示例4: SpawnNpcToMap
public static void SpawnNpcToMap(IMap map, int npcNum, int minLevel, int maxLevel, int spawnX, int spawnY, PacketHitList packetlist)
{
PacketHitList.MethodStart(ref packetlist);
MapNpcPreset npc = new MapNpcPreset();
npc.SpawnX = spawnX;
npc.SpawnY = spawnY;
npc.NpcNum = npcNum;
npc.MinLevel = minLevel;
npc.MaxLevel = maxLevel;
map.SpawnNpc(npc);
PacketHitList.MethodEnded(ref packetlist);
}