PDA

View Full Version : making choices



rob_whatman
06-01-2005, 07:09 AM
I have been trying to think of a way to allow the player to make choices by pressing one of three hotkeys. I haven't had any success so far. Is my method on the right track or doomed?

Here is one of the 3 hotkeyed item cogs for choices:



# Jedi Knight Cog Script
#
# item_choice1.COG
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

message activated
int bin=117 local

end

# ================================================== ======================================

code

activated:

player = GetSourceRef();

SetInvActivated(player, bin, 0); // sets the choice1 BIN to 1 or ON.
Print("BIN 117 Choice 1 is switched ON."); // this message has never printed, so I must have made a mistake

return;

# .................................................. ......................................

end


Here is an example of a dialogue cog that asks the player to make a choice:



# Jedi Knight Cog Script
#
# suicidaldroid.COG
#
# This is a test cog for my dialogue choices system.
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

message activated
message pulse

thing droid

int done=0 local

end

# ================================================== ======================================

code

activated:

player=GetLocalPlayerThing();

Print("Hello, I am D4K6. I am sorry to be unable to serve you as best I might.");
Print("My programming is insufficient for even simple tasks. Shall I self-destruct, master?");

Print("CHOICE 1: Yes, blow up now!");
Print("CHOICE 2: No, live!");
Print("CHOICE 3: I don't care, you decide.");

SetPulse(1); // starts search for a hotkey depression

return;

pulse:

# I never get any positive response, suggesting that my hotkeys don't do anything.

choice1=IsInvActivated(player, 117);
choice2=IsInvActivated(player, 118);
choice3=IsInvActivated(player, 119);

if(choice1==1)
{
Print("very good, master...");
SetThingHealth(droid, 0);
SetInvActivated(player, 117, 0);
SetInvActivated(player, 118, 0);
SetInvActivated(player, 119, 0);
done=1;
SetPulse(0); // ends search for a hotkey depression
return;
}

if(choice2==1)
{
Print("Oh no, master, I am afraid that would be a disservice to you! Goodbye...");
SetThingHealth(droid, 0);
SetInvActivated(player, 117, 0);
SetInvActivated(player, 118, 0);
SetInvActivated(player, 119, 0);
done=1;
SetPulse(0); // ends search for a hotkey depression
return;
}

if(choice3==1)
{
Print("Oh, master, how wise! Yes, perhaps I should define my own role in life. Thank you, master!...");
SetThingHealth(droid, 100);
SetInvActivated(player, 117, 0);
SetInvActivated(player, 118, 0);
SetInvActivated(player, 119, 0);
done=1;
SetPulse(0); // ends search for a hotkey depression
return;
}

else
return;


# .................................................. ......................................

end


I modified items.dat like this:

fieldlight 42 1 1 0x122 cog=item_fieldlight.cog
keyred 117 1 1 0x122 cog=item_choice1.cog
keyblue 118 1 1 0x122 cog=item_choice2.cog
keygreen 119 1 1 0x122 cog=item_choice3.cog

Is there a better way to do what I want to do? Is it possible? Thanks for any suggestions!

ReT
06-01-2005, 12:13 PM
Don't you want a deactivated: message with a SetPulse(0); ?

Right now I think the pulse just keeps on going which might be screwing it up.



activated:
SetPulse(1.0);

pulse:
// Do stuff here
Return;

deactivated:
SetPulse(0);
Return;

LKOH_SniperWolf
06-01-2005, 01:35 PM
No ReT. His is fine. As far as I can see, it should work. Check if both cogs are working at all by throwing in some prints. While you're at it, add a print to the activated part of each hotkey.

darthslaw
06-01-2005, 01:45 PM
Methinks an error is right here:

SetInvActivated(player, bin, 0); // sets the choice1 BIN to 1 or ON.
First cog. The comment says it should set it to 1, but the statement sets it to 0.


I think there may be a bin flag error if that cog doesn't print anything.
May we see the new hotkey entries in the items.dat?


Also, in the second cog, get rid of that last 'else' before the 'return' and put 'else' s in front of the second and third 'if' statements.

rob_whatman
06-01-2005, 04:07 PM
Thanks guys. I'll try your suggestions now. Here is my items.dat file, Darth Slaw.

rob_whatman
06-02-2005, 08:04 AM
Still no luck with getting any response from the three hotkeys. I checked that the 'suicidaldroid' cog is sending its pulse and checking the bin availability, and altered the lines in the items cogs as Darth Slaw suggested so that they should set the bins to available, but pressing the hotkeys doesn't bring any response from the item cogs... hmm. Here is my jkstring.uni file. Perhaps I haven't put in the correct activate lines for my hotkeys?

rob_whatman
06-03-2005, 08:24 AM
I have been testing my item cogs, and I can get a response by adding a startup message and using SetBinAvailable(player, bin, 1). Up on the screen comes the item activated icon (in my case a key icon), and the 'suicidaldroid' cog comes to the appropriate conclusion.

But I can't think of anything else to check to make the activated message work.

So what should I do to make sure a bin is properly hotkeyed? I used flag 0x122 (0x2 inventory item, 0x20 always present, 0x100 hotkeyable), and listed the item cog in items.dat. I listed the three new hotkeys in jkstring.uni at "ACTIVATE20" to 22, and increased the message count by 3. I placed the item cogs in my level cog folder and added them to my level. What is the next step?