- 好友
- 0
- 在线时间
- 0 小时
- 最后登录
- 2026-9-14
随仆

- UID
- 3223690
- 第纳尔
- 139
- 精华
- 0
- 互助
- 1
- 荣誉
- 0
- 贡献
- 0
- 魅力
- 0
- 注册时间
- 2021-2-27
 鲜花( 0)  鸡蛋( 0)
|
本帖最后由 llkkp 于 2026-9-1 11:12 编辑
好像很少人用WSE2,分享一下自己写的简单脚本。
仅仅只在WSE2启动生效!(文件解压之后,把lua丢进模组目录里(比如C:\SteamLibrary\steamapps\common\MountBlade Warband\Modules\Viking Conquest)
WSE2最新版本已经测试生效(https://github.com/Ruslan-700/WSE2-Releases/releases/tag/v1.1.5.1)
WSE2 Lua: 所有战场命中伤害保底 1 点:
function hitCond()
return true
end
function hitHandler()
local damage = game.store_trigger_param_3(0)
if not damage or damage >= 1 then return end
game.set_trigger_result(1)
return 1
end
玩家击杀增加属性:
local ProcChance = 100 -- 击杀后获得的概率(%)
local StrengthBonus = 1 -- 每次增加的值
math.randomseed(os.time())
function attackerIsPlayer()
local attacker = game.store_trigger_param_2(0)
local playerId = game.get_player_agent_no(0)
return attacker == playerId
end
function lifeSteal()
-- 概率加力量(同时加魅力)0=力量,1=敏捷,2=智力,3=魅力)
local strGained = false
if math.random(1, 100) <= ProcChance then
if game.troop_raise_attribute then
local ok, err = pcall(game.troop_raise_attribute, 0, 0, StrengthBonus)
if ok then
strGained = true
pcall(game.troop_raise_attribute, 0, 3, StrengthBonus) -- 加魅力
else
print("[ERROR] troop_raise_attribute failed:", err)
end
else
print("[ERROR] game.troop_raise_attribute not found")
end
end
end
-- 全部模板注册
for i = 0, game.getNumTemplates() - 1 do
game.addTrigger(i, -26.0, 0, 0, attackerIsPlayer, lifeSteal)
end
玩家击杀敌随机增加金钱:
math.randomseed(os.time())
function addPlayerGold(amount)
if game.troop_add_gold then
game.troop_add_gold(0, amount)
else
game.execute_operation("troop_add_gold", 0, amount)
end
end
function attackerIsPlayer()
local attacker = game.store_trigger_param_2(0)
local playerId = game.get_player_agent_no(0)
return attacker == playerId
end
function lifeStealGoldOnly()
local randomGold = math.random(50, 5000)
local goldOk, _ = pcall(addPlayerGold, randomGold)
if goldOk then
game.display_message("+" .. randomGold .. " Gold", 0x00FF00)
end
end
for i = 0, game.getNumTemplates() - 1 do
game.addTrigger(i, -26.0, 0, 0, attackerIsPlayer, lifeStealGoldOnly)
end
game.display_message("Lua: 击 杀 加 钱 已 加 载 ", 0x00FF00)
|
|