中级玩家
 
- 贡献度
- 0
- 金元
- 1070
- 积分
- 107
- 精华
- 0
- 注册时间
- 2013-10-25
|
我的红胡子海盗团,每次到冒险之门旁边的时候,让他们打几下,就自动跳出(没有警告)你看看哪里错了
forest.lua
local assets =
{
Asset("IMAGE", "images/colour_cubes/day05_cc.tex"),
Asset("IMAGE", "images/colour_cubes/dusk03_cc.tex"),
Asset("IMAGE", "images/colour_cubes/night03_cc.tex"),
Asset("IMAGE", "images/colour_cubes/snow_cc.tex"),
Asset("IMAGE", "images/colour_cubes/snowdusk_cc.tex"),
Asset("IMAGE", "images/colour_cubes/night04_cc.tex"),
Asset("IMAGE", "images/colour_cubes/insane_day_cc.tex"),
Asset("IMAGE", "images/colour_cubes/insane_dusk_cc.tex"),
Asset("IMAGE", "images/colour_cubes/insane_night_cc.tex"),
Asset("ANIM", "anim/snow.zip"),
Asset("ANIM", "anim/lightning.zip"),
Asset("ANIM", "anim/splash_ocean.zip"),
Asset("ANIM", "anim/frozen.zip"),
Asset("SOUND", "sound/forest_stream.fsb"),
Asset("IMAGE", "levels/textures/snow.tex"),
Asset("IMAGE", "images/wave.tex"),
}
local forest_prefabs =
{
"world",
"adventure_portal",
"resurrectionstone",
"deerclops",
"gravestone",
"flower",
"animal_track",
"dirtpile",
"beefaloherd",
"beefalo",
"penguinherd",
"penguin_ice",
"penguin",
"koalefant_summer",
"koalefant_winter",
"beehive",
"wasphive",
"walrus_camp",
"pighead",
"mermhead",
"rabbithole",
"carrot_planted",
"tentacle",
"wormhole",
"cave_entrance",
"teleportato_base",
"teleportato_ring",
"teleportato_box",
"teleportato_crank",
"teleportato_potato",
"pond",
"marsh_tree",
"marsh_bush",
"reeds",
"mist",
"snow",
"rain",
"maxwellthrone",
"maxwellendgame",
"maxwelllight",
"maxwelllock",
"maxwellphonograph",
"puppet_wilson",
"puppet_willow",
"puppet_wendy",
"puppet_wickerbottom",
"puppet_wolfgang",
"puppet_wx78",
"puppet_wes",
"puppet_woodie",
"marblepillar",
"marbletree",
"statueharp",
"statuemaxwell",
"eyeplant",
"lureplant",
"purpleamulet",
"monkey",
"livingtree",
}
local function fn(Sim)
local inst = SpawnPrefab("world")
inst.prefab = "forest"
inst.entity:SetCanSleep(false)
--add waves
local waves = inst.entity:AddWaveComponent()
waves:SetRegionSize( 40, 20 )
waves:SetRegionNumWaves( 6 )
waves:SetWaveTexture( "images/wave.tex" )
-- See source\game\components\WaveRegion.h
waves:SetWaveEffect( "shaders/waves.ksh" ) -- texture.ksh
--waves:SetWaveEffect( "shaders/texture.ksh" ) --
waves:SetWaveSize( 2048, 512 )
inst:AddComponent("clock")
inst:AddComponent("seasonmanager")
inst:AddComponent("birdspawner")
inst:AddComponent("butterflyspawner")
inst:AddComponent("hounded")
inst:AddComponent("basehassler")
inst:AddComponent("hunter")
inst.components.butterflyspawner:SetButterfly("butterfly")
inst:AddComponent("frograin")
inst:AddComponent("lureplantspawner")
inst:AddComponent("penguinspawner")
inst:AddComponent("colourcubemanager")
inst.Map:SetOverlayTexture( "levels/textures/snow.tex" )
return inst
end
return Prefab( "forest", fn, assets, forest_prefabs)
adventure_portal.lua
local BigPopupDialogScreen = require "screens/bigpopupdialog"
local assets=
{
Asset("ANIM", "anim/portal_adventure.zip"),
}
local function GetVerb(inst)
return STRINGS.ACTIONS.ACTIVATE.GENERIC
end
local function OnActivate(inst)
--do popup confirmation
--do portal presentation
--save and do restart
ProfileStatsSet("portal_used", true)
SetPause(true,"portal")
local function startadventure()
local function onsaved()
StartNextInstance({reset_action=RESET_ACTION.LOAD_SLOT, save_slot = SaveGameIndex:GetCurrentSaveSlot()}, true)
end
TheFrontEnd opScreen()
SetPause(false)
GetPlayer().sg:GoToState("teleportato_teleport")
ProfileStatsSet("portal_accepted", true)
GetPlayer() oTaskInTime(5, function() SaveGameIndex:StartAdventure(onsaved) end)
end
local function rejectadventure()
TheFrontEnd opScreen()
SetPause(false)
inst.components.activatable.inactive = true
ProfileStatsSet("portal_rejected", true)
end
-- A/B test
local bodytext = GetTestGroup() == 0 and STRINGS.UI.STARTADVENTURE.BODY or STRINGS.UI.STARTADVENTURE.BODY_TEST
TheFrontEnd ushScreen(BigPopupDialogScreen(STRINGS.UI.STARTADVENTURE.TITLE, bodytext,
{{text=STRINGS.UI.STARTADVENTURE.YES, cb = startadventure},
{text=STRINGS.UI.STARTADVENTURE.NO, cb = rejectadventure} }))
end
local function fn(Sim)
local inst = CreateEntity()
local trans = inst.entity:AddTransform()
local anim = inst.entity:AddAnimState()
inst.entity:AddSoundEmitter()
MakeObstaclePhysics(inst, 1)
local minimap = inst.entity:AddMiniMapEntity()
minimap:SetIcon( "portal.png" )
anim:SetBank("portal_adventure")
anim:SetBuild("portal_adventure")
anim layAnimation("idle_off", true)
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 layAnimation("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 istenForEvent("death", function()
local pt1 = bandit:GetPosition()
for k = 1,math.random(15,25) do
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 weapons = {"goldenaxe","spear","tentaclespike","batbat","ruins_bat"}
local weapon = weapons[math.random(#weapons)]
SpawnPrefab(weapon).Transform:SetPosition(pt1.x, 0, pt1.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 istenForEvent("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 estroy(bandit)
end
end)
bandit oPeriodicTask(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 ick(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 istenForEvent( "daytime", function() createbandit(inst) end , GetWorld())
inst istenForEvent( "nighttime", function() delbandit(inst) end , GetWorld())
inst.components.inspectable:RecordViews()
inst:AddComponent("playerprox")
inst.components.playerprox:SetDist(4,5)
inst.components.playerprox.onnear = function()
inst.AnimState ushAnimation("activate", false)
inst.AnimState ushAnimation("idle_loop_on", true)
inst.SoundEmitter laySound("dontstarve/common/maxwellportal_activate")
inst.SoundEmitter laySound("dontstarve/common/maxwellportal_idle", "idle")
inst oTaskInTime(1, function()
if inst.ragtime_playing == nil then
inst.ragtime_playing = true
inst.SoundEmitter:PlaySound("dontstarve/common/teleportato/ragtime", "ragtime")
else
inst.SoundEmitter:SetVolume("ragtime",1)
end
end)
end
inst.components.playerprox.onfar = function()
inst.AnimState:PushAnimation("deactivate", false)
inst.AnimState:PushAnimation("idle_off", true)
inst.SoundEmitter:KillSound("idle")
inst.SoundEmitter:PlaySound("dontstarve/common/maxwellportal_shutdown")
inst oTaskInTime(1, function()
inst.SoundEmitter:SetVolume("ragtime",0)
end)
end
inst:AddComponent("activatable")
inst.components.activatable.OnActivate = OnActivate
inst.components.activatable.inactive = true
inst.components.activatable.getverb = GetVerb
inst.components.activatable.quickaction = true
return inst
end
return Prefab( "common/adventure_portal", fn, assets)
|
|