Animating Background+Bool

Started by Gabarts, Sun 10/06/2012 21:52:23

Previous topic - Next topic

Gabarts

Ok, maybe this is a bit complex for me at the moment but I'd like to have some advices on how to create these things:

Background animation

I've seen that is better using many backgrounds instead of single animating objects, but what if you want 3-4 looping characters in your background like for example in Venice for "Last Crusade"?

Interact with a looping character

Let say I want to talk with a character that is doing a loop action in background (maybe using RepExec function, don't know) and when I click he stops, start dialogue and then restart the loop, is easy to do?

Bool or conditions

This instead is when you can't open a door until you get some items or talk with someone for example, I was thiking to the bool function, but maybe is a different thing.

Can you give me some tips to start with these things? Thanks

EchosofNezhyt

I got a art background and a tiny tiny tiny amount of experience (A tad bit of java/lua.)
Only been using ages for a bit over a week but here we go.

Background animation

If there all doing different actions it might be hard because lets say a guy is smoking a cig and a woman is dancing and a guy is having a convo all of them require a different amount of frames.

Id draw a simple version of frame one of what the action starts as and then draw frame 4 of how it ends and then fill it in and see how it looks. I'd group the simple animations that don't require interaction into backgrounds. (Guy smoking and talking)

It just depends on so much.

Interact with a looping character
Easy just use
  Charatername.SpeechView = AnimationViewNumberHere;
Then after dialog switch it back.

Bool or conditions

I'm guessing it is a preference because it "most likely doesn't matter"
I personally use bools.


If you got anymore I'll try and help but limited experience here.

Deu2000

To animate a character repeteadly, use Character.Animate()



EchosofNezhyt

Yeah if you want him to just animate or whatever use Character.Animate()
if you set a speech view up it will automatically switch to that when talking.(I switch between mad, angry, sad and laugh expressions though so i use the Speechview)

Khris

Background frames are useful for fluttering banners or waves at a beach.
If you want NPCs you can talk to, don't animate them using the background frames; you have to implement them as characters anyway and it is much easier to just assign them an Idle view. Look up Character.SetIdleView.

That should also answer your second question because afaik, an NPC with a set idle animation can talk just like any character. If he happens to idle animate during the dialog, just deactivate the idle anim before the dialog and start it again at the end.

The third question falls into the "asked and answered countless times" category.
Create a bool variable in the Global variables pane, initial value: false, then set it to true in cBartender's TalkTo code:
Code: ags
    talked_to_bartender = true;


In the door's use/open code, do:
Code: ags
    if (talked_to_bartender) ...
    else player.Say("I should ask around first.");

Gabarts

Thanks, the first two are definitely more clear now, as for variables (true, false) I need to dedicate much more time and do some tries. I can set a variable for all kind of actions, right? The goal is finding the proper code :)

EchosofNezhyt

You can set it for whatever.

The tutorial/help built into ags is invaluable.

You'll be fine just give it a few trys and don't look up everything try to figure some of it out I think it helps learning.

Good Luck.

Gabarts

I've tried to code this but maybe is completely wrong, can you help me?

Here what I've coded (I want the door opens only if an item is in inventory):

Code: AGS
function hPorta_AnyClick() {
   
   
    if (MovePlayer(46, 105)) {
      player.FaceDirection(eDir_Left);
    // LOOK AT
    if(UsedAction(eGA_LookAt)) {
      player.Say("E' il portone blu di casa.");
      }
    // USE
    else if(UsedAction(eGA_Use)) {
      player.Say("Meglio di no.");
    }
    // OPEN
    else if(UsedAction(eGA_Open)) {
      
      if (Portafogli_inv = true) {
       player.LockView(19);
       player.Animate(1, 0, eOnce, eBlock, eForwards);
       player.UnlockView();
       oPorta1ap.Visible = true;
      }
      
      else {
      
      player.Say("Non posso andarmene senza il mio portafogli.");
      player.Say("E' da qualche parte qua nella casa ma non riesco proprio a ricordarmi dove l'ho lasciato.");
    }
  }


And here the code for the variable

Code: AGS
bool Portafogli_inv {
  player.ActiveInventory(iPortafogli);
}


I've set a Global variable bool Portafogli_inv to false

NickyNyce

look under HasInventory...no variable needed

if (player.HasInventory(iKey))
{
  Display("The player has the key!!");
}

Gabarts

... Thanks, I'll check again all the functions. But if I want to use for dialogue variables like Chris said, I only need to use the bool name (for example talked_to_bartender) and set it to true in talk_to action?
What about a more complex bool to code under globalscript.asc? I think the way I've coded it is wrong... ;)

Khris

#10
First of all, indent your code properly... I can't stress enough how important this is.

Now, like Nicky said, to simply check if the player possesses a certain inventory item, use player.HasInventory.

If, on the other hand, you want to find out whether the player has used a certain inventory item, you'll need this:
Code: ags
    else if (UsedAction(eGA_UseInv)) {
      if (player.ActiveInventory == iCup) player.Say("I used the cup.");
      else Unhandled();    // <-- this is needed to handle other inv items
    }


As for your bool code, you can't define a Global variable called Portafogli_inv, then define it again within a script.
Also, to create a bool function, you'll need a) parameter brackets after the name and b) a return value. The following will compile:
Code: ags
bool player_is_using_key() {
  if (player.ActiveInventory == iKey) return true;
  else return false;
}

Or the short version:
Code: ags
bool player_is_using_key() {
  return (player.ActiveInventory == iKey);
}

This function is useless though since you can directly check HasInventory() or ActiveInventory.

BUTT, and this is the most important part:
There's already a special function that does all the door handling. It's called any_click_on_door_special and is explained in the goddamn PDF that comes with the fucking template.
Not only does it allow you to specify the inv item that unlocks the door but also the message supposed to be displayed if the player tries opening the door while it's locked or looks at it.
There's also example code right there in the first room of the game.

Edit: May I also remind you of this thread: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=46182.0
Did you forget everything I posted in there...?

Gabarts

At first glance I didn't understand well the any_click_on door special and had a bit hard time to clear my way until now. In fact I've used a longer way to reach the actions... sorry
I will try to read more careful and pay attention to details. Thanks

Now I've finished the DEMO, thank all for your support. -of course is ridiculous coded DEMO but is what I wanted :)-

SMF spam blocked by CleanTalk