Sign in to follow this  

How to check mission is completed or not?

This topic is 3299 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, Our FPS game has 50 enemies in a scene. And mission is wiping out all of them. How should I check when the mission is completed? I've verified the number of entity each frame. It isn't a feasible solution, is it? Could anyone give me an algorithm to resolve the issue please? Thanks a lot, conlagia

Share this post


Link to post
Share on other sites
Checking the number of enemies each frame is the easiest and most straightforward solution available. It involves counting from 1 to 50 (in the worst case) once per frame, which is certainly within reach of any computer sold in the last decade. Why do you believe it is unfeasible?

Share this post


Link to post
Share on other sites
If you have a well-designed system, you could also just count every time an enemy is killed. It doesn't matter even if it is the enemy in question - just if any enemy is killed, check. To avoid a never-ending quest due to a bug of the last death not firing the check, I'd also use ToohrVyk's idea of checking every now and then while the quest is active - maybe every 5 seconds or so.

But what you need to decide is, "is it worth it, to me, for my product, to do this more efficiently?" We could all spend years making our projects better, run faster, easier to maintain, etc. But if something already works, doesn't need to be expanded, and has absolutely no intention on being expanded in the product, don't bother rewriting it until you need to.

Share this post


Link to post
Share on other sites
I assume you already have some sort of event system for when a unit dies. It should be a simple matter to hook into that.

If you keep it general enough, you can easily script any number of kill-related details: kill at least x enemies, don't lose more than x units, keep you kill ratio below x:y, or whatever else you can think of.

Share this post


Link to post
Share on other sites
Thanks for all credible helps. However, there are some aspects make me think that it can be better, more efficient.
- According to Prgramming a multiplayer FPS in DirectX, we have a litte time for application-specific processing such as game logic, time-consuming operations such as AI. Therefore it's needed to save time for them.
- All entities are connected by Messages, so I think there are other ways to check the entities existing, no need to count and verify in game loop (??? - not sure)

Thanks, one again. Any other ideas?
conlagia

Share this post


Link to post
Share on other sites
Quote:
Original post by conlagia
Thanks for all credible helps. However, there are some aspects make me think that it can be better, more efficient.
- According to Prgramming a multiplayer FPS in DirectX, we have a litte time for application-specific processing such as game logic, time-consuming operations such as AI. Therefore it's needed to save time for them.
- All entities are connected by Messages, so I think there are other ways to check the entities existing, no need to count and verify in game loop (??? - not sure)

Thanks, one again. Any other ideas?
conlagia


For More flexibility I would do the following:
-Have each enemy be able to generate a death event
-Create a KillCounter class
-Make KillCounter Subscribe to each enemies death event
-When handling a death event, KillCounter decrements a counter. Once the counter reaches 0, KillCounter ends the game (either sets a variables, or sends an EndGame event etc.)

In future implementations you can have different KillCounters subscribe to different enemies and perform different actions once the count expires. For example to end the game you either have to kill 20 easy guys or 2 bosses. etc.

Overall, only the parts that you plan to change in future should be appropriately generic. If there is only one way to finish a level in the game and you don't plan to change that, then don't bother over designing the game.

Share this post


Link to post
Share on other sites
If the game involves killing things to complete missions, then have a section of code that checks the player mission list every time the player kills something. The search should only happen on death, not per frame.

The player will have like what, maybe several dozen missions open? Scan those to see if this death fulfills a quest requirement, and decrement where appropriate.

The missions should handle the decrementing, possibly by a class function or the like, so that they can flag as complete and do their thing when their counter(s) hit zero.

Share this post


Link to post
Share on other sites
Quote:
Original post by conlagia
- All entities are connected by Messages, so I think there are other ways to check the entities existing, no need to count and verify in game loop (??? - not sure)

This is easily done. When player kills an enemy, decrease counter. When you spawn a new enemy, increase counter. You only have to check if counter is zero. That check can be done in the game loop (before spawning new enemies!) or when decreasing counter.

Share this post


Link to post
Share on other sites
Quote:
Original post by ville-v
Quote:
Original post by conlagia
- All entities are connected by Messages, so I think there are other ways to check the entities existing, no need to count and verify in game loop (??? - not sure)

This is easily done. When player kills an enemy, decrease counter. When you spawn a new enemy, increase counter. You only have to check if counter is zero. That check can be done in the game loop (before spawning new enemies!) or when decreasing counter.


This is a great way to keep track. So many people prefer to complicate something so simple. Just count for each enemy death from 50-0 or 0-50, when it hits 50, or 0 then the games shows the mission complete screen.

Share this post


Link to post
Share on other sites

This topic is 3299 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this