Hello.

I looking for a solution how to remove in servuo the possibility of the cast the spells with LRC stuff lower than 100 if caster havnt a reagents in his/her backpack. We try changes that on our testserver but still without effect.

The problem is that the current character with such LRC 50 can cast spells without magical reagents because only in case of LRC test failure is notified of their lack. Thus, you can for example train magery without any reagents via macro and constantly attempt to cast a spell from low level to GM.

I believe that a better solution would be to block such a possibility. At LRC < 100 - a toon would need to have the ingredients for a spell cast, but with chance that they will not consume reagents during the spell cast. And only with the LRC at 100 they does not need a magical ingredients in the bag to spell casting. It's prevent for example full character training without any one piece of reagents lost (consume) if toon got a very low LRC (by endless try to cast macro).
 
This is much more complicated than you might think. I am looking at the code for consuming reagents, and it looks like it calls the "ConsumeTotal" method of the container class (looking for regs in your pack.) ConsumeTotal will only return true if all of the items are able to be consumed, otherwise it will end up consuming one or more reagent(s), even though you don't have the other reagent(s) necessary to complete the spell. There might be ways to get around this, if you create one method that calculates the total number of regs required, divides by the LRC, and rounds up. Then create another routine that takes the new number of regs, and randomly determines which regs are still required. These new regs are passed to the ConsumeTotal call in the form of an array of types and amounts. (type[], amount[]).

I am actually intrigued by this question, so I will see what I can come up with in the next couple hours.
 
First - many thanks for your help Lokai.
Look please also in to spell.cs script. Here is a part of code:
public virtual bool ConsumeReagents()
{
if (m_Caster.AccessLevel >= AccessLevel.Counselor)
return true;

if (m_Scroll != null || !m_Caster.Player)
{
return true;
}

if (AosAttributes.GetValue(m_Caster, AosAttribute.LowerRegCost) > Utility.Random(100)
{
return true;
}


if (DuelContext.IsFreeConsume(m_Caster))
{
return true;
}

Container pack = m_Caster.Backpack;
if (pack == null)
{
return false;
}

if (pack.ConsumeTotal(m_Info.Reagents, m_Info.Amounts) == -1)
{
return true;
}


return false;
}

and

else if (!ConsumeReagents())
{
m_Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502630); // More reagents are needed for this spell.
}
Also here is a part of code from mageryspells.cs
public override bool ConsumeReagents()
{
if (base.ConsumeReagents())
return true;

if (ArcaneGem.ConsumeCharges(this.Caster, (Core.SE ? 1 : 1 + (int)this.Circle)))
return true;

return false;
}
but As I see it's a really problematic - as you rightlywrote. I check many of ways but still without effect. I wonder about the possible settings this in spells.cs (and set red lines to be used only under the condition that the character has reagents, needed for a spell or simple any mage reagents for mage spell /necro regs for a cast necro spell). In the worst case - if such a change is not possible - I'll probably considered the test for LRC dependence on the level of skills /magery or necro/ (although it's a little flawed solution).
 
Last edited:
Here is what I have come up with. Basically, what happens is...

1. If they have 100 or more LRC, then it returns true (meaning no regs are consumed and the spell can continue.)
2. If they have less than 100 LRC, it checks to make sure that there is at least 1 of each of the required regs in their pack or else it returns false, meaning no regs are consumed, but the spell fails.
3. If they have at least 1 of each of the required regs, then it tests LRC to the Random number, and if the LRC is higher then it returns true.
4. If LRC is lower then it tries to consume the regs, and the spell continues after that.

Code:
     public virtual bool ConsumeReagents()
     {
       if (m_Scroll != null || !m_Caster.Player)
       {
         return true;
  }

  int LRC = AosAttributes.GetValue(m_Caster, AosAttribute.LowerRegCost);
  int random = Utility.Random(100);

  if (LRC >= 100) return true;
   
       Container pack = m_Caster.Backpack;

  if (pack == null) { return false; }

  foreach (Type t in m_Info.Reagents)
  {
  if (pack.FindItemByType(t) == null)
  {
  m_Caster.SendMessage("Missing {0}", t.Name);
  return false;
  }
  else
  {
  if (Core.Debug) m_Caster.SendMessage("Found {0}", t.Name);
  }
  }

  if (LRC > random)
  {
  if (Core.Debug) m_Caster.SendMessage("LRC = {0}, random = {1} so returning TRUE.", LRC, random);
  return true;
  }
  if (Core.Debug) m_Caster.SendMessage("LRC = {0}, random = {1} so returning FALSE.", LRC, random);

       if (DuelContext.IsFreeConsume(m_Caster))
       {
         return true;
       }

       if (pack.ConsumeTotal(m_Info.Reagents, m_Info.Amounts) == -1)
       {
         return true;
       }

       return false;
     }
 
Back