Page 2 of 3

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Sat Jun 27, 2015 12:32 am
by minmay
AndakRainor wrote:There is nothing bizarre in allowing a projectile to leave the map if it has open border, as is a beach map bordered by the sea. It is far more immersive than exploding on invisible walls.
But items and the party still can't leave the map. How is "spells can leave the map, but you can't, and any item you throw off the map will magically reappear inside the map" immersive?
AndakRainor wrote:Yes, iterating over allEntities() is a part I also don't like, but still I did not see any frame delays with it. Perhaps with a slow computer or with maps filled with a very high number of entities, but I still doubt it can cause a noticeable effect. If it was the case, this function should be banned from all scripts we could run more than once.
That's what I would recommend as a rule of thumb. There is usually little reason to use it after dungeon start, and I definitely see delays from it on levels with many entities.
AndakRainor wrote:
minmay wrote:What the hell? Why would you let the player stand on the border of the map in the first place if there isn't a visible wall there already???
It is what the main campaign does with the beach, I just re-tested to be sure. Also, the main campaign lets projectiles leave the map in those places.
Yes, the main campaign has bugs in it, I am not sure why this is relevant. It also allows projectiles to go directly through stairs and leave the map that way, does that mean custom dungeons should do that, too?

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Sat Jun 27, 2015 12:56 am
by AndakRainor
It's magic !!! You know, the tide is so strong that anything you throw and falls in the water comes back to you, and you can't even swim away from the game in square water tiles ;)

I didn't know about the stairs ! I can imagine that if the main campaign does that, the risk is high for mods to do it too !

Yes many things are far from realistic in this game, but it would be a little sad to make a design rule of it... And honestly, hitting poor innocent players with their own spells just because they are at the wrong place at the wrong time, if I didn't know better I would think you really hate them :lol:

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Sat Jun 27, 2015 10:46 pm
by bongobeat
well, thanks for these scripts!

I just check, I have a few open area in the water, with only one square of water, just on the edge of the map.
I did not have any place to enlarge these area, to avoid that the player get hurt by his spell.
Should I redesign these places? It will be bad luck if the player cast a spell toward the sea in these areas as their is no need for.

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Sun Jun 28, 2015 10:35 am
by AndakRainor
Here is a reworked version of the script. You can safely use it in only one script entity anywhere in your dungeon:

Code: Select all

performanceHit = 0.001 -- must be in [0.000001, 0.01]
vanishDistance = 300 -- in meters = tiles * 3

level = 1
tile = -1

--entities = 0
--duration = 0
--maps = 1

function check()
  local begin = Time.systemTime()
  local levels = Dungeon.getMaxLevels()
  local pHit = 0
  repeat 
    local map = Dungeon.getMap(level)
    local X, Y = map:getWidth()-1, map:getHeight()-1
    tile = tile+1
    local x, y
    if tile<X then x=tile y=0
    elseif tile<X+Y then x=X y=tile-X
    elseif tile<X+X+Y then x=X+X+Y-tile y=Y
    elseif tile<X+X+Y+Y then x=0 y=X+X+Y+Y-tile
    else
      tile=0 x=0 y=0 level = level % levels + 1
      map = Dungeon.getMap(level)
      X, Y = map:getWidth()-1, map:getHeight()-1
      --maps = maps+1
    end
    for e in map:entitiesAt(x,y) do
      if e.projectile then
        local w = e:getWorldPosition()
        --hudPrint(e.name.." at map("..e.x..", "..e.y..") world("..w.x..", "..w.y..", "..w.z..")")
        if w.x < -vanishDistance or w.y < -vanishDistance-21 or w.z < -vanishDistance
        or w.x > X*3+3+vanishDistance or w.y > vanishDistance+21 or w.z > Y*3+3+vanishDistance
        then e:destroy() end
      end
      --entities = entities + 1
    end
    pHit = Time.systemTime() - begin
  until pHit >= performanceHit
  local delay = pHit/performanceHit - pHit
  delayedCall(self.go.id, delay, "check")
  --duration = duration + pHit * 1000000000
  --print("time/map = "..math.floor(duration/maps).."ns, entities/map = "..math.floor(entities/maps)..", time/entity = "..math.floor(duration/entities).."ns, frame = 1/60s, entity/frame = "..math.floor(entities/duration * 1000000000/60)..", delay = "..math.floor(delay*1000).."ms")
end

