Jump to content

Need help with something... special.


QuickShot010

Recommended Posts

Another thing i was thinking about is to let it spawn in the world only once, just like chester's eyebone. But the problem with that is that non-Drok characters get the stone as well while i want only Drok to get the stone. I don't think there is a work around... but who knows.

 

I think if you add the component "characterspecific", it'll automagically disappear for the other characters.

 

I'm not sure about the "once per world" thing. Maybe by adding a "room" (a small biome) to worldgen, or some "AddSimPostInit" magic that detects walkable offset. Or maybe Midrealm knows a better solution.

Link to comment
Share on other sites

I'll have to look at the Minimap code when I get home (at work right now)

 

I'm not sure how one would prevent an item from spawning based on characters.

Hopefully someone else has an idea.

 

I do know you can make the crafting recipe specific to Drok, so even if other characters found it, they couldnt do anything with it. Not the best solution, but it would work.

 

I already fixed the minimap for the custom prefabs in my modmain instead of prefab lua, but thanks again anyway :)

Assets = {     (...)    Asset( "IMAGE", "minimap/wigstan.tex" ),    Asset( "ATLAS", "minimap/wigstan.xml" ),    Asset( "IMAGE", "minimap/wigstanstone.tex" ),    Asset( "ATLAS", "minimap/wigstanstone.xml" ),}function AddMap(inst)    local minimap = inst.entity:AddMiniMapEntity()    minimap:SetIcon( inst.prefab .. ".tex" )endAddPrefabPostInit("wigstan", AddMap)AddPrefabPostInit("wigstanstone", AddMap)AddMinimapAtlas("minimap/wigstan.xml")AddMinimapAtlas("minimap/wigstanstone.xml") 

I think if you add the component "characterspecific", it'll automagically disappear for the other characters.

 

I'm not sure about the "once per world" thing. Maybe by adding a "room" (a small biome) to worldgen, or some "AddSimPostInit" magic that detects walkable offset. Or maybe Midrealm knows a better solution.

 

The chester eyebone spawns only once in every world. But when i take a look at the eyebone prefab lua i get confused

Here is the prefab lua, maybe one of you knows how to solve this mystery :D

 

local assets={    Asset("ANIM", "anim/chester_eyebone.zip"),    Asset("ANIM", "anim/chester_eyebone_build.zip"),    Asset("ANIM", "anim/chester_eyebone_snow_build.zip"),    Asset("ANIM", "anim/chester_eyebone_shadow_build.zip"),}local SPAWN_DIST = 30local trace = function() endlocal function RebuildTile(inst)    if inst.components.inventoryitem:IsHeld() then        local owner = inst.components.inventoryitem.owner        inst.components.inventoryitem:RemoveFromOwner(true)        if owner.components.container then            owner.components.container:GiveItem(inst)        elseif owner.components.inventory then            owner.components.inventory:GiveItem(inst)        end    endendlocal function MorphShadowEyebone(inst)    inst.AnimState:SetBuild("chester_eyebone_shadow_build")    inst.openEye = "chester_eyebone_shadow"    inst.closedEye = "chester_eyebone_closed_shadow"        inst.EyeboneState = "SHADOW"    RebuildTile(inst)endlocal function MorphSnowEyebone(inst)    inst.AnimState:SetBuild("chester_eyebone_snow_build")    inst.openEye = "chester_eyebone_snow"    inst.closedEye = "chester_eyebone_closed_snow"        inst.EyeboneState = "SNOW"    RebuildTile(inst)endlocal function MorphNormalEyebone(inst)    inst.AnimState:SetBuild("chester_eyebone_build")    inst.openEye = "chester_eyebone"    inst.closedEye = "chester_eyebone_closed"        inst.EyeboneState = "NORMAL"    RebuildTile(inst)endlocal function GetSpawnPoint(pt)    local theta = math.random() * 2 * PI    local radius = SPAWN_DIST	local offset = FindWalkableOffset(pt, theta, radius, 12, true)	if offset then		return pt+offset	endendlocal function SpawnChester(inst)    trace("chester_eyebone - SpawnChester")    local pt = Vector3(inst.Transform:GetWorldPosition())    trace("    near", pt)            local spawn_pt = GetSpawnPoint(pt)    if spawn_pt then        trace("    at", spawn_pt)        local chester = SpawnPrefab("chester")        if chester then            chester.Physics:Teleport(spawn_pt:Get())            chester:FacePoint(pt.x, pt.y, pt.z)            return chester        end    else        -- this is not fatal, they can try again in a new location by picking up the bone again        trace("chester_eyebone - SpawnChester: Couldn't find a suitable spawn point for chester")    endendlocal function StopRespawn(inst)    trace("chester_eyebone - StopRespawn")    if inst.respawntask then        inst.respawntask:Cancel()        inst.respawntask = nil        inst.respawntime = nil    endendlocal function RebindChester(inst, chester)    chester = chester or TheSim:FindFirstEntityWithTag("chester")    if chester then        inst.AnimState:PlayAnimation("idle_loop", true)        inst.components.inventoryitem:ChangeImageName(inst.openEye)        inst:ListenForEvent("death", function() inst:OnChesterDeath() end, chester)        if chester.components.follower.leader ~= inst then            chester.components.follower:SetLeader(inst)        end        return true    endendlocal function RespawnChester(inst)    trace("chester_eyebone - RespawnChester")    StopRespawn(inst)    local chester = TheSim:FindFirstEntityWithTag("chester")    if not chester then        chester = SpawnChester(inst)    end    RebindChester(inst, chester)endlocal function StartRespawn(inst, time)    StopRespawn(inst)    local respawntime = time or 0    if respawntime then        inst.respawntask = inst:DoTaskInTime(respawntime, function() RespawnChester(inst) end)        inst.respawntime = GetTime() + respawntime        inst.AnimState:PlayAnimation("dead", true)        inst.components.inventoryitem:ChangeImageName(inst.closedEye)    endendlocal function OnChesterDeath(inst)    StartRespawn(inst, TUNING.CHESTER_RESPAWN_TIME)endlocal function FixChester(inst)	inst.fixtask = nil	--take an existing chester if there is one	if not RebindChester(inst) then        inst.AnimState:PlayAnimation("dead", true)        inst.components.inventoryitem:ChangeImageName(inst.closedEye)				if inst.components.inventoryitem.owner then			local time_remaining = 0			local time = GetTime()			if inst.respawntime and inst.respawntime > time then				time_remaining = inst.respawntime - time					end			StartRespawn(inst, time_remaining)		end	endendlocal function OnPutInInventory(inst)	if not inst.fixtask then		inst.fixtask = inst:DoTaskInTime(1, function() FixChester(inst) end)		endendlocal function OnSave(inst, data)    trace("chester_eyebone - OnSave")    data.EyeboneState = inst.EyeboneState    local time = GetTime()    if inst.respawntime and inst.respawntime > time then        data.respawntimeremaining = inst.respawntime - time    endendlocal function OnLoad(inst, data)    if data and data.EyeboneState then        if data.EyeboneState == "SHADOW" then            inst:MorphShadowEyebone()        elseif data.EyeboneState == "SNOW" then            inst:MorphSnowEyebone()        end    end    if data and data.respawntimeremaining then		inst.respawntime = data.respawntimeremaining + GetTime()	endendlocal function GetStatus(inst)    trace("smallbird - GetStatus")    if inst.respawntask then        return "WAITING"    endendlocal function fn(Sim)    local inst = CreateEntity()    inst.entity:AddTransform()    inst.entity:AddAnimState()    --so I can find the thing while testing    --local minimap = inst.entity:AddMiniMapEntity()    --minimap:SetIcon( "treasure.png" )    inst:AddTag("chester_eyebone")    inst:AddTag("irreplaceable")	inst:AddTag("nonpotatable")    MakeInventoryPhysics(inst)        inst.AnimState:SetBank("eyebone")    inst.AnimState:SetBuild("chester_eyebone_build")    inst.AnimState:PlayAnimation("idle_loop", true)    inst:AddComponent("inventoryitem")    inst.components.inventoryitem:SetOnPutInInventoryFn(OnPutInInventory)        inst.EyeboneState = "NORMAL"    inst.openEye = "chester_eyebone"    inst.closedEye = "chester_eyebone_closed"       inst.components.inventoryitem:ChangeImageName(inst.openEye)        inst:AddComponent("inspectable")    inst.components.inspectable.getstatus = GetStatus	inst.components.inspectable:RecordViews()    inst:AddComponent("leader")    inst.MorphNormalEyebone = MorphNormalEyebone    inst.MorphSnowEyebone = MorphSnowEyebone    inst.MorphShadowEyebone = MorphShadowEyebone    inst.OnLoad = OnLoad    inst.OnSave = OnSave    inst.OnChesterDeath = OnChesterDeath	inst.fixtask = inst:DoTaskInTime(1, function() FixChester(inst) end)    return instendreturn Prefab( "common/inventory/chester_eyebone", fn, assets)  

Link to comment
Share on other sites

The chester eyebone spawns only once in every world. But when i take a look at the eyebone prefab lua i get confused

Here is the prefab lua, maybe one of you knows how to solve this mystery :grin:

I don't think the eybone itself will contain the information about spawning itself.

Most of the information that I can decipher (with my limited knowledge) seems to be about spawning Chester.

 

But I think Mobbstar is onto an idea..

 

Create a custom setpiece that contains the wigstone and limit that setpiece to one per world

http://forums.kleientertainment.com/topic/32602-tutorial-making-a-custom-setpiece/

 

The setpiece could be very small only 1x1 would be all that was needed.

Link to comment
Share on other sites

I don't think the eybone itself will contain the information about spawning itself.

Most of the information that I can decipher (with my limited knowledge) seems to be about spawning Chester.

 

But I think Mobbstar is onto an idea..

 

Create a custom setpiece that contains the wigstone and limit that setpiece to one per world

http://forums.kleientertainment.com/topic/32602-tutorial-making-a-custom-setpiece/

 

The setpiece could be very small only 1x1 would be all that was needed.

 

Going to try this,

but are those setpieces not hard to find? I think it could take ages to find that...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...