Jump to content

Recommended Posts

I'm not sure if this is because I'm using the latest beta or if its been like this for a while. It seems all 3 types of the hounds are compressed into a single prefab file but in hounded.lua it mentions multiple prefabs including firehound and icehound, is it possible for any clarification on this? as I've been searching for a while but haven't turned much up all Ive found is that this is in hound.lua when I'd assume each would be separated from the normal hounds so to add another hound would I simply copy one of these and just tweak some of the statistics and lootdropper prefabs (after adding said prefabs to the associated prefabs part at the top of course)

 

local function fnfire(Sim)local inst = fncommon(Sim)inst.AnimState:SetBuild("hound_red")    inst.components.combat:SetDefaultDamage(TUNING.FIREHOUND_DAMAGE)    inst.components.combat:SetAttackPeriod(TUNING.FIREHOUND_ATTACK_PERIOD)    inst.components.locomotor.runspeed = TUNING.FIREHOUND_SPEED    inst.components.health:SetMaxHealth(TUNING.FIREHOUND_HEALTH)    inst.components.lootdropper:SetLoot({"monstermeat","houndstooth","houndfire","houndfire","houndfire"})    inst.components.lootdropper:AddChanceLoot("redgem", 0.2)inst:ListenForEvent("death", function(inst)inst.SoundEmitter:PlaySound("dontstarve/creatures/hound/firehound_explo", "explosion")end)return instendlocal function fncold(Sim)local inst = fncommon(Sim)inst.AnimState:SetBuild("hound_ice")    inst.components.combat:SetDefaultDamage(TUNING.ICEHOUND_DAMAGE)    inst.components.combat:SetAttackPeriod(TUNING.ICEHOUND_ATTACK_PERIOD)    inst.components.locomotor.runspeed = TUNING.ICEHOUND_SPEED    inst.components.health:SetMaxHealth(TUNING.ICEHOUND_HEALTH)    inst.components.lootdropper:SetLoot({"monstermeat","houndstooth","houndstooth"})    inst.components.lootdropper:AddChanceLoot("bluegem", 0.2)inst:ListenForEvent("death", function(inst)inst.SoundEmitter:PlaySound("dontstarve/creatures/hound/icehound_explo", "explosion")end)return instendlocal function fnfiredrop(Sim)local inst = CreateEntity()inst.entity:AddTransform()    MakeInventoryPhysics(inst)    MakeLargeBurnable(inst, 6+ math.random()*6)    MakeLargePropagator(inst)    inst.components.burnable:Ignite()    return instendreturn Prefab( "monsters/hound", fndefault, assets, prefabs),Prefab( "monsters/firehound", fnfire, assets, prefabs),Prefab( "monsters/icehound", fncold, assets, prefabs),Prefab( "monsters/houndfire", fnfiredrop, assets, prefabs) 

and of course sorry to bother you all after some additional searching I have found out icehound and firehound seem to be set_builds but this file compression still has me a little confused on how to add more

Edited by Craig_Perry

At the end of hound.lua you see this

return Prefab( "monsters/hound", fndefault, assets, prefabs),        Prefab( "monsters/firehound", fnfire, assets, prefabs),        Prefab( "monsters/icehound", fncold, assets, prefabs),

which tells you the prefabs and their respective functions - fndefault() fnfire() fncold()

 

And if you go to those functions in hound.lua you'll see code like this, example fndefault()

local function fndefault()    local inst = fncommon(Sim)   	 MakeMediumFreezableCharacter(inst, "hound_body")    MakeMediumBurnableCharacter(inst, "hound_body")    return instend

 

or fncold()

local function fncold(Sim)    local inst = fncommon(Sim)    inst.AnimState:SetBuild("hound_ice")   	 inst.components.combat:SetDefaultDamage(TUNING.ICEHOUND_DAMAGE)    inst.components.combat:SetAttackPeriod(TUNING.ICEHOUND_ATTACK_PERIOD)    inst.components.locomotor.runspeed = TUNING.ICEHOUND_SPEED    inst.components.health:SetMaxHealth(TUNING.ICEHOUND_HEALTH)    inst.components.lootdropper:SetLoot({"monstermeat","houndstooth","houndstooth"})    inst.components.lootdropper:AddChanceLoot("bluegem", 0.2)        inst:ListenForEvent("death", function(inst)        inst.SoundEmitter:PlaySound("dontstarve/creatures/hound/icehound_explo", "explosion")    end)    return instend

 

In other words the file is defining variations of hounds, drawn from the fncommon().

At the end of hound.lua you see this

return Prefab( "monsters/hound", fndefault, assets, prefabs),        Prefab( "monsters/firehound", fnfire, assets, prefabs),        Prefab( "monsters/icehound", fncold, assets, prefabs),

which tells you the prefabs and their respective functions - fndefault() fnfire() fncold()

 

And if you go to those functions in hound.lua you'll see code like this, example fndefault()

local function fndefault()    local inst = fncommon(Sim)   	 MakeMediumFreezableCharacter(inst, "hound_body")    MakeMediumBurnableCharacter(inst, "hound_body")    return instend

or fncold()

local function fncold(Sim)    local inst = fncommon(Sim)    inst.AnimState:SetBuild("hound_ice")   	 inst.components.combat:SetDefaultDamage(TUNING.ICEHOUND_DAMAGE)    inst.components.combat:SetAttackPeriod(TUNING.ICEHOUND_ATTACK_PERIOD)    inst.components.locomotor.runspeed = TUNING.ICEHOUND_SPEED    inst.components.health:SetMaxHealth(TUNING.ICEHOUND_HEALTH)    inst.components.lootdropper:SetLoot({"monstermeat","houndstooth","houndstooth"})    inst.components.lootdropper:AddChanceLoot("bluegem", 0.2)        inst:ListenForEvent("death", function(inst)        inst.SoundEmitter:PlaySound("dontstarve/creatures/hound/icehound_explo", "explosion")    end)    return instend

In other words the file is defining variations of hounds, drawn from the fncommon().

I see, Im trying to add a new hound to the mix (Ive got hounded.lua complete) but Im just suprised and a little confused as to how Im going to add a new hound

 

edit: do I have to look into fncommon()?

Edited by Craig_Perry

I think you could do

local function fn()	local inst = SpawnPrefab("hound")	inst.prefab, inst.name = nil		--[[/* customize prefab here */]]--	return instend
where SpawnPrefab is replacing CreateEntity. Edited by simplex

I think you could do

local function fn()	local inst = SpawnPrefab("hound")	inst.prefab, inst.name = nil		--[[/* customize prefab here */]]--	return instend
where SpawnPrefab is replacing CreateEntity.

 

I'll give it a shot

 

edit: Ive added it to hound.lua is this placement appropriate for these lines

local function fncommon()local inst = CreateEntity()     local inst = SpawnPrefab ("hound")     --[[/Yellow_Hound/]]--      return instendlocal trans = inst.entity:AddTransform()local anim = inst.entity:AddAnimState()    local physics = inst.entity:AddPhysics()local sound = inst.entity:AddSoundEmitter()local shadow = inst.entity:AddDynamicShadow()shadow:SetSize( 2.5, 1.5 )    inst.Transform:SetFourFaced() 

Edited by Craig_Perry

I'll give it a shot edit: Ive added it to hound.lua is this placement appropriate for these lines

local function fncommon()local inst = CreateEntity()     local inst = SpawnPrefab ("hound")     --[[/Yellow_Hound/]]--      return instendlocal trans = inst.entity:AddTransform()local anim = inst.entity:AddAnimState()    local physics = inst.entity:AddPhysics()local sound = inst.entity:AddSoundEmitter()local shadow = inst.entity:AddDynamicShadow()shadow:SetSize( 2.5, 1.5 )    inst.Transform:SetFourFaced() 
No, they should be inside their "fn", which you will give to the Prefab(). Also, if you're going to stick it directly into hound.lua, SpawnPrefab("hound") is pointless. Just call fncommon().

No, they should be inside their "fn", which you will give to the Prefab(). Also, if you're going to stick it directly into hound.lua, SpawnPrefab("hound") is pointless. Just call fncommon().

yeah, I've been experimenting for a long while with the code and decided not to continue as I'm not experienced enough I need to study lua more. But thanks for the help

yeah, I've been experimenting for a long while with the code and decided not to continue as I'm not experienced enough I need to study lua more. But thanks for the help

It's your call. But I think that if you pushed a bit more you'd get at least a basic version working.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...