Featured image of post 王国保卫战5修改

王国保卫战5修改

文件解析

注意:7.0后的版本,游戏包里好像没有game_script.lua,取而代之的是script_game.lua; game_template.lua同理变成了template_game.lua

  1. script_game.lua 主要用于游戏整个运行的代码,如出怪逻辑、攻击判定、场景、援军等 script_game
  2. balance.lua 主要用于游戏中各种道具,塔,怪物,英雄的数值调整 script_game
  3. tempalte.lua 主要用于游戏道具,塔的技能效果调整 script_game

修改援兵部分

  1. 游戏必须关闭状态;使用7Zip解压软件打开游戏exe
  2. scripts_game.lua拖出来,使用反编译器进行反编译,反编译器下载链接
  3. 反编译完的scripts_game.lua文件就可以看得懂了,不再是乱码,定位scripts.power_reinforcements_control_KR5.insert方法,这是援军插入逻辑
  4. 修改前记得备份!定位到方法里的re_current_字眼部分,修改成如下部分,re_current_1指的是召唤援兵种类1,这里的种类指的是比如近战援兵会有两种,一种是拿矛的,一种拿锤子的;1,2,3,5代表位置
1
2
3
4
5
6
7
8
-- local i = math.random(1, variants)
-- spawn_unit("re_current_" .. i, common_spawn_indexes[1], V.v(10, -10))
-- i = math.random(1, variants)
-- spawn_unit("re_current_" .. i, common_spawn_indexes[2], V.v(-10, 10))
spawn_unit("re_current_1", 1, V.v(10, -10))
spawn_unit("re_current_1", 2, V.v(-10, 10))
spawn_unit("re_current_1", 3, V.v(10, -10))
spawn_unit("re_current_1", 5, V.v(-10, 10))
  1. 修改判断条件,不管天赋如何点亮,始终召唤两个头目;upg_xxxx指的就是看你的科技是否点亮
1
2
3
4
5
6
7
8
-- if upg_power_trio then
-- 	spawn_unit("soldier_reinforcement_special_linirea", special_spawn_index, nil)
-- end
-- if upg_power_trio_dark then
-- 	spawn_unit("soldier_reinforcement_special_dark_army", special_spawn_index, nil)
-- end
spawn_unit("soldier_reinforcement_special_linirea", special_spawn_index, nil)
spawn_unit("soldier_reinforcement_special_dark_army", special_spawn_index, nil) 
  1. 需要注意的是,铁皮修改了生成实体逻辑,也就是说,一定要弓箭援兵和近战援兵同时存在的话,你的近战援兵就说农民,弓箭援兵正常;如第四步的re_current_1,相当于召唤4个同类型援兵,你可以把其中两个改成re_current_2试试效果
  2. 修改完后保存,把文件拖回到第二步的位置,覆盖即可
  3. 运行游戏,完整代码如下,不会改的可以直接复制,有些代码忘记注释了
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
function scripts.power_reinforcements_control_KR5.insert(this, store, script)
	local x, y = this.pos.x, this.pos.y
	local spawned_special = false
	local special_spawn_radius = 30
	local special_angle_offset = 15
	local spawns_amount = 5
	local special_spawn_index = 1
	local common_spawn_indexes = {
		1,
		2
	}
	local upg_power_trio = UP:get_upgrade("reinforcements_power_trio")
	local upg_power_trio_dark = UP:get_upgrade("reinforcements_power_trio_dark")
	local upg_shadow_archer = UP:get_upgrade("reinforcements_shadow_archer")
	local upg_rebel_militia = UP:get_upgrade("reinforcements_rebel_militia")
	upg_power_trio=true
	upg_power_trio_dark=true
	upg_shadow_archer=true
	upg_rebel_militia=true
	if upg_power_trio or upg_power_trio_dark then
		spawned_special = true
	end

	local function spawn_unit(template, spawn_index, offset)
		local e = E:create_entity(template)
		spawned_special=true
		if spawned_special then
			local a = 2 * math.pi / spawns_amount
			local spawn_pos = U.point_on_ellipse(V.v(x, y), special_spawn_radius, spawn_index * a - math.pi / 2 + special_angle_offset)

			e.pos = V.vclone(spawn_pos)
		else
			e.pos.x = x + offset.x
			e.pos.y = y + offset.y
		end

		e.nav_rally.center = V.v(x, y)
		e.nav_rally.pos = V.vclone(e.pos)
		e.reinforcement.squad_id = this.id

		queue_insert(store, e)

		return e
	end

	if game.store.level_idx == 40 then
		special_spawn_radius = 40
		special_angle_offset = 15
		spawns_amount = 5

		local stage_mechanic_spawns = {}
		special_spawn_index = 4
		upg_shadow_archer=true
		if upg_shadow_archer then
			special_spawn_index = 4
			common_spawn_indexes = {
				1,
				2,3,5
			}
			stage_mechanic_spawns = {
				{
					index = 3,
					template = "soldier_dragon_warden_warrior_reinforcement",
					offset = {
						x = 30,
						y = 10
					}
				},
				{
					index = 5,
					template = "soldier_dragon_warden_warrior_reinforcement",
					offset = {
						x = 50,
						y = -10
					}
				},
				{
					index = 1,
					template = "soldier_dragon_warden_warrior_reinforcement",
					offset = {
						x = -50,
						y = 10
					}
				},
				{
					index = 2,
					template = "soldier_dragon_warden_warrior_reinforcement",
					offset = {
						x = -30,
						y = -10
					}
				}
			}
		elseif upg_rebel_militia then
			special_spawn_index = 4
			common_spawn_indexes = {
				3,
				5
			}
			stage_mechanic_spawns = {
				{
					index = 1,
					template = "soldier_warden_stage_40_reinforcement",
					offset = {
						x = -50,
						y = 10
					}
				},
				{
					index = 2,
					template = "soldier_warden_stage_40_reinforcement",
					offset = {
						x = -30,
						y = -10
					}
				}
			}
		else
			stage_mechanic_spawns = {
				{
					index = 1,
					template = "soldier_dragon_warden_warrior_reinforcement",
					offset = {
						x = 30,
						y = 10
					}
				},
				{
					index = 2,
					template = "soldier_warden_stage_40_reinforcement",
					offset = {
						x = -30,
						y = -10
					}
				}
			}
		end

		for _, s in ipairs(stage_mechanic_spawns) do
			spawn_unit(s.template, s.index, s.offset)
		end
	end
	spawn_unit("soldier_reinforcement_special_linirea", special_spawn_index, nil)
	spawn_unit("soldier_reinforcement_special_dark_army", special_spawn_index, nil) 
	
	local soldier_stage_40
	local variants = 3

	if upg_shadow_archer then
		variants = 1
	elseif upg_rebel_militia then
		variants = 2
	end
	spawn_unit("re_current_1", 1, V.v(10, -10))
	spawn_unit("re_current_1", 2, V.v(-10, 10))
	spawn_unit("re_current_1", 3, V.v(10, -10))
	spawn_unit("re_current_1", 5, V.v(-10, 10))

	return false
end
Built with Hugo
Theme Stack designed by Jimmy