Photography

BigKevSexyMan's Photography Script

This script allows you to take pictures and store them in up to six available slots. The scripts are stored in an easy to use menu. Also, the events that are in your picture will be recorded by name. You can also check if the event you want is in the picture. Hit F5 to take the picture and F6 to go to your photography menu.

Screenshots:
http://img.photobucket.com/albums/v603/ ... nshot2.png[/img]

http://img.photobucket.com/albums/v603/ ... nshot1.png[/img]

Demo:
http://www.box.net/public/n7x3unoybp

Coding:
Photography by BigKevSexyMan
# -----------------------------
# BigKev's Picture Camera
# -----------------------------

class Game_Stored
attr_accessor :picture_database
attr_accessor :picture_events
def initialize
@new_picture_calling = false
@picture_database = []
@picture_events = []
end

def check_picture_events # Whenever you want to check if an event that had it's picture taken use $game_stored.check_picture_events
for i in 1...6 # Cycles through each picture to see the events located within
for j in 0...299 # Cycles through every possible event in each picture
if $game_stored.picture_events[i] != nil
if $game_stored.picture_events[i][j] == "PurpleFlower" # Events taken by pictures are recognized by name
$game_switches[2] = true # PurpleFlower
$game_map.refresh # You gotta refresh the map everytime you turn a switch on/off if you want it to take effect.
end
if $game_stored.picture_events[i][j] == "Fairy"
$game_switches[3] = true # fairy
$game_map.refresh
end
if $game_stored.picture_events[i][j] == "Sticks"
$game_switches[5] = true # sticks
$game_map.refresh
end
if $game_stored.picture_events[i][j] == "Fire"
$game_switches[4] = true # campfire
$game_map.refresh
end
if $game_stored.picture_events[i][j] == "Lich"
for k in 0...299 # Recycles through every possible event in each picture
if $game_stored.picture_events[i][k] == "Ghost"
$game_switches[7] = true # CaughtGhosts
$game_map.refresh
end
end
end
# Insert other pictures you want taken here
end
end
end
end
end

class Scene_Photo_Menu # Menu that displays all the pictures you have taken
def initialize(menu_index = 0)
@menu_index = menu_index
end

def main
# Sets up the information on the picture that shows in Window_Photo_Display
@selected_picture = Sprite.new
@selected_picture.x = 75
@selected_picture.y = 20
@selected_picture.z = 9998
@selected_picture.zoom_x = 0.75
@selected_picture.zoom_y = 0.75

@window_photo_select = Window_Photo_Select.new
@window_photo_select.index = @menu_index
@window_photo_select.x = 0
@window_photo_select.y = 400
@photo_display_window = Window_Photo_Display.new
@photo_display_window.x = 0
@photo_display_window.y = 0
@photo_options_window = Window_Photo_Options.new
@photo_options_window.index = @menu_index
@photo_options_window.x = 0
@photo_options_window.y = 400
@photo_options_window.visible = false
@photo_options_window.active = false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@window_photo_select.dispose
@photo_display_window.dispose
@photo_options_window.dispose
end

