Jump to content

Questions about GemRB code


Recommended Posts

Hello, I just wanted to say, that GemRB or/and the Infinity Engine is awesome and I'm going through the code structure every day for hours. I must admit I'm a BG/IWD fanatic which leads to my goal to create a very similar game experience just in 3D, so I'm developing "this nameless game" with Unity3D which I'm using for 12 years now and am trying to adopt some of the ideas that I find in GemRB/IE. Along the way I'm learning about bits and bytes as much as possible to better understand the dynamics of the engine.

But I'm still struggling to grasp certain things here and there, i.e. identifying what functions are used inside a loop and what is called once.

To be a little more detailed. I'm currently trying to integrate the attacking loop that happens if I command an actor via mouse click (or 'TryToAttack' in GameControl.cpp). What happens next?

-> CommandActor(action) -> Stop actors current action and pathing -> Set to current action and execute -> if(pc) if(target) ??

That's where I lose it. In the game when I click an enemy, the PC attacks continuously. But in the GameScript.ExecuteAction function I see nothing that would lead to that behaviour, other than copying the action and putting the copy in the queue. Does the attack action itself contain the loop or can a queued action be repeated automatically?

Can anyone shed some light on this?

I'd be really interested to learn more about the engine's inner workings.

Link to comment

Not all actions are "instants", meaning they get executed immediately. The so called blocking ones are internally executed until their job is done. See this high level comment:


Also IESDP has some details on the data side:



Link to comment

These links are very helpful for diving deeper into the matter. Thanks!

I know some actions are instantly executed and some are processed over time. But how does it work for the standard melee/ranged attack command where PCs attack in a loop until interrupted? Is this a special case where an action puts itself back on the queue when done or just exists as long as the player doesn't give another command?

I really appreciate any insight!

Link to comment

I think I understand. I assumed an attack action is responsible for only a single swing or a single shot of a bow, which wouldn't be very efficient now that I think about it. The upper comment in GameScript.cpp actually answered my question.

Is there a flow chart diagram available somewhere to help understanding the code relations?

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...