vans163 / LKEmuV2

The Last Kingdom Emulator
GNU General Public License v2.0
1 stars 1 forks source link

Question on spell cast #1

Open minotaurrr opened 6 years ago

minotaurrr commented 6 years ago

@vans163 Thanks for sharing this, I'm not sure if you're still managing this but I was playing around with it and came across a bug I couldn't figure out how to fix.

Under Scripts/Spells.cs

SpellList.Add("VIEW", new Spell("VIEW", 7, E_MagicType.Target2, new SpellSequence
                 (0, 0, 0, 0, 0xFF, 0, 0))
            {
                ClassReq = (int)E_Class.Any,
                ManaCost = 5,
                Cast = new Action<Player.LeafSpell, Player.Player, Mobile, Point2D>(
                    (Player.LeafSpell s, Player.Player p, Mobile tar, Point2D tarloc) =>
                    {
                        CastView(s, p, tar);
                    })
            });

and the CastView function is this

public static void CastView(Player.LeafSpell spell, Player.Player caster, Object.Mobile target)
        {
            if (target == null)
                return;

            if (target is Craft)
            {
                var cstd = target as Craft;
                StringBuilder sb = new StringBuilder();
                sb.Append(string.Format("The contents: ", cstd.Name));
                foreach (var ob in cstd.Contents)
                    sb.Append(string.Format("{0} ", ob.Value.Name));
                caster.WriteWarn(sb.ToString());
            }
    }

I tried adding another condition for when it's casted on an item that's on the ground like if(target is Item) but the spell doesn't even cast for some reason.

I added Console.WriteLine(target) just to see whether it's even being executed but it's not. It's almost like the function just doesn't exist when it comes to items on the ground.

Any idea why this happens?

etherplague commented 3 years ago

Thats because the target its looking for in spell is mobile, I ran into this same issue when trying to code pick up sell to work. Unfortunately I switched to fixing and adding other things in the server version of lkemuv2 I'm working on. I know this is an old comment I'm replying to but I have just recently started trying to flesh out the lkemuv2 server. Also, @vans163 if this is still an interest of yours and youd like to collaborate I can point you to my subreddit of my progress and send my edits over. I have put around ~30+ hours into coding the server. Thats probably mainly due to reverse engineering your code to help better understand how to implement things. If interested subreddit is https://www.reddit.com/r/TheLastKingdomMMO/

vans163 commented 3 years ago
 Thats probably mainly due to reverse engineering your code

I got a good laugh out of this one haha.

Il join the sub and check it out, pretty sweet. feel free to fork it I do not think I would be working on it anytime soon (mostly lack of interest), I can def peek around.

etherplague commented 3 years ago

Hey I appreciate the go ahead. Got it going pretty good, pick up was rough but it works great now but thunder storm is a beast trying to get a sprite on each target in range of a point... Gonna take some brain power.

Sent from Yahoo Mail on Android

On Thu, May 20, 2021 at 4:19 PM, @.***> wrote:

Thats probably mainly due to reverse engineering your code

I got a good laugh out of this one haha.

Il join the sub and check it out, pretty sweet. feel free to fork it I do not think I would be working on it anytime soon (mostly lack of interest), I can def peek around.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

Chajac commented 1 year ago

Would you consider releasing your code as to where you're at right now etherplague? Couldn't see any repos on your profile.

Hey I appreciate the go ahead. Got it going pretty good, pick up was rough but it works great now but thunder storm is a beast trying to get a sprite on each target in range of a point... Gonna take some brain power. Sent from Yahoo Mail on Android On Thu, May 20, 2021 at 4:19 PM, @.***> wrote: Thats probably mainly due to reverse engineering your code I got a good laugh out of this one haha. Il join the sub and check it out, pretty sweet. feel free to fork it I do not think I would be working on it anytime soon (mostly lack of interest), I can def peek around. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

etherplague commented 1 year ago

Chajac and anyone else interested in the work I was doing on lk join me on my reddit and discord reddit:r/TheLastKingdomMMO and discord:https://discord.gg/MkPkxzZn