查看: 3108|回复: 3

[转载发布] 发个战斗前截取当前地图当背景的脚本

[复制链接]
梦石
0
星屑
910
在线时间
94 小时
注册时间
2005-10-22
回帖
335
发表于 2013-12-13 10:25:47 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 ikki 于 2013-12-13 10:32 编辑

随便发着玩。。。不需要神马精华啥的了,毕竟都是古董了。。。国外的东东。。。附件内是调用的dll
[pre lang="ruby" line="1"]#===============================================================================
#
# 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 = "screenshot", typ = 1)
    # 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/Battlebacks/"   
    # 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[/pre]
screenshot.7z (44.06 KB, 下载次数: 80)
做脚本先从修改脚本做起,我只修改自己觉得能用到的东西。
以后的任何作品都将不会进行分享。
Bilibili:https://space.bilibili.com/288814521
梦石
0
星屑
76
在线时间
1379 小时
注册时间
2012-7-5
回帖
1643

开拓者

发表于 2013-12-13 12:55:10 | 显示全部楼层
本帖最后由 kuerlulu 于 2013-12-13 12:56 编辑

截图脚本我以前玩过【雾。。
夏娜大大加了个防止多个RM一起运行导致获取窗口句柄出错的方法。【这句和上面一句没有必然联系
  1. #==============================================================================
  2. # ■ Kernel
  3. #------------------------------------------------------------------------------
  4. #  该模块中定义了可供所有类使用的方法。Object 类中包含了该模块。
  5. #==============================================================================
  6. module Kernel
  7.   #--------------------------------------------------------------------------
  8.   # ● 需要的 Windows API 函数
  9.   #--------------------------------------------------------------------------
  10.   GetWindowThreadProcessId = Win32API.new("user32", "GetWindowThreadProcessId", "LP", "L")
  11.   GetWindow = Win32API.new("user32", "GetWindow", "LL", "L")
  12.   GetClassName = Win32API.new("user32", "GetClassName", "LPL", "L")
  13.   GetCurrentThreadId = Win32API.new("kernel32", "GetCurrentThreadId", "V", "L")
  14.   GetForegroundWindow = Win32API.new("user32", "GetForegroundWindow", "V", "L")
  15.   #--------------------------------------------------------------------------
  16.   # ● 获取窗口句柄
  17.   #--------------------------------------------------------------------------
  18.   def get_hWnd
  19.     # 获取调用线程(RM 的主线程)的进程标识
  20.     threadID = GetCurrentThreadId.call
  21.     # 获取 Z 次序中最靠前的窗口
  22.     hWnd = GetWindow.call(GetForegroundWindow.call, 0)
  23.     # 枚举所有窗口
  24.     while hWnd != 0
  25.       # 如果创建该窗口的线程标识匹配本线程标识
  26.       if threadID == GetWindowThreadProcessId.call(hWnd, 0)
  27.         # 分配一个 11 个字节的缓冲区
  28.         className = " " * 11
  29.         # 获取该窗口的类名
  30.         GetClassName.call(hWnd, className, 12)
  31.         # 如果匹配 RGSS Player 则跳出循环
  32.         break if className == "RGSS Player"
  33.       end
  34.       # 获取下一个窗口
  35.       hWnd = GetWindow.call(hWnd, 2)
  36.     end
  37.     return hWnd
  38.   end
  39. end
  40. #===============================================================================
  41. #===============================================================================
  42. # ■设置存放截图文件夹
  43. DIR = "Screenshot"
  44. Dir.mkdir("./#{DIR}") unless FileTest.exist?(DIR + "/")
  45.   # 主模块 Screen API ★方法:Screen::shot★
  46. module Screen
  47.   @i = 1 # 又要玩迭代了
  48.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  49.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  50.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  51.   module_function
  52.   def shot(file = "shot", typ = 1) # Screen::shot("save", 1)
  53.     if typ == 0
  54.       typname = ".bmp"
  55.     elsif typ == 1
  56.       typname = ".jpg"
  57.     elsif typ == 2
  58.       typname = ".png"
  59.     end
  60.     dir = DIR + "/"
  61.     @i += 1 while FileTest.exist?(dir + file.to_s  + @i.to_s + typname.to_s)
  62.     file_name = dir + file.to_s  + @i.to_s + typname.to_s # 生成带路径的文件名
  63.     @screen.call(0,0,640,480, file_name, get_hWnd, typ) # call出截图
  64.   end
  65. #  def handel
  66. #    game_name = "\0" * 256
  67. #    @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  68. #    game_name.delete!("\0")
  69. #    return @findwindow.call('RGSS Player',game_name)
  70. #  end
  71. end
复制代码

  -fk: -azogi:
回复

使用道具 举报

梦石
0
星屑
910
在线时间
94 小时
注册时间
2005-10-22
回帖
335
 楼主| 发表于 2013-12-13 14:06:32 | 显示全部楼层
kuerlulu 发表于 2013-12-13 12:55
截图脚本我以前玩过【雾。。
夏娜大大加了个防止多个RM一起运行导致获取窗口句柄出错的方法。【这句和上面 ...

{:2_265:}我发的只是初版。。。话说。。。其实我可以不截图直接用地图的。。。
做脚本先从修改脚本做起,我只修改自己觉得能用到的东西。
以后的任何作品都将不会进行分享。
Bilibili:https://space.bilibili.com/288814521
回复

使用道具 举报

梦石
0
星屑
910
在线时间
94 小时
注册时间
2005-10-22
回帖
335
 楼主| 发表于 2013-12-13 14:50:57 | 显示全部楼层
这个脚本是很强大的,也带作者的哦,主要现在我都找不到这些发在主页的哪里了。。。[pre lang="ruby" line="1"]#===============================================================
# 本脚本来自www.66rpg.com
# 功能:对于没有设置战斗背景的地图,直接用地图做战斗背景
#===============================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(flag = false)
   # 生成显示端口
   @viewport1 = Viewport.new(0, 0, 640, 480)
   @viewport2 = Viewport.new(0, 0, 640, 480)
   @viewport3 = Viewport.new(0, 0, 640, 480)
   @viewport2.z = 200
   @viewport3.z = 5000
   # 生成元件地图
   @tilemap = Tilemap.new(@viewport1)
   @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
   for i in 0..6
     autotile_name = $game_map.autotile_names
     @tilemap.autotiles = RPG::Cache.autotile(autotile_name)
   end
   @tilemap.map_data = $game_map.data
   @tilemap.priorities = $game_map.priorities
   # 生成远景平面
   @panorama = Plane.new(@viewport1)
   @panorama.z = -1000
   # 生成雾平面
   @fog = Plane.new(@viewport1)
   @fog.z = 3000
   unless flag
     # 生成角色活动块
     @character_sprites = []
     for i in $game_map.events.keys.sort
       sprite = Sprite_Character.new(@viewport1, $game_map.events)
       @character_sprites.push(sprite)
     end
     @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
   end
   # 生成天气
   @weather = RPG::Weather.new(@viewport1)
   # 生成图片
   @picture_sprites = []
   for i in 1..50
     @picture_sprites.push(Sprite_Picture.new(@viewport2,
       $game_screen.pictures))
     @viewport2.z = 9999
   end
   # 生成计时器块
   @timer_sprite = Sprite_Timer.new
   # 刷新画面
   update# unless flag
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose(flag = false)
   # 释放元件地图
   @tilemap.tileset.dispose
   for i in 0..6
     @tilemap.autotiles.dispose
   end
   @tilemap.dispose
   # 释放远景平面
   @panorama.dispose
   # 释放雾平面
   @fog.dispose
   unless flag
     # 释放角色活动块
     for sprite in @character_sprites
       sprite.dispose
     end
   end
   # 释放天候
   @weather.dispose
   # 释放图片
   for sprite in @picture_sprites
     sprite.dispose
   end
   # 释放计时器块
   @timer_sprite.dispose
   # 释放显示端口
   @viewport1.dispose
   @viewport2.dispose
   @viewport3.dispose
end
end

class Scene_Battle
alias battleback_map_main main
def main
  @battleback_sprite = Spriteset_Map.new(true)
  battleback_map_main
  @battleback_sprite.dispose(true)
end
end
#===============================================================
# 申请者:张永;脚本作者:bluefool 改善人:亿万星辰
#===============================================================
[/pre]
做脚本先从修改脚本做起,我只修改自己觉得能用到的东西。
以后的任何作品都将不会进行分享。
Bilibili:https://space.bilibili.com/288814521
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部