AtomicTorch Studio Forums

CryoFall => Modding info => Topic started by: Spyrex on May 02, 2021, 03:09:11 am

Title: How to make the player's character move?
Post by: Spyrex on May 02, 2021, 03:09:11 am
What is the best way to make the player move to a location or towards a specific direction only using code?
Title: Re: How to make the player's character move?
Post by: ai_enabled on May 02, 2021, 03:14:03 am
Hello!

As the game code is available in open source, you can see how exactly the player input is read on the client side and applied:
https://github.com/AtomicTorchStudio/CryoFall/blob/master/Core.cpk/Scripts/Characters/Input/ComponentPlayerInputUpdater.cs#L134

Regarding PvP servers, please note that client modifications are forbidden (and mods are automatically disabled) when joining any official PvP servers to ensure fair gameplay for everyone, with no players gaining advantage through the mods usage.

Regards
Title: Re: How to make the player's character move?
Post by: Spyrex on May 02, 2021, 03:24:37 am
Hello!

As the game code is available in open source, you can see how exactly the player input is read on the client side and applied:
https://github.com/AtomicTorchStudio/CryoFall/blob/master/Core.cpk/Scripts/Characters/Input/ComponentPlayerInputUpdater.cs#L134

Regarding PvP servers, please note that client modifications are forbidden (and mods are automatically disabled) when joining any official PvP servers to ensure fair gameplay for everyone, with no players gaining advantage through the mods usage.

Regards

Thank you for the reply!
I already found that part in the code before and tried to call the SetInput() method:
Code: [Select]
ComponentPlayerInputUpdater.SetInput();
But it's not working due to it's degree of protection.
I am really unpractised in C# but could you help me with this anyway? ;)
Title: Re: How to make the player's character move?
Post by: ai_enabled on May 02, 2021, 03:37:26 am
Alas, we cannot help with this further. We have provided the game source code and modding tools (including CryoFall Editor) so anyone can learn and experiment with the game code.
If you're not familiar with C#, I would suggest learning about C# basics first—without it, your attempts to modding will be really hard as C# is a relatively complex programming language.

Regards!
Title: Re: How to make the player's character move?
Post by: Spyrex on May 02, 2021, 04:46:42 am
Alas, we cannot help with this further. We have provided the game source code and modding tools (including CryoFall Editor) so anyone can learn and experiment with the game code.
If you're not familiar with C#, I would suggest learning about C# basics first—without it, your attempts to modding will be really hard as C# is a relatively complex programming language.

Regards!

How much and what exactly do you recommend learning for Cryofall's mod development?
I already know the basics in C# and did more advanced stuff in Java and Python for years.
It's hard to find a tutorial that fits my knowledge. Also, I've never worked professionally on such big projects like the Cryofall's core and it's hard to find learning resources about the right project structure and coding guidelines for those.
Additionally, I couldn't find a documentation for cryofall or it's engine.
Title: Re: How to make the player's character move?
Post by: ai_enabled on May 02, 2021, 06:00:39 am
If you have experience with Java and Python then it should be not a problem as the OOP concepts are the same.

We've tried to write clear code (and put comments where necessary) but the amount of code is indeed very big. You can use Object Browser in Visual Studio to browse the scripting API. There is no documentation provided besides this community-created guide about modding and programming for CryoFall https://steamcommunity.com/sharedfiles/filedetails/?id=1707742469 I highly recommend reading it first as it contains the concepts of modding approach that the game has.

To start experimenting with the code, I would suggest installing CryoFall Editor from Steam, unpacking the Core.cpk (there is a script), and using Visual Studio 2019 to load the C# project. Then you can edit the code and save the changes — CryoFall Editor supports live editing so it will automatically recompile changed code. This way you can experiment with ComponentPlayerInputUpdater as you wish.
When you're happy with the result of your experiment you can create a mod that will override ComponentPlayerInputUpdater file with your version.

Regards!
Title: Re: How to make the player's character move?
Post by: Spyrex on May 02, 2021, 06:48:20 am
Code: [Select]
If you have experience with Java and Python then it should be not a problem as the OOP concepts are the same.

We've tried to write clear code (and put comments where necessary) but the amount of code is indeed very big. You can use Object Browser in Visual Studio to browse the scripting API. There is no documentation provided besides this community-created guide about modding and programming for CryoFall https://steamcommunity.com/sharedfiles/filedetails/?id=1707742469 I highly recommend reading it first as it contains the concepts of modding approach that the game has.

To start experimenting with the code, I would suggest installing CryoFall Editor from Steam, unpacking the Core.cpk (there is a script), and using Visual Studio 2019 to load the C# project. Then you can edit the code and save the changes — CryoFall Editor supports live editing so it will automatically recompile changed code. This way you can experiment with ComponentPlayerInputUpdater as you wish.
When you're happy with the result of your experiment you can create a mod that will override ComponentPlayerInputUpdater file with your version.

Regards!

At the time I created this topic, I had already got my own mod running. Indeed, I really only asked for advice on how to move the player by code, because I already tried overwriting it, but then just making the SetInput() function public and static, it's not working because the function needs to refer to the this-instance.
So because my first attempt failed, I looked for someone having the required knowledge about the project structure to help me modifying the player movement.
Basically, I don't know where to get the information about how the player movement in this game works. I could try to put a lot of time into understanding it by reading through that mass of code, but I decided to ask here instead.

Sorry for making the initial request so short and misleading.  :-\
Title: Re: How to make the player's character move?
Post by: Spyrex on May 02, 2021, 07:05:32 am
I got it working by thinking a way around!
I just rewrote the SetInput() function instead of trying to make it public or sth.

Now I only wonder how to make the character walk diagonal.
How does this movement system in Cryofall works?
Title: Re: How to make the player's character move?
Post by: ai_enabled on May 02, 2021, 07:06:50 am
That's the right approach with editing the existing code! :-)
To walk diagonally you need to set movement flags for two directions (e.g. up and right).

Regards!
Title: Re: How to make the player's character move?
Post by: Spyrex on May 02, 2021, 07:14:19 am
Thank you so much, now it finally works! I haven't seen Flags before because it seems to be C# exclusive...

Have a great day!