def update
@window_photo_select.update
@photo_display_window.update
@photo_options_window.update
if @window_photo_select.active
case @window_photo_select.index
when 0
# Set's the picture to the stored picture's bitmap to the corresponding picture in the database
if $game_stored.picture_database[1] != nil
@selected_picture.bitmap = RPG::Cache.picture("Picture1")
else
@selected_picture.bitmap = RPG::Cache.picture("NoPicture")
end
when 1
if $game_stored.picture_database[2] != nil
@selected_picture.bitmap = RPG::Cache.picture("Picture2")
else
@selected_picture.bitmap = RPG::Cache.picture("NoPicture")
end
when 2
if $game_stored.picture_database[3] != nil
@selected_picture.bitmap = RPG::Cache.picture("Picture3")
else
@selected_picture.bitmap = RPG::Cache.picture("NoPicture")
end
when 3
if $game_stored.picture_database[4] != nil
@selected_picture.bitmap = RPG::Cache.picture("Picture4")
else
@selected_picture.bitmap = RPG::Cache.picture("NoPicture")
end
when 4
if $game_stored.picture_database[5] != nil
@selected_picture.bitmap = RPG::Cache.picture("Picture5")
else
@selected_picture.bitmap = RPG::Cache.picture("NoPicture")
end
when 5
if $game_stored.picture_database[6] != nil
@selected_picture.bitmap = RPG::Cache.picture("Picture6")
else
@selected_picture.bitmap = RPG::Cache.picture("NoPicture")
end
end
if Input.trigger?(Input::C)
# Enters Photo Options Menu
if $game_stored.picture_database[@window_photo_select.index+1] != nil
@window_photo_select.active = false
@window_photo_select.visible = false
@photo_options_window.visible = true
@photo_options_window.active = true
$game_system.se_play($data_system.decision_se)
else
$game_system.se_play($data_system.cancel_se)
end
end
# Leaves the Menu
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@selected_picture.dispose
$scene = Scene_Map.new
end
return
end
if @photo_options_window.active
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_photo_select.active = true
@window_photo_select.visible = true
@photo_options_window.visible = false
@photo_options_window.active = false
end
if Input.trigger?(Input::C)
case @photo_options_window.index
when 0 # Deletes the picture
$game_stored.picture_database[@window_photo_select.index+1] = nil
$game_stored.picture_events[@window_photo_select.index+1] = []
RPG::Cache.picture("Picture"+(@window_photo_select.index+1).to_s).dispose
@selected_picture.bitmap = RPG::Cache.picture("NoPicture")
$game_system.se_play($data_system.decision_se)
when 1 # Returns to Photo Select Menu
@window_photo_select.active = true
@window_photo_select.visible = true
@photo_options_window.visible = false
@photo_options_window.active = false
$game_system.se_play($data_system.cancel_se)
end
end
return
end
end
end

class Scene_New_Picture # Menu when you take the picture
def initialize(index, menu_index = 0)
@menu_index = menu_index
@index = index
end

def main
@window_save_picture = Window_Save_Picture.new
@column_max = 2
@window_save_picture.index = @menu_index
@window_save_picture.x = 0
@window_save_picture.y = 400
@new_picture_window = Window_New_Picture.new(@index)
@new_picture_window.x = 0
@new_picture_window.y = 0
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@window_save_picture.dispose
@new_picture_window.dispose
end

def update
@window_save_picture.update
@new_picture_window.update
if @window_save_picture.active
if Input.trigger?(Input::C)
case @window_save_picture.index
when 0
$game_system.se_play($data_system.decision_se)
for i in 1..6 # Checks to see if there is an open slot available
if $game_stored.picture_database[i] == nil
# Storing the newly taken picture in the database
$game_stored.picture_database[i] = 1
events_within_range(i)
break
end
end
$scene = Scene_Map.new
when 1
# Deletes the picture
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
RPG::Cache.picture("Picture" + @index.to_s).dispose
return
end
end
return
end
end

def events_within_range(id) # Checking to see what events are within the picture
if $game_map.events.keys.max != nil
$game_stored.picture_events[id] = []
for i in 0...$game_map.events.keys.max+1
if $game_map.events[i] != nil
if $game_map.events[i].real_x >= $game_map.display_x + 64
if $game_map.events[i].real_x <= $game_map.display_x + 2496
if $game_map.events[i].real_y >= $game_map.display_y + 128
if $game_map.events[i].real_y <= $game_map.display_y + 1792
$game_stored.picture_events[id].push($game_map.events[i].event.name)
end
end
end
end
end
end
end
end
end

class Window_Photo_Options < Window_Selectable
def initialize
super(0, 400, 640, 80)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
refresh
@item_max = 2
@column_max = 2
@commands = ["Delete", "Back"]
draw_item(0, normal_color)
draw_item(1, normal_color)
self.index = 0
end

def refresh
self.contents.clear
end

