RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Karma requirement possible?

I played many many years ago (pre-RunUO) on a shard that had Holy Armor and Unholy Armor. Each one had Karma requirements in order to arm/wear/use them. Is there anyway to do that now? I am VERY new to scripting and what little I do know I am self taught through trial and error, but I want to make some virtue based quests and would like to create some Heavenly/Hellish Armor but I would lke them to require either positive or negative karma in order to be used. I know you can make items raise or lower a players karma but can you make them do a karma check?
 

Morxeton

Sorceror
On your item you need to override OnEquip( Mobile from ), then check the karma of the mobile and return false if karma requirements aren't met.
 
Thank you Morxeton I will see if I can figure out how to do that. Like I said I am new and self taught to scripting and I while I know this might be a large undertaking I think it will be rewarding personally if I can get it working and be something that the players enjoy =) .
 

Bittiez

Sorceror
This is an example shirt that requires 100 karma:
I didn't test it, but it should work fine.

C#:
using System;
using System.Text;
using Server.Items;
 
namespace Server.Items
{
    public class TestShirt : Shirt
    {
        [Constructable]
        public TestShirt()
        {
            Name = "Test Karma Shirt";
        }
        public TestShirt(Serial serial) : base(serial) { }
 
        public override bool OnEquip(Mobile from)
        {
            if (from.Karma < 100)
            {
                from.SendMessage("Your karma is not high enough");
                return false;
            }
            return base.OnEquip(from);
        }
 
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
        }
    }
}
 
ok loaded with no problems and it would not allow me to put it on if i did not have at least 100 karma so works the way its supposed to. also tested for negative karma but when i changed the karma to -100 and set my karma -101 it would not allow me to wear the shirt saying that my karma was not high enough. So if I wanted to make it require a players karma to be -5000 or lower (-5001, -5002 etc) is it done the same or is it completely differently?
 

Bittiez

Sorceror
This code denies being able to wear the item IF the wearer's karma is <(less than) min(100) AND is also > (greater than) -100
In other words, if the user has more than 100 or less than -100 they can wear it, if they have anything between -100 and 100 it will deny them.

C#:
using System;
using System.Text;
using Server.Items;
 
namespace Server.Items
{
    public class TestShirt : Shirt
    {
        [Constructable]
        public TestShirt()
        {
            Name = "Test Karma Shirt";
        }
        public TestShirt(Serial serial) : base(serial) { }
 
        public override bool OnEquip(Mobile from)
        {
            int min = 100;
 
            if (from.Karma < min && from.Karma > -min)
            {
                from.SendMessage("Your karma is not high enough");
                return false;
            }
            return base.OnEquip(from);
        }
 
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
        }
    }
}
 

Morxeton

Sorceror
ok loaded with no problems and it would not allow me to put it on if i did not have at least 100 karma so works the way its supposed to. also tested for negative karma but when i changed the karma to -100 and set my karma -101 it would not allow me to wear the shirt saying that my karma was not high enough. So if I wanted to make it require a players karma to be -5000 or lower (-5001, -5002 etc) is it done the same or is it completely differently?
Just change your logic:
C#:
            if (from.Karma > -5000)
            {
                from.SendMessage("Your karma isn't low enough!");
 
                return false;
            }
 
Top