check()
As the previous ones, it auto starts and is called periodically.
You can set the performanceHit and vanishDistance values to your liking. The first one is a ratio of time used to run the script, so it should be a small value, near 0, but never 0 or it won't work. The second is in meters, as it is used with tests on the projectiles world positions instead of time spend out of maps. It does not test all entities in a map anymore but only those on borders. If you want to see what it does, you can uncomment the commented lines (times are shown in ns = nanoseconds).

Here is the data I got when testing performance hits with my previous scripts (hours of data);

Code: Select all

+-----------------+----------------+------------------+-----------------+---------------------+
|    loop type    |  time per map  | entities per map | time per entity | entities per frame* |
|                 | (milliseconds) |                  | (milliseconds)  |  (perf hit limit)   |
+-----------------+----------------+------------------+-----------------+---------------------+
|  all entities   | 1.724          | 1350             | 0.001275        | 13063               |
+-----------------+----------------+------------------+-----------------+---------------------+
| entities at x,y | 0.267          | 132              | 0.002016        | 8264                |
+-----------------+----------------+------------------+-----------------+---------------------+
(*): frame = 1/60 s = 16.667 ms

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Mon Jun 29, 2015 10:47 pm
by bongobeat
thanks,
I will give it a try!

While testing Minmay's script I notice something weird that I didn't have before implementing the script:

I got white lines, on each corner of the map, they are outside the map.
SpoilerShow
Image

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Mon Jun 29, 2015 11:20 pm
by Azel
AndakRainor wrote:It's magic !!! You know, the tide is so strong that anything you throw and falls in the water comes back to you, and you can't even swim away from the game in square water tiles ;)

I didn't know about the stairs ! I can imagine that if the main campaign does that, the risk is high for mods to do it too !

Yes many things are far from realistic in this game, but it would be a little sad to make a design rule of it... And honestly, hitting poor innocent players with their own spells just because they are at the wrong place at the wrong time, if I didn't know better I would think you really hate them :lol:
Completely agree. Being able to stand on a building and cast a fireball that flies across an ocean that the player himself is not able to swim over makes perfect sense; and certainly is more immersive than an imaginary wall making it vanish. A fake wall blocker would certainly kill immersion.

Not everyone is concerned about immersion, here's a quote from minmay's current Mod project, "There are no underwater areas, all water is purely decorative and you cannot dive into it." http://grimrock.net/forum/viewtopic.php?f=23&t=9130

So one could pose the same question... how does fake water used as decoration - even when the main game allows players to swim in it - create any immersion whatsoever? Maybe it's personal preference, but I think fake walls and fake water that stops the player from doing things that are very basic, commonplace, and expected, breaks immersion in a big way. Although I suppose if all the other elements in the game are enough of a distraction then the attention is diverted so that the lack of realism isn't an issue? I dunno, seems easier just to let people jump in and out of the water and throw their fireballs wherever they want :lol:

