flareteam / flare-game

Fantasy action RPG using the FLARE engine
http://flarerpg.org/
Other
1.12k stars 237 forks source link

Throwing traps through walls #244

Open stefanbeller opened 11 years ago

stefanbeller commented 11 years ago

Well the hero is a powerful dude: Screenshot from 2013-03-25 00:39:09

The traps got somehow on the other side of the collision. If teleporting over and getting the enemies closer to the wall and then teleporting back, let's you even use traps through the wall to harm said enemies.

dorkster commented 11 years ago

Maybe we need a requires_los=true for these trap powers?

stefanbeller commented 11 years ago

Is that already part of the engine?

dorkster commented 11 years ago

Yes it is, the Burn spell uses it.

stefanbeller commented 11 years ago

yeah I noticed sometimes these spells not working and wondered why. However: (it took me a while to get the timing to take this screenshot) Screenshot from 2013-03-25 00:58:07

So maybe the line-of-sight stuff is not working always correct?

dorkster commented 11 years ago

I'm sorry. The Teleport power doesn't use los. So that screenshot is correct.

clintbellanger commented 11 years ago

This is a larger engine issue that will require new code to solve. First everyone needs to understand what's happening.


The "line of sight" check for a power is checked when using a power, before the hazard is created. It specifically checks where the mouse is pointing.

The effect of this is very specific. Although e.g. missiles obey line of sight, you don't want to prevent the player from shooting a missile if they click behind a wall. Because the player isn't pointing at a target, they're pointing at a Direction. The missile itself will hit the wall when it gets there. Compare this to the Burn spell which spawns instantly at the target location -- we don't want that power to be cast behind walls.

In this case of setting a trap, the player is choosing a direction. So we don't obey their specific click location, so requiring line-of-sight on the click target isn't helpful.

What we really want is traps to only be set in a walkable location. Right now traps are automatically set at whatever the melee range of the player is (currently a bit longer than 1 tile). What we really want is a line check from the center of the player to the requested target, and put the trap at the furthest location that isn't an obstacle. (missiles and wall post effects kind of work this way already...)

Secondarily, we might want to add optional line of sight checks between hazards and enemies. Right now if a hazard has a large radius it can affect an enemy even if there is a wall between them. Sometimes this is wanted behavior, often it isn't.