ZPolyobject - ZScript Polyobject library This library adds Polyobject support to ZScript.
It makes querying polyobject state, such as current position, velocity and rotation, possible from within ZScript. In addition, it allows polyobject behavior to be customized through polyobject effectors.
Originally I wrote this code a while back for Dynamo's WIP Wolf3D-based mod, but I think it might also be useful on its own as a standalone library.
The code is heavily commented, so make sure to look through the source if you need any help.
class ExamplePolyobjectEffector: PolyobjectEffector { // void OnAdd() is run immediately after the effector is added by PolyobjectHandle override void OnAdd() { // self.Polyobject holds a reference to the affected polyobject Console.Printf("Added by polyobject %i", Polyobject.PolyobjectNum); }
// void PolyTick() is run every tic override void PolyTick() { // If too far away from initial position, return back if (Polyobject.GetPosDelta().Length() > 512) { Polyobject.MoveTo(NULL, Polyobject.GetOrigin(), 64); Console.Printf("there's no place like home"); } } }
Then pass an effector instance to PolyobjectHandler.AddEffector() method:
This effector keeps track of whether a polyobject door is open or closed, and sets/unsets the "block sound" flag on linedefs of its surrounding sector accordingly.
Wolf3D-like door behavior (PolyobjectWolfensteinDoorEffector.zs)
This effector gives polyobject door a more Wolf3D-like behavior:
1. The door will stay open if a player or a monster is in the way, and won't close until there's nothing blocking it. 2. If the door has started closing, using it will immediately make it open again.
A small test map is included, go to MAP01 to see them both in action.
Usage Feel free to use this library in your projects, as long as you credit me.
Credits Dynamo, for helping me find and fix bugs Kritzsie, for helping me out with ZScript
Not much I can say other than this is an absolutely fantastic package, which has been absolutely vital for my mod's continued progression. A hundred thumbs up
Sure, that would be great! There are some minor features I want to add at some point in the future (building a list of all linedefs that belong to a polyobject, methods that incapsulate calls to polyobject action specials, etc), but it's already fully functional as is.