Jump to content

Creating a character that can transform?


Recommended Posts

So I pretty much got my first mod done thanks to everybody's help! (Specially to Sabeku!) All he needs is a custom weapon, but I can work on that later.

 

My next character will probably be very hard to created?

Hes a human character, but, he has the ability to transform into a demon.

Anyone knows any tips on what to do to get started?

When he transforms into a demon, his sanity or health is half way taken away. His speed and power should increase.

Where should I do the coding for this? and where would his extra animations go too? (when he is a demon his whole appearance changes, obviously.)

Its kind of like wolfgang, itsn't it?

 

Anyways, sorry if asking a noob question, I thank anyone for their time!

Link to comment
Share on other sites

Its kind of like wolfgang, itsn't it?
Yup. Wolfgang constantly reapplies his mightiness, though, and you probably don't want that (if there's a specific event that triggers transformation). But you can look at Wolfgang's code to see how he transforms. 
Link to comment
Share on other sites

Yup. Wolfgang constantly reapplies his mightiness, though, and you probably don't want that (if there's a specific event that triggers transformation). But you can look at Wolfgang's code to see how he transforms. 

 

Yeah, I've been trying to look at his code trying to understand it.

Looks kind of hard to me since I'm still new to coding.

I think I know where to put his demon anim folders, but, thats probably it. xD

Edited by ZackOcs
Link to comment
Share on other sites

Yeah, I've been trying to look at his code trying to understand it.

Looks kind of hard to me since I'm still new to coding.

I think I know where to put his demon anim folders, but, thats probably it. xD

Well, first thing you need is a trigger. What causes him or her to transform into a demon?

 

The following code for example will trigger code in the "demonTransformation" function when dusk arrives. You probably want to have your trigger code at the bottom of your script in the function where you define your character.

inst:ListenForEvent( "dusktime", function() insertYourFunctionHere(inst) end , TheWorld) 

You will also need to create the function which is triggered by the even. The below example changes your characters model, health and damage multiplier when the event is triggered. Put this function before the functions which create your character.

local function insertYourFunctionHere(inst)  inst.components.combat.damagemultiplier = 1.5  inst.components.health.maxhealth = 250  inst.AnimState:SetBuild("whateverYouCalledYourDemonFormZip")

You can also use the same method to transform your character back to normal, probably with a different trigger.

Edited by RedMattis
Link to comment
Share on other sites

Well, first thing you need is a trigger. What causes him or her to transform into a demon?

 

The following code for example will trigger code in the "demonTransformation" function when dusk arrives. You probably want to have your trigger code at the bottom of your script in the function where you define your character.

inst:ListenForEvent( "dusktime", function() demonTransformation(inst) end , TheWorld) 

You will also need to create the function which is triggered by the even. The below example changes your characters model, health and damage multiplier when the event is triggered. Put this function before the functions which create your character.

local function insertYourFunctionHere(inst)  inst.components.combat.damagemultiplier = 1.5  inst.components.health.maxhealth = 250  inst.AnimState:SetBuild("whateverYouCalledYourDemonFormZip")

You can also use the same method to transform your character back to normal, probably with a different trigger.

 

Oooh, this looks very helpful! I understand it a bit more, thank you!

Well, I want him to transform when either his sanity or health is half way taken away, so, should I replace "dusktime" with something to do with his sanity and health? Sorry to be so confused, I'm still very new to this, so I hope you can bare with me, heh. :grin:

Also what exactly is the "demonTransformation" function part? I know it goes in the script, but, is it a file I need to create for the transformation or is it just a name there for the event? Sorry if I asked a silly question!

Link to comment
Share on other sites

Oooh, this looks very helpful! I understand it a bit more, thank you!

Well, I want him to transform when either his sanity or health is half way taken away, so, should I replace "dusktime" with something to do with his sanity and health? Sorry to be so confused, I'm still very new to this, so I hope you can bare with me, heh. :grin:

Also what exactly is the "demonTransformation" function part? I know it goes in the script, but, is it a file I need to create for the transformation or is it just a name there for the event? Sorry if I asked a silly question!

Ah, yeah sorry, the demonTransformation would be the function you call from the trigger. You can call it whatever. I actually made an error and gave them different names. I corrected that in my first post.

 

For the trigger, there probably is some sort of 'onhealthchange' command, but I'm not sure where to find that. Perhaps someone else here knows.

Link to comment
Share on other sites

  • Developer
For the trigger, there probably is some sort of 'onhealthchange' command, but I'm not sure where to find that. Perhaps someone else here knows.


You're probably looking for the "healthdelta" event which is pushed in Health:DoDelta.
Link to comment
Share on other sites

Still having some troubles if anybody wants to help. :-)

I've tries many things, and nothing works.

Well, show us what code you're trying to run and what error (if any) it produces. Without knowing the problem it is difficult to give good advice. :)

Link to comment
Share on other sites

I can definitely help since our characters are so similar,

        Asset( "ANIM", "anim/charname.zip" ),        Asset( "ANIM", "anim/ghost_charname_build.zip" ),        Asset( "ANIM", "anim/demon_form.zip" ),

