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.
We use essential cookies to make this site work, and optional cookies to enhance your experience.