View Single Post
Old 06-21-2012, 03:02 PM   #202
JCarter426
Senior Member
 
JCarter426's Avatar
 
Join Date: Feb 2008
Location: Look to your left.
Posts: 1,635
Here are two basic templates that should handle the job (well, two and a half); you just need to replace the stuff in quotes with the correct information, and repeat stuff as needed. The first checks if a container has the crystal you want:
Code:
int StartingConditional() {

	object oPLC = GetObjectByTag("plc", 0);
	string sTag = "tag";
	object oCrystal = GetItemPossessedBy(oPLC, sTag)

if(GetIsObjectValid(oCrystal)) return TRUE;
return FALSE;

}
You would attach this to a dialogue node... I'd do it as a player node; have the computer say "select the crystal you would like to modify" and then you choose one from the list it gives you, conditional script attached to each node. Then the next node gives you the list of which ones you can blend it with, in a similar fashion.

Now, for K1 you would have to create a different conditional script for every crystal. It would just be copy/paste work, put in a different tag. With K2 you wouldn't have to do this, though; you could create a universal script:
Code:
int StartingConditional() {

	object oPLC = GetObjectByTag("plc", 0);
	string sTag = GetScriptStringParameter();
	object oCrystal = GetItemPossessedBy(oPLC, sTag)

if(GetIsObjectValid(oCrystal)) return TRUE;
return FALSE;

}
Then you would just have to enter the appropriate tag in the string parameter of each dialogue node.

You might also want to have different conditionals, like "there aren't any crystals" or "a foreign object is present". That would be a bit more complicated.

The second script destroys two crystals and then creates a new one:
Code:
void main() {

	object oPLC = GetObjectByTag("plc", 0);
	string sTag1 = "tag1";
	object oCrystal1 = GetItemPossessedBy(oPLC, sTag1)
	string sTag2 = "tag2";
	object oCrystal2 = GetItemPossessedBy(oPLC, sTag2)
	string sNewTag = "newtag";

ActionTakeItem(oCrystal1, oPLC);
ActionTakeItem(oCrystal2, oPLC);
CreateItemOnObject(sNewTag, oPLC, 1, 0);

}
It could be converted to delete three, four, and so on; just duplicate the string sTag, object oCrystal, and ActionTakeItem lines, and adjust the information as required.



Now, I have a conundrum of my own. I was working on a script and I thought an efficient way to do it would be to use a switch for the string parameter. However, I wasn't sure if this is possible. I believe I've seen it done before, but I couldn't find anything by searching. I eventually did it with if trees instead... it was probably easier with ifs, actually. But I'm still curious. I believe it should look something like:
Code:
case "whatever":
...but you know how the engine is. Anyway, just curious... not a big deal. If any of you remember seeing something like this, just let me know.


JCarter426 is offline   you may: quote & reply,