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.
Maybe you'll encounter this script in v819. BUT YOU HAD BETTER PRAY THAT YOU DONT HAHAHahaha hoo boy.
No comments:
Post a Comment