要怎麼讀取資料庫中的資料(RGSS)
3 posters
回復: 要怎麼讀取資料庫中的資料(RGSS)
這是說明檔對敵人(Enemy)類的定義@~刀光劍影~@ 寫到:如何用RGSS來讀取資料庫中「敵人」的資料??
- 代碼:
module RPG
class Enemy
def initialize
@id = 0
@name = ""
@battler_name = ""
@battler_hue = 0
@maxhp = 500
@maxsp = 500
@str = 50
@dex = 50
@agi = 50
@int = 50
@atk = 100
@pdef = 100
@mdef = 100
@eva = 0
@animation1_id = 0
@animation2_id = 0
@element_ranks = Table.new(1)
@state_ranks = Table.new(1)
@actions = [RPG::Enemy::Action.new]
@exp = 0
@gold = 0
@item_id = 0
@weapon_id = 0
@armor_id = 0
@treasure_prob = 100
end
attr_accessor :id
attr_accessor :name
attr_accessor :battler_name
attr_accessor :battler_hue
attr_accessor :maxhp
attr_accessor :maxsp
attr_accessor :str
attr_accessor :dex
attr_accessor :agi
attr_accessor :int
attr_accessor :atk
attr_accessor :pdef
attr_accessor :mdef
attr_accessor :eva
attr_accessor :animation1_id
attr_accessor :animation2_id
attr_accessor :element_ranks
attr_accessor :state_ranks
attr_accessor :actions
attr_accessor :exp
attr_accessor :gold
attr_accessor :item_id
attr_accessor :weapon_id
attr_accessor :armor_id
attr_accessor :treasure_prob
end
end
在RMXP中一開始就將資料庫中的敵人資料全寫進$data_enemies裡
$data_enemies是以Array的形式儲存,例如要找id為1的敵人就用$data_enemies[1]
p $data_enemies[1].name # 1 號敵人的名稱
p $data_enemies[1].maxhp # 1 號敵人的maxhp
p $data_enemies[1].exp# 1 號敵人的經驗值
只要上面有定義為
attr_accessor :xxxx
你就可以用
$data_enemies[敵人id].xxxx
來讀取敵人資料庫參數
愚零鬥武多- 不正常人類研究中心自慰隊員
- 文章數 : 421
注冊日期 : 2008-04-06
回復: 要怎麼讀取資料庫中的資料(RGSS)
愚零鬥武多 寫到:這是說明檔對敵人(Enemy)類的定義@~刀光劍影~@ 寫到:如何用RGSS來讀取資料庫中「敵人」的資料??
- 代碼:
module RPG
class Enemy
def initialize
@id = 0
@name = ""
@battler_name = ""
@battler_hue = 0
@maxhp = 500
@maxsp = 500
@str = 50
@dex = 50
@agi = 50
@int = 50
@atk = 100
@pdef = 100
@mdef = 100
@eva = 0
@animation1_id = 0
@animation2_id = 0
@element_ranks = Table.new(1)
@state_ranks = Table.new(1)
@actions = [RPG::Enemy::Action.new]
@exp = 0
@gold = 0
@item_id = 0
@weapon_id = 0
@armor_id = 0
@treasure_prob = 100
end
attr_accessor :id
attr_accessor :name
attr_accessor :battler_name
attr_accessor :battler_hue
attr_accessor :maxhp
attr_accessor :maxsp
attr_accessor :str
attr_accessor :dex
attr_accessor :agi
attr_accessor :int
attr_accessor :atk
attr_accessor :pdef
attr_accessor :mdef
attr_accessor :eva
attr_accessor :animation1_id
attr_accessor :animation2_id
attr_accessor :element_ranks
attr_accessor :state_ranks
attr_accessor :actions
attr_accessor :exp
attr_accessor :gold
attr_accessor :item_id
attr_accessor :weapon_id
attr_accessor :armor_id
attr_accessor :treasure_prob
end
end
在RMXP中一開始就將資料庫中的敵人資料全寫進$data_enemies裡
$data_enemies是以Array的形式儲存,例如要找id為1的敵人就用$data_enemies[1]
p $data_enemies[1].name # 1 號敵人的名稱
p $data_enemies[1].maxhp # 1 號敵人的maxhp
p $data_enemies[1].exp# 1 號敵人的經驗值
只要上面有定義為
attr_accessor :xxxx
你就可以用
$data_enemies[敵人id].xxxx
來讀取敵人資料庫參數
所以ARPG小師就是用這個方法取得敵人的能力值
直接讀取資料庫的能力
不用耗到內建變數
應該是這樣吧!!
回復: 要怎麼讀取資料庫中的資料(RGSS)
@~刀光劍影~@ 寫到:愚零鬥武多 寫到:這是說明檔對敵人(Enemy)類的定義@~刀光劍影~@ 寫到:如何用RGSS來讀取資料庫中「敵人」的資料??
- 代碼:
module RPG
class Enemy
def initialize
@id = 0
@name = ""
@battler_name = ""
@battler_hue = 0
@maxhp = 500
@maxsp = 500
@str = 50
@dex = 50
@agi = 50
@int = 50
@atk = 100
@pdef = 100
@mdef = 100
@eva = 0
@animation1_id = 0
@animation2_id = 0
@element_ranks = Table.new(1)
@state_ranks = Table.new(1)
@actions = [RPG::Enemy::Action.new]
@exp = 0
@gold = 0
@item_id = 0
@weapon_id = 0
@armor_id = 0
@treasure_prob = 100
end
attr_accessor :id
attr_accessor :name
attr_accessor :battler_name
attr_accessor :battler_hue
attr_accessor :maxhp
attr_accessor :maxsp
attr_accessor :str
attr_accessor :dex
attr_accessor :agi
attr_accessor :int
attr_accessor :atk
attr_accessor :pdef
attr_accessor :mdef
attr_accessor :eva
attr_accessor :animation1_id
attr_accessor :animation2_id
attr_accessor :element_ranks
attr_accessor :state_ranks
attr_accessor :actions
attr_accessor :exp
attr_accessor :gold
attr_accessor :item_id
attr_accessor :weapon_id
attr_accessor :armor_id
attr_accessor :treasure_prob
end
end
在RMXP中一開始就將資料庫中的敵人資料全寫進$data_enemies裡
$data_enemies是以Array的形式儲存,例如要找id為1的敵人就用$data_enemies[1]
p $data_enemies[1].name # 1 號敵人的名稱
p $data_enemies[1].maxhp # 1 號敵人的maxhp
p $data_enemies[1].exp# 1 號敵人的經驗值
只要上面有定義為
attr_accessor :xxxx
你就可以用
$data_enemies[敵人id].xxxx
來讀取敵人資料庫參數
所以ARPG小師就是用這個方法取得敵人的能力值
直接讀取資料庫的能力
不用耗到內建變數
應該是這樣吧!!
變數也可以自己設定
而且你不用變數
怎麼讓怪物扣血
直接設定的話
下次遇到這支怪物生命就變0了...
雲的彼方- 拿著木劍的戰士
- 文章數 : 48
注冊日期 : 2008-08-09
回復: 要怎麼讀取資料庫中的資料(RGSS)
雲的彼方 寫到:@~刀光劍影~@ 寫到:愚零鬥武多 寫到:這是說明檔對敵人(Enemy)類的定義@~刀光劍影~@ 寫到:如何用RGSS來讀取資料庫中「敵人」的資料??
- 代碼:
module RPG
class Enemy
def initialize
@id = 0
@name = ""
@battler_name = ""
@battler_hue = 0
@maxhp = 500
@maxsp = 500
@str = 50
@dex = 50
@agi = 50
@int = 50
@atk = 100
@pdef = 100
@mdef = 100
@eva = 0
@animation1_id = 0
@animation2_id = 0
@element_ranks = Table.new(1)
@state_ranks = Table.new(1)
@actions = [RPG::Enemy::Action.new]
@exp = 0
@gold = 0
@item_id = 0
@weapon_id = 0
@armor_id = 0
@treasure_prob = 100
end
attr_accessor :id
attr_accessor :name
attr_accessor :battler_name
attr_accessor :battler_hue
attr_accessor :maxhp
attr_accessor :maxsp
attr_accessor :str
attr_accessor :dex
attr_accessor :agi
attr_accessor :int
attr_accessor :atk
attr_accessor :pdef
attr_accessor :mdef
attr_accessor :eva
attr_accessor :animation1_id
attr_accessor :animation2_id
attr_accessor :element_ranks
attr_accessor :state_ranks
attr_accessor :actions
attr_accessor :exp
attr_accessor :gold
attr_accessor :item_id
attr_accessor :weapon_id
attr_accessor :armor_id
attr_accessor :treasure_prob
end
end
在RMXP中一開始就將資料庫中的敵人資料全寫進$data_enemies裡
$data_enemies是以Array的形式儲存,例如要找id為1的敵人就用$data_enemies[1]
p $data_enemies[1].name # 1 號敵人的名稱
p $data_enemies[1].maxhp # 1 號敵人的maxhp
p $data_enemies[1].exp# 1 號敵人的經驗值
只要上面有定義為
attr_accessor :xxxx
你就可以用
$data_enemies[敵人id].xxxx
來讀取敵人資料庫參數
所以ARPG小師就是用這個方法取得敵人的能力值
直接讀取資料庫的能力
不用耗到內建變數
應該是這樣吧!!
變數也可以自己設定
而且你不用變數
怎麼讓怪物扣血
直接設定的話
下次遇到這支怪物生命就變0了...
我說的是內建變數...
如果還需要消耗到內建變數
愚大還會再補充的
回復: 要怎麼讀取資料庫中的資料(RGSS)
附帶一提,在RGSS裡敵人是以Game_Enemy的類別所生成一個獨立的本體,
在戰鬥前生成並存入Game_Troop這個類別
所以為何每次戰鬥就算重複的敵人都不會影響到$data_enemies裡的敵人本尊
白話一點就是說Game_Enemy是copy $data_enemies裡的敵人參數作為戰鬥者
在Game_Enemy你可以找到怪物對應的各種函數
在戰鬥前生成並存入Game_Troop這個類別
所以為何每次戰鬥就算重複的敵人都不會影響到$data_enemies裡的敵人本尊
白話一點就是說Game_Enemy是copy $data_enemies裡的敵人參數作為戰鬥者
在Game_Enemy你可以找到怪物對應的各種函數
愚零鬥武多- 不正常人類研究中心自慰隊員
- 文章數 : 421
注冊日期 : 2008-04-06
回復: 要怎麼讀取資料庫中的資料(RGSS)
恩,COPY一份後就不會發生遇到怪物生命變0之類的問題了愚零鬥武多 寫到:附帶一提,在RGSS裡敵人是以Game_Enemy的類別所生成一個獨立的本體,
在戰鬥前生成並存入Game_Troop這個類別
所以為何每次戰鬥就算重複的敵人都不會影響到$data_enemies裡的敵人本尊
白話一點就是說Game_Enemy是copy $data_enemies裡的敵人參數作為戰鬥者
在Game_Enemy你可以找到怪物對應的各種函數
這個論壇的權限:
您 無法 在這個版面回復文章
|
|