DGEvent-based Fighting patch for CircleMUD 3.0 bpl16 =================================================== by Kevin Doherty Introduction ------------ This patch is just a modification of the fighting engine such that it is event-based, using the dgevents event queue package by Eric Green. Every time set_fighting is called, an event is queued up. The event function fight_event returns the delay until the next event, based on the return value of the fight_delay function. stop_fighting cancels the current fighting event (if existant). Installation ------------ 1) Get dgevents and install it on your circle source tree. I used Circle 3.0bpl13a, and ended up having to put in one hunk manually (the declaration of pulse ("unsigned long pulse = 0;") in comm.c) 2) On top of that, in the primary circle directory (the directory immediately below the src directory), issue the following command: patch -p1 < fightevent.diff This should patch the code successfully. Note: while I'm happy to help out with any problems with my code, I'm not going to patch it in for you if you have modified source :) Differences in appearance ------------------------- As it is there's only one real difference in how the event-based engine looks compared to the regular perform_violence, and that is that when you're in a fight, you're not guaranteed that your hit will occur at the same time as your opponent's or anyone else's for that matter. This CAN be set up in set_fighting, but I'd kind of rather not do so as that code would need to be ripped out for anything other than emulating stock circle anyway. I'd appreciate feedback on this subject as I'm really undecided on what to do. While it would be possible to have a global variable along the lines of "emulate_stock" or something, I'm hesitant to put it in. Usage ----- Things should work roughly the same way for any code you've created. As long as set_fighting and stop_fighting are used exclusively as the interface to the fighting engine everything should be pretty groovy. One thing to keep in mind is the existance of the new event_fight field in char_player_specials. It's accessed through GET_FIGHTING (I know this isn't the greatest of macro names, but GET_FIGHT_EVENT was too long). Suggestions for usage --------------------- The main reason I really implemented this was ultimately to have non-round-based combat. Using event queues makes this MUCH easier, and my code is organized such that fight_delay can be easily modified to change it to a non-round-based fighting engine. I tested this using a very simple function that compared the character's strength, weight the weapon, and their dexterity, but there are a lot of ways to modify the equations to suit your opinion of what delays should be made. One final note on non-round-based combat: You'll probably want to change how haste works (or rather, where haste is checked). I was aiming for something that wouldn't change the player's view at all, so I left it the way it is, but I strongly advise that you change it. Final notes on code ------------------- Out of necessity, I changed the behavior of event_process slightly and added a new function to events.c, event_is_queued. I changed event_process so that it sets event->q_el to NULL before it calls the EVENTFUNC for the current event. This, in conjunction with event_is_queued, allows you to differentiate between a queued event and a currently executing event. (For instance, in this case, stop_fighting needs to know whether it can safely cancel the event. If it tried to cancel an event that's currently happening, the event code would dump core). Acknowledgements, et al. ------------------------ Thanks to Eric Green (ejg3@cornell.edu) for his cool dgevents package, and to Jeremy Elson for creating Circle in the first place. If you want to contact me, send me email at kdoherty@cosanostra.net.