I actually had a bug (that I'm very proud of lol) in the first version of my Mod, caused by allowing Lightning Bolts to fly over the Beach. It looked quite gorgeous at night, reflecting over the water. But of course, this caused a memory leak so I removed that functionality. Now with the script in this thread I may add it back for the final release!

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Tue Jun 30, 2015 3:01 am
by minmay
bongobeat wrote:thanks,
I will give it a try!

While testing Minmay's script I notice something weird that I didn't have before implementing the script:

I got white lines, on each corner of the map, they are outside the map.
SpoilerShow
Image
I left debugDraw on in the projectile colliders so that you could see where they are. You can just remove the "debugDraw = true," lines.
Azel wrote:Not everyone is concerned about immersion, here's a quote from minmay's current Mod project, "There are no underwater areas, all water is purely decorative and you cannot dive into it." viewtopic.php?f=23&t=9130

So one could pose the same question... how does fake water used as decoration - even when the main game allows players to swim in it - create any immersion whatsoever? Maybe it's personal preference, but I think fake walls and fake water that stops the player from doing things that are very basic, commonplace, and expected, breaks immersion in a big way. Although I suppose if all the other elements in the game are enough of a distraction then the attention is diverted so that the lack of realism isn't an issue? I dunno, seems easier just to let people jump in and out of the water and throw their fireballs wherever they want :lol:
Not sure why you're making things up about an unreleased mod that isn't even yours. There are no invisible walls in Requiem for Kraken's Arm; all water and map borders are blocked by visible walls. This is even shown in the screenshots!
Azel wrote:Completely agree. Being able to stand on a building and cast a fireball that flies across an ocean that the player himself is not able to swim over makes perfect sense; and certainly is more immersive than an imaginary wall making it vanish. A fake wall blocker would certainly kill immersion.
I wonder how many times I have to say this before someone acknowledges it: there are ALREADY "imaginary walls" on the map border for both the party AND projectiles. Items thrown outside the map reappear inside it. How the hell is that an improvement over having a proper projectile collider? Not to mention that you literally just said the party should be able to enter water...

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Tue Jun 30, 2015 5:24 am
by Azel
minmay wrote:Not sure why you're making things up about an unreleased mod that isn't even yours. There are no invisible walls in Requiem for Kraken's Arm; all water and map borders are blocked by visible walls. This is even shown in the screenshots!
Umm, when I made a small reference to your Mod I wasn't accusing you of having invisible walls, I very plainly referred (and quoted) to the feature you listed, "There are no underwater areas, all water is purely decorative and you cannot dive into it."

And I wasn't attacking you nor your Mod, I was simply illustrating that what is "immersive" to one person doesn't need to meet the standards of another. You do not allow players to immerse themselves in water, therefore that aspect of environmental immersion is absent in your Mod. It's not a judgement, it's an observation.
minmay wrote:I wonder how many times I have to say this before someone acknowledges it: there are ALREADY "imaginary walls" on the map border for both the party AND projectiles.
Maybe if you wouldn't act so emotional every time you read something that you don't agree with, you would get this acknowledgement that you're demanding? Just offering up a suggestion. I mean, look at one of your replies to the OP earlier in what should be a fun discussion, "What the hell? Why would you let the player stand on the border of the map in the first place if there isn't a visible wall there already???"

So you get upset with me for commenting on "an unreleased mod that isn't even yours" ... yet there you were earlier becoming overly emotional and judgmental about someone elses unreleased mod that isn't even yours. Why, exactly? Try to relax and remember that collaboration with a video game hobby is supposed to be "fun." Even doing dumb things, making mistakes, trying and failing over and over... can be really fun. It's unfortunate that you actively and regularly choose to interfere with the painful (yet fun) aspect of collaboration. There's beauty in the try/fail/learn/grow process. I think you would be pleasantly surprised (and much less stressed) by the result of just letting things happen naturally.
minmay wrote:Items thrown outside the map reappear inside it. How the hell is that an improvement over having a proper projectile collider? Not to mention that you literally just said the party should be able to enter water...
hmph, well you combined a few things to apply a different context to my words. I was literally referring to water that is well within the boundaries of a map. Much like your screenshot here: http://i.imgur.com/jbHsvEd.jpg

In that screenshot, the water is underneath areas that the player can actively explore. Yet you are choosing not to allow them to dive in to the water, by your own admission. What I am saying is that Grimrock is a game environment where in these types of situations, players are generally allowed to jump in to that water at some point. So fine, you removed immersion by preventing water immersion; what's so upsetting about pointing that out? I'm sure you will have plenty of other fun things for the players to do; again, I'm just commenting on an obvious observation.

On the other end, there is a discussion about water that extends out beyond the borders (eg, Ocean Water). If someone creates a script that returns items thrown outside of the map, then it could be very immersive depending on how that is executed. For example, the screen could have a Hud Print, "a magical force returns the items lost at sea." Or something equally cheesey :mrgreen: If someone casts a FireBall out at sea, then the player could have script that sends that fireball right back at them, while playing a wave file on par with: http://freesound.org/people/Nanakisan/sounds/253524/

Again, it's all about fun, creativity, and even if you personally think it is stupid/childish/illogical... the great thing about Mod's is that they extend the creators own ideas, which no one is forcing you to play.

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Tue Jun 30, 2015 7:38 am
by minmay
Azel wrote:And I wasn't attacking you nor your Mod, I was simply illustrating that what is "immersive" to one person doesn't need to meet the standards of another. You do not allow players to immerse themselves in water, therefore that aspect of environmental immersion is absent in your Mod.
ok I gotta admit I chuckled a bit this time, that was a really well done buildup

p.s. sorry about your thread, OP

Re: Remove out of map projectiles! Or how to clean the beach

Posted: Tue Jun 30, 2015 6:46 pm
by bongobeat
minmay wrote:I left debugDraw on in the projectile colliders so that you could see where they are. You can just remove the "debugDraw = true," lines.
Ok, thanks!