item decay whilst inside backpack ? / timespan datetype ?

Discussion about the technical aspects of scripting. Ask about all issues involving your freelance projects here.
Locked
User avatar
OldManAlewar
Legendary Scribe
Posts: 408
Joined: Sun Jan 06, 2008 3:42 pm

item decay whilst inside backpack ? / timespan datetype ?

Post by OldManAlewar »

every google i try returns timeSTAMP information or the equivalent i end up with a sloppy bucket of FAIL.

Code: Select all


timespan ts = new timespan();
ts. ?????????   <-- what do i do here ?
QuestMarker.DecayTime = ts;

also, will it even decay while in the backpack ? i'm rigging it so a completed quest can be redone when x amount of time has passed.


this belongs in "coding talk": i suck rooster
LordGaav
Adept Scribe
Posts: 49
Joined: Fri Sep 12, 2008 4:09 pm

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by LordGaav »

TimeSpan is part of the C# System namespace, use it like this:

Code: Select all

Timespan ts = System.Timespan.FromDays(1);
Timespan has various From* methods that create a Timespan object for the values given.

You can also just use the constructor:

Code: Select all

public TimeSpan(int hours, int minutes, int seconds);
public TimeSpan(int days, int hours, int minutes, int seconds);
User avatar
OldManAlewar
Legendary Scribe
Posts: 408
Joined: Sun Jan 06, 2008 3:42 pm

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by OldManAlewar »

sadly, its a read only property of Item/BaseItem for which there is no set()
User avatar
OldManAlewar
Legendary Scribe
Posts: 408
Joined: Sun Jan 06, 2008 3:42 pm

BUMP!

Post by OldManAlewar »

Code: Select all

  public override TimeSpan DecayTime
        {
            get
            {
                return TimeSpan.FromDays(7);
            }
        }

        public bool Decays
        {
            get { return true; }
        }
but the question remains ... can items even decay INSIDE a backpack?

(in this case, players could do the quest once per character, per week )
User avatar
+Colibri
Administrator
Posts: 4068
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by +Colibri »

Please don't trash the backpacks of our poor players :)

If you have a regular Quest typeof QuestSystem with QuestObjective-s, then in your

MyQuest : QuestSystem
{
put:
public override TimeSpan RestartDelay{ get{ return TimeSpan.FromMinutes( 30.0 ); } }
}


You can check how it's done in the grave digging quest:
http://www.runuo.com/forums/attachments ... st-2.0.zip
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
User avatar
OldManAlewar
Legendary Scribe
Posts: 408
Joined: Sun Jan 06, 2008 3:42 pm

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by OldManAlewar »

+Colibri wrote:Please don't trash the backpacks of our poor players :)

If you have a regular Quest typeof QuestSystem with QuestObjective-s, then in your

MyQuest : QuestSystem
{
put:
public override TimeSpan RestartDelay{ get{ return TimeSpan.FromMinutes( 30.0 ); } }
}


You can check how it's done in the grave digging quest:
http://www.runuo.com/forums/attachments ... st-2.0.zip
the decay is on the quest marker, not on the BACKPACK :P
User avatar
OldManAlewar
Legendary Scribe
Posts: 408
Joined: Sun Jan 06, 2008 3:42 pm

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by OldManAlewar »

also, i couldnt find what you pointed me to. (i found the file, just not where they set that little snippet of code )

either i fix this or i have to redo the logic of the quest :S
User avatar
+Colibri
Administrator
Posts: 4068
Joined: Sat Feb 25, 2006 4:08 pm
Location: static void Main

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by +Colibri »

Aha, as for the question itself. Just looking at the source Item.cs (you can download it from runuo), there's a function there:

Code: Select all

		public virtual bool OnDecay()
		{
			return ( Decays && Parent == null && Map != Map.Internal && Region.Find( Location, Map ).OnDecay( this ) );
		}
So i guess you need to put in your script something like this:

Code: Select all

		public override bool OnDecay()
		{
			return ( Decays && Map != Map.Internal && Region.Find( Location, Map ).OnDecay( this ) );
		}
(just removed the parent==null and made it so it's an override)
+Colibri, Administrator of UO Excelsior Shard

Don't know what the purpose of your life is? Well then make something up! ;)
(Old Colibrian proverb)
User avatar
OldManAlewar
Legendary Scribe
Posts: 408
Joined: Sun Jan 06, 2008 3:42 pm

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by OldManAlewar »

i solved it with a trashbarrel timer :) (i still exist, and the .delete is called ONLY on the invisible marker)

now for some slight debugging of the quest .... (been saying that for 2 weeks now)
User avatar
Harabakc
Legendary Scribe
Posts: 467
Joined: Thu Jun 22, 2006 2:43 pm

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by Harabakc »

The peerless quests have decay timers in them, I'm fairly sure that my stacks of adam's ribs decay 1 at a time even though it's in a stack. When the 30 days is up it just disappears out of the pile.
LordGaav
Adept Scribe
Posts: 49
Joined: Fri Sep 12, 2008 4:09 pm

Re: item decay whilst inside backpack ? / timespan datetype ?

Post by LordGaav »

Harabakc wrote:The peerless quests have decay timers in them, I'm fairly sure that my stacks of adam's ribs decay 1 at a time even though it's in a stack. When the 30 days is up it just disappears out of the pile.
Yup, the timers simply have a method that gets called when the specified duration is up. You can do basically anything in that method.
Locked