def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(160 + index * 160, 0, 128, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end

def update_cursor_rect
self.cursor_rect.set(160 + index * 160, 0, 128, 32)
end
end

class Window_Photo_Select < Window_Selectable
def initialize
super(0, 400, 640, 80)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
refresh
@item_max = 6
@column_max = 6
@commands = ["Photo1", "Photo2", "Photo3", "Photo4", "Photo5", "Photo6"]
draw_item(0, normal_color)
draw_item(1, normal_color)
draw_item(2, normal_color)
draw_item(3, normal_color)
draw_item(4, normal_color)
draw_item(5, normal_color)
self.index = 0
end

def refresh
self.contents.clear
end

def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(40 + index * 90, 0, 84, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end

def update_cursor_rect
self.cursor_rect.set(40 + index * 90, 0, 84, 32)
end
end

class Window_Photo_Display < Window_Base
def initialize
super(0, 0, 640, 400)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
refresh
end

def refresh
self.contents.clear
@frame = Sprite.new
@frame.bitmap = RPG::Cache.picture("Picture Frame")
@frame.x = 75
@frame.y = 20
@frame.z = 9999
@frame.zoom_x = 0.75
@frame.zoom_y = 0.75
end

def dispose
@frame.dispose
super
end
end

class Window_New_Picture < Window_Base
def initialize(index)
super(0, 0, 640, 400)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
@index = index
@temp_picture = Sprite.new
refresh
end

def refresh
self.contents.clear
@frame = Sprite.new
@frame.bitmap = RPG::Cache.picture("Picture Frame")
@frame.x = 75
@frame.y = 20
@frame.z = 9999
@frame.zoom_x = 0.75
@frame.zoom_y = 0.75
@temp_picture.bitmap = RPG::Cache.picture("Picture"[email hidden]_s)
@temp_picture.x = 75
@temp_picture.y = 20
@temp_picture.z = 9998
@temp_picture.zoom_x = 0.75
@temp_picture.zoom_y = 0.75
end

def dispose
@frame.dispose
@temp_picture.dispose
super
end
end

class Window_Save_Picture < Window_Selectable
def initialize
super(0, 400, 640, 80)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
refresh
@item_max = 2
@column_max = 2
@commands = ["Keep", "Delete"]
draw_item(0, normal_color)
draw_item(1, normal_color)
self.index = 0
end

def refresh
self.contents.clear
end

def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(160 + index * 160 + 4, 0, 128 - 10, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end

def update_cursor_rect
self.cursor_rect.set(160 + index * 160, 0, 128, 32)
end
end

class Scene_Map
alias bksm_photography_update update
def update
if Input.trigger?(Input::F5) # Takes a new picture
if $game_stored.picture_database[1] != nil
if $game_stored.picture_database[2] != nil
if $game_stored.picture_database[3] != nil
if $game_stored.picture_database[4] != nil
if $game_stored.picture_database[5] != nil
if $game_stored.picture_database[6] != nil
print "No vacancy available" # If no slot is available
end
end
end
end
end
end
for i in 1...6
if $game_stored.picture_database[i] == nil
# If slot is available
Screen::shot("Picture" + i.to_s, 2)
$game_player.straighten
$scene = Scene_New_Picture.new(i, 0)
break
end
end
end
if Input.trigger?(Input::F6) # Calls the Photo Menu
$game_player.straighten
$scene = Scene_Photo_Menu.new
end
bksm_photography_update
end
end

class Scene_Title
alias bksm_camera_command_new_game command_new_game
def command_new_game
$game_stored = Game_Stored.new
bksm_camera_command_new_game
end
end

class Scene_Load
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)

$game_stored = Marshal.load(file)

if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
end

class Scene_Save
def write_save_data(file)
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
$game_system.save_count += 1
$game_system.magic_number = $data_system.magic_number
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)

Marshal.dump($game_stored, file)
end
end

class Game_Event
attr_reader :event
end
Expand to see the code.


Screenshot script by Andreas21 and cybersam
#===============================================================================
#
# Screenshot V2
#
# Screenshot Script v1 & screenshot.dll v1 created by: Andreas21
# Screenshot Script v2 created/edit by: cybersam
# the autor is found on a german board...
# the comments are added by me...
# since the autor didnt want to add any comment...
# so thats it from here...
# have fund with it... ^-^
#
# oh yea.. the needed command line is found in "Scene_Map" in "def update"
#
#===============================================================================

module Screen

@screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
@readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
@findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'

module_function

#-----------------------------------------------------------------------------
# here comes the stuff...
# i add here the stuff for automatic change of the number for the screenshot
# so it wont overrite the old one...
# if you want to change so stuff change them in this line below
# or you can change them in your command line... like
# Screen::shot("screenshot", 2)
# this change the name and the type of the screenshot
# (0 = bmp, 1 = jpg and 2 = png)
# ----------------------------------------------------------------------------
def shot(file = "New_Picture", typ = 2)

# to add the right extension...
if typ == 0
typname = ".bmp"
elsif typ == 1
typname = ".jpg"
elsif typ == 2
typname = ".png"
end

file_index = 0

dir = "Graphics/Pictures/"

# make the filename....
file_name = dir + file.to_s + typname.to_s

# make the screenshot.... Attention dont change anything from here on....
@screen.call(0,0,640,480,file_name,handel,typ)
end
# find the game window...
def handel
game_name = "\0" * 256
@readini.call('Game','Title','',game_name,255,".\\Game.ini")
game_name.delete!("\0")
return @findwindow.call('RGSS Player',game_name)
end
end
Expand to see the code.


Instructions:
First, place the above code into your rgss. Next, place to following images in your database:
http://img.photobucket.com/albums/v603/ ... icture.png[/img]
http://img.photobucket.com/albums/v603/ ... eFrame.png[/img]
*The big black space is a picture....

Finally, download the screenshot.dll located here: http://www.box.net/public/3c1isic7bm And put it in your game folder.

Credits and Thanks:
Big thanks to Andreas21 and Cybersam for their screenshot script
!!

Holy crap! First time Ive seen something like this!

*Goes to try it*

EDIT: Cool, cool very cool. I really like the way a NPC can check if you have the right picture by using event names!

Awesome script, thanks for posting! ^^
Thanks, I originally put this up on rmxp.net, but that went down.
Thats awesome. You could use this for some really good puzzles.
okay....it wont work on my game
You're going to have to give me a little more info. Did you download the Screenshot.dll?
how can change this to when someone takes a picture it save to a folder outside of the graphics folder, so instead of saving to Graphics/Pictures, it saves to a folder called Pictures.
This is a great script.
catkitten: If you want to put the folder outside of the graphics folder, then I suppose you would have to add this code.

module RPG
  module Cache
    def self.camera_pictures(filename)
      self.load_bitmap("Pictures/", filename)
    end
  end
end
Expand to see the code.


This line in the screenshot script would have to be modified for that:

dir = "Pictures/"

And coding like this, in the camera script:

RPG::Cache.picture

into this:

RPG::Cache.camera_pictures
BigKevSexyMan: Thank you it worked. :)
Whoa. Incredible script. It would make many people happy, as it could very well be an excellent feature in most games.

