Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Wave-based game Goto page 1, 2 Next

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Sat Aug 05, 2006 9:56 am Post subject: Wave-based game |

I'm trying to create a mapper-friendly wave-based game and have a few problems planning out the code. First, how might I go about making a monster angry at the player(s) as soon as it is spawned. Also, I have decided to let the mapper set the number of waves for the level with a key in worldspawn because I don't really want to put a cap on the number of waves.
My problem is that I also need some kind of mapper-set variables determining what resources are given to the player(s) each wave. I was thinking of doing this perhaps by having an entity placed by the mapper for each wave with the wave number and what to give to the player(s) on that wave as keys. But how do I get these entities to interact with every client without setting a new set of global variables for each wave and limiting the number of waves in the level?
I am trying to retain coop compatibility here too.
Sorry if I have not put this too clearly, can anybody help me?

Back to top |

Quake Matt Joined: 05 Jun 2005 Posts: 129 |

Posted: Sat Aug 05, 2006 10:41 pm Post subject: |

Now, let's see, I made a coop mod like this a while back. Can't remember everything about it though... I know I had the waves pre-coded in the QC, which was easy to do, but meant every map had the same monsters in it. Having an entity for each wave would certainly work though. How you'd access the entity would depend on how the waves work, but you'd probably need to use the find() function from the player entity. A global variable would hold the wave number and then, when the players need to be given new resources, you'd do something like:

Code:
local entity mywave; mywave = find(world, classname, "info_wave"); while (mywave) { if (mywave.wavenum == global_wavenum)
{
Do stuff...
}
mywave = find(mywave, classname, "info_wave");
}

The alternative is to turn on it's head and search for player entities from the wave entity.
As for monsters becoming angry, I think it's a simple case of just setting their .enemy field (wouldn't hurt to set their .goalentity field too). Your best bet is to look around in the FindTarget() function in ai.qc, since that's what they usually use when looking for players.
Here's the one I made, which might be of some use if you can understand my shoddy code!
Hope this helps!

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Sun Aug 06, 2006 12:05 am Post subject: |

Great, thanks!

Back to top |

FrikaC Site Admin Joined: 08 Oct 2004 Posts: 947 |

Posted: Sun Aug 06, 2006 2:28 am Post subject: |

Every time I see this topic, I think "A game based entirely on the sound() function".

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Sat Aug 12, 2006 8:39 pm Post subject: |

I'm still having trouble with this i'm afraid. I've got a few more questions. Whenever I spawn monsters close to each other (but still with a reasonable gap between them) they seem to be getting stuck in each others bboxes despite the bbox dimensions having been set to quite a small size. Does anybody know why this is happening and how to fix it?
Another problem i'm having is that the find player code, as helpfully explained by Matt seems to either be turning up the info_player_start or nothing at all (it's difficult to tell right now on my test map which one). Here's how my code looks. What's wrong with this picture?

Code:
player = find(world, classname, "player"); while (player.classname != "player") player = find(player, classname, "player"); monster.enemy = player; FoundTarget();

And for the bonus point, how might I go about temporarily shutting off all the lights in a level (or at least giving that illusion) without breaking the existing light behaviour?

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Sat Aug 12, 2006 10:30 pm Post subject: |

Are you sure the monsters are getting stuck in eachother's bounding boxes, and not in the world? As for your findplayer function, I'm not sure what you're trying to accomplish there. The

Code:
while (player.classname != "player") player = find(player, classname, "player");

lines do nothing, so you can remove it. What your code should do is always find the first player. Not sure how it would be picking up info_player_start.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Sat Aug 12, 2006 11:36 pm Post subject: |

I put those in to double-check when it wasn't working really. The monsters that are being spawned are either trying to walk into the info_player_start or just walking through it as a result of their angle. They don't seem to be stuck in the world as they free themselves as soon as the adjacent monsters are killed.

Back to top |

Quake Matt Joined: 05 Jun 2005 Posts: 129 |

Posted: Sun Aug 13, 2006 12:25 pm Post subject: |

Quote:
The monsters that are being spawned are either trying to walk into the info_player_start or just walking through it as a result of their angle.

That's... odd...
When they get to and then pass the info_player_start, do the monsters turn around and go back through it, or do they continue until they hit a wall?
If they keep going in a straight line, the problem might be something to do with their yaw angle. You should probably check that you've given the monster a proper yaw_speed variable. If you aren't already using it, the standard monster initialisation routines are in monsters.qc, and you'll probably want to be looking into walkmonster_start_go() for the most part.

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Sun Aug 13, 2006 1:55 pm Post subject: |

I just checked the code and did a few tests and the yaw speed is definitely set correctly. I'm pretty sure they're going after the info_player_start. They walk into it as though it were solid and turn to face it wherever they begin to go off track.
I suspect the problem might be something to do with the custom monster i'm spawning. I'll swap it out and test.
EDIT: The info_player_start is at '0 0 0'. Perhaps they are chasing world instead?

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Sun Aug 13, 2006 10:08 pm Post subject: |

That's a hundred times more likely :O _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Mon Aug 14, 2006 8:49 am Post subject: |

I just figured find was coming up with partial matches or something. :S Anyway, I tried swapping out the monster but it didn't make any difference. The bbox is being set to '-8 -8 -24', '8 8 40'. Is that small enough? I'm tugging at straws here...

Back to top |

Quake Matt Joined: 05 Jun 2005 Posts: 129 |

Posted: Mon Aug 14, 2006 11:53 am Post subject: |

Well, if all else fails, it's time to use bprint! Add some code into the monster AI (ai_run() should be called every frame, found in ai.qc) that constantly spews out some information, like the classname and origin of the monster's enemy. Also, do the same for your player-finding function, before and after FoundTarget(). That should let you know what your monster's thinking and when it does and doesn't have the right target.
As for your bounding box, you've got it set to a non-valid size. I only learnt it fairly recently, but Quake BSP only supports two sizes and anything else will probably go a bit wonky. I can't remember exactly what the sizes are, but you can find them in defs.qc, called something like VEC_HULL_MIN and VEC_HULL_MAX for the upper and lower bounds.

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Mon Aug 14, 2006 1:48 pm Post subject: |

Right, i've managed to make the monsters angry at the player. I had to set the goalentity field as you mentioned before and set the monster's first think to run rather than walk. I've set the monster's bbox to a legal size now but they still don't like being spawned next to each other, which unfortunately is not something I can map around with this mod.
When the grey monsters are killed, the red ones are freed. They are not touching. Is this a problem with quake?

Back to top |

Lardarse Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK |

Posted: Tue Aug 15, 2006 11:58 pm Post subject: |

Code:
vector VEC_HULL_MIN = '-16 -16 -24'; vector VEC_HULL_MAX = '16 16 32'; vector VEC_HULL2_MIN = '-32 -32 -24'; vector VEC_HULL2_MAX = '32 32 64';

So you're limited to 32x32x56 and 64x64x88. Note that the origin can be anywhere within that bounding box. Items generally have it at the bottom, and so are '-16 -16 0' to '16 16 56'

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Wed Aug 16, 2006 12:22 am Post subject: |

Entity vs entity collisions don't have to abide by the hull sizes though, so if they're actually getting stuck in each other I can't see how that'd be the problem. _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT Goto page 1, 2 Next
Page 1 of 2

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group