游戏达人
  
- 贡献度
- 80
- 金元
- 19062
- 积分
- 2236
- 精华
- 1
- 注册时间
- 2010-11-27
|
靚仔 发表于 2013-12-11 21:49 
把更新發一下。。。
順便問一下,寧哥都玩什麼形式的代碼啊。。。
我在玩visual basic ,跟lua得有好大分別 ...
lua我也只是了解一些皮毛,你可以看看http://www.lua.org/manual/5.2/
一八六.宠物狗(用齿轮种宠物狗,陪伴、战斗两相宜)
1.用记事本打开游戏目录\data\scripts\prefabs\gears.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function OnDeploy (inst, pt)
local dog = SpawnPrefab("teenbird")
dog.Transform:SetPosition(pt.x, pt.y, pt.z)
dog.AnimState:SetBank("hound")
dog.AnimState:SetBuild("hound_ice")
dog:SetStateGraph("SGhound")
dog.components.follower:SetLeader(GetPlayer())
dog.Transform:SetScale(0.6, 0.6, 0.6)
dog:AddTag("dogs")
dog.components.health:SetMaxHealth(10000)
dog.components.locomotor.runspeed = 20
dog:RemoveComponent("growable")
inst.components.stackable:Get():Remove()
end
inst:AddComponent("deployable")
inst.components.deployable.ondeploy = OnDeploy
2.用记事本打开游戏目录\data\scripts\prefabs\smallbird.lua文件,在inst:AddTag("teenbird")的下一行插入以下内容:
local function onsave(inst, data)
if inst:HasTag("dogs") then
data.dogs = true
end
end
local function onload(inst, data)
if data.dogs then
inst.AnimState:SetBank("hound")
inst.AnimState:SetBuild("hound_ice")
inst:SetStateGraph("SGhound")
inst.components.follower:SetLeader(GetPlayer())
inst.Transform:SetScale(0.6, 0.6, 0.6)
inst.components.health:SetMaxHealth(10000)
inst.components.locomotor.runspeed = 20
inst:RemoveComponent("growable")
inst:AddTag("dogs")
end
end
inst.OnSave = onsave
inst.OnLoad = onload
即可用齿轮种一只宠物狗,它可以陪伴你,帮你打怪,是个活力十足的小淘气。宠物狗需要喂食(什么都吃),不然会咬你(轻轻的),通过喂食可以为它补血。最好在家的角落里扔一些食物,让它随饿随吃。宠物狗也是有脾气的,一旦强制攻击了它,就不和你作朋友了(存档退出后再读档,可恢复跟随)
一八七.人工女友(骨眼召唤女友,可背东西、做饭、换衣帽,89685版及以后游戏使用)
用记事本打开游戏目录\data\scripts\prefabs\chester.lua文件
1.将下列内容:
inst.AnimState:SetBank("chester")
inst.AnimState:SetBuild("chester")
替换为:
inst.AnimState:SetBank("wilson")
inst.AnimState:SetBuild("wendy")
inst.AnimState:Hide("ARM_carry")
inst.AnimState:Show("ARM_normal")
2.将下列内容:
--print(" sleeper")
inst:AddComponent("sleeper")
inst.components.sleeper:SetResistance(3)
inst.components.sleeper.testperiod = GetRandomWithVariance(6, 2)
inst.components.sleeper:SetSleepTest(ShouldSleep)
inst.components.sleeper:SetWakeTest(ShouldWakeUp)
--print(" sg")
inst:SetStateGraph("SGchester")
inst.sg:GoToState("idle")
替换为:
inst:SetStateGraph("SGshadowwaxwell")
inst.sg:GoToState("idle")
inst:AddTag("fridge")
inst:DoPeriodicTask(400, function()
local names = {"waffles","turkeydinner","baconeggs"}
local name = names[math.random(#names)]
local foods = SpawnPrefab(name)
inst.components.container:GiveItem(foods)
inst.SoundEmitter:PlaySound("dontstarve/HUD/research_available")
end)
local function turnon(inst)
local hats = {"hat_flower","hat_earmuffs","hat_feather","hat_slurper","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_beefalo"}
inst.hat = hats[math.random(#hats)]
local armors = {"armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_sanity","armor_slurper"}
inst.armor = armors[math.random(#armors)]
inst.components.machine.ison = true
inst.sg:GoToState("hit")
inst.AnimState:OverrideSymbol("swap_hat", inst.hat, "swap_hat")
inst.AnimState:OverrideSymbol("swap_body", inst.armor, "swap_body")
inst.AnimState:Show("HAT")
inst.AnimState:Show("HAT_HAIR")
inst.AnimState:Hide("HAIR_NOHAT")
inst.AnimState:Hide("HAIR")
end
local function turnoff(inst)
inst.components.machine.ison = false
inst.sg:GoToState("stunned")
inst.AnimState:Hide("HAT")
inst.AnimState:Hide("HAT_HAIR")
inst.AnimState:Show("HAIR_NOHAT")
inst.AnimState:Show("HAIR")
inst.AnimState:ClearOverrideSymbol("swap_body")
inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt")
end
inst:AddComponent("machine")
inst.components.machine.turnonfn = turnon
inst.components.machine.turnofffn = turnoff
inst:AddComponent("sanityaura")
inst.components.sanityaura.aura = TUNING.SANITYAURA_HUGE
inst:AddComponent("heater")
inst.components.heater.heat = 180
即可在地图上找到骨眼后,获得人工女友(温蒂),除了帮你拿东西外(可以冷藏),每天还将为你做一份料理(鼠标左键点她,在格子里拿取)。用鼠标右键点女友,可以为她换衣服、帽子,再次点右键脱下衣帽。与她紧紧依偎可以获得温暖(不会冻伤),并补充脑值(不再孤独了)。携带骨眼则女友跟随,放下骨眼则女友原地等待,一旦女友牺牲了,将骨眼扔在地上,几天后会再相聚。如果将其中inst.AnimState:SetBuild("wendy")替换为inst.AnimState:SetBuild("willow"),则将女友设定为薇洛。原有切斯特狗箱取消
一九三.许愿池(给池塘黄金消顽皮值,天上有机会下黄金雨,接到就是你的)
用记事本打开游戏目录\data\scripts\prefabs\pond.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function ShouldAcceptItem(inst, item)
if item.prefab == "goldnugget" then
return true
end
return false
end
local function OnGetItemFromPlayer(inst, giver, item)
if GetPlayer().components.kramped and GetPlayer().components.kramped.threshold > 0 then
GetPlayer().components.kramped.threshold = GetPlayer().components.kramped.threshold -1
GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/krampus/beenbad_lvl3")
end
if math.random()<.1 then
GetPlayer().SoundEmitter:PlaySound("dontstarve/music/music_hoedown", "beavermusic")
SpawnPrefab("multifirework_fx").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition())
inst:StartThread(function()
for k = 1, 50 do
local pt = Vector3(giver.Transform:GetWorldPosition())
local gold = SpawnPrefab("goldnugget")
gold.Transform:SetPosition(pt.x+(math.random(5)-math.random(5)), 20, pt.z+(math.random(5)-math.random(5)))
gold.components.inventoryitem.canbepickedup = false
inst:DoTaskInTime(1.8, function()
local pos = Vector3(gold.Transform:GetWorldPosition())
local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2)
for k,v in pairs(ents) do
if v:HasTag("player") then
v.components.inventory:GiveItem(gold)
end
end
end)
inst:DoTaskInTime(2, function()
local pt2 = gold:GetPosition()
if not gold.components.inventoryitem:IsHeld() then
GetPlayer().SoundEmitter:PlaySound("dontstarve/common/stone_drop")
SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(pt2.x, 0, pt2.z)
gold:Remove()
else
gold.components.inventoryitem.canbepickedup = true
end
end)
Sleep(1)
end
GetPlayer().SoundEmitter:KillSound("beavermusic")
end)
end
end
inst:AddComponent("trader")
inst.components.trader.onaccept = OnGetItemFromPlayer
inst.components.trader:SetAcceptTest(ShouldAcceptItem)
即可拿着黄金对池塘点左键,每次消减一点顽皮值(杀小动物的惩罚点数),并发出喘息声,如果没有喘息声,表示你的顽皮值已经为零,罪已经赎清了。许愿的过程中,天上有一定概率下起黄金雨(50个黄金),黄金落地弹起的刹那,如果你接到就归你了(跑到黄金掉落位置),否则会摔碎,试试你的反应能力吧
二0七.璀璨流星雨(给远古盔甲10个黄金或荧光果,为你下场流星雨)
用记事本打开游戏目录\data\scripts\prefabs\armor_ruins.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function ShouldAcceptItem(inst, item)
if GetPlayer().components.inventory:Has("goldnugget", 10) then
if item.prefab == "goldnugget" then
return true
end
end
if GetPlayer().components.inventory:Has("lightbulb", 10) then
if item.prefab == "lightbulb" then
return true
end
end
return false
end
local function OnGetItemFromPlayer(inst, giver, item)
if item.prefab == "goldnugget" then
giver.components.inventory:ConsumeByName("goldnugget", 9)
elseif item.prefab == "lightbulb" then
giver.components.inventory:ConsumeByName("lightbulb", 9)
end
local bullet = SpawnPrefab("trinket_5")
bullet.Transform:SetPosition(inst.Transform:GetWorldPosition())
bullet:RemoveComponent("edible")
bullet.components.inventoryitem.canbepickedup = false
bullet.Physics:SetMotorVelOverride(0,20,0)
giver.components.sanity:DoDelta(10)
GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo")
inst:DoTaskInTime(1, function() bullet:Remove()
SpawnPrefab("multifirework_fx").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition()) end )
inst:DoTaskInTime(1.5, function()
inst:StartThread(function()
for k = 1, 200 do
local pt = Vector3(GetPlayer().Transform:GetWorldPosition())
local rain = SpawnPrefab("lightbulb")
rain.components.inventoryitem.canbepickedup = false
if item.prefab == "goldnugget" then
rain.AnimState:SetMultColour(math.random(255)/255,math.random(255)/255,math.random(255)/255,1)
end
rain.Transform:SetPosition(pt.x+(math.random(30)-math.random(30)), 20, pt.z+(math.random(30)-math.random(30)))
inst:DoTaskInTime(5, function()
local pt2 = rain:GetPosition()
SpawnPrefab("explode_small").Transform:SetPosition(pt2.x, 0, pt2.z)
rain:Remove()
end)
Sleep(0.2)
end
end)
end)
end
inst:AddComponent("trader")
inst.components.trader.onaccept = OnGetItemFromPlayer
inst.components.trader:SetAcceptTest(ShouldAcceptItem)
即可拿着黄金或荧光果,对放在地上的远古盔甲点鼠标左键,将向空中发射火箭,打下漫天的流星雨。每次发射消耗10个黄金或荧光果,身上数量不足时无法发射。如果给远古盔甲的是黄金,则下彩色流星雨,如果给的是荧光果则下白色流星雨。可以连续发射,但不要连续次数太多,除非你的计算机硬件足够坚强。每场流星雨可补脑10点。另外穿着远古盔甲,拿黄金或荧光果对装备格点鼠标右键,同样可以发射。远古盔甲在远古选项(画着远古祭坛)下,用6个铥矿石、4个噩梦燃料制造,制造时需要靠近远古祭坛
二0八.完好如初(红色魔杖可修复物品、回复新鲜度、补充燃料及治愈同伴)
用记事本打开游戏目录\data\scripts\prefabs\staff.lua文件,在local inst = commonfn("red")的下一行插入以下内容:
local function canbeback(staff, caster, target, pos)
if caster.components.inventory:Has("goldnugget", 1) then
return true
end
return false
end
local function beback(staff, target, pos)
local player = GetPlayer()
SpawnPrefab("book_fx").Transform:SetPosition(target.Transform:GetWorldPosition())
if target.components.fueled then
target.components.fueled.currentfuel = target.components.fueled.maxfuel
player.components.inventory:ConsumeByName("goldnugget", 1)
end
if target.components.finiteuses then
target.components.finiteuses.current = target.components.finiteuses.total
player.components.inventory:ConsumeByName("goldnugget", 1)
end
if target.components.armor then
target.components.armor.condition = target.components.armor.maxcondition
player.components.inventory:ConsumeByName("goldnugget", 1)
end
if target.components.perishable then
target.components.perishable.perishremainingtime = target.components.perishable.perishtime
player.components.inventory:ConsumeByName("goldnugget", 1)
end
if target.components.health then
target.components.health.currenthealth = target.components.health.maxhealth
player.components.inventory:ConsumeByName("goldnugget", 1)
end
end
inst:AddComponent("spellcaster")
inst.components.spellcaster:SetSpellFn(beback)
inst.components.spellcaster:SetSpellTestFn(canbeback)
inst.components.spellcaster.canuseontargets = true
inst.components.spellcaster.canusefrominventory = false
即可将想要修复的物品放在地上,装备红色魔杖右键点地上的物品,可修复武器装备使用百分比,回复食物新鲜度,为照明物品补充燃料,也可用于治疗同伴。每次使用须支付1个黄金,身上没有黄金时无法使用。可堆叠的物品尽量堆在一起修复,这样只要花费1个黄金即可
二0九.乡间别墅(用巨鹿眼球种别墅,左键点击可睡觉,右键点击打开库房)
1.用记事本打开游戏目录\data\scripts\prefabs\deerclops_eyeball.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function OnDeploy (inst, pt)
local house = SpawnPrefab("tent")
house.Transform:SetPosition(pt.x, pt.y, pt.z)
house.AnimState:SetBank("pig_house")
house.AnimState:SetBuild("pig_house")
house.AnimState:PlayAnimation("lit", true)
house.AnimState:SetMultColour(150/255,150/255,150/255,1)
house.Transform:SetScale(1.5, 1.5, 1.5)
house:AddTag("houses")
local minimap = house.entity:AddMiniMapEntity()
minimap:SetIcon( "pighouse.png" )
house.components.finiteuses:SetMaxUses(10000)
house.components.finiteuses:SetUses(10000)
if house.components.trader then house:RemoveComponent("trader") end
local light = house.entity:AddLight()
light:Enable(true)
house:AddComponent("machine")
house.components.machine.turnonfn = function() house.components.container:Open(GetPlayer()) end
house.components.machine.turnofffn = function() house.components.container:Open(GetPlayer()) end
house.components.container.canbeopened = true
house.components.sleepingbag.onsleep = function(inst, sleeper)
sleeper.components.health:SetInvincible(true)
sleeper.components.playercontroller:Enable(false)
GetPlayer().HUD:Hide()
TheFrontEnd:Fade(false,1)
inst:DoTaskInTime(1.2, function()
GetPlayer().HUD:Show()
TheFrontEnd:Fade(true,1)
sleeper.components.sanity:DoDelta(TUNING.SANITY_HUGE)
sleeper.components.hunger:DoDelta(TUNING.CALORIES_HUGE, false, true)
sleeper.components.health:DoDelta(TUNING.HEALING_HUGE, false, "tent", true)
sleeper.components.temperature:SetTemperature(sleeper.components.temperature.maxtemp)
GetClock():MakeNextDay()
sleeper.components.health:SetInvincible(false)
sleeper.components.playercontroller:Enable(true)
end)
end
inst:Remove()
end
inst:AddComponent("deployable")
inst.components.deployable.ondeploy = OnDeploy
2.用记事本打开游戏目录\data\scripts\prefabs\tent.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function onsave(inst, data)
if inst:HasTag("houses") then
data.houses = true
end
end
local function onload(inst, data)
if data and data.houses then
inst.AnimState:SetBank("pig_house")
inst.AnimState:SetBuild("pig_house")
inst.AnimState:PlayAnimation("lit", true)
inst.AnimState:SetMultColour(150/255,150/255,150/255,1)
inst.Transform:SetScale(1.5, 1.5, 1.5)
inst:AddTag("houses")
local minimap = inst.entity:AddMiniMapEntity()
minimap:SetIcon( "pighouse.png" )
inst.components.finiteuses:SetMaxUses(10000)
inst.components.finiteuses:SetUses(10000)
if inst.components.trader then inst:RemoveComponent("trader") end
local light = inst.entity:AddLight()
light:Enable(true)
inst:AddComponent("machine")
inst.components.machine.turnonfn = function() inst.components.container:Open(GetPlayer()) end
inst.components.machine.turnofffn = function() inst.components.container:Open(GetPlayer()) end
inst.components.container.canbeopened = true
inst.components.sleepingbag.onsleep = function(inst, sleeper)
sleeper.components.health:SetInvincible(true)
sleeper.components.playercontroller:Enable(false)
GetPlayer().HUD:Hide()
TheFrontEnd:Fade(false,1)
inst:DoTaskInTime(1.2, function()
GetPlayer().HUD:Show()
TheFrontEnd:Fade(true,1)
sleeper.components.sanity:DoDelta(TUNING.SANITY_HUGE)
sleeper.components.hunger:DoDelta(TUNING.CALORIES_HUGE, false, true)
sleeper.components.health:DoDelta(TUNING.HEALING_HUGE, false, "tent", true)
sleeper.components.temperature:SetTemperature(sleeper.components.temperature.maxtemp)
GetClock():MakeNextDay()
sleeper.components.health:SetInvincible(false)
sleeper.components.playercontroller:Enable(true)
end)
end
end
end
inst.OnSave = onsave
inst.OnLoad = onload
local light = inst.entity:AddLight()
light:SetFalloff(1)
light:SetIntensity(.8)
light:SetRadius(10)
light:Enable(false)
light:SetColour(180/255, 195/255, 50/255)
local slotpos = {}
for y = 2, 0, -1 do
for x = 0, 8 do
table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2+75,0))
table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2-175,0))
table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2-425,0))
end
end
inst:AddComponent("container")
inst.components.container:SetNumSlots(#slotpos)
inst.components.container.widgetslotpos = slotpos
inst.components.container.widgetpos = Vector3(-150,300,0)
inst.components.container.side_align_tip = 160
inst.components.container.canbeopened = false
inst:AddTag("fridge")
即可用巨鹿眼球种别墅,用鼠标左键点击别墅可睡觉(白天也可以睡),睡醒后会补脑、饥饿、生命值。鼠标右键点击别墅,会打开库房(远离别墅自动关闭),共81格存储空间,并有冷藏功能。别墅日夜灯火通明,会照亮周边。不想要别墅时,用锤子砸毁即可,记住先把库房里的东西取出来哦
|
|