-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WorldThingGoalReached Virtual #2823
Conversation
Called whenever an actor chasing a goal reaches it. - `Thing`: actor that reached the goal - `Inflictor`: The previous goal it just reached. - The new goal is stored in actor's `goal`.
can't you just, in a mod, save the old goal and check if the pointer changed and if the distance is close? what's the need for an actual event? |
Doing that to many, many monsters at once isn't healthy. |
if you run the checks from an inventory item (DoEffect) instead of from an event handler it should be fine |
That'd triple the number of tick-like function calls, and double the amount of thinkers - for my purposes specifically, it's about giving all the monsters some sort of path to follow within the map. No monster is excluded. |
would this be used in maps where thinker count is a bottleneck? for most maps rendering visible actors is way slower than ticking all actors |
Yes. |
still not convinced this is needed, but what's the difference in performance between using this event and going the inventory item route? |
The idea itself seems fine, imo. Positive use for this would be to have a cross-mod compatibility so that each mod doesn't have to make its own active listener (imagine having 10 mods which each attach one inventory just to do the same check for their own purposes). |
Rave nailed it. Especially for slaughter maps, and ones that are highly detailed like Sunder. And they have a lot of ACS stuff going on, which can also slow things down. |
Existing maps are rarely ever going to use the goal system and from the sounds of it this might not even be desired behavior. Keep in mind that any UDMF map that has a monster using a path will also trigger this event with zero way to validate if it's a map monster doing its thing or your own custom behavior. If you're going to check against custom nodes, you might as well program that behavior into the node handling itself. Goals already have the ability to activate specials on arrival. If you're doing this for a universal mod it really sounds like you're just making your own goals anyway, so spawn a goal special as well and have that execute a script of your choosing. I don't think this is conceptually a bad idea, but there's already ways to handle this and frankly, any mod mixing and matching goal handling is already going to be fighting against each other and, arguably worse, the mapper. |
self->Level->localEventManager->WorldThingGoalReached(self, oldgoal); | ||
} | ||
|
||
DEFINE_ACTION_FUNCTION(AActor, GoalReached) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be native
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GoalReached, GoalReached)
@@ -2370,6 +2371,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2) | |||
return 0; | |||
} | |||
|
|||
void GoalReached(AActor* self, AActor* oldgoal) | |||
{ | |||
if (self && self->Level) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self
doesn't need to be nulled checked since the VM ensures that this won't happen
@@ -2592,6 +2608,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi | |||
} | |||
actor->flags7 &= ~MF7_INCHASE; | |||
actor->goal = newgoal; | |||
GoalReached(actor, savedgoal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing destruction check before calling this since a goal special could delete it.
if (!(actor->ObjectFlags & OF_EuthanizeMe))
I, likewise, am not convinced that this is needed. The engine gets a constant barrage of features that have very niche use and in this case you can accomplish the same thing with a +NOBLOCKMAP goal actor that detects when it is bumped with for example CollidedWith. |
Last I tried that, it requires |
If it doesn't work you can also try an actor like this: class pathinggoal : actor
{
default
{
+INVISIBLE;
}
states
{
Spawn:
TNT1 A -1;
loop;
}
override bool CanCollideWith(actor other, bool passive)
{
if (passive)
{
// actor 'other' entered my area, do stuff here, keep this as short as possible because this will be called a lot
}
return false;
}
} |
I'll come back to this after I do a bit more testing. Closing this for now. |
Added WorldThingGoalReached(WorldEvent e).
Called whenever an actor chasing a goal reaches it, only by A_DoChase.
Thing
: actor that reached the goalInflictor
: The previous goal it just reached.goal
.