Ever a popular game mechanic in ARPGs and the like, farming for items and loot can add more playability to your game as players scout around gathering bits and bobs they need to prepare for a long journey or gruelling boss fight. This guide will teach you how to implement this mechanic into your project.
Guide to Explain Farming Mechanics
In this section I will show you how to make the most basic technique of respawning items. It allows the player to pick up an item, then for that item to respawn once the player moves to another map and returns. Due the ‘open to abuse’ nature of this mechanic, I expect very few of you to use this in your game. However, it’s a good place to start learning and will set you up for the more complex mechanics I will introduce later in the guide.
Firstly, we will want to right click in the map where you want the respawn event to appear. Select Create/Change Trigger. In the checkered square box, you will most likely want to add an image so that the player knows it is an area of interest.
Unfortunately, iFAction does not come with a lot of visual assets by default, so I just used D – Object, Save (Star Coin). It’s your choice whether to check or uncheck the Parallel box. Generally it is better turned off. If you choose to leave it on, be aware that other processes continue while this event fires such as being attacked.
Now, under Contents: Double Click to Add, do this and select Others tab (Jigsaw Piece) and choose Change Items function. Select the item you wish to receive and the quantity.
Now again under Contents: Double Click to Add, do so and select Logic Tab (Light Bulb) and click Control Variables. Click on the pencil icon and create a new variable in the list. Call it something like Item1 for reference.
The type must be set to Switch and the default must be set as ON (I love this feature). The switch constant must be set OFF, so that the game recognises the player has farmed the item.
Now, under the event Appearing Conditions, select Satisfy All and then find your switch variable Item1. Set Constant as ON.
Next, look over to the left of the Edit Trigger screen and under Actor Touch and Press Confirm Button, Double Click to Add for a new page. Leave everything blank but make sure Reiterative and Parallel are checked and now under Appearing Conditions, select Item1 varaible as OFF. The logic of this page is that the player already picked up the item and the event image disappears and nothing else can be done. You can also add text informing the player of this (optional). Check out your game and you should find this is the case.
Next step, find your event that transitions to another map screen, whether that be a door or just a transitional passage. Right click to Create/Change Trigger. Above where you have your Transfer Player function, we want Control Variables as before. This time, set your Item1 variable to ON, so that when the player moves off the map, the variable moves back to ON and the player can go farm another item. Playtest and see for yourself, it basically resets the whole event back to the start and back again once you grab another potion. This is the basic principal of this mechanic. Useful, but very abuse-able just to move off the map and get 99 free potions… At least this introduces the logic. In the next step I will expand on this and make it so that the event respawns based on time passed. This way, the mechanic will not be open to so much abuse and be potentially game breaking.
In this slightly more complex section, I will outline what we need to do to acheive the above, but in a more creative/better way. In this method, the player will pick up the item, then it will respawn after a certain amount of time has elapsed rather than moving away from the map.
Ok, so in our event created in the Basic operation section, we want to Right click to Create/Change Trigger, we are going to alter it.
In the first page, highlight the part which reads: Control Variables Item1 is OFF. Right click and then choose Insert. Go to Logic Tab and we want to create another variable, so Control Variables. Click the pencil and Double click to Add in the list and rename your new variable. I chose PotionCurrent (since it will be a changing value) Set default at 100 then Apply and Confirm, then set Operation = 0, then Confirm. You can now see in the list the logic taking shape. Default value is 100, meaning it needs to be this for the item to respawn and once the player picks it up, it is set as 0 and will start climbing again to 100 after that. That is the next step.
In your second page that is Actor Touch and Press Confirm Button – 2, we want to change this now. Select Trigger Conditions and choose Auto-Run from the drop down menu. Now on the area we left blank, we now need to Double Click to Add then find the Logic Tab. Select Loop function. Now under Loop: Repeat Below, directly below, Double Click to Add, do it and find Logic Tab again and click the Wait Function. Set this at 6 frames. This means it will fire 10 times per second. You can use your own values if you wish. Under the Wait command, Double Click to Add and go to Logic tab again. Control Variables and select your PotionCurrent variable. Where it gives you the option to change operation, it will say Equal. Change this to Add and then Constant to 1. This means that PotionCurrent’s value will increase by 1 every 6 frames until it reaches 100 and the player can pick up another item.
We’re not done yet, however, we need to make the game recognise this is the case and reset the event. Under Control Variables, Double Click to Add do that and select Logic Tab and Conditional Branch. Uncheck the Create Else Branch at the bottom, we don’t need this and Double Click to Add and find the PotionCurrent variable again. Set Comparison as Equals and Constant to 1000 and then Confirm.
Now, underneath where it reads: Then, Double Click to Add and Control Variables once more. This time you want to locate your Item1 switch you made earlier. Set Constant as ON. Confirm and test it out. You should find that the event comes back after a small amount of time.
Now that you know it works, I would consider increasing the time it takes to respawn. You can do this a number of ways.
My preferred method is simply to increase PotionCurrent variable to 1000. You also need to ensure you set the variable’s default at 1000 if you do it this way, or you will get errors. You can also increase/decrease the Wait command in frames as it adds the variable values to accomodate your needs. Just ensure it is easy for you to track how long each event fires.
For example, you can make common healing plants spawn much faster than magic seeds that increase stats, for example. This method gives you optimum control over your farming mechanics, but will leave the player guessing at how long each item takes to spawn.
In the final section, I will show you how to create a progress bar that pops up after the player takes the item. This bar will refill depending on the PotionCurrent value, giving visual representation of how long they have to wait for the item to respawn.
This final step will take us into the UI editor to make a progress bar. Please back up your project in case of mistakes here, as messing around in the UI editor can lead to bugs and errors. I’ll say again: Please back up your project before continuing! I cannot stress the importance of this enough. An alternative is to do what I do, create a blank project while I test out different mechanics.
Onwards and forwards then. Make sure you are in the UI tab and not Controls and then select the Main Interface on the left hand side. At the bottom, there is a Progress Bar button. Left click and drag that anywhere in the interface and it will visually create a new progress bar. Now you need to find the properties of this bar. On the right hand side of the editor, find it in the list of items with the padlocks and name it (optional). Also optional, but you may want an alternative image for the bar. The big progress bar I find to be quite visually intrusive for it’s purpose. Under Image, Base Image, select the pencil to edit and then find the file bar-actor-exp-0.png. Now on Progress Bar Image, seek out the file bar-actor-exp-1.png. This will be visually more practical for our needs. Continue on to Progress bar section underneath and select Designation with Variable. Simply select the PotionCurrent variable we made earlier.
Now for the Max Value, we must make another variable. Call it PotionMax and set this at 100 (or whatever else value that matches up with your earlier variable). Since we changed the bar image, we need to also change the direction to top to bottom or vice versa rather than left to right.
Under Appearing Conditions, click the pencil and find the Item1 Switch variable and set the Constant to OFF. This means the bar will only display when the character picks the item up. Once the guage is filled, it will disappear again. Finally, locate the Text button at the bottom of the interface and drag it up next to wherever you set your progress bar. I like this to display near the pause button at the top right so it’s nice and neat and doesn’t interfere with gameplay too much. In the properties of the text on the right, change the text to say Potion, and under Appearing Conditions set Potion1 and constant OFF as above. Confirm and save everything then playtest your game.
In addition to having items that respawn over time, you now have a visual representation of how long the item will take to reappear. Feel free to mess around with the values and the UI. You may wish to have the progress bar appear above the actually harvest spot and then disappear after maybe three seconds. This can be achieved by using X and Y variables to determine the location of the harvest point and you could maybe use a separate ON/OFF variable switch to activate/deactivate the progress bar UI after applying the Wait function.
Recommended for You
- None Found