Programming & Scripting

View unanswered posts | View active topics


Post a new topicPost a reply
Previous topic | Next topic 

User avatar   Experienced Modder Experienced ModderMember since: 22.04.2012, 15:00Posts: 411 Likes: 6
 

 Post Topic: Creating new Entity based on Grunt
PostPosted 21.06.2012, 01:37 
I would like to create a completely new entity based on Grunt but am having some issues. I copied Grunt.lua and Grunt_x.lua and did a search and replace, created a new .ent file and pointed it to my new custom lua file. Everything looked okay, it shows up in the editor but when I add my new custom grunt(I have not changed anything in the files yet) it kills my fps when I look at it and he doesn't have any animations. Errors print out in the console:

[Warning] RegisterWithAI: no Actor for MyGrunt1. <Scope> [Entity]MyGrunt1
[Warning] AI: <CScriptBind_AI> Tried to set parameters with entity without AI actor [MyGrunt1]. <Scope> [Entity]MyGrunt1
[Warning] [Lua Error]

I found this post on here with the same issue but it looks like it never was resolved.

viewtopic.php?t=53144

It seems like this would be pretty straight forward but maybe Grunt is hard coded in some places I am not aware of. Has anyone successfully created a new entity based on Grunt?



User avatar   Skilled Modder Skilled ModderMember since: 29.10.2007, 07:14Posts: 778 Likes: 8
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 21.06.2012, 22:35 
I haven't managed to do this yet unfortunately, and I am under the impression that some c++ coding/compilation is involved in creating a new custom entity class that you can then use in the editor.

If anyone could shed some light on the matter it would be swell...


User avatar   Crytek Staff Member Crytek Staff MemberMember since: 11.07.2008, 20:25Posts: 11633Location: Frankfurt am Main Likes: 10
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 21.06.2012, 22:47 
I believe you also need to register your actor in GameFactory.cpp; see line 130:

Code:
REGISTER_FACTORY(pFramework, "Player", CPlayer, false);
REGISTER_FACTORY(pFramework, "Grunt", CPlayer, true);


Anti-flowgraph campaigner, professional server destroyer.
User avatar   Experienced Modder Experienced ModderMember since: 22.04.2012, 15:00Posts: 411 Likes: 6
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 22.06.2012, 00:14 
Thank you! I will try this soon and let everyone know how it turns out.


User avatar   Experienced Modder Experienced ModderMember since: 22.04.2012, 15:00Posts: 411 Likes: 6
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 22.06.2012, 03:47 
I rebuild GameFactory.cpp and still have the same issues. I noticed that ulukai from the other thread also did this. I get the same errors as he did.

I guess I will have to just use archetypes till I or someone else figures this out.


User avatar   Skilled Modder Skilled ModderMember since: 29.10.2007, 07:14Posts: 778 Likes: 8
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 23.06.2012, 12:03 
It looks like I got it working (but keep in mind I'm a c++ newbie, so I could be doing something weird). At least, it's a first step. Here's what I did:

- First, as mentioned in the sticky thread, I went to the .../Code/Game/GameDll folder and opened GameDll.rc in a text editor and changed:
Code:
#include "afxres.h"
to:
Code:
#include "windows.h"
- Then I downloaded and used this solution file (since the original one didn't work for me): http://dl.dropbox.com/u/3620456/i59/CryMod/CryEngine_GameCodeOnly.sln. I just copied the file over the existing one in .../Code/Solutions and double-clicked it to launch Microsoft Visual C++ 2010 Express.

- in GameFactory.cpp at line 132 I added:
Code:
REGISTER_FACTORY(pFramework, "rat_skeleton", CPlayer, true);
- I duplicated the Grunt.lua and Grunt_x.lua, renamed them and replaced all references to "Grunt" by my character name ("rat_skeleton").

- Then back in Visual C++ I rebuilt the 64bit platform of CryGame.

- Finally within Sandbox my new character class was there (in Entity->AI), so I clicked and dragged it in my level and lo and behold, it appeared without problem!

So of course for now it looks like a Grunt because it uses the Grunt model (with all the proper animations playing fine), since I didn't change the anim graph or the .cdf references in the .lua files. But there's no slowing down or anything strange to report.

Now the next step is to have this new class point to my custom .cdf and anim graphs...

Which brings me to a (probably stupid) question, but: Can I just copy and paste my new CryGame.dll and .lua files to another vanilla Free SDK directory that I have and expect things to work?




Last edited by seith on 28.06.2012, 17:53, edited 2 times in total.
User avatar   Crytek Staff Member Crytek Staff MemberMember since: 11.07.2008, 20:25Posts: 11633Location: Frankfurt am Main Likes: 10
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 23.06.2012, 12:07 
Great stuff :) Yep, pasting the files into another engine directory will work just fine.


Anti-flowgraph campaigner, professional server destroyer.
User avatar   Skilled Modder Skilled ModderMember since: 29.10.2007, 07:14Posts: 778 Likes: 8
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 23.06.2012, 12:57 
Yep, it worked! :)

So I just had to add two lines at the beginning of my rat_skeleton_x.lua (previously Grunt_x.lua) to point to the correct anim graphs like so:
Code:
Script.ReloadScript( "SCRIPTS/Entities/actor/BasicActor.lua");
Script.ReloadScript( "SCRIPTS/Entities/AI/Shared/BasicAI.lua");

rat_skeleton_x =
{

  AnimationGraph = "rat_skeleton.xml",
  UpperBodyGraph = "rat_skeleton.xml",

  colliderEnergyScale = 10,
  colliderRagdollScale = 150,
...


Now seeing what you have to do to register a new class, I really have to say (or actually repeat) that this functionality should be available by default in Sandbox. Just click "Add Class", enter a name, restart Sandbox and that's it. That way, artists could create as many different types of enemies as they wish, without having to compile anything.

Now I'll have to figure out all the AIMovementAbility parameters. Is there some good documentation about that topic?


User avatar   Experienced Modder Experienced ModderMember since: 22.04.2012, 15:00Posts: 411 Likes: 6
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 27.06.2012, 16:51 
Awesome Seith! I will give what you did a try! It seems like this would be something like a lot of people would need to do. Thanks!


  Trainee TraineeMember since: 21.12.2011, 14:24Posts: 152Location: Holland Likes: 0
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 28.06.2012, 13:13 
this is what ive been looking for for days now.
But I understand I need microsoft visual c++ for compiling a file?
havent been coding for decades, but im gonna try and get my animal AI ingame :-)
Thanks Seith.
  Trainee TraineeMember since: 21.12.2011, 14:24Posts: 152Location: Holland Likes: 0
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 28.06.2012, 16:15 
Quote by seith:
...Then I downloaded and used this solution file (since the original one didn't work for me): http://dl.dropbox.com/u/3620456/i59/CryMod/CryEngine_GameCodeOnly.sln

- I rebuilt the 64bit platform of CryGame (in Microsoft Visual C++ 2010 Express) and launched Sandbox.



Can I get some more info on these 2 steps?
what should I do with the first file and how do I proceed on the second step?
I have downloaded Microsoft visual studio 2010 express, but I have no idea how to move further.
User avatar   Skilled Modder Skilled ModderMember since: 29.10.2007, 07:14Posts: 778 Likes: 8
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 28.06.2012, 17:55 
@Rinz: You're welcome! I just updated my original post to give more information about the process. I hope that things are clearer now.


  Trainee TraineeMember since: 21.12.2011, 14:24Posts: 152Location: Holland Likes: 0
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 28.06.2012, 19:04 
yeah its a bit clearer now, ive downloaded the CryEngine_GameCodeOnly.sln and replaced it with the original, but when I try to open it I get the following error:
error.jpg

I am a big nub on microsoft visual studio, so could you tell me in some simple steps how to rebuild crygame?

cheers for the help :)
User avatar   Skilled Modder Skilled ModderMember since: 29.10.2007, 07:14Posts: 778 Likes: 8
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 28.06.2012, 19:57 
You could try installing the Windows SDK... But I should probably let someone with more experience answer that one.

Rebuilding CryGame is as simple as right-clicking on CryGame (in the left column, when you get it working) and selecting "Rebuild".


User avatar   Crytek Staff Member Crytek Staff MemberMember since: 11.07.2008, 20:25Posts: 11633Location: Frankfurt am Main Likes: 10
 

 Post Topic: Re: Creating new Entity based on Grunt
PostPosted 28.06.2012, 20:30 
You've downloaded the web dev version of VS Express; you want the C++ version: http://www.microsoft.com/visualstudio/e ... pp-express


Anti-flowgraph campaigner, professional server destroyer.