Page 1 of 1

Magic Reflect charge consumption

Posted: Sun Oct 03, 2010 10:11 pm
by Mikel123
Charge consumption on Magic Reflect items is still a little wonky. I quickly dressed and undressed an item of MR three separate times. The first time, it used 0 charges. The second time, it used 2 charges. The third time, it used 1 :-)

What got me thinking about this in the first place was that I thought it didn't make sense that it would immediately use a charge upon arming, since in that very instant it cannot possibly reflect a spell. It would make more sense if the first charge was used after 5 seconds had passed.

I also am not certain that it should use a charge when it actually reflects a spell. (it's nearly impossible for me to tell if it does currently, but I thought it did). Derrick pasted the code for it from the demo:

Code: Select all

ONEVENT( unequip )(object unequippedfrom)
{
  detachScript(unequippedfrom, "reflctor");  // Remove effect
  return(0x01);
}

ONEVENT( time , "min:**" )()  // once per UO minute, or 5 seconds realtime, 20 ticks
{
  if(isEquipped(this))
  {
    object Q4E2 = containedBy(this);
    if(Q4E2 == NULL())
    {
      return(0x01);
    }
    if(!Q53Z())   // Failed to consume charge?
    {
      detachScript(Q4E2, "reflctor");
      detachScript(this, "wearrflct");
    }
    else  // Charge was consumed
    {
      attachScript(Q4E2, "reflctor");  // apply (or reapply) effect
    }
  }
  return(0x01);
}
Anyways, two questions:

1) Does this code above state that a charge is used upon equipping?
2) Does this code above state that a charge is used upon actually reflecting a spell?

Re: Magic Reflect charge consumption

Posted: Sun Oct 03, 2010 11:23 pm
by Kaivan
To answer your questions:

1. Yes, a charge is consumed upon equipping an item, but it is not shown in the code that you pasted (its part of the equip event).
2. No, a charge is used every 5 seconds. All this code does is attach the reflect script to a player, while they are wearing an item that has reflect charges. It will continually use a reflect charge every 5 seconds, reapplying the script as necessary, until all charges have been exhausted. At the 5 second interval just after the last last charge is used, it will remove the reflect script from the player.

Re: Magic Reflect charge consumption

Posted: Mon Oct 04, 2010 6:44 am
by Mikel123
Got it, OK thanks for the clarification.

Makes sense to use an initial charge for every other item but this one; I guess the programmers got lazy :-)

So, my items of spell reflection with 1 charge are essentially useless, right?

Re: Magic Reflect charge consumption

Posted: Thu Nov 11, 2010 11:51 am
by dren
Reflect items should only use charges when a spell is reflected. I've noticed that this is bugged here also...

Re: Magic Reflect charge consumption

Posted: Thu Nov 11, 2010 7:57 pm
by Kaivan
Actually, magic reflect items should use a charge once every 5 seconds regardless of whether a spell has been reflected or not. This is reflected in the OSI code, and is reflected in newsgroup postings from the era that consistently show magic reflect items to be essentially useless.

Re: Magic Reflect charge consumption

Posted: Thu Nov 11, 2010 9:45 pm
by Faust
dren wrote:Reflect items should only use charges when a spell is reflected. I've noticed that this is bugged here also...
Only during UOR and forward.

Re: Magic Reflect charge consumption

Posted: Fri Nov 12, 2010 2:21 pm
by Jester
Kaivan wrote:Actually, magic reflect items should use a charge once every 5 seconds regardless of whether a spell has been reflected or not. This is reflected in the OSI code, and is reflected in newsgroup postings from the era that consistently show magic reflect items to be essentially useless.
Wait a second I might be misunderstanding here... If I have an item with 100 charges equipped and 5 seconds pass so it uses 1 of them up, I'm left with 99, doesn't that mean that I have a charge of SR on me at that time? Or does a mob/player have to cast a spell at me at the exact time that the item uses a charge for it to work?

Re: Magic Reflect charge consumption

Posted: Fri Nov 12, 2010 3:30 pm
by Kaivan
Every 5 seconds, the item uses up a reflect charge and attempts to apply magic reflect to you. If you already have magic reflect on you, the charge is effectively wasted. This means that if a person shoots a spell at you, as long as magic reflect is applied, the spell is reflected. To give you some examples, lets assume that someone casts harm on you while wearing a reflect item.

When you equip a reflect item, the reflect spell is automatically added to you and a charge is used, so if a person casts harm on you right after you equip the item, the spell is reflected. The same case is true if he waits 2 or 3 seconds to hit you as well. Now, supposing that the person cast harm on you right after you equipped the item and pulled down your reflect as a result, if he waits another 5 seconds and then casts harm on you again that spell will also be reflected. This is because 5 seconds after you equipped the item, another charge is used reapplying the reflect to you as necessary. So, in any general situation, if the second spell hits you after a new reflect is applied by the item, it too will be reflected. Finally, if we now suppose that after pulling down your reflect a second time (which is now about 5.5 seconds after equipping the item in the first place), 2 seconds later your opponent casts another harm. In this case, since it has not been 5 seconds since the last time that the reflect spell was applied to you, the spell is not reflected back because you do not have the spell adhering to you in the first place.

I hope that covers how the actual item works in enough detail.

Re: Magic Reflect charge consumption

Posted: Sat Nov 13, 2010 4:45 am
by Jester
Thanks Kaivan, I get it now :>

But imo, it doesn't make SR items useless, I think they sound pretty nifty :)

Re: Magic Reflect charge consumption

Posted: Sat Nov 13, 2010 4:46 am
by nightshark
Jester wrote:Thanks Kaivan, I get it now :>

But imo, it doesn't make SR items useless, I think they sound pretty nifty :)
magic reflect items are amazing when used correctly

and kaivan i think theres an error in what you said. currently reflect items renew themselves if your reflect is pulled off.

eg:
Harm
Harm
Harm
Harm

all casted in succession, will be reflected while a MR item is equipped, regardless of whether there is 5 seconds between harms. It seems to take about 0.5s for magic reflect items to reapply themselves when reflect is removed.

Re: Magic Reflect charge consumption

Posted: Sat Nov 13, 2010 6:00 am
by Kaivan
If that's currently the case, that shouldn't be happening. In this post, Batlin outlines the time scale for UO time to real time. Every UO minute is equivalent to 5 real seconds, and in any script with the following line of code

Code: Select all

#on time<"min:**">
the script will trip every time the UO minute changes (the * signifies any change in that column). This means that every 5 seconds the script should attempt to re-apply the reflect script to you. This should give you an open window where a player can pull down your reflect and then hit you with spells in between 5 second intervals.