mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-10 07:05:41 +12:00
Maybe? NPC Randomly Wander..
This commit is contained in:
parent
f20e67bfd6
commit
0767f82299
4 changed files with 124 additions and 14 deletions
|
@ -50,6 +50,14 @@ namespace HISP.Game.Chat
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
questId = int.Parse(args[1]);
|
questId = int.Parse(args[1]);
|
||||||
|
if(args.Length >= 3)
|
||||||
|
{
|
||||||
|
if (args[2] == "FORCE")
|
||||||
|
{
|
||||||
|
Quest.CompleteQuest(user, Quest.GetQuestById(questId));
|
||||||
|
goto msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
Quest.ActivateQuest(user, Quest.GetQuestById(questId));
|
Quest.ActivateQuest(user, Quest.GetQuestById(questId));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
@ -61,6 +69,7 @@ namespace HISP.Game.Chat
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
msg:;
|
||||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||||
user.LoggedinClient.SendPacket(chatPacket);
|
user.LoggedinClient.SendPacket(chatPacket);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace HISP.Game
|
||||||
|
|
||||||
public NpcReply[] Replies;
|
public NpcReply[] Replies;
|
||||||
}
|
}
|
||||||
public struct NpcEntry
|
public class NpcEntry
|
||||||
{
|
{
|
||||||
public int Id;
|
public int Id;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
@ -43,6 +43,95 @@ namespace HISP.Game
|
||||||
public bool LibarySearchable;
|
public bool LibarySearchable;
|
||||||
public int IconId;
|
public int IconId;
|
||||||
|
|
||||||
|
private int udlrScriptPos = 0;
|
||||||
|
|
||||||
|
private bool canNpcBeHere(int x, int y)
|
||||||
|
{
|
||||||
|
// Horses cannot be in towns.
|
||||||
|
if (World.InTown(x, y))
|
||||||
|
return false;
|
||||||
|
if (World.InSpecialTile(x, y))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Check Tile Type
|
||||||
|
int TileID = Map.GetTileId(x, y, false);
|
||||||
|
string TileType = Map.TerrainTiles[TileID - 1].Type;
|
||||||
|
if (TileType != this.StayOn)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (Map.CheckPassable(x, y)) // Can the player stand over here?
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void RandomWander()
|
||||||
|
{
|
||||||
|
if(Moves)
|
||||||
|
{
|
||||||
|
if(UDLRStartX == 0 && UDLRStartY == 0) // not scripted.
|
||||||
|
{
|
||||||
|
if (GameServer.GetUsersAt(this.X, this.Y, true, true).Length > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int direction = GameServer.RandomNumberGenerator.Next(0, 3);
|
||||||
|
int tryX = this.X;
|
||||||
|
int tryY = this.Y;
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
tryX += 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
tryX -= 1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
tryY += 1;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
tryY -= 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canNpcBeHere(tryX, tryY))
|
||||||
|
{
|
||||||
|
X = tryX;
|
||||||
|
Y = tryY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Is Scripted.
|
||||||
|
{
|
||||||
|
|
||||||
|
X = UDLRStartX;
|
||||||
|
Y = UDLRStartY;
|
||||||
|
for(int i = 0; i < udlrScriptPos; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (UDLRScript.ToLower()[i])
|
||||||
|
{
|
||||||
|
case 'u':
|
||||||
|
Y++;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
Y--;
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
X--;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
X++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
udlrScriptPos++;
|
||||||
|
|
||||||
|
if (udlrScriptPos > UDLRScript.Length)
|
||||||
|
udlrScriptPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public NpcChat[] Chatpoints;
|
public NpcChat[] Chatpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +212,16 @@ namespace HISP.Game
|
||||||
throw new KeyNotFoundException("Npc id: " + id + " not found!");
|
throw new KeyNotFoundException("Npc id: " + id + " not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void WanderNpcs()
|
||||||
|
{
|
||||||
|
Logger.DebugPrint("Making NPC's randomly wander.");
|
||||||
|
foreach(NpcEntry npc in NpcList)
|
||||||
|
{
|
||||||
|
if(GameServer.RandomNumberGenerator.Next(0,100) > 50)
|
||||||
|
npc.RandomWander();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static NpcEntry[] GetNpcByXAndY(int x, int y)
|
public static NpcEntry[] GetNpcByXAndY(int x, int y)
|
||||||
{
|
{
|
||||||
List<NpcEntry> npcs = new List<NpcEntry>();
|
List<NpcEntry> npcs = new List<NpcEntry>();
|
||||||
|
|
|
@ -121,19 +121,19 @@ namespace HISP.Game
|
||||||
|
|
||||||
public static bool CanComplete(User user, QuestEntry quest)
|
public static bool CanComplete(User user, QuestEntry quest)
|
||||||
{
|
{
|
||||||
|
// Has completed other required quests?
|
||||||
|
foreach (int questId in quest.RequiresQuestIdCompleted)
|
||||||
|
if (user.Quests.GetTrackedQuestAmount(questId) < 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Has NOT competed other MUST NOT BE required quests
|
||||||
|
foreach (int questId in quest.RequiresQuestIdNotCompleted)
|
||||||
|
if (user.Quests.GetTrackedQuestAmount(questId) > 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (quest.Tracked)
|
if (quest.Tracked)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Has completed other required quests?
|
|
||||||
foreach (int questId in quest.RequiresQuestIdCompleted)
|
|
||||||
if (user.Quests.GetTrackedQuestAmount(questId) < 1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Has NOT competed other MUST NOT BE required quests
|
|
||||||
foreach (int questId in quest.RequiresQuestIdNotCompleted)
|
|
||||||
if (user.Quests.GetTrackedQuestAmount(questId) > 1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Has allready tracked this quest?
|
// Has allready tracked this quest?
|
||||||
if (user.Quests.GetTrackedQuestAmount(quest.Id) >= quest.MaxRepeats)
|
if (user.Quests.GetTrackedQuestAmount(quest.Id) >= quest.MaxRepeats)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -91,6 +91,7 @@ namespace HISP.Server
|
||||||
Database.IncPlayerTirednessForOfflineUsers();
|
Database.IncPlayerTirednessForOfflineUsers();
|
||||||
DroppedItems.Update();
|
DroppedItems.Update();
|
||||||
WildHorse.Update();
|
WildHorse.Update();
|
||||||
|
Npc.WanderNpcs();
|
||||||
minuteTimer.Change(oneMinute, oneMinute);
|
minuteTimer.Change(oneMinute, oneMinute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1169,6 +1170,7 @@ namespace HISP.Server
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " tried to deposit/witthdraw NaN money....");
|
Logger.ErrorPrint(sender.LoggedinUser.Username + " tried to deposit/witthdraw NaN money....");
|
||||||
|
UpdateArea(sender);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,12 +1183,12 @@ namespace HISP.Server
|
||||||
sender.SendPacket(chatPacket);
|
sender.SendPacket(chatPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((moneyWithdrawn >= sender.LoggedinUser.BankMoney) && moneyWithdrawn != 0)
|
if ((moneyWithdrawn <= sender.LoggedinUser.BankMoney) && moneyWithdrawn != 0)
|
||||||
{
|
{
|
||||||
sender.LoggedinUser.BankMoney -= moneyWithdrawn;
|
sender.LoggedinUser.BankMoney -= moneyWithdrawn;
|
||||||
sender.LoggedinUser.Money += (int)moneyWithdrawn;
|
sender.LoggedinUser.Money += Convert.ToInt32(moneyWithdrawn);
|
||||||
|
|
||||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatWithdrawMoneyMessage((int)moneyWithdrawn), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatWithdrawMoneyMessage(Convert.ToInt32(moneyWithdrawn)), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(chatPacket);
|
sender.SendPacket(chatPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue