iFAction游戏制作工具

iFAction游戏制作工具

评价数不足
Basic Variables/Triggers Functions
由 PorkChip 制作
Triggers and Variables are very important and essential for creating a game with any kind of context above and beyond just running around the level hacking goblins like a madman. Here I will cover some of the most basic and useful applications of variables and triggers. They are used to store data such as what has happened in the game, who you have met, why is such and such happening right now instead of something else.
   
奖励
收藏
已收藏
取消收藏
Creating an unlockable door
The basic premise here will be to create a locked door that requires the player to find a key before the door will unlock and allow progress to continue.

Go to Trigger tool on the top task bar. Right click and select Create/Change Trigger.
You can rename the trigger if you want. Generally, I skip it. In the squared box it says Double Click to Edit. Do so.
Find a suitable door image for your trigger. Mine was under D - Object, Door of log cabin.
Confirm, Apply the changes and Confirm again and a door image will appear on your map.
Save and playtest and you notice the door is static and you cannot go through.
Now, let's make it so the player has to find a key to open this door.
Right click on the red box on your door image and select Create/Change Trigger.
On the left where it reads: Actor Touch and Press Confirm Button - 1, right click here and select Copy.
Now underneath, where it says: Double Click to Add, right click here and select Paste.
This will give you a duplicate of the above event. We need this for later, but for now, just Apply and Confirm.
Now we will make our item which will be a key to open this door.
Right click on your map where you wish to acquire your key and select Create/Change Trigger.
Make sure you uncheck the Reiterative box so the event only fires the once.
Under where it reads Contents: Double Click to Add, do so and then choose Others and then Change Items option.
Now select your key from the drop down menu and then Apply and Confirm everything.
Go back to your door event and on the left hand side, click in Actor Touch and Press Confirm Button - 2.
On the top right you will see Appearing Conditions, click on the pencil and it will open Condition Setting.
Set it to Satisfy All and then Double click to add a condition.
The one we want is: Others tab, Items [Your key] is carried, then Apply and Confirm everything.
Now under Contents: We need to Double Click to Add, then select the Action Tab (Running man).
The top left option is Set Actor/Trigger Action, choose that.
Under Action/Trigger option, it will read Actor. Change this to: This Trigger from the drop down menu.
Now under Commands, we need to select Set Action, then Choose a Custom Action from the drop down menu.
Find the Animation which is in folder D - Object, Door of log cabin, then select Opened from the list and Apply and Confirm all.
Save and play your game and try opening the door. Nothing happens... well duh... we haven't the key yet.
Go to your key and pick it up. Now try the door and viola! Inski we go...
That was as easy as open sesame... well not quite. Anyway this event can now be fleshed out. Add in some SFX, change map,
display some text like 'You opened the door with Skeleton Key' or something. Be creative.
One creative idea you can try is if the player is equipped with a crowbar they can force open doors, but if they equip a knife, they cannot.
This is easily achieved by simply following the above steps but inputting Actor, weapon is equipped under Condition Settings when
we create our Appearing Conditions in the second tab of the door event rather than the item key. This means you are only allowed to go through when the weapon is equipped.
Creating a basic quest
So the logic of this will be very similar to the door event above, except that rather than the player finding a key, someone has given them a quest or task and this changes dialogue because when we speak to the NPC again we need them to say different things depending on the situation. Here I will explain how to make a simple Bounty quest.

First up, let's create an NPC who will dole out this quest for us. Right click in the map and select Create/Change trigger.
Choose a character in the squared box, I chose the assault rifle guy that looks like Ian Rush from the 1980s. Google him if you don't know who I mean :P
Now under Contents: Double Click to Add, do that and then choose Text tab, Show Dialog option. Now input the text you want him to say.
"You'll never walk alon..." ahem... I mean, something like "Go slay that goblin for me!" or something alone those lines.
Now he's given us a task, this will set some things in motion. Underneath, in Double Click to Add, do it and select Logic Tab (Light bulb) and Control Variables.
Click on the pencil to create a new variable and call it Quest1 for reference. This needs to be a Switch type variable and just leave default OFF.
Confirm this and then set the Constant as ON. Apply and Confirm. This lets the game know we have initiated this quest, similar to finding the key in the above method.
Now, go place an enemy in the map. Yes, an easy part!
Go back to your Trigger tool in the task bar and right click anywhere in the map to create a new trigger.
Leave the square box blank because we don't want any image showing up, this is just a quick event handler we are making here.
Under trigger conditions, set this to Auto-Run. Make sure the Parallel box is checked and the Reiterative is unchecked.
Under Contents: Double Click to Add, do this and go to Logic Tab and Control Variables again.
Create a new variable as before and call it Quest1 Finished or something boring like that. Leave default OFF and Confirm.
Set this Constant as ON. Now in the Appearing Conditions of the event, Double click to Add then find the Enemies tab.
Select the designated enemy for the quest from the drop down list and select Be Killed. Apply and Confirm to everything.
Head back to your NPC quest giver and right click to edit. Click on Actor Touch and Press Confirm Button - 1 and select Copy after right clicking.
Paste below and you will have a duplicate. Now in this new section, delete all contents under the Contents: space.
Here you can now add some dialogur for the NPC to show gratitude to the player for killing the enemy. Also use this section to give rewards etc.
When you are done customising, go to the top right and select Appearing Conditions. Choose Satisfy All and then Double Click to Add a new condition.
Simply find your quest done varaible in the list below and confirm everything and you're done.
The game has been notified that the enemy was killed and this variable will handle the event change.
Playtest this and you will find the NPC will say the same thing over and over until you kill the enemy.
Of course this is only basic narrative. You can use another variable that recognises that the player has talked to NPC once and returns having not slayed the enemy and the NPC can show a dialogue of his frustration. The possibilities are almost never ending if you are willing to put in the work.

So I think I've covered the basics. Using these I am sure you can find more creative ways to build your games. Thanks for reading this guide and please I ask that you rate it up if it has helped you out.