Check if buttons show visible on seperate GUI'S.. need help with conditions

Started by barefoot, Thu 19/05/2011 22:43:45

Previous topic - Next topic

barefoot

Hi

UPDATE: I've gone for Give Score / Game score to deal with this.. if you know better please let me know

--------------------------------------------------------------

I have an idea and it involves GUI and buttons..

Each GUI (6 in all) has a hire and hired button..

When you click the hire button it's replaced with the hired button after some text.

What i am trying to do if have a condition if any3 buttons say hired (hired buttons visible after clicking hire) is to proceed to next scene.

I'm ok up until the condition of if any of the 3 hired buttons visible.

Maybe a variable?

Any thoughts/ideas which could help me in the right direction would be helpful and appreciated..  hope this is clear

cheers

barefoot

I May Not Be Perfect but I Have A Big Heart ..

barefoot

Hi

well, so far so good.. iv'e managed to get any player selected (hired) to go to the next room. only 3 are allowed.

This is where i need to check what hired players are in the room... obviously this is needed for commands like say, walk, view etc etc  I need a way to check who's in the room besides the main player.

barefoot
I May Not Be Perfect but I Have A Big Heart ..

Khris

I'm going to do this quickly instead of elegant:

Use a button or clickable hotspot to start off, proceeding to the next scene immediately after the 3rd party member is hired is a bit annoying to the player.
You should also provide them with a possibility to unhire a party member again.

Code: ags
  int party_members;
  if (HiredButton1.Visible) party_members++;
  if (HiredButton2.Visible) party_members++;
  if (HiredButton3.Visible) party_members++;
  if (HiredButton4.Visible) party_members++;
  if (HiredButton5.Visible) party_members++;
  if (HiredButton6.Visible) party_members++;

  if (party_members < 3) Display("You need to hire three players.");
  else if (party_members > 3) Display("You can only hire three players.");
  else {
    ...
  }


The next step is to change the player to the first hired character, then move the other two to the next room, then the player.

Can the player choose which character they control/switch during the game?
If not, I'd simply declare two global Character pointers and let them point at the other two characters.

barefoot

Hi Khris

What I have so far:

The actual npc's are in the first room hidden behind walkbenhind.

There are photos and details of each person on separate GUI'S (looks like tabs) each with a button: hire which changes to hired if you click the hire button.

When a hire button is pressed the npc goes to the next room (you don't see it).
This repeats until you have 3 members and then you the player goes to the next room.

I was trying to figure out a way where you would know who was chosen so you could control that person ie walk, talk, interact etc.

Having any selection as hiredA  hiredB  hiredC seems a good way to go i suppose.

At the moment the player can't change his mind about the team he has hired.

I will look over the code you provided.

cheers Khris

barefoot




I May Not Be Perfect but I Have A Big Heart ..

barefoot

Hi Khris

I've got the first bit working up to where you display 'You can only hire three players' after you have selected 3...

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Sephiroth

I suppose you have one specific character assigned to each button, so maybe you'd need to keep track of who's in the party after the selection. Using a character tab could help. You could have something like that inside the on_button_click of your "hire" buttons:

Code: ags

 //global script outside functions
 Character *party[10];

 //global script end
 export party;

 //global script .ASH
 import Character *party[10];

//button1_click
 party[0] = cChar1;

//button2_click
 party[1] = cChar2;


Then you can set the one you want to be playable with:

Code: ags

 party[1].SetAsPlayer();
 //hide others, changeview or changeroom


barefoot

Hi

thanks for that Sepiroth

it is the npc'c that get chosen and sent to the next room first. The main player goes only once the 3 have been selected (they meet up in an old warehouse).

Of course without knowing which npc was chosen may be awkward and may involve multiple scripting for each npc (if char / else if char/ etc etc}

I could have no faces on gui's and just choose 3 chars for the next room, would defeat the issue but may work if in say to them about changing their names to protect giving away their true identity.. mad i know..

This may be a something that is not really feasible an other options may have to be looked at.

cheers

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Sephiroth

If you use the tab I described, you'd just have to fill it with the selected characters, change cNPCs to the characters you have:

Code: ags

//global outside functions
int party_members;

//hire button1 click
if(party_members<3)
{
 party[0] = cNPC1;
 party[0].ChangeRoom(2);
 party_members++;
}

//hire button2 click
if(party_members<3)
{
 party[1] = cNPC2;
 party[1].ChangeRoom(2);
 party_members++;
}

//hire button3 click
if(party_members<3)
{
 party[2] = cNPC3;
 party[2].ChangeRoom(2);
 party_members++;
}


Then when the player changes room and meets them, you'll need to use this  to change the playable character ( either in dialog or button_click or whatever ):

Code: ags

party[1].SetAsPlayer();


This should teleport to the NPC you've chosen as the player, if you wanted him to replace the player at his current position then make him changeroom to the current room before setting him as player.

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Sephiroth

This is of course on top of what Khris told you, I mean you still have to include the check if(party_members<3) before adding party members. (edited the code)

Khris

Sephiroth:

While your approach is fine in principle, you are bound to end up with three characters randomly allocated in slots 0-5 while the other three are null which pretty much defeats the purpose of having the array.

(Btw you don't need to put the export line at the end of the script, just after the declaration is fine and much tidier.)

Having a specific player character and three additional ones makes this easier though;

Code: ags
// next room's before fadein

  party[0] = player;
  int party_index;
  int i = 1;  // assuming the six characters are #1-6 in the editor's character list (player is #0)
  while (i < 7) {
    if (character[i].Room == player.Room) {
      party_index++;
      party[party_index] = character[i];
    }
    i++;
  }


Now the three selected characters are stored in party[1], party[2] and party[3].

Sephiroth

Right, I was about to post something index driven like this, but you beat me ;)

As for the export declaration, I usually do it right after as well, but it is mentioned in the manual it has to be at the end, so I figured there's an obscure reason to it that may cause problems in other's scripts.

barefoot

Cheers Khris and Sephiroth

May i assume that i can script cNPC1  cNPC2  etc as their names?

eg

cNPC1.Say("");

cNPC2.Walk();

etc etc

thanks again

:=

bareoot
I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk