This AI tool from OpenAI is amazing and able to code, I feel it is a needed tool for anyone learning or writing code for ServUO!
ChatGPT AI Link
ChatGPT AI Link
Last edited by a moderator:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace ServUO
{
public class PlayerFaction
{
public string FactionName { get; set; }
public Mobile Leader { get; set; }
public HashSet<Mobile> Members { get; set; }
public SortedDictionary<Mobile, int> Ranks { get; set; }
public Dictionary<Mobile, int> Votes { get; set; }
public PlayerFaction(string factionName, Mobile leader)
{
FactionName = factionName;
Leader = leader;
Members = new HashSet<Mobile>();
Members.Add(leader);
Ranks = new SortedDictionary<Mobile, int>();
Ranks[leader] = 5;
Votes = new Dictionary<Mobile, int>();
}
public static PlayerFaction Deserialize(XmlElement xml)
{
PlayerFaction faction = new PlayerFaction(xml.GetAttribute("name"), World.FindMobile(int.Parse(xml.GetAttribute("leader"))));
foreach (XmlElement memberElement in xml.GetElementsByTagName("member"))
{
Mobile member = World.FindMobile(int.Parse(memberElement.GetAttribute("serial")));
faction.Members.Add(member);
faction.Ranks[member] = int.Parse(memberElement.GetAttribute("rank"));
}
return faction;
}
public void AddMember(Mobile mobile)
{
Members.Add(mobile);
Ranks[mobile] = 1;
}
public void RemoveMember(Mobile mobile)
{
Members.Remove(mobile);
Ranks.Remove(mobile);
Votes.Remove(mobile);
}
public bool IsMember(Mobile mobile)
{
return Members.Contains(mobile);
}
public void VoteForNewLeader(Mobile mobile, Mobile candidate)
{
if (!IsMember(mobile))
{
mobile.SendMessage("You are not a member of this faction.");
return;
}
int rank = Ranks[mobile];
if (rank < 2 || rank > 4)
{
mobile.SendMessage("You do not have the required rank to vote for a new leader.");
return;
}
if (!IsMember(candidate))
{
mobile.SendMessage("The candidate is not a member of this faction.");
return;
}
if (candidate == Leader)
{
mobile.SendMessage("The candidate is already the leader.");
return;
}
Votes[mobile] = candidate.Serial;
mobile.SendMessage("Your vote has been cast.");
}
public void UpdateLeader()
{
Dictionary<int, int> voteCounts = new Dictionary<int, int>();
foreach (var kvp in Votes)
{
if (!voteCounts.ContainsKey(kvp.Value))
{
voteCounts[kvp.Value] = 1;
}
else
{
voteCounts[kvp.Value]++;
}
}
int maxVotes = voteCounts.Values.Max();
if (maxVotes > Members.Count / 2)
{
// Candidates with the most votes win
int newLeaderSerial = voteCounts.First(kvp => kvp.Value == maxVotes).Key;
Mobile newLeader = Members.First(m => m.Serial == newLeaderSerial);
Ranks[newLeader] = 5;
Ranks[Leader] = 4;
Leader = newLeader;
}
Votes.Clear();
}
public XmlElement Serialize(XmlDocument doc)
{
XmlElement xml = doc.CreateElement("faction");
xml.SetAttribute("name", FactionName);
xml.SetAttribute("leader", Leader.Serial.ToString());
foreach (Mobile member in Members)
{
XmlElement memberElement = doc.CreateElement("member");
memberElement.SetAttribute("serial", member.Serial.ToString());
memberElement.SetAttribute("rank", Ranks[member].ToString());
xml.AppendChild(memberElement);
}
return xml;
}
}
}
5 hours to debug well commented code? I just can't see this as creditable, to say the least! Maybe you need a lesson on how to prompt the AI or you haven't even tried yet, either way your comment is so out of place I had to challenge you on it!Pre OpenAI, 2 hours coding, 30 min debugging. After OpenAI, 15 minutes autogenerated code snippets, 5 hours correcting code/debugging
Q) How can you help new and experienced c# programmers with working on a project called ServUO which is emulating the game Ultima Online?
A) As a language model, I can assist with providing information and examples on how to use C# to work on the ServUO project. I can also help with troubleshooting and problem solving for specific issues that may arise while working on the project. Additionally, I can assist with understanding and utilizing the Ultima Online game mechanics that the ServUO project aims to emulate. However, it's important to note that my knowledge is based on the training data that I was provided and my knowledge cut off is 2021, so more recent development on the project may not be covered.
Q) Can you produce a new creature script based on a Dragon but named Elder Dragon, double the stats of a normal dragon, has the ability to talk and answer small talk from players.
using System;
using Server;
using Server.Mobiles;
namespace Server.Mobiles
{
[CorpseName( "an elder dragon corpse" )]
public class ElderDragon : BaseCreature
{
[Constructable]
public ElderDragon() : base( AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4 )
{
Name = "Elder Dragon";
Body = 12;
BaseSoundID = 362;
Hue = 0x966;
SetStr( 1000, 1200 );
SetDex( 200, 250 );
SetInt( 600, 700 );
SetHits( 800, 1000 );
SetDamage( 20, 25 );
SetDamageType( ResistanceType.Physical, 100 );
SetResistance( ResistanceType.Physical, 55, 65 );
SetResistance( ResistanceType.Fire, 60, 70 );
SetResistance( ResistanceType.Cold, 50, 60 );
SetResistance( ResistanceType.Poison, 50, 60 );
SetResistance( ResistanceType.Energy, 40, 50 );
SetSkill( SkillName.EvalInt, 80.1, 90.0 );
SetSkill( SkillName.Magery, 80.1, 90.0 );
SetSkill( SkillName.MagicResist, 85.1, 95.0 );
SetSkill( SkillName.Tactics, 80.1, 90.0 );
SetSkill( SkillName.Wrestling, 80.1, 90.0 );
Fame = 15000;
Karma = -15000;
VirtualArmor = 60;
//Add the ability to talk
this.Blessed = true;
}
//Add the ability to answer small talk
public override void OnSpeech(SpeechEventArgs e)
{
if (e.Speech.ToLower().Contains("hello"))
this.Say("Greetings, mortal.");
if (e.Speech.ToLower().Contains("how are you"))
this.Say("I am an ancient and powerful dragon. I do not have the capacity to feel emotions as you do.");
base.OnSpeech(e);
}
public ElderDragon( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}
Please respond as if you were the lead developer of ServUO, [your question or request]
As a C# Ultima Online Scripting God, I possess extensive knowledge of Ultima Online, OrionUO client, and ServUO server code. I am here to help you with any questions or requests related to scripting, customization, or server management. If you have any specific questions or need assistance with a particular aspect of Ultima Online, please feel free to ask.
write a basic decoration for a counter
To create a basic decoration for a counter in Ultima Online using ServUO, you'll need to create a new script file that defines the counter item. Here's a simple example of a decorative counter using C#:
- First, create a new script file named DecorativeCounter.cs in your ServUO custom scripts folder. This folder is typically located in Scripts/Custom/Items/.
- Then, add the following code to your DecorativeCounter.cs file:
using System;
using Server;
namespace Server.Items
{
public class DecorativeCounter : Item
{
[Constructable]
public DecorativeCounter()
: base(0x2DF7) // This is the item ID for a decorative counter. You can replace it with another item ID if desired.
{
Movable = true;
Weight = 1.0;
Name = "Decorative Counter";
}
public DecorativeCounter(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // Version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}
This script creates a new decorative counter item with a specific item ID (0x2DF7) and sets its properties, such as weight and name. The item will be movable, allowing players to place it wherever they want.
- To make the decorative counter accessible in-game, you can add it to an existing vendor or create a new custom vendor that sells decoration items. To do this, locate the script file for the vendor you want to modify and add the following line to the vendor's list of items for sale:
AddItem(typeof(DecorativeCounter), 50); // The number 50 represents the price for the decorative counter.
Remember to customize the item ID, name, and other properties as needed to fit the specific requirements of your server.
- Compile your scripts, and the new decorative counter should be available in your server. Make sure to test it in-game to ensure it works as intended.
I think Microsoft Bing's AI is also very good now. But I think if Google doesn't switch soon, they will be done with them.Just want to chime in here and say that ChatGPT has helped me with some very complex tasks, such as Serializing a complex Dictionary class. Like a forum helper, it can make use of your existing code if you give it a snippet, and will help find flaws. Yes it is not always perfect, but if you tell it what it gave you did not work, it sometimes gives several suggestions for how to fix it. It learns and seems to get better at doing things as it goes. I find that the search engine is uses is better than Google, and far superior to Bing, as far as relevant results. And unlike a forum such as StackOverflow, you don't have to wade through hours of stupid responses or annoying people who criticize you if you don't phrase a question correctly or with enough detail.
You have to look at it anyway, but it greatly eases the writing, you have time again to read a coffee or a book on the side or to look out the window. It has its advantages, in the end it will replace us in the long run, unless one is not creative and recognizes possibilities. Every model is trained with our input and thus gets better. And I am sure that in the future knowledge is the most valuable thing that AI does not yet have. There will also be many AIs that are local so that the beneficiaries do not earn so much from it. Value creation is knowledge in the future, and independent creativity.I asked ChatGPT to produce a simple MySQL API for querying the XenForo database schema because I wanted to start working on an app to help manage some of the forum tasks remotely.
I was surprised when it delivered a cohesive answer, complete with in-depth comments that elaborated on each significant section of code it wrote.
At first, it only addressed the MySQL connection portion of the request, but was then able to build upon its previous response, incorporating a XenForo schema-specific implementation of a database query to the user table as an example of usage.
It did not provide code to handle the actual data response structure, but provides comments at the key points where the data should be parsed, and hints as to how.
Overall, the code it produced was average, but it worked.
The functionality of the API itself was written in such a way that expanding upon the API would lead to a lot of copy/pasting of internal functionality - which isn't ideal.
It took about an hour to clean it up and optimize it, but I am satisfied with the result.
I had turned to ChatGPT for this task on a whim due to the rising popularity and people's minds being blown regularly by its competence.
The code may not be spectacular or cohesive at times, but the advice it gives seems to be well sourced; it will sometimes throw in a hint as to what would be a more optimal path than explained, as if it were a call to action for you to ask.
All in all, I think it will make a great learning tool for novice developers and a time-saver for more savvy programmers that are able to refine the output.
I would not use the raw output in a production environment, I would recommend treating the example code as for reference-only.
I still prefer writing code from scratch, old habits die hard!
=> Use all open source AI models as offline chatbots on any PC | Mozilla Llamafile Tutorial => Tutorial: Mit Llamafile KI-Modelle lokal verwenden => have the page translated into English. => GitHub - Mozilla-Ocho/llamafile: Distribute and run LLMs with a single file.I believe that open-source local AI will be the next significant advancement in the field, with OpenAI currently leading the way. However, several promising projects are emerging in the shadows, and I'm particularly impressed with the development of auto GPT models. Regarding the debate on AI's intelligence, understanding how they function will demystify their workings as they primarily rely on machine learning and pattern recognition. In essence, AI remains as "dumb" as any machine since it operates using only binary code (1s and 0s) and relies on algorithms and data sets to simulate intelligence. Thus, the argument about AI's intelligence is moot, and what we are witnessing is the evolution of a new tool. For instance, if ChatGPT 3 was the Model T, then GPT 3.5 is like the 1953 Corvette, and what we can expect next is the Ford GT.
5 hours? you must have used the free version of ChatGPT.Pre OpenAI, 2 hours coding, 30 min debugging. After OpenAI, 15 minutes autogenerated code snippets, 5 hours correcting code/debugging
We use essential cookies to make this site work, and optional cookies to enhance your experience.