Jump to content

Perks/ Pros and Cons


Recommended Posts

I want my character to recovery sanity in the rain... and to move faster in the rain... I put this in my characters file,

 

local function onisraining(inst, israining)
    if israining then
        inst.components.locomotor.walkspeed = 20
    	inst.components.locomotor.runspeed = 24
    else
    	inst.components.locomotor.walkspeed = 2
    	inst.components.locomotor.runspeed = 3  
    end
end

 

The numbers are high, because I still can't see a difference and I'm not sure if it's even working...

Link to comment
Share on other sites

1 hour ago, Lumina said:

how do you call this line ?

I'm not very sure what that means... sorry. I'm slightly/mediocre-ly experienced in the specific formats of Java, Javascript, Python/Ren'Py, C++ and C#, but lua is brand new to me. It looked very similar to Javascript from when I worked on RPGMaker MV plugins, but there's many differences that are new to me...

Here is the Entire Script of the character's prefab lua file.

local MakePlayerCharacter = require "prefabs/player_common"


local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
}
local prefabs = {}

-- Custom starting items
local start_inv = {
}

local function onisraining(inst, israining)
    if israining then
        inst.components.locomotor.walkspeed = 20
    	inst.components.locomotor.runspeed = 24
    else
    	inst.components.locomotor.walkspeed = 2
    	inst.components.locomotor.runspeed = 3  
    end
end

-- When the character is revived from human
local function onbecamehuman(inst)
	-- Set speed when reviving from ghost (optional)
	inst.components.locomotor:SetExternalSpeedMultiplier(inst, "buizel_speed_mod", 1)
end

local function onbecameghost(inst)
	-- Remove speed modifier when becoming a ghost
   inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "buizel_speed_mod")
end

-- When loading or spawning the character
local function onload(inst)
    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
    inst:ListenForEvent("ms_becameghost", onbecameghost)

    if inst:HasTag("playerghost") then
        onbecameghost(inst)
    else
        onbecamehuman(inst)
    end
end

-- This initializes for both the server and client. Tags can be added here.
local common_postinit = function(inst) 
	-- Minimap icon
	inst.MiniMapEntity:SetIcon( "buizel.tex" )
end

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
	-- choose which sounds this character will play
	inst.soundsname = "willow"
	
	-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
	
	-- Stats	
	inst.components.health:SetMaxHealth(180)
	inst.components.hunger:SetMax(200)
	inst.components.sanity:SetMax(140)

	-- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1
	
	-- Hunger rate (optional)
	inst.components.hunger.hungerrate = 1.2 * TUNING.WILSON_HUNGER_RATE

	inst.components.sanity.neg_aura_mult = 1 * 0
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload

end

return MakePlayerCharacter("buizel", prefabs, assets, common_postinit, master_postinit, start_inv)

Thank you for taking time to reply!

Link to comment
Share on other sites

Put this inside YOURCHAR,lua above the master_poisnioti

local function Rain_Bonus(inst)

	if TheWorld.state.israining then
		inst.components.sanity.dapperness = TUNING.DAPPERNESS_SMALL
		inst.components.locomotor:SetExternalSpeedMultiplier(inst, "rain_bonus", 1.25)
	else
		inst.components.sanity.dapperness = 0
		inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "rain_bonus")
	end
end

put this inside your master_postinit

inst:DoTaskInTime(0, Rain_Bonus)

inst:WatchWorldState("startrain", function()
	Rain_Bonus(inst)
end)
    
inst:WatchWorldState("stoprain", function()
	Rain_Bonus(inst)
end)

 

Link to comment
Share on other sites

1 hour ago, SuperDavid said:

Put this inside YOURCHAR,lua above the master_poisnioti


local function Rain_Bonus(inst)

	if TheWorld.state.israining then
		inst.components.sanity.dapperness = TUNING.DAPPERNESS_SMALL
		inst.components.locomotor:SetExternalSpeedMultiplier(inst, "rain_bonus", 1.25)
	else
		inst.components.sanity.dapperness = 0
		inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "rain_bonus")
	end
end

put this inside your master_postinit


inst:DoTaskInTime(0, Rain_Bonus)

inst:WatchWorldState("startrain", function()
	Rain_Bonus(inst)
end)
    
inst:WatchWorldState("stoprain", function()
	Rain_Bonus(inst)
end)

 

what does "dapperness" refer to specifically? is it losing sanity, or gaining it?

Link to comment
Share on other sites

To preform a check for tags you would do something like this

if inst:HasTag("this_is_a_tag") then
	
end

 

For the boss thing I don't really know how to make a character refuse to fight something or to lower it's damage against certain entities so I won't really be any help with that unfortunately, sorry about that :(!

Link to comment
Share on other sites

49 minutes ago, SuperDavid said:

To preform a check for tags you would do something like this


if inst:HasTag("this_is_a_tag") then
	
end

 

For the boss thing I don't really know how to make a character refuse to fight something or to lower it's damage against certain entities so I won't really be any help with that unfortunately, sorry about that :(!

Does that check the player for tags? Or does it check the entity the player clicks on?

Link to comment
Share on other sites

9 minutes ago, TagumonYatsuray said:

Does that check the player for tags? Or does it check the entity the player clicks on?

"inst" will check the player for tags, for checking entities for example in event "onattackother" using "data.target" will reference the entity you are attacking instead of the player

inst:ListenForEvent("onattackother", function(inst, data)
	if data.target:HasTag("player") then
	end
end)

 

Link to comment
Share on other sites

local function BossBonus
  if data.target:HasTag("boss") then
    inst.components.combat.damagemultiplier = 5
  else
    inst.components.combat.damagemultiplier = 1
  end
end

 

From what you showed me, Couldn't I put the above into my lua and the below into my postinit? the boss tag does exist I think. and if not, I could use the boss-tags themselves, like the "deerclops" tag. 

inst:ListenForEvent("onattackother", function(inst,data)
	BossBonus(inst)
end)
Link to comment
Share on other sites

Your code would work giving the char a damage boost when attacking bosses and turning back to default damage when hitting a normal entity, just change the tag to "epic" I think that's the tags all bosses have & nice job :D

-- outside master_postinit
local function BossBonus(inst)
	if data.target:HasTag("epic") then
		inst.components.combat.damagemultiplier = 5
    else
        inst.components.combat.damagemultiplier = 1
    end
end


-- inside master_postinit
inst:ListenForEvent("onattackother", function(inst,data)
	BossBonus(inst)
end)
Edited by SuperDavid
Link to comment
Share on other sites

On 11/30/2017 at 10:50 PM, SuperDavid said:

Your code would work giving the char a damage boost when attacking bosses and turning back to default damage when hitting a normal entity, just change the tag to "epic" I think that's the tags all bosses have & nice job :D


-- outside master_postinit
local function BossBonus(inst)
	if data.target:HasTag("epic") then
		inst.components.combat.damagemultiplier = 5
    else
        inst.components.combat.damagemultiplier = 1
    end
end


-- inside master_postinit
inst:ListenForEvent("onattackother", function(inst,data)
	BossBonus(inst)
end)

Hmm... Is there a way to change the "attack," to an "Examine" inside the else statement? that way they would examine instead of attacking?

Link to comment
Share on other sites

On 12/4/2017 at 12:51 PM, TagumonYatsuray said:

Hmm... Is there a way to change the "attack," to an "Examine" inside the else statement? that way they would examine instead of attacking?

Pretty sure in order to do that, you'd have to edit every prefab, I could be wrong about this.

I'm going to check Webber's code and get back to you on that.

 

So I found this in their code

inst:AddTag("spiderwhisperer")
inst:AddTag("monster")
inst:AddTag(UPGRADETYPES.SPIDER.."_upgradeuser")

It doesn't seem like you can without adding every single entity, although I'd think it'd be nice if they allowed us to have a tag like this.

Link to comment
Share on other sites

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
 Share

×
  • Create New...