Showing posts with label Debugging. Show all posts
Showing posts with label Debugging. Show all posts

13 August 2013

The Back-up Back Up Plan

My creative patch for my current script did not work as intended, which means I go to Plan B.  Or am I now on Plan C?

Anyways, work continues on it, although sometimes it is discouraging.  I want to get it done and away from me so that I may work on something else, but then I also want it to work well.

Writing bad code is easy!  It's the good stuff which takes time.

12 August 2013

Timing Is Everything

While putting the finishing touches on my latest script, I came across a wrinkle in which no amount of ironing would smoothen.

The script, like another script I recently completed, is a process which hangs out in the background and watches the goings-on of nearby NPCs.  The function of this script needs to know if the NPC is busy with a player.

I tested my script on my test server, and overall the script is looking sturdy.  It did fumble a little bit on the task of checking the availability of a NPC: the script could not seem to recognize that a player was bumping into a NPC.

As with the combat script, I think this too is a matter of bad timing on my part.  My derpy script is looking blindly for bump flags which may or may not have been set.  I think that I am checking too early in the clock cycle – way before the NPC/player bump has been processed.

So I have rigged a hack-ish solution.  It's not very pretty, but it looks as though it will get the job done.  Maybe.  I will test it and confirm that it works.  Or I will confirm that it does not work.

As the old saying goes, timing is everything.  I seem to have a genius for bad timing.

05 August 2013

Script Polishing

Today was a vacation day for me, so I got to stay home and do fun stuff: I spent my entire day debugging and polishing a new script (and this script is not in any way related to combat).

The script runs a new tool for v819, and I got it to a point where it works well enough, but it works well with vulnerabilities.  Being a rather frightened and slightly paranoid Yappy, I am working to seal off any perceived leaks and problems.  The last thing I want to have is a scripting misfire resulting in the injury of one of our gerbils.

I need to work fast.  The update is less than 48 hours away.  Does anyone know where I can buy some gerbil insurance?

04 August 2013

Did I Tag Yet?

I have learned far more about the internal mechanisms of combat than I had ever had hoped to learn.  Or cared to have learned.

Before pushing the v819 update out to the UpdateGMs, I wanted to get one more script submitted before the deadline.  And as the one who receives and packages the updates, I get to choose the timing of that deadline!

The script is a simple one on paper: monitor the combat of a monster and inform the script when the monster has tagged a player.  Simple, right?  In practice it is, and there are heaps of scripts that already handle this precise function (herpetids come to mind: if the herpetid hits the player, then the player becomes increasingly intoxicated).

The catch: my script is a sort of a supplemental script which kind of hangs out in the background.  It isn't as plugged into combat system the same way as, say, the monster AIs scripts are.  My script is an independent entity, if you will, and just observes combat.

I completed the script and tested it.  What a disaster.  I spawned several monsters running my monitoring script, and while the monsters were knocking the stuffing out from me, my monitoring script observed my beat-down in awed silence.  That was bad.  The script should have been triggered by the monster's first damage delivery, and nothing happened.

Back to the drawing board.  I added my debugging notices.  I recompiled the script.  I generated more monsters running my script.  I got pwned by my monsters.  I cried – not because my monsters pwned me, but because after reviewing the logs I saw that my script was receiving absolutely no notification of my entering combat and subsequent pwnage.  I added more debugging notices.  More monsters.  More beat-downs.  And a lot more of nothing from the script.

At this point I felt that I failed to understand the mechanics of Clan Lord combat, so I started researching and reading about it.  It's a fascinating mechanic, IF YOU LOVE MATH.  Out of desperation (and by this point I was also nearly out of time), I then turned to the ServerGM and described my problem.  What was I doing wrong?  Why was my script ignoring combat?

ServerGM had the answer: this was not so much of a scripting issue as it was a timing issue.  ServerGM described what was happening:
  • At the beginning of each frame, all of the combat flags are cleared (Clan Lord runs roughly five frames per second)
  • My goofy script would then check the status of the combat flags and see that no combat had taken place
  • Then sometime before the end of the frame, combat would take place, and the appropriate combat flags would get set
  • The frame ends, combat resolves, and then we go on to the beginning of the next frame.
ServerGM recommended a couple of approaches to help achieve my intention for the script.  These suggestions worked brilliantly, and my script now correctly recognizes a monster tagging a player.

Maybe you'll encounter this script in v819.  BUT YOU HAD BETTER PRAY THAT YOU DONT HAHAHahaha hoo boy.