Script needs a better algorythm...

Started by Heretic86, April 25, 2012, 05:51:32 pm

Previous topic - Next topic

Heretic86

Not releasing this script here yet.  I wanna do some more tweaking to something I dont particularly care for.

Script is for simulating Cloud Altitude.
http://www.775.net/~heretic/downloads/rmxp/CloudAltitude0.2.zip

There are two versions.  One for Devs to help them figure out what Speeds and Altitude they want to use.  They can use key combos in that version to adjust the variables on the fly so they can work out what looks good for them.  The math for both versions is the same.  What I've come across is that if the Cloud (Fog) Scroll Speed is moving faster than the players speed, when the player walks in that same direction the Clouds are moving, the clouds seem to get "stuck" at the same speed as the player moves, regardless of the speed the Clouds are set to move at.  Yeah, there is probably a ton of stuff I could improve on, but its a work in progress.

I think the only way to explain it is to see it in action for what the script does, hence the download above.

Here's the part that the way of crunching the numbers needs to change...

Spoiler: ShowHide
  def set_scroll_speed
    # Scrolls Fog Opposite Direction
    # for the appearance of Height
   
    #player_spd = $game_player.move_speed
    #fog_spd_x = $game_map.fog_origsx
    #fog_spd_y = $game_map.fog_origsy
    #altitude = $game_map.fog_altitude
   
    if $game_map.fog_direction == 2
      #Screen DOWN, Fog UP
      $game_map.fog_sy =  $game_map.fog_origsy - ($game_player.move_speed + $game_map.fog_altitude)

      #Resets Horizontal Fog Speed
      $game_map.fog_sx = $game_map.fog_origsx
    elsif $game_map.fog_direction == 4
      #Screen LEFT, Fog RIGHT
      $game_map.fog_sx = $game_map.fog_origsx + ($game_player.move_speed + $game_map.fog_altitude)

      #Resets Vertical Fog Speed
      $game_map.fog_sy = $game_map.fog_origsy
    elsif $game_map.fog_direction == 6
      #Screen RIGHT, Fog LEFT
      $game_map.fog_sx = $game_map.fog_origsx - ($game_player.move_speed + $game_map.fog_altitude)

      #Resets Vertical Fog Speed
      $game_map.fog_sy = $game_map.fog_origsy
    elsif $game_map.fog_direction == 8
      #Screen Up, Fog DOWN
      $game_map.fog_sy =  $game_map.fog_origsy + ($game_player.move_speed + $game_map.fog_altitude)

      $game_map.fog_sx = $game_map.fog_origsx
    end
  end


Other thing is problematic is that it isnt compatible with 8 directional movement scripts.  Just kind of hoping one of our more experienced scripters has a solution, at least to fix the speed stuff...  Suggestons?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

Didn't look in depth yet, but I at a glance, the largest technical error is using $game_map to store sprites. Rendered objects cannot be Marshaled, and $game_map is saved, therefore you get potential errors. I saw you had to alias the save method to prevent crashes, when all you need to do is not use Game_Map. Sure, it may work for the default save system as a quick and cheap hack, but compatibility goes out the window for any custom save system that does not use the named method. If the data doesn't need saved, it would be wiser, and easier to use Spriteset_Map. Take a look at how the default system works. The pertinent values are stored in Game_Map, and are simply read by Spriteset_Map. This allows you it to be saved without actually saving the Sprite. The same goes with Sprite_Character, etc.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

Did you reply to the wrong thread?  :p

Im not too worried about the sprite, its just there for displaying fog stats, so Mappers know what variables to plug into a live version of their game.  Im just looking at the algorythm for determining the fog's speed.  Thats where I think I messed up...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

No, I didn't reply to the the wrong thread. Don't worry about it though.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Heretic86

I see what it was.  There was a 2nd script in there I totally forgot to remove!   :facepalm:
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Heretic86

Still looking for a hand with the algorythm...  The demo has a 2nd script which shouldnt interfere.  The one I was looking for help with was the Cloud Altitude script. 

Just trying to find a better way to calculate the Scroll Speed of the fog...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)