Jump to content

Moon Phases and Components


Recommended Posts

Hello, any help would be greatly appreciated: The below applies to a custom char.

 

How to use auras for things other than sanity

 

How to make items or the character have a randomly generated one, or more, combat-related components            from a list

How to re-roll from that list by using something, edibles, equipables, etc

How to control the active duration of the randomly chosen component(s) so that it lasts only for the two                    days of the current moon phase

How to have each individual Moon Phase, not just Full Moon, act as a multiplier for that component(s). I think each phase is 2 days. So each phase would multiply the component's value for that long.

 

How to make it so that using/eating/equiping something, ( haven't decided what specific thing yet), would re-roll the component for that moon phase if the player wanted for a chance at a component more preferable. Another item could be of some nature that re-rolled the component every couple of minutes or at random intervals for the sake of variation. I imagine two days would be just long enough before the active component got stale gameplay wise.

 

 

Character can generate one, or 2 (if Fullmoon), components at random from a list. Selected component(s) would be active for the current moon phases's duration of two days. While active the component(s) will be multiplied by a value determined by the current moon phase's range of values.

 

example: If 3/4 Moon then selected component from x list is multiplied by random value from within x range.

 

Multipliers Determined by Moon Phase are as follows:

 

New Moon = 1.0

Quarter (Crescent) Moon = math.random(1.1, 1.3)

Half Moon = math.random(1.4, 1.6)

3/4 (Gibbous) Moon = math.random(1.7, 1.9)

Full Moon = math.random(2, 2.2)  (applies to the two components selected during this phase)

3/4 (Gibbous) Moon = math.random(1.7,1.9)

Half Moon = math.random(1.4,1.6)

Quarter (Crescent) Moon = math.random(1.1,1.3)

New Moon = 1.0

 

And it'd repeat like so for every Moon Cycle. Current values are in the rough.

 

There would be one, (or two if Full Moon), of 8 possible components that would last for the two days of each moonphase and then be re-rolled at next phase:

 

damage

defense

attack range

attack speed

movement speed

hp drain from mobs when attacking them

Damage reflection onto attacking enemy

can't think of one for 8th place atm

 

 

I hope I explained this well. I wouldn't know where to even begin setting up the code. Ideally I wanted a pet that would emit an aura that did all this and then the moon phases did their thing. But things like aura fall off in relation player/pet proximity and if the component was something like movement speed.. didn't seem too quality of life compatible. So I looked into how the catcoon and birdcage randomize their fur ball loot and seeds payout but those are with objects. And using items sounds even more confusing. If it were an equipable then the 2 components on Full Moon would get wonky. Not to mention how to even tackle this if it was something edible.

 

These components would work right from the mod character if that's the easiest/best route to go about this. So I'm not sure how I'd use items to go about it in regards to randomly generating components, their activation, duration, and how the moon phase determined multiplier would be coded to apply only to those items when equiped on that specific char.

 

Could also make an item that generates at day that has x components,(2 if FM), from x list, spoils in two days regardless of use or if even equiped. But then how to apply character specific Moon Phase multiplier/ make item char. specific too.

 

Thank you kindly for your time and assistance!

 

 

Spent like a whole hour rewriting this. Going crazy. Hope it all makes sense. And thank you, thank you for any help and for your time!

 

Link to comment
Share on other sites

Pardon me, and also may need a way to indicate to the player what component is active. Maybe if its an equipable that manages the components then it could glow a color corresponding to what's active.  But if its on the character um maybe something like a super small light. but it'd be hard to tell what that was during summer or sanity loss since the i think the ambient lighting of the screen changes.

 

An equipable necklace that changes names according to its component, decays in two days, and generates the component when its spawned in the world and not when equipped would work. Not sure how item that changes the element or phases would apply.   

 

Again thank you for any information on how to go about this or directions to look.

 

Link to comment
Share on other sites

I'm a bit lost. Your character changes on itself or you have a body slot amulet?

 

To make something react at fullmoon, you can listen phase changes with WatchWorldState.

 

Example:

inst:WatchWorldState("startnight", function(inst)	if TheWorld.state.isfullmoon then		-- Do change	endend)

So when night starts, function runs, checks for full moon, then changes something if true.

Link to comment
Share on other sites

Hello, and thank very much. Would using the other phases of the moon work in place of full moon?  The worldstate showed this. It only says fullmoon as an option. This wiki link http://dont-starve-game.wikia.com/wiki/Moon_Cycle  says the game has those other phases though. Is it possible to just replace 'isfullmoon'  with  say 'ishalfmoon', or 'isquartermoon' etc,  or would I have to add that to the world state SetVariable list somehow.

 

local function OnPhaseChanged(src, phase)
    SetVariable("phase", phase)
    SetVariable("isday", phase == "day", "day")
    SetVariable("isdusk", phase == "dusk", "dusk")
    SetVariable("isnight", phase == "night", "night")
    SetVariable("isfullmoon", phase == "night" and self.data.moonphase == "full")
end
 
local function OnMoonPhaseChanged(src, moonphase)
    SetVariable("moonphase", moonphase)
    SetVariable("isfullmoon", self.data.isnight and moonphase == "full")
end
 
 

 

I think I'd prefer the character changes on itself, but not sure how to make the change obvious to the player so they know what component is getting buffed. If it was a body slot equipable I think I could make the item change its name somehow.

 

Thank you kindly for your reply and your time. 

Link to comment
Share on other sites

inst:WatchWorldState("startnight", function(inst)    local moonphase = TheWorld.state.moonphase    if moonphase == "new" then        -- Do new change    elseif moonphase == "quarter" then        -- Do quarter change    elseif moonphase == "half" then        -- Do half change    elseif moonphase == "threequarter" then        -- Do threequarter change    elseif moonphase == "full" then        -- Do full change    endend)

To reflect the changes there are many ways:

1) Have an item that when examined by your character, he says the buffs he has

