woodenpixel Posted July 14, 2021 Share Posted July 14, 2021 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. Quote Link to comment
lynx Posted July 15, 2021 Share Posted July 15, 2021 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: https://github.com/gemrb/gemrb/blob/bf7148b4ac21fb053a4d9689d0226dba3fc01b13/gemrb/core/GameScript/GameScript.cpp#L21 Also IESDP has some details on the data side: https://gibberlings3.github.io/iesdp/scripting/actions/index.htm https://gibberlings3.github.io/iesdp/file_formats/ie_formats/bcs.htm Quote Link to comment
woodenpixel Posted July 15, 2021 Author Share Posted July 15, 2021 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! Quote Link to comment
lynx Posted July 15, 2021 Share Posted July 15, 2021 The former, as the point of the action is not "attack for a tick", but "attack". There are other ways to interrupt it as well though. Quote Link to comment
woodenpixel Posted July 15, 2021 Author Share Posted July 15, 2021 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? Quote Link to comment
Nugrud Posted July 16, 2021 Share Posted July 16, 2021 I somehow understand more about game scripts from this guide: https://www.pocketplane.net/tutorials/simscript.html than IESDP. And why not follow the code in VS Code run-by-line (F10/F11)? Quote Link to comment
woodenpixel Posted July 16, 2021 Author Share Posted July 16, 2021 Thanks for the reply and the link, Nugrud! I'll make sure to try what you suggested. Quote Link to comment
lynx Posted July 17, 2021 Share Posted July 17, 2021 Well, in this case we just reuse a scripting action to save on code duplication. The originals often did the same. This is the only "code relations" thing we have, but of course you could use external tools to generate graphs: https://gemrb.org/Engine-overview.html Quote Link to comment
woodenpixel Posted July 17, 2021 Author Share Posted July 17, 2021 Lynx, I thought as much. The Engine Overview is already very helpful! When I'm working with Unity I have the GemRB solution open in Visual Studio, but only at the side for peeking. I think the next step is to set it up properly to run and test it. Quote Link to comment
Recommended Posts
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.