Rune Central http://runequake.com/forums/ |
|
[code] Dead player smashed in door - drops out of level http://runequake.com/forums/viewtopic.php?f=2&t=802 |
Page 1 of 1 |
Author: | Bam [ Thu Jul 21, 2005 2:16 am ] |
Post subject: | [code] Dead player smashed in door - drops out of level |
Here's a cool little function for preventing players' bodies/heads getting smashed in doors. I tested many doors and it works perfectly everytime, even with platforms. Just after the if condition: if (self.flags & FL_ONGROUND) in PlayerDeathThink, put: Code: if (pointcontents (self.origin) == CONTENT_SOLID) { set_safeorigin (self.origin); droptofloor (0, 0); } Then, the function: Code: // I use setorigin () to continually update
// your origin instead of using "from" the // whole way through, because I had to use // droptofloor () (pointcontents doesn't // always register correctly, Grr Quake C). void (vector from) set_safeorigin = { local float p, safe, giveup, type, n; local vector oldfrom; local entity spot; p = pointcontents (from); // Origin is already safe if (p != CONTENT_SOLID) return; oldfrom = from + '0 0 20'; while (!giveup && !safe) { from = oldfrom; while (n < 50 && !droptofloor (0, 0)) { n = n + 1; if (type == 0) from_x = from_x + 1; else if (type == 1) from_y = from_y + 1; else if (type == 2) from_x = from_x - 1; else if (type == 3) from_y = from_y - 1; from_z = from_z + 0.5; setorigin (self, from); p = pointcontents (self.origin); } // This takes care of most (even all?) the // problems with 2 shutting doors, instead // of the 1 shutting door. What happens // otherwise is it thinks your not in a solid // when you're right in the crack of the // two doors when shut. if (type == 0) from_x = from_x + 2; else if (type == 1) from_y = from_y + 2; else if (type == 2) from_x = from_x - 2; else if (type == 3) from_y = from_y - 2; setorigin (self, from); if (pointcontents (self.origin) != CONTENT_SOLID) safe = 1; else { type = type + 1; n = 0; } // We've tested all 4 directions if (type >= 4) giveup = 1; } if (self.health < -40) setsize (self, '-16 -16 0', '16 16 56'); else setsize (self, VEC_HULL_MIN, VEC_HULL_MAX); // As a last resort... if (!safe || giveup) { spot = SelectSpawnPoint (); setorigin (self, spot.origin + '0 0 1'); } }; This code could probably be modified to make it even better. It seemed to work nicely though. EDIT: Lol, I noticed too many things wrong with this function. I had just made it and showed it without looking over it, fixed now. The players' heads may not be moved to the best height, but you could always fix that later . Bam |
Author: | Slot Zero [ Fri Jul 22, 2005 7:12 pm ] |
Post subject: | |
Thanks for the code! |
Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |