游戏达人
  
- 贡献度
- 80
- 金元
- 19062
- 积分
- 2236
- 精华
- 1
- 注册时间
- 2010-11-27
|
本帖最后由 yzzn2009 于 2014-1-19 03:11 编辑
loliy01 发表于 2014-1-19 02:17 
易宁哥,我今晚有反复测试了一下优化的红胡子脚本,可是。。。还是不显示人物。。。
...
我又优化了一下,按这个版本改,再试试
一九九.红胡子强盗团(强盗团通过冒险之门入侵,烧杀抢掠,打死强盗可得黄金、武器,89685版及以后游戏使用)
1.用记事本打开游戏目录\data\scripts\prefabs\forest.lua文件,在"puppet_wes",的下一行插入"puppet_woodie",
2.用记事本打开游戏目录\data\scripts\prefabs\adventure_portal.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function createbandit(inst)
for k = 1,math.random(20,35) do
local pt = inst:GetPosition()
local bandit = SpawnPrefab("beardhair")
bandit.Transform:SetPosition(pt.x+(math.random(50)-math.random(50)), 0, pt.z+(math.random(50)-math.random(50)))
bandit.AnimState:SetBank("wilson")
bandit.AnimState:SetBuild("woodie")
bandit.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat")
bandit.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body")
bandit.AnimState:Show("HAT")
bandit.AnimState:Show("HAT_HAIR")
bandit.AnimState:Hide("HAIR_NOHAT")
bandit.AnimState:Hide("HAIR")
bandit.AnimState:Hide("ARM_carry")
bandit.AnimState:Show("ARM_normal")
bandit.AnimState:PlayAnimation("idle")
local sound = bandit.entity:AddSoundEmitter()
local shadow = bandit.entity:AddDynamicShadow()
shadow:SetSize( 1.3, .6 )
bandit.Transform:SetFourFaced()
local brain = require "brains/frogbrain"
bandit:SetBrain(brain)
bandit:AddComponent("locomotor")
bandit.components.locomotor.walkspeed = 5
bandit.components.locomotor.runspeed = 10
bandit:SetStateGraph("SGshadowwaxwell")
MakeCharacterPhysics(bandit, 75, .5)
bandit:RemoveComponent("inventoryitem")
bandit:RemoveComponent("stackable")
bandit:RemoveComponent("fuel")
bandit:RemoveComponent("burnable")
bandit:RemoveComponent("propagator")
bandit:AddComponent("inventory")
bandit:AddComponent("thief")
bandit:AddComponent("knownlocations")
bandit:AddComponent("health")
bandit.components.health:SetMaxHealth(1500)
bandit:ListenForEvent("death", function()
for k = 1,math.random(15,25) do
local pt1 = bandit:GetPosition()
local gold = SpawnPrefab("goldnugget")
gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3)))
end
if math.random() < 0.1 then
local pt2 = bandit:GetPosition()
local weapons = {"goldenaxe","spear","tentaclespike","batbat","ruins_bat"}
local weapon = weapons[math.random(#weapons)]
SpawnPrefab(weapon).Transform:SetPosition(pt2.x, 0, pt2.z)
end
end )
bandit:AddComponent("combat")
bandit.components.combat:SetDefaultDamage(20)
bandit.components.combat:SetAttackPeriod(1)
bandit.components.combat:SetRetargetFunction(2, function(bandit)
if not bandit.components.health:IsDead() then
return FindEntity(bandit, 20, function(guy)
return bandit.components.combat:CanTarget(guy) and not guy:HasTag("bandits")
end )
end
end )
bandit.components.combat.onhitotherfn = function(bandit, other, damage) bandit.components.thief:StealItem(other) end
bandit:ListenForEvent("attacked", function(bandit, data)
bandit.components.combat:SetTarget(data.attacker)
bandit.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("bandits") and not dude.components.health:IsDead() end, 5)
end )
bandit.Physics:SetCollisionCallback(function(bandit, other)
if other and other.components.workable and other.components.workable.workleft > 0 then
other.components.workable:Destroy(bandit)
end
end)
bandit:DoPeriodicTask(1, function(bandit)
local pos = Vector3(bandit.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3)
for k,v in pairs(ents) do
if v.components.pickable and v.components.pickable:CanBePicked() then
v.components.pickable:Pick(bandit)
end
if v.components.crop then
v.components.crop:Harvest(bandit)
end
end
end )
local minimap = bandit.entity:AddMiniMapEntity()
minimap:SetIcon( "lucy_axe.png" )
bandit:AddTag("monster")
bandit:AddTag("bandits")
end
end
local function delbandit(inst)
local range = 3000
local pos = Vector3(inst.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, range)
for k,v in pairs(ents) do
if v:HasTag("bandits") then
v:Remove()
end
end
end
inst:ListenForEvent( "daytime", function() createbandit(inst) end , GetWorld())
inst:ListenForEvent( "nighttime", function() delbandit(inst) end , GetWorld())
3.用记事本打开游戏目录\data\scripts\prefabs\beardhair.lua文件,在Asset("ANIM", "anim/beardhair.zip"),的下一行插入以下内容:
Asset("ANIM", "anim/woodie.zip"),
Asset("SOUND", "sound/woodie.fsb"),
4.在inst:AddComponent("inspectable")的下一行插入以下内容:
local names = {"swap_goldenaxe","swap_spear","swap_spike","swap_batbat","swap_ruins_bat"}
local weapon = names[math.random(#names)]
local items = { SWORD = weapon }
local function EquipItem(inst, item)
if item then
inst.AnimState:OverrideSymbol("swap_object", item, item)
inst.AnimState:Show("ARM_carry")
inst.AnimState:Hide("ARM_normal")
end
end
inst.items = items
inst.equipfn = EquipItem
EquipItem(inst)
local function onsave(inst, data)
if inst:HasTag("bandits") then
data.bandits = true
end
end
local function onload(inst, data)
if data and data.bandits then
inst.AnimState:SetBank("wilson")
inst.AnimState:SetBuild("woodie")
inst.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat")
inst.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body")
inst.AnimState:Show("HAT")
inst.AnimState:Show("HAT_HAIR")
inst.AnimState:Hide("HAIR_NOHAT")
inst.AnimState:Hide("HAIR")
inst.AnimState:Hide("ARM_carry")
inst.AnimState:Show("ARM_normal")
inst.AnimState:PlayAnimation("idle")
local sound = inst.entity:AddSoundEmitter()
local shadow = inst.entity:AddDynamicShadow()
shadow:SetSize( 1.3, .6 )
inst.Transform:SetFourFaced()
local brain = require "brains/frogbrain"
inst:SetBrain(brain)
inst:AddComponent("locomotor")
inst.components.locomotor.walkspeed = 5
inst.components.locomotor.runspeed = 10
inst:SetStateGraph("SGshadowwaxwell")
MakeCharacterPhysics(inst, 75, .5)
inst:RemoveComponent("inventoryitem")
inst:RemoveComponent("stackable")
inst:RemoveComponent("fuel")
inst:RemoveComponent("burnable")
inst:RemoveComponent("propagator")
inst:AddComponent("inventory")
inst:AddComponent("thief")
inst:AddComponent("knownlocations")
inst:AddComponent("health")
inst.components.health:SetMaxHealth(1500)
inst:ListenForEvent("death", function()
for k = 1,math.random(15,25) do
local pt1 = inst:GetPosition()
local gold = SpawnPrefab("goldnugget")
gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3)))
end
if math.random() < 0.1 then
local pt2 = inst:GetPosition()
local weapons = {"goldenaxe","spear","tentaclespike","batbat","ruins_bat"}
local weapon = weapons[math.random(#weapons)]
SpawnPrefab(weapon).Transform:SetPosition(pt2.x, 0, pt2.z)
end
end )
inst:AddComponent("combat")
inst.components.combat:SetDefaultDamage(20)
inst.components.combat:SetAttackPeriod(1)
inst.components.combat:SetRetargetFunction(2, function(inst)
if not inst.components.health:IsDead() then
return FindEntity(inst, 20, function(guy)
return inst.components.combat:CanTarget(guy) and not guy:HasTag("bandits")
end )
end
end )
inst.components.combat.onhitotherfn = function(inst, other, damage) inst.components.thief:StealItem(other) end
inst:ListenForEvent("attacked", function(inst, data)
inst.components.combat:SetTarget(data.attacker)
inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("bandits") and not dude.components.health:IsDead() end, 5)
end )
inst.Physics:SetCollisionCallback(function(inst, other)
if other and other.components.workable and other.components.workable.workleft > 0 then
other.components.workable:Destroy(inst)
end
end)
inst:DoPeriodicTask(1, function(inst)
local pos = Vector3(inst.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3)
for k,v in pairs(ents) do
if v.components.pickable and v.components.pickable:CanBePicked() then
v.components.pickable:Pick(inst)
end
if v.components.crop then
v.components.crop:Harvest(inst)
end
end
end )
local minimap = inst.entity:AddMiniMapEntity()
minimap:SetIcon( "lucy_axe.png" )
inst:AddTag("monster")
inst:AddTag("bandits")
end
end
inst.OnSave = onsave
inst.OnLoad = onload
即可有红胡子强盗通过冒险之门入侵你的大陆(修改后第2天早晨出现),他们将盘踞在冒险之门附近,毁坏森林、拆毁建筑、抢掠农作物,所到之处没有活口。通过小地图可查询强盗所在位置,显示为红斧子图标。与强盗交战时,他们会抢掠你身上的物品,并且附近的强盗将一起来围攻你,蛮干无异于送死,争取各个击破吧。从此在冒险之门周围,白天和傍晚都是危险的,只有漆黑的夜里,才是你可以喘息之际。打死强盗可获得战利品(不菲的黄金和他们抢来的赃物),还有一定概率掉落武器。如果同时修改了“雇佣兵工厂”,你的铁甲战团终于有了用武之地。同胞们,饥荒世界正遭遇重大危机,亿万苍生期盼着你,起兵去攻打强盗吧,这是旷日持久的反抗,也是正义而光荣的战争,用你的每一滴鲜血去证明,新一代的救世主,从此诞生了
|
|