Ok so this is going to be a scattered release as I don't plan on going through my source and finding every possible thing you could ever need. If there are problems post away and I may help but for the most part you will be on your own to get this working.
What is this?
This is a quest/event I designed at like 4 am one night when I couldn't sleep after getting pissed off at all the BAD quests released (not pointing fingers... but you all gotta admit there have been some very pointless quests)
What does it do?
This event consists of treasure boxes (currently using Lotto boxes as I didn't feel like searching through all the possible npcs, you can change them to whatever you want though).
These treasure boxes spawn randomly around the game world producing a msg to all the server telling people what town it's near (Note: added a system to convert map ID to Name for use with this type of thing... if there is such functionality built into CoEmu I didn't see it.. again it was 4 am though). When used the box will despawn and award the user with a random prize and (assuming the event is still in progress), respawn somewhere else in the game world.
Locations are stored in a SQL database (refer to my random teleport release, it's the same system. This is the type of stuff I designed it for, I just didn't feel like coding anything past the actual db itself at that point)
Well that's cool, how do I customize it?
Simple enough, everything is somewhat labled and I've included some handy commands to start/stop the event (doing it via times of day or counting how many boxes are allowed to be spawned per event is up to you. It's simple enough to do but I'm done coding for a little while), commands to add new points easily to the random location database as well as being rather easy to customize in the first place.
The Release:
Note: CoEmu 5095, not releasing or converting it for lotf, that's up to you guys.
Part 1: Refer to my Random teleport release for further instructions on how to set this up but for extra help I'll release what I can remember of it here.
public static void AddRandomPortal(int NewPortMap, int NewPortX, int NewPortY) { try { lock (DatabaseConnection.NewConnection()) { MySqlCommand Cmd = new MySqlCommand("INSERT INTO randomportal(GotoMap, GotoX, GotoY) VALUES(" + NewPortMap + "," + NewPortX + "," + NewPortY + ")", DatabaseConnection.NewConnection()); Cmd.ExecuteNonQuery(); } } catch { Console.WriteLine("Error: Could not add Random portal to Database!"); } }
nano.cs
Code:
public static Dictionary<int, Struct.RandomPortal> RandomPortals = new Dictionary<int, Struct.RandomPortal>();
and
PHP Code:
public static bool HuntNpcUsed = false; public static int HutnNpcToSpawn = 0; public static bool NpcHuntOn = false; public static bool NpcHuntSpawned = false;
and down @
Code:
Struct.LoadTNpcs();
put
Code:
Database.Database.GetRandomPortal();
Now: I have a handler file called functions to store any new stuff I'm adding so you will wanna add one. Name it what you want but mine is Handlers>Functions.cs. Here is the full file with the applicable info in it
using System; using System.Collections; using System.Collections.Generic; using CoEmu_v2_GameServer.Connections; using CoEmu_v2_GameServer.Entities; using CoEmu_v2_GameServer.Structs; using CoEmu_v2_GameServer.Packets; using CoEmu_v2_GameServer.Calculations; using System.Threading;
namespace CoEmu_v2_GameServer.Handlers { public partial class Handler { public class Functions {
public static void SpawnNpc(int id, int type, int subtype, int map, int x, int y, int direction, int flag) {//blabla { { Structs.Struct.NPC NPC = new Structs.Struct.NPC(); NPC.Direction = direction; NPC.Flag = flag; NPC.ID = id; NPC.Map = map; NPC.SubType = subtype; NPC.Type = type; NPC.X = Convert.ToUInt16(x); NPC.Y = Convert.ToUInt16(y); if (Nano.Npcs.ContainsKey(NPC.ID)) { while (Nano.Npcs.ContainsKey(NPC.ID)) NPC.ID = Nano.Rand.Next(100, 10000); Console.WriteLine("Npc Id in use, selected random id: " + NPC.ID); }
Console.WriteLine("Successfuly added npc to server");
}
} }
public static void DespawnNpc(int RemovalType, int ID) {//blabla switch (RemovalType) { case 1://Npc Type { foreach (KeyValuePair<int, Struct.NPC> LoopId in Nano.Npcs) { if (LoopId.Value.Type == ID) { Nano.Npcs.Remove(LoopId.Value.ID); Console.WriteLine("Found type in for each loop! " + Convert.ToInt32(LoopId.Value.Type)); break; } } break; } case 2://Npc Id { Nano.Npcs.Remove(ID); Console.WriteLine("Removed Npc ID: " + Convert.ToString(ID)); break; } }
}
public static void SpawnHuntNpc() { int PointTouse = Nano.Rand.Next(0, (Nano.RandomPortals.Count)); Struct.RandomPortal RandPortData = Nano.RandomPortals[PointTouse]; int NpcUid = Nano.Rand.Next(100, 10000); Handler.SpawnVoid.SpawnNpc(NpcUid, 105051, 9277, RandPortData.PortalMap, RandPortData.PortalX, RandPortData.PortalY, 2, 0);
ConquerPacket.ToServer(ConquerPacket.Chat(0, "[NpcHunt]", "ALLUSERS", "Treasure has spawned somewhere near " + MapToName.IdToName(RandPortData.PortalMap), Struct.ChatType.Center), 0); Nano.HuntNpcUsed = false; Nano.NpcHuntSpawned = true;
case "newrandme": { int ToAddMap = (int)CSocket.Client.Map; int ToAddX = CSocket.Client.X; int ToAddY = CSocket.Client.Y; Database.Database.AddRandomPortal(ToAddMap, ToAddX, ToAddY); Database.Database.GetRandomPortal(); break; }
case "newrand": { int ToAddMap = Convert.ToUInt16(Command[1]); int ToAddX = Convert.ToUInt16(Command[2]); int ToAddY = Convert.ToUInt16(Command[3]); Database.Database.AddRandomPortal(ToAddMap, ToAddX, ToAddY); Database.Database.GetRandomPortal(); break; }
Ooh and just so you have it, here's a command to teleport to one of the locations in the database (remove if you don't want people being able to use it to get to the npcs super fast)
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace CoEmu_v2_GameServer.Calculations { public class MapToName { public static string IdToName(int MapNumber) { string MapName = ""; switch (MapNumber) {
case 1002: { MapName = "Twin City"; break; } case 1000: { MapName = "Desert City"; break; } case 1015: { MapName = "Bird Island"; break; } case 1011: { MapName = "Phoenix Castle"; break; } case 1020: { MapName = "Ape Mountain"; break; }
} return MapName; }
} }
Also for convenience, here is the backup of my rand tele database file
note: it's nearly empty. I just added a few points for testing. Give it a try though, everything should work just great.
For the record, to start it (unless you code it to auto start which is easy enough to do)
/huntnpc (amount for quest)
To add new locations to the database
Current character location
/newrandme
or
/newrand map x y
<edit>
Update: tested with the new upgrade. Everything works fine now
Update: removed box when event ended (it was not a problem as it only gives prize once regardless of if it moves but still, it's better that way)
Note: The whole teleporting the clear the screen thing was again my own lazyness. It was not updating my screen properly (I tried a few methods) and instead of looking into it more I decided to just leave it as it works now.
Honestly to convert it to new lotf would be alot of work. You'd be best off re-writing the entire thing for it. The systems themselves would be good reference to code these features in lotf though.
Note: I just realized... this basically combines everything I've released in the past few weeks into one actually useful feature instead of a vague concept when I first released them.
Daily Quests & Divac`s Treasure Map Event 06/15/2010 - Battle of the Immortals - 2 Replies There are 4 Daily Quests in Battle of Immortals
You can get them with Level 65 in Hall of Illusions.
Just go to the Hall of Illusions Teleporter in Atlantic Square.
For one of this Daily Quest you obtain 90000 Exp and 10000 Coins.
So 40000 Coins for this Quests are not bad.
You can find the Teleporter in Atlantic Square "Expedition Union"
[RELEASE] SEA 0.1.17 Random TP 07/17/2009 - Dragonica Hacks, Bots, Cheats & Exploits - 4 Replies Just because I can :P
This serves no purpose whatsoever but to randomly teleport you around the map once per second for lulz.