Movetypes, Lighttraces, and AI

Unfortunately, I can’t get my mind off of making a new gamemode, but before I consider starting it, I will need some insight as to how realistic it’s needs will be.

It will require a few things:
[ul]Some custom movetypes:
Think along the lines of mounting, fence-jumping, wall-climbing, and wall-hugging. They need to be smooth transitions too.
[/ul]
[ul]Dynamic Light traces:
I need a LOT of dynamic lights, and I need to detect how much light is on the player as a whole. Unfortunately, this needs to communicate with the server (so no render.GetLightColor) which brings us to AI.
[/ul]
[ul]Artificial Intelligence:
I’ve never been good with SNPC’s, and I’ll be needing some rather elaborate ones. They will need a wide variety of behaviors. A brief list of examples would be things like guarding, patrolling, wandering, investigating on 3 levels of alertness, pursuit, and idling in several forms (like alert, drunk, tired, etc.). [/ul]
So are these possible?

  1. You can’t essentially make new movetypes, but you can control the player’s movement. It will, however, involve rewriting a lot of stuff.

  2. If you know the position, direction and radius of the lights, you can fake the rays by doing a few traces. You can then approximate how much light is hitting the player.

  3. Valve’s npc system is pretty extensive and easy to use. Guarding is pretty much following an object and looking for targets, patrolling, wandering and investigating is also just following a path to a target. You can do all that with the predefined schedules and tasks. Drunk and tired will require custom tasks, though.

  1. MOVETYPE_CUSTOM (And in reality, the transitions don’t need to be that smooth, only the player’s view needs to be. So you can smooth his view with a calc view hook and some interpolation between transition points.)

  2. I’d actually recommend hull traces, that way they have a much higher chance of hitting the player with fewer traces needed.

  3. SNPCs are slow. Very slow. (With custom tasks) I’d actually recommend making your own psudo npc system with sents.

  1. Well I’d like it to be multiplayer so getting from point A to point B should be relatively smooth.
  2. Hull traces… How accurate will those be?
  3. How would I go about doing that?
  1. Right. Can I do physicssimulate on a player?
  2. Again, how accurate can I be with that?
  3. Alright cool. I’m still not good with that sorta stuff.

How accurate do they need to be?

It’s so NPC’s will know whether to ignore the player or not. If they are totally in the light and they are seen by the code as completely in shadow, then that could be exploited. Same as being in pitch black and seen as fully bright. That would be ridiculous.

Assuming you’re not going for light cones, Hull Traces will be able to tell you if a player is in direct view of the light.
For everything else (like partially lit by the light being blocked by something) the number of traces you do will be the level of accuracy you get. I’d suggest 8 for base accuracy.

This is cheap if you use a custom map.

In your map, have a volume trigger of some sort and have it fire when a player enters it and leaves it. You can determine if the player is inside any given light-source like this cheaply.

Although it has some arbitrary problems, such as overlapping triggers and a digital sensitivity rather than analog, it’d probably be the most efficient manner of doing it.

  1. Sadly you can’t. You’ll have to tinker with either SetVelocity or the MoveData object you get from Move/FinishMove hooks.
  2. Depends on how many traces you make. The more traces the more accurate but also more expensive.

Why can’t I parent the player to an entity?

That would work, yeah.

Well, so far it sounds like the light tracing is going to be the most difficult.

Also, make sure to trace from the player to the light, so as to reduce the number of traces. That’s 1 or 2 (depending on how many positions you want to check from) versus how everymany you send out in all directions from the light.

Or you could just FindInSphere the radius of the light… >:3

Only that doesn’t take shadows into account.

Perhaps a combination of raytraces and findinsphere?

Are you using globe lights or spotlights? I was assuming spotlights when I gave my first idea, but if they’re globular, I’d suggest doing the sphere and then running a trace to the head, chest, pelvis and feet of any players found, so you can get a ‘percentage’ of them that’s in the light.

[editline]06:58PM[/editline]

Oh and use this instead of ents.FindInSphere.
No sense in doing more Distance()s than you need to.
[lua]function player.FindInSphere(pos,radius)
local ret = {}
for _,ply in ipairs(player.GetAll()) do
if ply:GetPos():Distance(pos) <= radius then
table.insert(ret,ply)
end
end
return ret
end[/lua]