I've been learning to modify scripts well enough, but some things I just can't get to work.
In this case, I can make a function that can read the Luck from PlayerMobile, but I can't get that to pass to any other functions in a script, and when I try to add the (PlayerMobile whatever) to existing scripts they throw an error.

Take for example the craft satchels from heartwood quests.
Code:
    public class FletcherCraftsmanSatchel : BaseCraftsmanSatchel
    {
        [Constructable]
        public FletcherCraftsmanSatchel()
            : base()
        { 
            if (this.Items.Count < 2 && 0.5 > Utility.RandomDouble())
                this.DropItem(Reward.FletcherRecipe());
				
            if (0.01 > Utility.RandomDouble())
                this.DropItem(Reward.FletcherRunic());
        }

It is simple enough to modify it so that Luck/100 % be added to the chance for a recipe, but I can't get it to read from the player inside the function, which for some reason I cannot add parameters to without it breaking, and can't get it to read the value from another function in the script - even set to public.
 
Last edited by a moderator:
Do you mean you want to pass the Luck of the player to the constructor of the Satchel?

For example, the player kills a monster, the monster drops a Satchel, it reads the player's Luck that killed the monster, that Luck is passed into the Satchel's constructor, and used in the above code. Is that what you are looking for?
 
Essentially, yes, but the problem seems to be limited to existing scripts, and only certain of them - namely existing scripts that fill a container.

Outside of those, I don't have any problems getting the data... even to the point of creating an additional 'harvest' system from the ground up that uses Luck extensively (archaeology) and the only trouble I had was that I kept running into the items the game has *cough* interesting spellings for.

When I try to add parameters to existing functions that fill anything, it rejects them telling me they don't have a constructor made for "0 arguments" and when I make my own functions to read the value and assign it to a public variable - they don't recognize the variable exists.

I suspect I am missing something obvious, but C## is foreign to me. I worked almost exclusively in x86 assembler until we migrated the railway network to Java in the last three years before I retired. I understand the components and the logic, but my grasp of the syntax is weak.
 
Not sure what you mean by functions that "fill anything" but what I was thinking was just create another constructor, like this:

Code:
    public class FletcherCraftsmanSatchel : BaseCraftsmanSatchel
    {
        [Constructable]
        public FletcherCraftsmanSatchel()
            : this(0)
        {
        }
       
        [Constructable]
        public FletcherCraftsmanSatchel(int luck)
            : base()
        {
            double bonus = (double)(luck/100);
            if (this.Items.Count < 2 && 0.5 > Utility.RandomDouble())
                this.DropItem(Reward.FletcherRecipe());
               
            if ((bonus + 0.01) > Utility.RandomDouble())
                this.DropItem(Reward.FletcherRunic());
        }

In the creature that drops this on death, pass the LastKiller's luck to the constructor of the satchel.
 
Not sure what you mean by functions that "fill anything" but what I was thinking was just create another constructor, like this:
...

In the creature that drops this on death, pass the LastKiller's luck to the constructor of the satchel.
Filling containers as the purpose of the script, like the boxes and satchels you get from quests and the pre-made TC containers for materials and things.

As I said though, the problem is specific to scripts dealing with quests (and those instigated by gumps).
A mobile's corpse, as you suggest, can just reference the mobile "killer."
A resource node or equivalent can use -as they do in all resources you can interract with through an object- "from."

But I haven't been able to find a method to reach the player that caused scripts that are called by gumps such as 'Talk' or the completion of a quest.
 
But I haven't been able to find a method to reach the player that caused scripts that are called by gumps such as 'Talk' or the completion of a quest.

If it is a "BaseQuest" then the player is referenced by "Owner". If it is a "QuestSystem" then the player is referenced by "From".
 
Back