Add  Asset( "ANIM", "anim/demon_form.zip" ), to your assets for the build ^

local function becomecharname(inst)		inst.demon = false        inst.AnimState:SetBuild("charname")				inst.Transform:SetScale(1, 1, 1)        (insert charname stats here)		end  local function becomedemon_form(inst)		inst.demon = true        inst.AnimState:SetBuild("demon_form")				inst.Transform:SetScale(1, 1, 1) 		inst.components.combat.damagemultiplier = 2.5			inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.25)			inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.25)        (insert other demon stats here)end

use this to set stats for demon_form and your character ^

local becomeformtreshold = (insert turn into value here)local unbecomeformtreshold = (insert turn back value here)local function sanity_event_listener(inst, data)if inst.components.sanity.current <= becomeformtreshold and not inst.demon then        becomedemon_form(inst)elseif inst.components.sanity.current >= unbecomeformtreshold and inst.demon then        becomecharname(inst)				endend

use this function for sanity in order to transform into demon at half sanity and back to regular 10 or whatever above half  ^

local master_postinit = function(inst)	-- choose which sounds this character will play	inst.soundsname = "(insertsoundnamehere)"	-- Stats        (insert charname stats here)	inst:ListenForEvent("sanitydelta", sanity_event_listener)end

then add a ListenForEvent set to sanitydelta inside of local master_postinit ^

 

Hope this helped even though most credit goes to @rezecib and @bizziboi :razz:

Edited by ELEMENTALCRAFTER009
Link to comment
Share on other sites

I can definitely help since our characters are so similar,

        Asset( "ANIM", "anim/charname.zip" ),        Asset( "ANIM", "anim/ghost_charname_build.zip" ),        Asset( "ANIM", "anim/demon_form.zip" ),

Add  Asset( "ANIM", "anim/demon_form.zip" ), to your assets for the build ^

local function becomecharname(inst)		inst.demon = false        inst.AnimState:SetBuild("charname")				inst.Transform:SetScale(1, 1, 1)		end  local function becomedemon_form(inst)		inst.demon = true        inst.AnimState:SetBuild("demon_form")				inst.Transform:SetScale(1.4, 1.4, 1.4) 		inst.components.combat.damagemultiplier = 2.5			inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.25)			inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.25)end

use this to set stats for demon_form and your character ^

local becomeformtreshold = (insert turn into value here)local unbecomeformtreshold = (insert turn back value here)local function sanity_event_listener(inst, data)if inst.components.sanity.current <= becomeformtreshold and not inst.demon then        becomedemon_form(inst)elseif inst.components.sanity.current >= unbecomeformtreshold and inst.demon then        becomecharname(inst)				endend

use this function for sanity in order to transform into demon at half sanity and back to regular 10 or whatever above half  ^

local master_postinit = function(inst)	-- choose which sounds this character will play	inst.soundsname = "(insertsoundnamehere)"	-- Stats(insert charname stats here)	inst:ListenForEvent("sanitydelta", sanity_event_listener)end

then add a ListenForEvent set to sanitydelta inside of local master_postinit ^

 

Hope this helped even though most credit goes to @rezecib and @bizziboi :razz:

 

Hey there! Thank you very much for helping me out! I finally got it to work! :grin:

I'm really thankful for everybody trying to help me out here in this whole coding thing.

The only problem is, I think his stats are his demon stats in his normal form.  But, you think this is the same for you? If not is there a way to fix it? ( Also, not sure if this is normal, but he gets larger in his demon form, but I think thats fine if not fixable. XD)

Again, thank you for posting me this. :-) and everyone who helped you and the people who tried to help me on this forum.

Link to comment
Share on other sites

Hey there! Thank you very much for helping me out! I finally got it to work! :grin:

I'm really thankful for everybody trying to help me out here in this whole coding thing.

The only problem is, I think his stats are his demon stats in his normal form.  But, you think this is the same for you? If not is there a way to fix it? ( Also, not sure if this is normal, but he gets larger in his demon form, but I think thats fine if not fixable. XD)

Again, thank you for posting me this. :-) and everyone who helped you and the people who tried to help me on this forum.

I fixed my post with the scale of the demon form (my fault XD) and added a few more (insert here) for a little help with the stats.

 

EDIT: Also,  don't add any sanity stats for the demon form or else it will reset it to max which will negate the transformation.

Edited by ELEMENTALCRAFTER009
Link to comment
Share on other sites

I fixed my post with the scale of the demon form (my fault XD) and added a few more (insert here) for a little help with the stats.

 

EDIT: Also,  don't add any sanity stats for the demon form or else it will reset it to max which will negate the transformation.

 

Ah thank you dude. :D I think the problem is fixed, and so is his size. XD I really appreciate your help! :3

Link to comment
Share on other sites

Do you think you can post the file for your character, or at least the scripts and stuff (like where the image files for the transformation goes and stuff like that)?

Coding confuses me, and I'm trying to make a character that does the same thing, but my game just keeps crashing...

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