I'm working on a "small" project & so far, so good. The only thing I'm having issues with at the moment is my gargoyles axe spawning wood elementals. I have the ele's scripted & can get 1 to spawn, but only one. If I try to use the default method used for Mining, they seem to spawn to the internal map only. So I'm using the method I used for FireRock Craft to spawn the fire rock ele. Only problem is, it will only spawn the 1 type. Heres the area for spawning them. The axe works great otherwise, mutates the vein like it should & will spawn the 1 ele, but I cant get the others to go in as well.
Code:
        private static Type[] m_Types = new Type[]
        {
            typeof(OakWoodElemental ),
            typeof(AshWoodElemental ),
            typeof(YewWoodElemental),
            typeof(HeartwoodElemental ),
            typeof(BloodwoodElemental ),
            typeof(FrostwoodElemental)

        };
        public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested)
        {
            if (tool is GargoylesAxe && def == m_Definition && 0.1 > Utility.RandomDouble() && HarvestMap.CheckMapOnHarvest(from, harvested, def) == null)
            {
                try
                {
                    Type tospawn = (m_Types[Utility.Random(m_Types.Length)]);
                    Map map = from.Map;
                    if (map == null) return;
                    BaseCreature spawned = (OakWoodElemental)Activator.CreateInstance(tospawn);
                    if (spawned != null)
                    {
                        int offset = Utility.Random(8) * 2;
                        for (int i = 0; i < m_Offsets.Length; i += 2)
                        {
                            int x = from.X + m_Offsets[(offset + i) % m_Offsets.Length];
                            int y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];
                            if (map.CanSpawnMobile(x, y, from.Z))
                            {
                                spawned.MoveToWorld(new Point3D(x, y, from.Z), map);
                                spawned.Combatant = from;
                                return;
                            }
                            else
                            {
                                int z = map.GetAverageZ(x, y);
                                if (map.CanSpawnMobile(x, y, z))
                                {
                                    spawned.MoveToWorld(new Point3D(x, y, z), map);
                                    spawned.Combatant = from;
                                    return;
                                }
                            }
                        }
                        spawned.MoveToWorld(from.Location, from.Map);
                        spawned.Combatant = from;
                    }
                }
                catch { }
            }
        }
If I try adding them this way
Code:
BaseCreature spawned = (OakWoodElemental || AshWoodElemental)Activator.CreateInstance(tospawn);
I get ; expected with a nice red line under Activator. Any suggestions? Full script added.
 

Attachments

  • Lumberjacking.cs
    13.6 KB · Views: 8
Well thats because you can not cast between two types like that. I wonder if you even need a cast for the Activator at all.

Anyway you could try to use BaseCreature as cast instead of the elemental directly
 
I'll give that a try & let you know.
[doublepost=1485361569][/doublepost]That worked beautifully. Does have one little interesting thing though. Doesnt matter what colored wood you're getting, the eles are random. Oak can get you any of them, as can Bloodwood, Yew. Kind of nice actually. Now all I need to do is figure out how to tone down how often they spawn. I'm getting one every few swings at 120 skill, which is a tad high for a spawn rate.
 
well the chance is set to 10% flat with the 0.1 you could lower that.

Also you can use the lowered value and increase it with the skilllevel so that the higher you are the higher chance you got. How you want to do it is up to you. And in case you want to swtich to Oak gives Oak elementals and so on you would probably need an switch block and from there you would then define wich one you spawn
 
I changed it to 0.05 & that worked wonders. 67 uses off the axe & only got 2 eles. Works for me. As for the randomness, I think I'll keep that. Adds a uniqueness to things. So many things are measured & rigid. x amount of critters per level in a champ spawn, do this to get that in a quest. Its usually the same. This could add spice to things. When using a garg pick while mining, you get an ele of the ore you're getting. Valorite gets a valorite ele. With this, oak can get you bloodwood, or frostwood could get you yew. I like it. :D Thanks for the help PyrO. Now on to the next headache inducer. lol *I'll be back* (probably)..
 
And now the next headache inducer, also involving elementals. Modifying the GargoylesKnife from OWLTR to work for a non OWLTR server. I have it working (sort of), but with issues. Using coding from WoodElementals as base, but in knife itself. Spawns eles as they should. No leather appears on original corpse & gives the "You see nothing useful to carve from the corpse" message (I can live with that if needed, but would rather not). When using the gargoyles knife on the spawned eles, there is a chance of it spawning another ele, but gives no message at all (I see exploit). That's the biggest problem, spawning an ele from an eles corpse.
Code:
            private static Type[] m_Types = new Type[]
        {
            typeof(SpinedLeatherElemental ),
            typeof(HornedLeatherElemental ),
            typeof(BarbedLeatherElemental),
            typeof(PyreticLeatherElemental ),
            typeof(GlacialLeatherElemental ),
            typeof(BaneLeatherElemental)

        };
            protected override void OnTarget(Mobile from, object target)
            {
                if (target is Corpse)
                {
                    Corpse c = (Corpse)target;
                    if (c.Owner is BaseCreature)
                    {
                        if (c.Carved == false && ((BaseCreature)c.Owner).Hides != 0)
                        if (0.5 > Utility.RandomDouble())
                        {
                    Type tospawn = (m_Types[Utility.Random(m_Types.Length)]);
                    Map map = from.Map;
                    if (map == null) return;
                    BaseCreature spawned = (BaseCreature)Activator.CreateInstance(tospawn);
                    if (spawned != null)
                    {

                        from.SendMessage("When you used your gargoyles knife on the corpse a leather elemental came to defend it.");
                        from.PlaySound(1098); //play m_yell
                        int offset = Utility.Random(8) * 2;
                        for (int i = 0; i < m_Offsets.Length; i += 2)
                        {
                            int x = from.X + m_Offsets[(offset + i) % m_Offsets.Length];
                            int y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];
                            if (map.CanSpawnMobile(x, y, from.Z))
                            {
                                spawned.MoveToWorld(new Point3D(x, y, from.Z), map);
                                spawned.Combatant = from;
                                return;
                            }
                            else
                            {
                                int z = map.GetAverageZ(x, y);
                                if (map.CanSpawnMobile(x, y, z))
                                {
                                    spawned.MoveToWorld(new Point3D(x, y, z), map);
                                    spawned.Combatant = from;
                                                return;
                                            }
                                        }
                                    }
                                    try
                                    {
                                        spawned.MoveToWorld(from.Location, from.Map);
                                        spawned.Combatant = from;
                                    }
                                    catch
                                    {
                                    }
                                }
                    else
                    {
                        from.SendMessage("You can't use gargoyles knife on that.");
                        from.PlaySound(1066); //play giggle sound
                        return;
                    }
                    c.Carved = true;
                    if (m_Knife != null)
                    {
                        if (m_Knife.UsesRemaining > 1)
                            m_Knife.UsesRemaining--;
                        else
                        {
                            m_Knife.Delete();
                            from.SendMessage("You used up your gargoyles knife");
                        }
                    }
                                else
                                {
                                    from.SendMessage("Nothing happened when you used your gargoyles knife on the corpse.");
                                    if (from.BodyValue == 401)
                                        from.PlaySound(787); // play f_cry
                                    else if (from.BodyValue == 400)
                                        from.PlaySound(1058); //play m_cry
                                }
                            }
                            else
                                from.SendMessage("You see nothing useful to carve from the corpse.");
                        }
                    }
                }
            }
 
Last edited:
Back