cmileto

Member
Im trying to drop a letter and a weapon into this bag depending on what race the character is. This is in charactercreation.cs
When i make a new toon they get the bag with only skillball, gold, and map... no weapon or letter. What am i doing wrong? Prob noob mistake.

Code:
Bag bag = new Bag();
bag.Hue = Utility.RandomList(102, 2432, 2450);
bag.Name = string.Format("{0}'s sack", m.Name);
PlaceItemIn(bag, 16, 51, new SkillBall(50));
PlaceItemIn(bag, 28, 51, new Gold(1000));
PlaceItemIn(bag, 40, 51, new TreasureMap(1, Map.Trammel));
{
if ((m.Race == Race.Elf) && (m.Race == Race.Gargoyle)) // is human
{
PlaceItemIn(bag, 52, 51, new Dagger());
PlaceItemIn(bag, 64, 51, new LetterofApprenticeship());
}
if ((m.Race == Race.Elf) && (m.Race == Race.Human)) // is gargoyle
{
PlaceItemIn(bag, 64, 51, new GargishDagger());
PlaceItemIn(bag, 64, 51, new LetterofGargoyleApprenticeship());
}
if ((m.Race == Race.Gargoyle) && (m.Race == Race.Human)) // is elf
{
PlaceItemIn(bag, 64, 51, new Bow());
PlaceItemIn(bag, 64, 51, new LetterofApprenticeship());
}
}
PackItem(bag);
 
You are using a conditional AND (&&), meaning that both things must be met. You didn't use a NOT operation (!), so there is no possible way that your IF statement can be true.

I think you meant to do this:
Code:
if ((m.Race != Race.Elf) && (m.Race != Race.Gargoyle)) // is human
{
PlaceItemIn(bag, 52, 51, new Dagger());
PlaceItemIn(bag, 64, 51, new LetterofApprenticeship());
}

However, even that is an odd way to do it. You should probably do this:

Code:
If (m.Race == Race.Human) // is Human
{
Place....
}
 
if (m.Race == Race.Gargoyle) // is Gargoyle
{
Place...
}
 
I had tried
If (Race == Race.Human) before and it didnt work.
No idea why I didnt try m.Race
or maybe it was m.Race==Human i tried, either way it didnt work and yours does.
ty!
 
Last edited:
Race == Race.Human would not work, because it would be assuming you mean (this.Race == Race.Human)

m.Race == Human would not work, because it would be assuming you mean (m.Race == this.Human)

Unless you are referring to the direct class you are in, you must declare the object. In this case the object you are checking is the Mobile, known as "m".

Thus m.Race is like saying "the Race of the Mobile". Just like you created a new object here:

Code:
Bag bag = new Bag();

You then did something to that object and had to declare it:

Code:
bag.Hue = Utility.RandomList(102, 2432, 2450);

Which is saying the new object "bag" should have a Hue of: and then pick a random from the list.

If you don't declare the object, it assumes you mean "this" which always refers to the class itself.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back