Jump to content

Recommended Posts

local Assets=

{

Asset("IMAGE", "images/inventoryimages/brandon.tex"),

Asset("ATLAS", "images/inventoryimages/brandon.xml")

}

local function OnPickup(inst)

if GetPlayer().components.maskswitch then

GetPlayer().components.maskswitch:SetMask("brandon")

end

inst:Remove()

return inst

end

local function fn()

local inst = CreateEntity()

inst.entity:AddTransform()

inst.entity:AddAnimState()

inst.entity:AddNetwork()

MakeInventoryPhysics(inst)

inst:AddComponent("inspectable")

inst:AddComponent("inventoryitem")

inst.components.inventoryitem.atlasname = "images/inventoryimages/brandon.xml"

inst.components.inventoryitem:SetOnPickupFn(OnPickup)

return inst

end

return Prefab( "common/inventory/brandon", fn, Assets)

SetHealth is not a function of inventoryitem.

 

You go to the component that activates effects when masks are picked up, and within the brandon part of the component, you put self.inst.components.health:SetMaxHealth(200) for example.

 

Have you modded anything before?

What are you trying to do, port a mod from single player into DST?

yes i have modded before, this is my character http://steamcommunity.com/sharedfiles/filedetails/?id=432224649

 

the thing is the masks are crafted, they will not appear in the inventory nor the headslot, so i dont know where to put the attributes of the mask

p.d you can add me in steam if you want

Oh alright. I see you modded a character and a custom weapon, pretty nice.

 

Where do you want your masks to appear?

Because one thing to do is to make masks as hats, so you can equip them in the headslot.

Another is to make the masks a consumable, that would switch your character from the jacket build into the brandon build.

 

That code makes your mask get removed on pickup, triggering a function on a nonexistant component.

We can make that component give jacket atributes, but how would we reflect what mask he's currently using?

I wasn't creative enough.

I gave brandon more speed, and 100 damage with his fists.

Also gains 5 sanity per kill.

 

Also tweaked masks, you drop em on the floor, and you wear em right clicking them.

Also, now you have the masks.lua file where you put MakeMask("brandon") and generates the brandon mask.

 

Enjoy.

Jacket.zip

First, you add a MakeMask("Jake") in masks.lua.

 

Then, you go to the onbecome(inst, mask) and add if mask == "Jake".

Then, under that if, you put all the stats you want.

The stats in a mask should appear on the onbecomerichard function, to normalize the player.

Like how I included defaultdamage in Brandon first, then in Richard, setting it to 0.

 

For things like ListenForEvents, or periodic tasks, you will put a flag like inst.Jake = true, so when normalizing, you check for it and perform functions to cancel the previous ones, like RemoveEventCallback or task:Cancel() for tasks.

 

You will go from Richard to Mask, then from Mask to Richard to other Mask. Richard is restores everything.

It's easier this way, to avoid having a trillion checks from inbetween masks.

Thanks :)) okok so ill have to add this under remove special stats from mask, for each mask

-- removes special stats from masks	if inst.brandon then		inst.brandon = nil		inst:RemoveEventCallback("killed", onkilled)	endif inst.tony then		inst.tony = nil		inst:RemoveEventCallback("killed", onkilled)	endif inst.rasmus then		inst.rasmus = nil		inst:RemoveEventCallback("killed", onkilled)	end

Only if tony and rasmus have:

inst.tony = trueinst:ListenForEvent("killed", onkilled)inst.rasmus = trueinst:ListenForEvent("killed", onkilled)

The removal of callbacks are in richard to counter the masks, normalize them.

 

You may have something else in them, for example.

-- in richardif inst.rasmus then   inst.rasmus = nil   inst:RemoveEventCallback("attacked", onattacked)end-- in rasmusinst.rasmus = trueinst:ListenForEvent("attacked", onattacked)

Not necessarily the same event.

 

You can make tasks or watchworldstates too.

defaultdamage is the damage that you do with your fists.

 

And that is actually an error from my part, it should be 10, the unarmed damage value.

 

You should move the 100 from Brandon to Tony. I messed up the masks.

Edited by DarkXero

i got another issue i added tony today, it works fine but brando lost its abilities and acts just like richard

 

heres the code:

local function onkilled(inst, data)	inst.components.sanity:DoDelta(5)	inst.components.talker:Say("HAHAHA!")endlocal function onbecomerichard(inst)	-- normal stats	inst.components.health.maxhealth = 80	inst.components.health:DoDelta(0)	inst.components.hunger.max = 80	inst.components.hunger:DoDelta(0)	inst.components.sanity.max = 50	inst.components.sanity:DoDelta(0)	inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.25)	inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.25)	inst.components.combat.damagemultiplier = 2.0	inst.components.combat.defaultdamage = 0		-- removes special stats from masks	if inst.brandon then		inst.brandon = nil		inst:RemoveEventCallback("killed", onkilled)	end		if inst.tony then		inst.tony = nil		inst:RemoveEventCallback("killed", onkilled)	endendlocal function onbecome(inst, mask)	if mask == "brandon" then		-- normal stats overriden		inst.components.health.maxhealth = 50		inst.components.health:DoDelta(0)		inst.components.hunger.max = 50		inst.components.hunger:DoDelta(0)		inst.components.sanity.max = 50		inst.components.sanity:DoDelta(0)		inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 3)		inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 3)		inst.components.combat.damagemultiplier = 1.1		inst.components.combat.defaultdamage = 0				-- special mask stats that must be overriden when normalizing		inst.brandon = true		inst:ListenForEvent("killed", onkilled)	endendlocal function onbecome(inst, mask)	if mask == "tony" then		-- normal stats overriden		inst.components.health.maxhealth = 200		inst.components.health:DoDelta(0)		inst.components.hunger.max = 100		inst.components.hunger:DoDelta(0)		inst.components.sanity.max = 50		inst.components.sanity:DoDelta(0)		inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.9)		inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.9)		inst.components.combat.damagemultiplier = 1.5		inst.components.combat.defaultdamage = 100				-- special mask stats that must be overriden when normalizing		inst.tony = true		inst:ListenForEvent("killed", onkilled)	endend

The code should look like:

local function onkilled(inst, data)    inst.components.sanity:DoDelta(5)    inst.components.talker:Say("HAHAHA!")end local function onbecomerichard(inst)    -- normal stats    inst.components.health.maxhealth = 80    inst.components.health:DoDelta(0)    inst.components.hunger.max = 80    inst.components.hunger:DoDelta(0)    inst.components.sanity.max = 50    inst.components.sanity:DoDelta(0)    inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.25)    inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.25)    inst.components.combat.damagemultiplier = 2.0    inst.components.combat.defaultdamage = 0         -- removes special stats from masks    if inst.brandon then        inst.brandon = nil        inst:RemoveEventCallback("killed", onkilled)    end         if inst.tony then        inst.tony = nil        inst:RemoveEventCallback("killed", onkilled)    endend local function onbecome(inst, mask)    if mask == "brandon" then        -- normal stats overriden        inst.components.health.maxhealth = 50        inst.components.health:DoDelta(0)        inst.components.hunger.max = 50        inst.components.hunger:DoDelta(0)        inst.components.sanity.max = 50        inst.components.sanity:DoDelta(0)        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 3)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 3)        inst.components.combat.damagemultiplier = 1.1        inst.components.combat.defaultdamage = 0                 -- special mask stats that must be overriden when normalizing        inst.brandon = true        inst:ListenForEvent("killed", onkilled)    end    if mask == "tony" then        -- normal stats overriden        inst.components.health.maxhealth = 200        inst.components.health:DoDelta(0)        inst.components.hunger.max = 100        inst.components.hunger:DoDelta(0)        inst.components.sanity.max = 50        inst.components.sanity:DoDelta(0)        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.9)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.9)        inst.components.combat.damagemultiplier = 1.5        inst.components.combat.defaultdamage = 100                 -- special mask stats that must be overriden when normalizing        inst.tony = true        inst:ListenForEvent("killed", onkilled)    endend

What do you mean per use.

You mean to get a sanity debuff when putting on a mask?

 

Then you put that line like

inst.components.sanity:DoDelta(-5)

inside a mask, like

    if mask == "tony" then        -- normal stats overriden        inst.components.health.maxhealth = 200        inst.components.health:DoDelta(0)        inst.components.hunger.max = 100        inst.components.hunger:DoDelta(0)        inst.components.sanity.max = 50        inst.components.sanity:DoDelta(0)        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.9)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.9)        inst.components.combat.damagemultiplier = 1.5        inst.components.combat.defaultdamage = 100                  -- special mask stats that must be overriden when normalizing        inst.tony = true        inst:ListenForEvent("killed", onkilled)				-- one time use effects that don't need a counter on richard		inst.components.sanity:DoDelta(-5)    end

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...