Intro
The following code will allow you to add a gender requirements to items. This is useful if your male/female models have different UV co-ords, or if the models are completely different.
PYTHON MODFICATIONS
genesis.py
Find both instances of:
ItemRace,
Add after:
ItemGender,
Thats all for Genesis. Save and close the file.
mud\world\defines.py
Find
RPG_ITEMREQUIREMENT_CLASSREVERSED = 1 << 2
after it, add
# When checking required gender, see that the character has none of the listed. RPG_ITEMREQUIREMENT_GENDERREVERSED = 1 << 3
Close and save Defines.py
mud\world\shared\playdata.py
Find
# Races
if len(self.RACES):
setNewline = True
colorCode = 1 if self.REQFLAGS&RPG_ITEMREQUIREMENT_RACEREVERSED else 2
text.append(r'\c3Races: \c%i%s '%(colorCode,' '.join(self.RACES)))
after it, add
# Gender
if len(self.GENDERS):
setNewline = True
colorCode = 1 if self.REQFLAGS&RPG_ITEMREQUIREMENT_GENDERREVERSED else 2
text.append(r'\c3Gender: \c%i%s '%(colorCode,' '.join(self.GENDERS)))
Find
self.RACES = tuple(item[0] for item in con.execute('SELECT racename FROM item_race WHERE item_proto_id = %i;'%self.PROTOID))
after it, add
self.GENDERS = tuple(item[0] for item in con.execute('SELECT gendername FROM item_gender WHERE item_proto_id = %i;'%self.PROTOID))
Find
# Check if the character meets the race requirements.
if len(self.RACES):
# If the RPG_ITEMREQUIREMENT_RACEREVERSED flag is set,
# the character isn't allowed to have one of the listed races.
if self.REQFLAGS&RPG_ITEMREQUIREMENT_RACEREVERSED:
if cinfo.RACE in self.RACES:
# Can't use based on race.
return False
# Otherwise check the positive way (need race).
elif cinfo.RACE not in self.RACES:
# Can't use based on race.
return False
after it, add
# Check if the character meets the sex requirements.
if len(self.GENDERS):
# If the RPG_ITEMREQUIREMENT_RACEREVERSED flag is set,
# the character isn't allowed to have one of the listed races.
if self.REQFLAGS&RPG_ITEMREQUIREMENT_GENDERREVERSED:
if cinfo.SEX in self.GENDERS:
# Can't use based on race.
return False
# Otherwise check the positive way (need race).
elif cinfo.SEX not in self.GENDERS:
# Can't use based on race.
return False
Save and close Playdata.py
mud\world\item.py
Find
class ItemRace(Persistent):
itemProto = ForeignKey('ItemProto')
racename = StringCol()
after it, add
class ItemGender(Persistent):
itemProto = ForeignKey('ItemProto')
gendername = StringCol()
Find
# Require one of these races.
racesInternal = MultipleJoin('ItemRace')
after it, add
# Require one of these genders.
gendersInternal = MultipleJoin('ItemGender')
Find
def _get_races(self):
if self.raceList != None:
return self.raceList
self.raceList = tuple(race.racename for race in self.racesInternal)
return self.raceList
after it, add
def _get_genders(self):
if self.genderList != None:
return self.genderList
self.genderList = tuple(sex.gendername for sex in self.gendersInternal)
return self.genderList
Find
# Check if the mob meets the race requirements.
if len(proto.races):
# If the RPG_ITEMREQUIREMENT_RACEREVERSED flag is set,
# the mob isn't allowed to have one of the listed races.
if proto.requirementFlags&RPG_ITEMREQUIREMENT_RACEREVERSED:
if spawn.race in proto.races:
# Can't use based on race.
return False
# Otherwise check the positive way (need race).
elif spawn.race not in proto.races:
# Can't use based on race.
return False
after it, add
# Check if the mob meets the gender requirements.
if len(proto.genders):
# If the RPG_ITEMREQUIREMENT_RACEREVERSED flag is set,
# the mob isn't allowed to have one of the listed races.
if proto.requirementFlags&RPG_ITEMREQUIREMENT_GENDERREVERSED:
if spawn.sex in proto.genders:
# Can't use based on gender.
return False
# Otherwise check the positive way (need gender).
elif spawn.sex not in proto.genders:
# Can't use based on gender.
return False
Close and save Item.py
genesis\dbdict.py
Find
ItemRace,
after it, add
ItemGender,
Find
self.races = []
after it, add
self.genders = []
Find
def addRace(self,race):
if race not in self.races:
self.races.append(race)
after it, add
def addGender(self,sex):
if sex not in self.genders:
self.genders.append(sex)
Find
def clearRaces(self):
self.races = []
after it, add
def clearGenders(self):
self.genders = []
Find
for s in item.itemSets:
s.destroySelf()
after it, add
for s in item.gendersInternal:
s.destroySelf()
Find
del set['races']
after it, add
del set['genders']
Find
for race in self.races:
ItemRace(racename=race,itemProto=item)
after it, add
for sex in self.genders:
ItemGender(gendername=sex,itemProto=item)
Close and save Dbdict.py
Usage
To use the gender requirement with your items, simply add either
item.addGender("Female")
or
item.addGender("Male")
to the item.

