I'm trying to figure out a good way to allow monsters to trigger buttons (open certain doors, use certain plats...). The big problem is that entities with MOVETYPE_STEP don't actually come in contact with the "touch" of the button (I have changed the button touch function to include specific monsters), so that doesn't seem to be the way to go. I don't really want to change to MOVETYPE_WALK, unless I have to. It seems I can't treat a func_button as an entity, which would open up a lot of possibilities. So, I'm kinda at a loss.
I'm sure someone has this all figured out. Any help would be appreciated.
Monsters triggering buttons
Re: Monsters triggering buttons
rewrite movetogoal and walkmove to use traceboxes forward, and as part of that check the ents that they come in contact with.
or just add a tracebox/traceline after those calls to do it for you.
frankly the biggest issue is getting the monster to walk towards the button instead of the doorway.
or just add a tracebox/traceline after those calls to do it for you.
frankly the biggest issue is getting the monster to walk towards the button instead of the doorway.
-
- InsideQC Staff
- Posts: 1120
- Joined: Sat Oct 16, 2004 3:34 pm
Re: Monsters triggering buttons
func_button should still count as an entity but since they use a brush for a model you can't use .origin on them. Use something like:
First get your monster to find the button you want it to press, then have it get the actual origin of the func_button. After that, do a vlen to determine whether the button is within pushing distance and if so, have them trigger the button. Note that by default, buttons are designed to ignore anything that isn't a player, so you'll need to do some modifications to make the code not crash because its trying to print button messages to a monster.
Code: Select all
self.realorigin = (self.mins + self.maxs)*0.5;
-
- Posts: 52
- Joined: Thu Sep 30, 2010 6:46 am
Re: Monsters triggering buttons
Thanks for the replies. I'm using waypoints with built-in functions, so traceline/tracebox on every walkmove call is not needed.
The origin trick is what I used. I already had realorigin in my functions, but didn't think to use it there for whatever reason. It's working now though, and here's the code in case anyone needs something like this.
I could probably take out the temps, but I don't want to impact anything I haven't foreseen yet.
edit: one would also have to add the monster classname to the button_touch function.
The origin trick is what I used. I already had realorigin in my functions, but didn't think to use it there for whatever reason. It's working now though, and here's the code in case anyone needs something like this.
Code: Select all
.vector func_origin;
void() waypoint_button =
{
local entity butt, temps;
butt = find(world, classname, "func_button");
while(butt)
{
butt.func_origin = realorigin(butt);
if (vlen(self.origin - butt.func_origin) <= 80)
{
temps = self;
other = self;
self = butt;
button_touch();
self = temps;
}
butt = find(butt, classname, "func_button");
}
};
edit: one would also have to add the monster classname to the button_touch function.
-
- InsideQC Staff
- Posts: 1120
- Joined: Sat Oct 16, 2004 3:34 pm
Re: Monsters triggering buttons
Another, better trick you can use instead of classname checks is to use a .flags & FL_MONSTER check.silverjoel wrote: edit: one would also have to add the monster classname to the button_touch function.
-
- Posts: 52
- Joined: Thu Sep 30, 2010 6:46 am
Re: Monsters triggering buttons
That works, too. I only want certain monsters to be able to use buttons though, so classnames for me. I'll probably add a "can use buttons" check later, but for now, classnames.Dr. Shadowborg wrote:Another, better trick you can use instead of classname checks is to use a .flags & FL_MONSTER check.silverjoel wrote: edit: one would also have to add the monster classname to the button_touch function.