Envelope_Void Posted December 13, 2021 Report Posted December 13, 2021 Hello, I would like to implement a new system in my game that allows the player to search an area for herbs to gather. I've got this working on the client side, but obviously this will be a completely different challenge to implement on the server. Here is the workflow: 1. (client) Player presses gather button 2. (server) Server receives client button press, player world location, world location season/weather/time of day, player gathering skill level, player attributes, player modifiers affect gathering (racial/item/magic bonuses) 3. (server) Server does some logic based on that stuff and a global herb table data 4. (client) Player receives a list of potential herbs that can be gathered and the difficulty. Player clicks on one of the options 5. (server) Server receives client button press, does some RNG magic, and returns success/fail 6. (client) Client receives success/fail. If successful, a prefab of the herb is generated nearby that the player can harvest for an item Here are my questions/assumptions to start this project: 1. I assume that UI modifications will be relatively straightforward and can all be done in Unity. For now, after the "gather" cooldown, I want a UI window to pop up showing herbs that can possibly be gathered. After a player selects an herb and successfully "finds" it, a path will be displayed nearby and a prefab will be generated. Then, I assume that the player can harvest the herb via normal loot mechanics. Is that correct? 2. For the server code, I assume that I should create a plugin that can subscribe to the button clicks, send server messages asking for player and world data, and send client messages with relevant data back to the player. I've started by looking at the QuestPlugin and QuestClient code, because that's a system that is pretty easy to understand and interact with in Atavism. Where can I see the Log.debug messages for the server code? I modified world.properties to show Debug logging, but I'm not sure which log handles quest messages. 3. I have the herb prefabs created, but I'm not sure how to reference them within the existing server logic. Resource node doesn't seem to fit. Perhaps as a mob that could be spawned? I can't seem to find an example in the code that I could reference for something like dynamic prefab spawning. Quote
Martin (Dragonsan) Posted December 15, 2021 Report Posted December 15, 2021 On 12/13/2021 at 5:29 PM, Envelope_Void said: 1. I assume that UI modifications will be relatively straightforward and can all be done in Unity. For now, after the "gather" cooldown, I want a UI window to pop up showing herbs that can possibly be gathered. After a player selects an herb and successfully "finds" it, a path will be displayed nearby and a prefab will be generated. Then, I assume that the player can harvest the herb via normal loot mechanics. Is that correct? Yes, I think so, but the resource nodes would have to be instantiated dynamically in this case, because currently they are based on the database entries. On 12/13/2021 at 5:29 PM, Envelope_Void said: 2. For the server code, I assume that I should create a plugin that can subscribe to the button clicks, send server messages asking for player and world data, and send client messages with relevant data back to the player. I've started by looking at the QuestPlugin and QuestClient code, because that's a system that is pretty easy to understand and interact with in Atavism. Where can I see the Log.debug messages for the server code? I modified world.properties to show Debug logging, but I'm not sure which log handles quest messages. Depending on the plugin/server you are modifying, logs will be in the atavism_server/logs/world/server_name logs file. On 12/13/2021 at 5:29 PM, Envelope_Void said: 3. I have the herb prefabs created, but I'm not sure how to reference them within the existing server logic. Resource node doesn't seem to fit. Perhaps as a mob that could be spawned? I can't seem to find an example in the code that I could reference for something like dynamic prefab spawning. I think resource nodes will fit, but you would have to instantiate such resource nodes and refresh the resource node list, to let the logic work further. Quote
Envelope_Void Posted December 23, 2021 Author Report Posted December 23, 2021 I've made some progress in getting all of this to work but I'm having trouble understanding how the server actually generates GameObjects in the game. So far, I have created a new plug-in with a custom hook called BeginGatheringHook. This hook mirrors a hook that I found in the CraftingPlugin.java class called InstanceLoadedHook. Specifically, I took the following statement from InstanceLoadedHook: resourceNodes.put(instanceOid, cDB.loadResourceNodes(instanceID, instanceOid, resourceNodeGroups)); I created my own version of this in my plugin, and I have started to look at the ContentDatabase.java function that is being called. I have been able to successfully call that function and pass parameters from the game, and I've looked extensively at the WorldManagerPlugin spawn() and the ObjectManager generateObject() methods. I don't believe that the game is spawning any GameObjects when I click the appropriate button, but it's hard to tell from my logs. Any help in understanding this workflow would be appreciated. I've attached some object manager logs from when I spammed the button and got the server responding. I THINK the server is tracking the objects as created, but I'm seeing nothing in the game. I only tested this live for a few seconds. When I logged into the game, I spammed the "Gathering" button that I created about 20 times. In those few seconds, the server generated 4 full objmgr.log files, so something is definitely happening. I have attached the objmgr.log files. objmgr-3.log contains the actual logs of me pressing the button. These can be found by searching the file for "GATHERING:" and "CONTENT DATABASE:". I have also attached the modified code I used within content database. All the code beyond line 37 is unmodified from the original function (which is ContentDatabase.loadResourceNodes(). objmgr.log objmgr-1.log.gz objmgr-2.log.gz objmgr-3.log.gz contentdatabasefunction.txt Quote
Envelope_Void Posted December 24, 2021 Author Report Posted December 24, 2021 To add on to my last post, I fired up the game this morning and did nothing while I looked at some UI elements. I went to open my logs and noticed this that the mobserver logs were going crazy! I have attached a screen shot of my world logs folder and one of the archived log files. mobserver_1-3.log.gz Quote
Zbawcasan Posted December 28, 2021 Report Posted December 28, 2021 Have you set the model of the object in the spawn function? Have you unchecked ignore server prop object? if you have set the logging level on trace it is normal for the logs to grow up quickly Quote
Envelope_Void Posted December 28, 2021 Author Report Posted December 28, 2021 23 minutes ago, Zbawcasan said: Have you set the model of the object in the spawn function? No. Where does that happen within the existing code for loading resources? If I'm tracing the normal workflow for generating resource nodes from the CraftingPlugin it goes something like this: CraftingPlugin.InstanceLoadedHook() resourceNodes.put(instanceOid, cDB.loadResourceNodes(instanceID, instanceOid, resourceNodeGroups)) ContentDatabase.loadResourceNodes() ResourceNodeGroup.spawn() ObjectManagerClient.generateObject(ObjectManagerClient.BASE_TEMPLATE_ID, ObjectManagerClient.BASE_TEMPLATE, markerTemplate) WorldManagerClient.spawn(objectOID) I don't see any obvious reference to a model in this code path. In my code, I put a log after the WorldManagerClient.spawn to make sure that my code was hitting that. My code was successfully spawning resources at locations using WorldManagerClient. 42 minutes ago, Zbawcasan said: Have you unchecked ignore server prop object? That did it! What does that check box specifically do? I now have this: As I wrote above, I have essentially copied and pasted the code from the CraftingPlugin.InstanceLoadedHook() and the ContentDatabase.loadResourceNodes() functions. How do I attach everything else I need to these created objects? Quote
Zbawcasan Posted December 29, 2021 Report Posted December 29, 2021 By default atavism uses Resource Node Group and does not spawn resource node in the scene but turns it on or off. if you using ResourceNodeGroup then atavism binds resource node to group depending on the position and only spawn group to check interaction distance for group to enable or disable resource nodes. If you are not using ResourceNodeGroup you can by default spawn object in the scene when you set gameobject param (path to model in resource folder). Check box "IgnoreServerPropObjects" is to not spawn objects with "_ign_" in the name. By default resource node and Resource Node Group have in name "_ign_" in this line you can change name Quote markerTemplate.put(Namespace.WORLD_MANAGER, WorldManagerClient.TEMPL_NAME, "_ign_" + name + id); in this lines you can set model to be spawned Quote DisplayContext dc = new DisplayContext(gameObject, true); dc.addSubmesh(new DisplayContext.Submesh("", "")); markerTemplate.put(Namespace.WORLD_MANAGER, WorldManagerClient.TEMPL_DISPLAY_CONTEXT, dc); markerTemplate.put(Namespace.WORLD_MANAGER, "model", gameObject); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.