[GameSDK] Problem while Implementing a weapon

Hi all.
I'm currently running into some trouble with the GameSDK code. I want to implement a new weapon (a flashlight). So as a test, I just added the "HandheldFlashlight.cpp" which only has a default constructor and destructor.

Code: Select all

#include "HandheldFlashlight.h"



Then I added the corresponding "HandheldFlashlight.h", which looks like this:

Code: Select all


#pragma once

#include "Weapon.h"

class CHandheldFlashlight : public CWeapon




What I also did is that I modified the GameFactory.cpp. I included the HandheldFlashlight.h and then added this line:
REGISTER_FACTORY(pFramework, "HandheldFlashlight", CHandheldFlashlight, false);

So just really basic stuff. Up to now, I haven't done any real implementation. But it won't build my solution.
I don't really know why. Is there anything that I have forgotten?
I'm getting the following errors:

#error directive: Code configuration error: eCryModule needs to be set for all modules using the CRYENGINE memory manager

identifier "QueuedRayID" is undefined

identifier "RayCastResult" is undefined

CListenerSet is not a template

I don't know what is going on here. I appreciate any kind of help. Thanks.
- Jannis

Re: [GameSDK] Problem while Implementing a weapon

All my files import the stdafx.h.
But I got it working... Seems as if it was really some kind of bug.
After hours of frustration, I deleted both of my files. Then I added two new files to the soultion and added the same code as before. Works fine now.

By the way, I'm now using the flashlight accessory as a reference for my flashlight and it's working pretty good so far.

Thanks for the help.

- Jannis

Re: [GameSDK] Problem while Implementing a weapon

Hi. I'm running into a new problem with my weapon. I need to execute a Flowgraph module form code and I need a callback.
So this part of the documentation seems to fit perfectly:
http://docs.cryengine.com/display/SDKDO ... ule+System

If you scroll down to "C++ Interface" and "Calling a Module from C++", you can see exactly what I was looking for. Only problem here: it doesn't work in 5.3 anymore.
The 5.3 documentation sadly doesn't mention anything about it.

So what I did was this: I first included "CryFlowGraph\IFlowGraphModuleManager.h".
Then I encountered the first problem. The following code tells me that the identifier is undefined:

Code: Select all

IFlowgraphModuleManager* pModuleManager = gEnv->pFlowSystem->GetIModuleManager();

So the code from the docs does not work. Anyways... I thought that I could bypass it and call the functions directly without saving a pointer to the modulemanager.

So my code looks like that:

Code: Select all

if (IFlowGraphModule* pModule = gEnv->pFlowSystem->GetIModuleManager()->GetModule("HandheldFlashlightReload"))
            TModuleParams inputParams;
            gEnv->pFlowSystem->GetIModuleManager()->CreateModuleInstance(pModule->GetId(), inputParams, functor(*this, &CMyClass::MyModuleCallback));

But it would of course be too easy. It seems as if the function "CreateModuleInstance" doesn't exist anymore in 5.3.
Does anyone know how I can call a Flowgraph module from code?

Thanks for your time.
- Jannis

Re: [GameSDK] Problem while Implementing a weapon

I'm not experienced with this but taking a quick look it seems you want to interact with the module root graph. You can activate specific nodes etc etc. Something like;

Code: Select all

   // Untested pseudo code.
   IFlowGraphModuleManager* pModuleManager = gEnv->pFlowSystem->GetIModuleManager();
   if (const auto pModule = pModuleManager->GetModule("MyModule"))
      auto pGraphRoot = pModule->GetRootGraph();

      auto nodeStartName = pModuleManager->GetStartNodeName("MyModule");
      auto nodeStartId = pGraphRoot->ResolveNode(nodeStartName);

Bear in mind I have not tested this. But should get you on the right track.
Maybe someone with a bit more experience can fill in the blanks.

As for the callback, you probably want to attach an activation listener.

good luck
Beginner Guides | My GitHub | Splash Plugin | CMakeLists Gen | C++ Project Templates

Re: [GameSDK] Problem while Implementing a weapon

np ;)

So I digged a little deeper, you want CryAction flowgraph include I'm guessing;

Code: Select all

#include <FlowSystem\Modules\Module.h>
   IFlowGraphModule * pModuleInterface = gEnv->pFlowSystem->GetIModuleManager()->GetModule("MyModule");
   CFlowGraphModule * pModule = static_cast<CFlowGraphModule*>(pModuleInterface);
   pModule->CallModuleInstance( ... );

Check out the call event to see how it's used;

Code: Select all

      if (IsPortActive(pActInfo, eIP_Call))
         // extract and load parameters
         TModuleParams params;
         for (size_t i = eIP_Param1, numInputs = m_pFactory->m_inputs.size() - 1; i < numInputs; ++i) // size-1 for the sentinel
            params.push_back(GetPortAny(pActInfo, i));

         if (GetPortBool(pActInfo, eIP_IsGlobalController))
            m_pModule->CallAllModuleInstances(params, this);
            // call the instance will start it or update it with new inputs
            // the instance is always called with the actual id on the port (not the saved member variable), specially in case it is '-1'
            TModuleInstanceId actualInstanceId = static_cast<TModuleInstanceId>(GetPortInt(pActInfo, eIP_InstanceId));
            if (actualInstanceId != m_instanceId)
               // CallModuleInstance will change the instance this node is associated with.
               m_pModule->UnregisterCallNodeForInstance(m_entityId, m_instanceId, m_callNodeId);
            m_instanceId = m_pModule->CallModuleInstance(m_entityId, actualInstanceId, params, this);

good luck
Beginner Guides | My GitHub | Splash Plugin | CMakeLists Gen | C++ Project Templates

Re: [GameSDK] Problem while Implementing a weapon

After some hours of trying (and crying), I think that I'm giving up. I'll now try to use an UI Action instead (I know that this is not really the proper way, but calling an UI Action from code is pretty simple).
I just can't get this code working. Anyways, thank you very much Uniflare. I appreciate that you took the time and looked into my problem.

Everything works fine now. Even though I improperly used an UI Action instead of a FG Module (which would really suit this situation much better), I could get everything to work.
Thanks for all the help.

Who is online

Users browsing this forum: No registered users and 1 guest