Red de conocimiento informático - Material del sitio web - Esperando en línea los documentos del juego Don't Starve data\scripts\prefabs\chester.lua

Esperando en línea los documentos del juego Don't Starve data\scripts\prefabs\chester.lua

requiere "prefabutil"

cerebro local = requiere "cerebros/chesterbrain"

requiere "stategraphs/SGchester"

local WAKE_TO_FOLLOW_DISTANCE = 14

SLEEP_NEAR_LEADER_DISTANCE local = 7

activos locales =

{

Activo("ANIM", "anim/ui_chester_shadow_3x4.zip" ),

Activo("ANIM", "anim/ui_chest_3x3.zip"),

Activo("ANIM", "anim/chester.zip"),

Activo("ANIM", "anim/chester_build.zip"),

Activo("ANIM", "anim/chester_shadow_build.zip"),

Activo(" ANIM", "anim/chester_snow_build.zip"),

Asset("SOUND", "sound/chester.fsb"),

}

local prefabs =

{

"chester_eyebone",

"die_fx",

"chesterlight",

"sparklefx",

}

la función local ShouldWakeUp(inst)

devuelve DefaultWakeTest(inst) o no inst.components.follower: IsNearLeader(WAKE_TO_FOLLOW_DISTANCE)

fin

función local ShouldSleep(inst)

--print(inst, "ShouldSleep", DefaultSleepTest(inst), not inst.sg:HasStateTag(" open"), inst.components.follower: IsNearLeader(SLEEP_NEAR_LEADER_DISTANCE))

devuelve DefaultSleepTest(inst) y no inst.sg: HasStateTag("open")

e inst.components .follower:IsNearLeader(SLEEP_NEAR_LEADER_DISTANCE)

y GetWorld().components.clock:GetMoonPhase() ~= "full"

fin

función local

ShouldKeepTarget(inst, target)

devuelve falso: Chester no puede atacar y no dormirá si tiene una función local objetivo

end

OnOpen(inst)

si no es inst.components.health:IsDead() entonces

si es inst.MorphTask entonces

inst.MorphTask:Cancel()

inst.MorphTask = nil

fin

inst.sg: GoToState("open")

fin

finalizar

función local OnClose(inst)

si no es inst.components.health:IsDead() entonces

inst.sg:GoToState("cerrar" )

end

end

-- el hueso del ojo fue asesinado/destruido

función local OnStopFollowing(inst)

--print("chester - OnStopFollowing")

inst: RemoveTag("companion")

end

función local OnStartFollowing(inst) p>

--print("chester - OnStartFollowing")

inst: AddTag("companion")

end

ranura localpos_3x3 = {}

para y = 2, 0, -1 hacer

para x = 0, 2 hacer

table.insert(slotpos_3x3, Vector3(80* x- 80*2 80, 80*y-80*2 80, 0))

fin

fin

ranura localpos_3x4 = {}

para y = 2.5, -0.5, -1 hacer

para x = 0, 2 hacer

table.insert(slotpos_3x4, Vector3(75*x-75* 2 75 , 75*y-75*2 75, 0))

fin

fin

función local MorphShadowChester(inst, dofx)

inst: AddTag("spoiler")

inst.components.container: SetNumSlots(#slotp

os_3x4)

inst.components.container.widgetslotpos = slotpos_3x4

inst.components.container.widgetanimbank = "ui_chester_shadow_3x4"

inst.components.container.widgetanimbuild = "ui_chester_shadow_3x4"

inst.components.container.widgetpos = Vector3(0, 220, 0)

inst.components.container.widgetpos_controller = Vector3(0, 220, 0)

inst.components.container.side_align_tip = 160

líder local = inst.components.follower.leader

si líder entonces

inst.components.follower.leader: MorphShadowEyebone()

end

inst.AnimState: SetBuild("chester_shadow_build")

inst.ChesterState = "SHADOW"

inst.MiniMapEntity: SetIcon("chestershadow.png")

end

función local MorphSnowChester(inst, dofx)

inst :AddTag("fridge")

inst:AddTag("lowcool")

líder local = inst.components.follower.leader

si líder entonces

inst.components.follower.leader: MorphSnowEyebone()

end

inst.AnimState: SetBuild("chester_snow_build")

inst .ChesterState = "NIEVE"

inst.MiniMapEntity:SetIcon("chestersnow.png")

fin

función local MorphNormalChester(inst, dofx) p>

inst: RemoveTag("fridge")

inst: RemoveTag("lowcool")

inst: RemoveTag("spoiler")

inst.AnimState:SetBuild("chester_build"

)

líder local = inst.components.follower.leader

si líder entonces

inst.components.follower.leader: MorphNormalEyebone()

fin

inst.ChesterState = "NORMAL"

inst.MiniMapEntity: SetIcon("chester.png")

fin

función local CanMorph(inst)

reloj local = GetWorld().components.clock

si no es reloj:IsNight() o reloj:GetMoonPhase() ~= "completo" o inst.ChesterState ~= "NORMAL" luego

devuelve falso, falso

final

contenedor local = inst.components.container

local canShadow = true

local canSnow = true

para i = 1, contenedor: GetNumSlots() do

elemento local = contenedor: GetItemInSlot(i)

si no es un elemento, entonces

canShadow = false

canSnow = false

descanso

fin

si item.prefab ~= "nightmarefuel" entonces

canShadow = false

end

si item.prefab ~= "bluegem" entonces

