Jump to content

Recommended Posts

So, I finally got my coding done on my character who can transform into a demon now, thank you for everyone who has tried to help me, greatly appreciated. :grin:

 

But, I wonder, if its possible for one character mod to have more then just one speech?

The character I have that transforms into a demon has a different personality then his human form, so I thought it'll be nice to let him say different things while in that form.

 

Anyway, any suggestions are nice, thank you for reading. :-)

I would go like how nightmarerock.lua works.

 

In modmain.lua:

local function getstatus(inst, viewer)   if viewer.prefab = "MyCharacter" then      return viewer.state -- that can be "NORMAL" or "DEMON", put inst.state inside your character prefab   endendAddPrefabPostInitAny(function(inst)   if inst and (not inst:HasTag("player")) and inst.components.inspectable then       inst.components.inspectable.getstatus = getstatus   endend)

However this will make the GetStatus in the component inspectable.lua not used fully, so if you want to add the "DEAD", "SLEEPING", etc. statuses you will need to make your getstatus function more complex. Because the NORMAL and DEMON would be the only ones used.

 

Then, when you add strings for your character, you do:

-- ExampleSTRINGS.CHARACTERS.MyCharacter.DESCRIBE.RESEARCHLAB = {   NORMAL = "It breaks down objects into their scientific components.",   DEMON = "I hate it."}
Edited by DarkXero

@ZackOcs, Possible, probably, but definitely not easy. You could change your prefab name on transformation (inst.prefab = "demonchar"), but I would expect to run into issues with saving/loading if you do that. Most places that get character speech pull from the prefab name, so apart from that I don't think there's a good way to do it.

 

Edit: Actually, DarkXero's approach should work for most of the speech entries. I think it might interfere with objects that inherently have multiple states, though.

Edited by rezecib

I think it might interfere with objects that inherently have multiple states, though.

 

NEW IDEA:

AddComponentPostInit("inspectable", function(self)   local old = self.GetStatus   function self:GetStatus(viewer)      local status = old(self, viewer)         if viewer.prefab == "MyCharacter" then         status = viewer.status..status      end      return status   endend)
Edited by DarkXero

However I must note that this only works for strings in DESCRIBE, duplicating everything into NORMAL and DEMON, and NORMALDEAD and DEMONDEAD, etc.

 

The real deal is editing the global function GetString, GetActionString, GetDescription, GetActionFailString, etc. in stringutil.lua. I will look into it later.

Edited by DarkXero

Well, update.

 

As rezecib said, GetString can get passed an inst argument, that can be a string or a table.

Well, I have no idea how to tag a string denoting a prefab into the entity that called GetString.

If there are two players using the mod, I don't know who is doing the GetString to go check their state.

So I would stick to the inspectable component and the DESCRIBE strings.

 

Unless you want to make two prefabs, a normal and a demon one and make them switch, then assign a speech to each one.

I had no issues switching from Wilson to Willow and back with a transformation, and saving and loading, but I don't know if there may be any data corruption lingering about, so I wouldn't risk it.

I hoped to see something for Woodie but then I saw that the werebeaver has no speech for itself.

I did something like this for a transforming character! Past a certain sanity threshold her lines change to be more violent, etc. All I did was create two copies of the speech file, one normal and one 'mad', then in the transformation functions I just called the function to set the speech lines to one or the other.

I am away from my computer right now. When I get back to it I can post mpre specific examples.

mikeek, I think I know what you mean.

 

On transformation you run:

STRINGS.CHARACTER.MYCHAR = require "NewSpeech"

so that the new speech appears. Then turning back, you do the same for the initial speech.

 

I considered this, but this has a small problem in multiplayer. Imagine two mod characters in a server.

If someone transforms, the other would also have these lines, from your point of view.

 

For single player or one character only, this works perfectly.

rezecib, indeed. If only one person plays the mod character, you can use the net to make the speech change in the client.

It's up to OP if he doesn't mind the small inconsistency that two or more mod characters may bring.

I personally don't mind it.

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