Page 1 of 1

item decay whilst inside backpack ? / timespan datetype ?

Posted: Thu Oct 09, 2008 12:49 pm
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

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

Posted: Thu Oct 09, 2008 12:55 pm
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);

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

Posted: Thu Oct 09, 2008 1:07 pm
by OldManAlewar
sadly, its a read only property of Item/BaseItem for which there is no set()

BUMP!

Posted: Mon Oct 13, 2008 3:29 am
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 )

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

Posted: Mon Oct 13, 2008 5:24 am
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

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

Posted: Mon Oct 13, 2008 8:25 am
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

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

Posted: Mon Oct 13, 2008 11:13 am
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

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

Posted: Mon Oct 13, 2008 11:32 am
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)

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

Posted: Tue Oct 14, 2008 6:03 am
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)

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

Posted: Tue Oct 14, 2008 6:05 am
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.

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

Posted: Tue Oct 14, 2008 12:19 pm
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.