Jump to content
Sign in to follow this  
ra1n0fpa1n

Npc Dialog Choices will execute Scripts (request Script)

Recommended Posts

Hey Guys,

ive have some trouble understanding the dialog control if someone can help me out that would be great,

what im trying to do is create an npc that has dialog for a mission which if the player chooses one on the the following dialog's a script will execute in result a new unit will be trained into the squad

for example

Dialog would be "Train Soldier"

the Script that would execute after

"FR_Assault_R" createUnit [position player, group player];

hint "Soldier Trained";

2nd Dialog would be "Train Medic"

the Script that would execute after

"USMC_Soldier_Medic" createUnit [position player, group player];

hint "Soldier Trained";

And So on

Any help would be greatly appreciated,

Share this post


Link to post
Share on other sites

Ok well if you are indeed talking of dialogs as in controls > dialogs, custom RSC, then that can be quite complicated. as far as i know there is an easy way in which you can create a menu, and each element in that menu to activate a script. So you may want to put this a init.sqf first:

infantryMenu_1 = [

["Squad Interface", false],

["Train Soldier",[2],"",-5,[["expression","create unit command"]],"1","1"],

["Train Medic",[3],"",-5,[["expression","create unit command"]],"1","1"]

];

take note that every line you add, adds a menu item, and that you must change the second element the number. also when you use the create unit command that where "USMC_Soldier_Medic" createUnit [position player, group player]; is you must do ""USMC_Soldier_Medic"" so the engine can process and define.

once this is established in the init.sqf, you can use (trigger or whatever) showCommandingMenu. unforutnately i haven't time to explain, so will post again with more info but bassically all this leads up to creating a menu that you can use to select what units you wish. hope it helps.

---------- Post added at 01:43 PM ---------- Previous post was at 12:45 PM ----------

Right, so as i have shown in my last post that is how you create the menu, i must add that notice on the first item, train soldier, at the very end of that line is a comma, yet on the next line there is no comma. For every item you add there should be a comma after it except the last line. In addition remember when using the expression create unit, double the "" syntax. The menu array is incredibly strict on syntax and won't work if all is proper and correct.

Now with the init.sqf, if you don't know how to create one then i suggest you search both forums and google, otherwise i can only suggest that you put the entire of the menu array in a unit's init box and that may work.

So that's how to create the menu, now how to show it. in a trigger or init box you could put:

showCommandingMenu "#USER:infantryMenu_1";

this will show the menu only once though. if you want a persistent menu then type this instead:

GUIMenu = [] spawn {while {true} do {sleep 10; showCommandingMenu "#USER:infantryMenu_1";}};

this means that the menu will always show even if exited or you select Train medic item or whatever. So you know now how to create a menu, how to show it, now how to end it if you go for persistent one. basically it's this:

terminate GUIMenu;

This could be typed in a trigger or in the expression section on the menu where you use create unit, you could add it in there after the create unit command, that way when you train a unit, the menu closes. there should be enough to play around with anyway. A few additional ideas are:

BIS_MENU_GroupCommunication = [

[localize "STR_SOM_COMMUNICATIONS", false],

["Train Soldier",[2],"",-5,[["expression","create unit command"]],"1","1"],

["Train Medic",[3],"",-5,[["expression","create unit command"]],"1","1"]

];

this will mean that everything you create is accesible through comms menu (0 > 8). though to use this the SOM module must NOT be placed in the editor.

hope it all helps anyway, more organsied than addAction and less complicated than custom dialogs.

Share this post


Link to post
Share on other sites
hope it all helps anyway, more organsied than addAction and less complicated than custom dialogs.

That has just made part of an addon project of mine very much simpler :D

Thanks very much for sharing this useful snippet. The Wiki articles on the command menu are somewhat opaque for newbies.

Cheers

Orcinus

Share this post


Link to post
Share on other sites
hope it all helps anyway, more organsied than addAction and less complicated than custom dialogs.

I got it to work without the commands. but every time i put the command in the init.sqf shows up but its blank, i know im doing something wrong but i don't know what, can you give me a functioning example of it working properly in init.sqf

Edited by ra1n0fpa1n

Share this post


Link to post
Share on other sites

//This menu is explained later, if you want haven't room in your menu, create a second set

ROOT_unitCreateMenu_02 = [

["Training Interface", false],

["Train: something",[2],"",-5,[["expression","""USMC_soldier"" createUnit [position player, group player];"]],"1","1"],

["Train: another medic",[3],"",-5,[["expression","""USMC_soldier"" createUnit [position player, group player];"]],"1","1"]

];

ROOT_unitCreateMenu_01 = [

["Training Interface", false],

["Train: Soldier",[2],"",-5,[["expression","""USMC_soldier"" createUnit [position player, group player];"]],"1","1"],

["Train: Medic",[3],"",-5,[["expression","""USMC_soldier"" createUnit [position player, group player];"]],"1","1"],

["Train: Something else",[4],"",-5,[["expression","""classname"" createUnit [position player, group player];"]],"1","1"],

["example of a waypoint",[5],"",-5,[["expression","[grp, 2] setWaypointStatements [""true"", ""hint """"ok""""""]"]],"1","1"],

["More",[6],"#USER:ROOT_unitCreateMenu_02",-5,[["expression",""]],"1","1"]

];

// this is again the code to call for a reminder: showCommandingMenu "#USER:ROOT_unitCreateMenu_01";

Ok, as you can see from the above, this is the author's request built and tested. For strict syntax take note of the numbers as they are listed, 2,3,4,5 etc. Take note that every line should end with a comma except the last line, and take note to how many quotas"" are used. Sometimes (in fact in the sqm also) expressions or commands as they can be known are encapsulated in "" when used in custom built arrays, FSMs and editor-interfaced expressions. however if a command such as createunit contains "" in itself the engine can't distiguish when this and that ends, so the "" must be doubled, that is, to the power of two. notice on the example of the waypoint, it can get crazy, because the hint command/expression is within another command, that is also within an array that allows an expression/command, the Hint needs 4 quotas" each side so the engine can keep track.

Also notice on the last menu item i have entered 'More', this is in case anyone wants to break the barrier of 10 items, basically #USER:ROOT_unitCreateMenu_02 has been entered meaning that when you select more, it will auto initiate a second menu, though that second menu must be established first as seen above, the second menu goes before the first menu that activates it.

By the way have only just remembered that in the case of a simple createunit command, that just requires """". i think you can do this '' .

I have pm'd the author about the thread, one last thing is that expression is the official terminology for command, that is anything that processes or initializes (doesn't return) such as removeAllWeapons or hint or unit create. think of it as the init box of the menu that triggers when you click on it.

For the benefit of anyone else who may be thinking of using this to create rpg-style conversations without voice files, and therefore can not use the new KB conversation system, then you could use these menus like this with a few useful commands, clearRadio, commandRadio, sideRadio and directSay. all commands are description.ext based though.

hope that has ironed out the creases and brought a MUCH NEEDED explanation on menus. Happy editing.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×