canSnow = false

fin

fin

return canShadow, canSnow

fin

función local MorphChester(inst)

reloj local = GetWorld().components.clock

si no es reloj: IsNight() o inst.ChesterState ~= "NORMAL" o reloj: GetMoonPhase() ~= "lleno" y luego

regresar

finalizar

contenedor local =

inst.components.container

local canShadow, canSnow = inst:CanMorph()

si canShadow entonces

contenedor: ConsumeByName("nightmarefuel", contenedor: GetNumSlots ())

MorphShadowChester(inst, true)

elseif canSnow entonces

contenedor: ConsumeByName("bluegem", contenedor: GetNumSlots())

MorphSnowChester(inst, true)

fin

fin

función local CheckForMorph(inst)

sombra local, nieve = inst: CanMorph()

si sombra o nieve entonces

si inst.MorphTask entonces

inst.MorphTask: Cancel()

inst.MorphTask = nil

fin

inst.MorphTask = inst: DoTaskInTime(6, función(inst)

inst.sg: GoToState("transición ")

fin)

fin

fin

función local OnSave(inst, datos)

datos .ChesterState = inst.ChesterState

end

función local OnPreLoad(inst, datos)

si no son datos, devuelve fin

si data.ChesterState == "SOMBRA" luego

MorphShadowChester(inst)

elseif data.ChesterState == "NIEVE" luego

MorphSnowChester(inst)

fin

fin

función local create_chester()

--print("chester - create_chester")

local inst = CreateEntity()

inst: AddTag("companion")

inst: AddTag("character")

i

nst: AddTag("scarytoprey")

inst: AddTag("chester")

inst: AddTag("notraptrigger")

inst: AddTag(" cattoy")

inst.entity: AddTransform()

minimapa local = inst.entity: AddMiniMapEntity()

minimapa: SetIcon( "chester.png" )

--print("AnimState")

inst.entity: AddAnimState()

inst.AnimState: SetBank("chester")

inst.AnimState: SetBuild("chester_build")

--print("sound")

inst.entity: AddSoundEmitter()

--print("sombra")

inst.entity: AddDynamicShadow()

inst.DynamicShadow: SetSize(2, 1.5)

--print( " Física")

MakeCharacterPhysics(inst, 75, .5)

--print("Colisión")

inst.Physics: SetCollisionGroup(COLLISION. CARACTERÍSTICOS)

inst.Physics: ClearCollisionMask()

inst.Physics: CollidesWith(COLLISION.WORLD)

inst.Physics: CollidesWith(COLLISION.OBSTACLES)

inst.Physics: CollidesWith(COLLISION.CHARACTERS)

inst.Transform: SetFourFaced()

--print("Userfuncs")

------------------------------------------------------

--print("combat")

inst: AddComponent("combat")

inst.components.combat.hiteffectsymbol = "chester_body"

inst.components.combat: SetKeepTargetFunction(ShouldKeepTarget)

--inst: ListenForEvent("atacado", OnAttacked)

> --print(" salud")

inst: AddComponent("salud")

inst.components.health: SetMaxHealth(TUNING.CHESTER_HEALTH)

inst.components.health: StartRegen(TUNING.CHESTER_HEALTH_REGEN_AMOUNT, TUNING.CHESTER_HEALTH_REGEN_PERIOD)

inst: AddTag("noauradamage")

--print(" inspectable")

inst: AddComponent("inspectable")

inst.components.inspectable: RecordViews()

--inst.components.inspectable.getstatus = GetStatus

--print("locomotor")

inst: AddComponent("locomotor")

inst.components.locomotor.walkspeed = 3

inst. componentes.locomotor.runspeed = 7

--print(" seguidor")

inst: AddComponent("seguidor")

inst: ListenForEvent("dejar de seguir ", OnStopFollowing)

inst: ListenForEvent("startfollowing", OnStartFollowing)

--print("ubicaciones conocidas")

inst: AddComponent("ubicaciones conocidas" )

--print(" burnable")

MakeSmallBurnableCharacter(inst, "chester_body")

--(" contenedor")

inst: AddComponent("contenedor")

inst.components.container: SetNumSlots(#slotpos_3x3)

inst.components.container.onopenfn = OnOpen

inst.components.container.onclosefn = OnClose

inst.components.container.widgetslotpos = slotpos_3x3

inst.components.container.widgetanimbank = "ui_chest_3x3"

inst.components.container.widgetanimbuild = "ui_chest_3x3"

inst.components.container.widgetpos = Vector3(0, 200, 0)

inst. componentes.container.side_align_tip = 160

--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("inactivo")

--print(" cerebro")

inst: SetBrain(cerebro)

inst.ChesterState = "NORMAL"

inst.CanMorph = CanMorph

inst.MorphChester = MorphChester

inst: ListenForEvent("noche", función() CheckForMorph(inst) fin, GetWorld())

inst: ListenForEvent("onclose", function() CheckForMorph(inst) end)

inst.OnSave = OnSave

inst.OnPreLoad = OnPreLoad p>

inst: DoTaskInTime(1.5, function(inst)

-- De alguna manera conseguimos un chester sin ojo. ¡Mátalo! ¡Mátalo con fuego!

si no es TheSim: FindFirstEntityWithTag("chester_eyebone") entonces

inst: Remove()

end

end)

--print (" chester - create_chester END")

return inst

end

return

Prefab("común/chester", create_chester, activos, prefabricados)