じ☆ve冰风 发表于 3 天前

Basic Evented Fog of War

Evented Fog Of War FOW Demo

This is a basic demo demonstration how you can use eventing to design a basic fog of war system.

No real instructions required, the evented system is pretty simple to follow.

If you have suggestions of how to improve or make more efficient please share.

Features:


[*]Unexplored Fog
[*]Previously Explored Fog
[*]Current sight
[*]Enemy invisible when in fog
Event Requirements:

1 - Parallel

1 - Common Event

Code Requirements:

You will need map extensions provided here and in demo:

http://forums.rpgmakerweb.com/index.php?/topic/25040-ace-useful-script-call-reference/

Spoiler#--------------------------------------------------------------------------
#Modifications
#--------------------------------------------------------------------------
#Changed Line 88 in Game_Event
#from
# if near_the_screen? && @stop_count > stop_count_threshold
#to
# if @stop_count > stop_count_threshold
#--------------------------------------------------------------------------
# REGION MANIPULATION
#--------------------------------------------------------------------------
class Game_Map
def setTileRegion(reg_x,reg_y,reg_id)

if reg_id > 63 || reg_id < 0
reg_id = 0
end

@thirdvalue = "%14b" % self.data

# binary split of the two elements
@bLEFT = @thirdvalue # REGION ID IN BINARY
@bRIGHT = @thirdvalue # SHADOW ID IN BINARY

@bLEFT = "%6b" % reg_id

@newvalue = @bLEFT.to_s + @bRIGHT.to_s
@newvalue = @newvalue.to_i(2)

self.data = @newvalue

end
def getTileRegion(reg_x,reg_y)

# gets a 14 bit long binary string from the map data array
@thirdvalue = "%14b" % self.data

# binary split of the two elements
@bLEFT = @thirdvalue # REGION ID IN BINARY
@bRIGHT = @thirdvalue # SHADOW ID IN BINARY

# converts the binary string back to an integer and returns
return(@bLEFT.to_i(2))

end
def getTileShadowID(reg_x,reg_y)

# gets a 14 bit long binary string from the map data array
@thirdvalue = "%14b" % self.data

# returns binary split of the two elements
@bLEFT = @thirdvalue # REGION ID IN BINARY
@bRIGHT = @thirdvalue # SHADOW ID IN BINARY

# converts the binary string back to an integer and returns
return(@bRIGHT.to_i(2))

end


#--------------------------------------------------------------------------
# MAP MANIPULATION
#--------------------------------------------------------------------------
def getTileIDByLayer(x,y,layer)
return(self.data)
end

def setTileIDByLayer(x,y,layer,tile_ID)
self.data = tile_ID
end


end


#--------------------------------------------------------------------------
# Save Tile Manipulation
#--------------------------------------------------------------------------
class Game_System
def changeTileByInternalID(map_id,x,y,layer,intID)
initialize_pos_list(map_id, layer)
tid = intID
@swapped_pos_tiles = [] if @swapped_pos_tiles.nil?
@swapped_pos_tiles = tid
$game_map.load_new_map_data
end
end
#--------------------------------------------------------------------------
# Battler Additions
#--------------------------------------------------------------------------
class Game_Battler < Game_BattlerBase
def wtype_equipped?(wtype_id)
return weapons.any? {|weapon| weapon.wtype_id == wtype_id }
end

def atype_equipped?(atype_id)
return armors.any? {|armor| armor.atype_id == atype_id}
end
end



Demo:

http://s000.tinyupload.com/?file_id=06010062965139142906

Screen:




本贴来自国际rpgmaker官方论坛作者:Quailar处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/basic-evented-fog-of-war.38029/
页: [1]
查看完整版本: Basic Evented Fog of War