2) Have an item that changes depending on your character's status

3) Have floating text (like the health badge) that says +Damage, or +Speed depending on the two status at once

Link to comment
Share on other sites

Omg this is awesome! Thank you!  Sweet! Thank you so much, gonna try this out right now!  I am new to mods and code of any sort so for now I've just been looking at how other things work and trying to understand it but was a total loss over this. Brain on meltdown.  Thank you so much for your help! Wicked awesome!

Link to comment
Share on other sites

Hello, I'm trying to add the components and I get an error saying:

 

The following mod(s) have caused a failure: Senriou

[string "script/mainfunctions.lua"]:92: Error loading file prefabs/senriou

[string "../mods/Senriou/scripts/prefabs/senriou.lua"]:42: '}' expected (to close '{' at line 41) near '='

LUA ERROR stack traceback:

           =[C] in function 'assert'

           scripts/mainfunctions.lua(92,1)

           =(tail call) ?

           =[C] in function 'rpcall'

           scripts/mods.lua(144,1)

 

 

 

 

senriou.lua

Edited by Syzuno
Link to comment
Share on other sites

Hello, thank you, I hit tab and accidentally posted before ready.  I edited the post with the error to include the prefab file and the rest of the error message.

 

The surrounding code of the error's location is this. I'm not sure what I have missing.

 

local Buffs = {
ONE = inst.components.locomotor.runspeed = 6,
TWO = inst.components.weapon:SetDamage = (TUNING.SCYTHE_DAMAGE),
THREE = inst.components.combat.min_attack_period = 1,
FOUR = inst.components.combat.self.hitrange = 6,
FIVE = inst.components.health:StartRegen(1, 1),
SIX = inst.components.sanityaura.aura = TUNING.SANITYAURA_SMALL,
SEVEN = inst.components.dapperness.dapperness = TUNING.DAPPERNESS_SMALL,
EIGHT = inst.components.weapon:SetDamage = (TUNING.SHARD_DAMAGE),
}
Edited by Syzuno
Link to comment
Share on other sites

Hello, thank you so much this is wicked awesome! The changes you made to the mess I tried to do are mind boggling.  Had some trouble with the tuning for shard and scythe damage so I removed those and the game launches the mod up fine now until the character select screen when creating a world.  There was no error message over the screen just a straight crash. Here's the log file.  Thank you so much for all of your help. No idea why game crashes though. Happens almost instantly after selecting mod char.

log.txt

Edited by Syzuno
Link to comment
Share on other sites

Okay, the crashes were from the AddComponents for health, combat, and inspectable. I deleted those lines 54-56 and  game works. Made it through a day to the save and nothing wonky happened^^! Thanks so much!!!!!!!!!!!!!!!!!!  Gonna try to do the indicators now from the various methods you pointed out to me earlier up and after that gonna try and figure out how to add the multiplier to the components, as well as how to add the scythe and shard damage back up there without errors this time. But I'll make errors for sure. Its destined.   

 

Thank you DarkXero for everything, the phases and editing my wonky list attempts. One day I will mod a bunch of custom marble statues into the game that have the names of all the modders. And much sparkles and fireworks and glows. and maybe rainbows, and dark rainbows and other epic stuff. As a thanks.

Link to comment
Share on other sites

0.0 I'm totally stunned. This is magic! So much awesome today.  This whole day, I swear the best all year. Oh my gosh.  You are golden. So much win! I open the file you send and its like this light blasts out of my screen and a chorus begins to chant.  If you'd ever like any art done, it's the least I can do! Besides spending forever to learn even half of what you know about coding.  Guest star eleventh dimension super being.

Link to comment
Share on other sites

Right, my mistake.

In line 151 and 154, it says:

Buffs[inst.buff_two](inst, multiplier)Buffs[inst.buff_one](inst, multiplier)

When it should say:

Buffs[inst.buff_two](inst, inst.multiplier)Buffs[inst.buff_one](inst, inst.multiplier)

This also happens on line 98 and 101.

 

 

senriou.lua

Link to comment
Share on other sites

	inst.components.locomotor:SetExternalSpeedMultiplier("senriou", "moonrun", 1.5 * multiplier)

into

	inst.components.locomotor:SetExternalSpeedMultiplier(inst, "moonrun", 1.5 * multiplier)

and

	inst.components.locomotor:RemoveExternalSpeedMultiplier("senriou", "moonrun")

into

	inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "moonrun")

@Syzuno.

Link to comment
Share on other sites

I'm trying to get the mod character's buff status to display when inspecting an item (called it mooncrystal for now). When I inspect the item with alt+lmb in game character just says the examine text I set for the item in modmain. No crash or anything but no status on what buff mod char has applied. 

 

this is what is in the modmain for the item

GLOBAL.STRINGS.NAMES.MOONCRYSTAL = "Moon Crystal"

GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.MOONCRYSTAL = "Has an ethereal radiance."

 

 

I tried putting these two parts where all the other components in the item's file seem to go towards the bottom of the file.

 

inst:AddTag("inspectable")
inst.components.inspectable.getstatus = getstatus
 
 
And I put this after Local Prefabs near the top of the file.
 
local function GetStatus(inst, viewer)
    if (inst.buff_one == 1) then
        return "SPEED"
    elseif (inst.buff_one == 2) then
        return "DAMAGE"
elseif (inst.buff_one == 3) then
        return "REGEN"
elseif (inst.buff_one == 4) then
        return "AURA"
elseif (inst.buff_one == 5) then
        return "DAPPERNESS"
    end
end

 

 

Here are the files themselves. I'm not sure how to get the item to get the status of the character and then relay that status to me. Is it possible to inspect the character directly via mouse over or something?

senriou.lua

mooncrystal.lua

Link to comment
Share on other sites

In GetStatus, inst is the mooncrystal. Viewer is senriou.

local function GetStatus(inst, viewer)	if (viewer.buff_one == 1) then		return "SPEED"	elseif (viewer.buff_one == 2) then		return "DAMAGE"	elseif (viewer.buff_one == 3) then		return "REGEN"	elseif (viewer.buff_one == 4) then		return "AURA"	elseif (viewer.buff_one == 5) then		return "DAPPERNESS"	endend

And you need to reflect that in the speech.

GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.MOONCRYSTAL = {	GENERIC = "Has an ethereal radiance.",	SPEED = "Gotta go fast.",	DAMAGE = "I am the strongest.",	REGEN = "The Mitochondria is the Powerhouse of the Cell.",	AURA = "How Can Auras Be Real If Sanity Isn't Real?",	DAPPERNESS = "I can't be any more australian than this.",}
Link to comment
Share on other sites

So that's what those parts inside the parenthesis of GetStatus refer to. Thank you. So I put your code in the modmain for the speech and the get status portion in the mooncrystal prefab, however I come across a hangup with  inst.components.inspectable.getstatus = getstatus

 

It says that variable 'getstatus' is not declared. I tried various combinations of the below but the game boots up then stalls while loading the save.

 

inst:AddComponent("inspectable")

inst.components.inspectable.getstatus = getstatus
inst:AddTag("inspectable")
 
I removed the line with getstatus = getstatus and the game loads smoothly after that but while ingame examining or alt+lmb inspecting gives the generic description of the mooncrystal
 
btw that line you added "REGEN = "The Mitochondria is the Powerhouse of the Cell.""  Hilarious /goodform
 
Here is the log file, prefab and modmain

log.txt

mooncrystal.lua

modmain.lua

Link to comment
Share on other sites

Woh, nvm, I got it to work.

 

I changed the capitalization and presto. I'm sure I tried that before and it didn't work. Lol wow;;  

 

 inst.components.inspectable.getstatus = getstatus  

 

 inst.components.inspectable.getstatus = GetStatus

 

Thank you for everything DarkXero =D    

 

Also, I'm not sure about forum etiquette but if I have anything else concerning my moon related mod and anything that is changed by the moon can I post any such issues here or does that belong in a whole new thread?

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