Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → making choices
making choices
2005-06-01, 4:09 AM #1
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:

Code:
# 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:

Code:
# 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!
2005-06-01, 9:13 AM #2
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.

Code:
activated:
   SetPulse(1.0);

pulse:    
   // Do stuff here
   Return;

deactivated:
   SetPulse(0);
   Return; 
2005-06-01, 10:35 AM #3
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.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2005-06-01, 10:45 AM #4
Methinks an error is right here:
Code:
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.
May the mass times acceleration be with you.
2005-06-01, 1:07 PM #5
Thanks guys. I'll try your suggestions now. Here is my items.dat file, Darth Slaw.
Attachment: 5309/items.txt (12,977 bytes)
2005-06-02, 5:04 AM #6
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?
Attachment: 5324/jkstrings.txt (64,552 bytes)
2005-06-03, 5:24 AM #7
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?

↑ Up to the top!