All of the required to scripts and objects to make the system work are downloadable in a. So let's get into the details of the system itself. Saves you the trouble of changing the sprite and making the other object behave like a 'door'. But it might be even better to just let it be a 'door' and change the 'action' you want to execute when you activate it. You could swap the 'door' with an 'npc', change it's sprite and set a couple of variables to make sure the 'door' won't start walking around. You already have an object 'npc' with that behavior so that's great. Let's say there's this special case where, when the player activates a door, you want a dialog to pop up saying "I can't go there right now, I should go this other way". When you activate an 'npc', it pops up a dialog and when you activate the door, it opens it. Let's say that in your RPG, you have 'npcs' and 'doors'. In the example above, 'condition' could be an array and we could make the chest check for any combination of strength, lock-picking skill or keys.Īn other example where this could be useful is for changing the behavior of an object in game. That way we can check for multiple conditions using only one call of 'scr_execute'. You can also combine all the returned values for all the script executions and return the result.
The problem we're trying to solve is that we're basically trying to find a way to write code that would look something like this :Īs long as 'condition' and 'action' are instances of obj_callable with their variables set correctly.Įven better, we can have our 'scr_execute' check if the object it receives is an array or not and execute all of the 'obj_callable' in the array. There might be some information that when used on a big scale commercial game might help quite a bit. The given example is a bit forced and the scale is very limited, but bear with me. If you still don't see how what I'm about to show you could be useful, I understand. That's why I came up with the system I'm about to show you. So what are your options? There are probably a couple of things you can do, but none that I ever found really satisfactory.
What if you suddenly want to make chest that requires both lock-picking skills and strength to open (Because the lid is very heavy.)? Are you going to add a child object 'obj_chest_lockpick_strength' and copy paste the code from your two previous chests into this one? That would work, but that's how we end up with code duplication and that's what we want to prevent as much as possible. It could get messy if we keep finding new reward types to add to our chests, but still.īut what if we play devil's advocate and we try to push things a little further. If(place_meeting(x,y,other) & other.In this scenario, we increase the complexity of our code a little bit, but it still isn't too bad, and not that bad of a solution. Open your bullet object and add some code to the following events. Go ahead and create the sprites and objects for all three, and let's start with the bullet stuff. We need a player, a bullet, and an enemy. Set upīefore we can start shooting bullets all over the place, we need to create a couple of objects and sprites. If you are unfamiliar, check out my previous entry on that exact topic, here.
This entry assumes you know a little bit about object parenting.
Both the player and enemies will use the same bullet object, but they will not be able to shoot/damage themselves. In the example below, I will be using a player, bullets, and enemies to illustrate how you can use a single object that can be “owned” by any other object. By assigning an owner to an object, which is usually another object, we can manage object interactions. Today, the topic of discussion is object ownership. Your boy (me) is back again with another GameMaker tutorial.