BTW, it very well reminds me of the camera feature in Metal Gear Solid 2.
Is posible to comapatyblity with SDK?
Slight problem with this when I use it..

It only takes 5 pictures, it won't let me take anymore.

Also, could you explain a little better where it is I place the code to be able to change the directory for where to save pictures?
*bump*

Still need to know?
how do you calling this script?
wher do you put the script????
[QUOTE=cheatking;107376]wher do you put the script????[/QUOTE]

CheatKing, please refrain from necroposting, in old topics. use the RGSS Support Forum for questions on old scripts and wait for the author BigKevSexyMan to return. But to answer your question add the scripts in a new script above main and you also need the screenshot dll http://www.box.net/public/3c1isic7bm and place it in your game folder. If that confuses you then download the demo and copy the script and dll from there. If you still have trouble make a thread in the RGSS Support Forum with a link to this script and the problems you are having
First, i want to say, I love the script, BUT now here's the multimillion dollar question...

With the ability to add multiple layers on top of each other with for instance, Daniels' two fog command, couldn't we in essence create a SPRITE creator IN game that would allow you to BUILD what your character looks like in the game? I'd DEFINITELY be interested in trying to do a demo on THAT!

EDIT: looked up and realized the post was almost a year old.
thanks, man. now my heroes may act more like spies do.
there is something else I would like to tell you now. I don't know why but I never could take more than 5 photos, even if there were 6 slots available...

Edit:
so this was a very old post...

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=6824