BASS Stub - A Lightweight BASS template

Started by Ghost, Thu 13/06/2013 11:09:45

Previous topic - Next topic

Ryan Timothy B

#20
I'm a little confused.

Quote from: Crimson Wizard on Wed 26/06/2013 08:20:41
There is no need to call Game.GetLocationName here, because you already know that it is "game.inv_activated" item id, therefore you can use inventory[game.inv_activated].Name; but further, you don't really need to compare Names, you can just compare pointers:
And then you have this:
Quote
Code: ags

// if player has active item in hand, use it no matter what (we may get "unhandled event" here)
if (mouse.Mode == eModeUseinv)
{
   if (player.ActiveInventory.Name != Game.GetLocationName(mouse.x, mouse.y))
      inventory[game.inv_activated].RunInteraction(eModeUseinv);
}

You're assuming that the object, hotspot, character or inventory item you're hovering over won't ever have identical names. I don't understand your logic here.

This would be better:
Code: ags
if (mouse.Mode == eModeUseinv)
{
  InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  if (item != null && player.ActiveInventory != item) inventory[game.inv_activated].RunInteraction(eModeUseinv);
  else if (GetLocationType(mouse.x,mouse.y) != eLocationNothing) ProcessClick(mouse.x, mouse.y, eModeUseinv);
}





Also, I very much dislike you doing this!:
Code: ags
if (inventory[game.inv_activated].IsInteractionAvailable(eModeUseinv) == 1)

It's a boolean and you're checking if it's 1. I know AGS's booleans are actually integers and this code will always work. But you shouldn't make this a practice. It should either be the two with no exceptions:
Code: ags
if (inventory[game.inv_activated].IsInteractionAvailable(eModeUseinv))
// OR
if (inventory[game.inv_activated].IsInteractionAvailable(eModeUseinv) == true)

If AGS ever gets a variable overhaul turning booleans into actual booleans, then this code could throw an error (if it's strict). Plus it's a VERY misleading condition statement that will only confuse people trying to understand the code.

Crimson Wizard

#21
Quote from: Ryan Timothy on Wed 26/06/2013 13:57:26
I'm a little confused.
<...>
You're assuming that the object, hotspot, character or inventory item you're hovering over won't ever have identical names. I don't understand your logic here.

I am sorry for confusion, Ryan, for the last code example I just mindlessly copied existing code, because the purpose of that example was to show different condition (mouse.Mode == eModeUseinv). I did not even paid attention to what is in the block.
Also, I was speaking about section of code under "button = eMouseLeftInv". There can't be any characters there.
If you read my posts further, you will see that I made two suggestions on how to optimize item comparisons.

Although your variant combines two of them :). First you take item from screen coordinates and then still use inventory[game.inv_activated]. If you use "game.inv_activated" there's no need to check item under mouse.

Ryan Timothy B

#22
My apologies. It's been ages since I've last used the game.inv_activated that I honestly couldn't remember what it was. I had also forgotten that AGS had a onClick handler for eMouseLeftInv. So it should've just been this:

Code: ags
if (mouse.Mode == eModeUseinv)
{
  // I don't know how this module was scripted, so as a fail-safe, I put: player.ActiveInventory != null
  if (player.ActiveInventory != null && game.inv_activated != player.ActiveInventory.ID) inventory[game.inv_activated].RunInteraction(mouse.Mode);
}


Edit: Also, I've never played BASS, if you're not going completely strict, the other option is this:
Code: ags
if (mouse.Mode == eModeUseinv)
{
  if (player.ActiveInventory != null && game.inv_activated == player.ActiveInventory.ID) 
  {
    player.ActiveInventory == null;  // deselect inventory item if you click the same item on itself
    mouse.Mode = eModePointer;
  }
  else inventory[game.inv_activated].RunInteraction(mouse.Mode);
}

Crimson Wizard

Quote from: Ryan Timothy on Wed 26/06/2013 14:22:50
My apologies. It's been ages since I've last used the game.inv_activated that I honestly couldn't remember what it was.
I never knew about it until Monsieur OUXX asked something related on forums.

There are a lot of "game" members, some of which have quite non-obvious meaning, and allow to change different aspects of the engine, that cannot be affected otherwise.

cat

Quote from: Ghost on Tue 25/06/2013 16:21:11
- The original BASS changed to an "exit" signs when over places where the character would leave the room. Useful, in my opinion, will do that.

I did something like that for SheepQuest, using custom properties to define the direction. I could clean up the code and donate it for your template if you want (that is - after OROW of course, this week I have different priorities ;) )

Ghost

Cat, that's a great offer, please do. I *have* done pretty much the same already, using regions and custom props to allow for different "direction" cursors... I'd sure like to see how our code compares!

Ghost

#26
*Bump* Version 2.0 is up; see first post.

dactylopus

This is very useful!  Thanks for developing this template!

frenzykitty

I don't know if I'm being a total idiot - but if I try and change the resolution of my game, things start acting very strangely?

For example if I make a new room after changing the resolution, it still makes it in the original resolution of the template? Am I being really stupid (laugh)


Ghost

Changing resolution works fine for me, but the test room, having a 320x240 image, may look odd because the image won't fill the screen (backgrounds aren't resized).
Does the new room actually tell you it's still 320x240? Have you imported an image that works with your resolution?

salak

I'm not sure if this is the right place to ask this but, does this template support saving and loading? If not, can I add that function manually or is there a plugin or something to do that? I hope the question is not sheer ignorance but this template works really perfect for me.

Crimson Wizard

Quote from: salak on Thu 12/09/2013 15:16:45
I'm not sure if this is the right place to ask this but, does this template support saving and loading? If not, can I add that function manually or is there a plugin or something to do that? I hope the question is not sheer ignorance but this template works really perfect for me.
Although this is not a direct answer to your question, I think it is worth to clarify - that the AGS template does not make any restrictions to your game, all it does is providing a starting script/resources. You may remove/rewrite any parts of it, even most of it if you like. Similarly you can add anything.

Ghost

The template has no custom-made save/load fucntions, but you can easily use AGS script to add that- read up the commands
RestoreGameDialog(), RestoreGameSlot() and SaveGameDialog(), SaveGameSlot()
in the AGS manual to learn how loading/saving works.

Then, you can just create a GUI with buttons that call your load/save functions. (The template, for example, has a "quit" button in the slide-in inventory GUI- you could also place load/save buttons there!)

For future reference, a template is a collection of scripts (and assets). You can ALWAYS alter/expand a template because once you create a new game from it, you can see all the code (and assets). Plugins are different since they are compiled by the author and can't be (easily) modified.

Hope this gets you started!

__
[edit]

Crimson was faster! But I was more elaborate! Mwuhaha!

Denzil Quixode

This is great, thank you!

Here is my contribution - a special BASS version of Character.Say()!

Code: AGS
function Say_BASS_Style(this Character*, String message)
{
  String bass_style = "";
  int space_idx = message.IndexOf(" ");
  bool prev = false;
  while (space_idx != -1)
  {
    String part = message.Substring(0, space_idx + 1);
    message = message.Substring(space_idx + 1, message.Length - (space_idx + 1));
    if (prev)
    {
      prev = false;
    }
    else if (Random(1) == 0)
    {
      part = part.UpperCase();
      prev = true;
    }
    bass_style = bass_style.Append(part);
    space_idx = message.IndexOf(" ");
  }
  if (!prev && Random(3) == 1) message = message.UpperCase();
  bass_style = bass_style.Append(message);
  return this.Say(bass_style);
}


( (laugh)  (laugh)  (laugh) )

Ghost

Quote from: Denzil Quixode on Thu 12/09/2013 16:31:10
Here is my contribution - a special BASS version of Character.Say()!

wItcHCrAfT !1!11 :=

Anian

I don't want the world, I just want your half

Monsieur OUXX

#36
Reporting a small issue with AGS 3.3.0 RC1:
When you click the "quit button" then the standard "Quit/Play" built-in dialog window appears but the text is shifted down 5 pixels lower or so. Its upper part is on the button, but its lower part pours out.
I haven't seen that with any other 3.3.0 RC1 game, so I guess it's caused by the template.

===========

@Ghost : I have migrated your template to 32-bits. PLEASE DOWNLOAD THAT VERSION AND DO ALL YOUR FURTHER CHANGES BASED ON IT.
 

Ghost

#37
Quote from: Monsieur OUXX on Mon 20/04/2015 17:20:23
When you click the "quit button" then the standard "Quit/Play" built-in dialog window appears but the text is shifted down 5 pixels lower or so. Its upper part is on the button, but its lower part pours out.
I haven't seen that with any other 3.3.0 RC1 game, so I guess it's caused by the template.
Yes, the text shift is caused by the template replacing the default fonts with ttfs that support the full range of characters. I am aware of this, but so far nobody really complained about it, and these days you see very few of the build-in windows being used anyway. I'll document it in an updated version- the solution is to simply reset the fonts.

Quote from: Monsieur OUXX on Mon 20/04/2015 17:20:23
@Ghost : I have migrated your template to 32-bits. PLEASE DOWNLOAD THAT VERSION AND DO ALL YOUR FURTHER CHANGES BASED ON IT.
I appreciate your work, but out of interest: I understand that 16bit is the hard default and 32bit isn't used that often and several people avoid it to keep their game smaller. Isn't it simpler to upgrade the (very few) sprites yourself when you want 32bit? I am genuinely curious.

Monsieur OUXX

There was another thread where it was discussed that 32-bits should now be the standard so I did that, but there seems to have been some misunderstanding, maybe on my side. So hold on. (roll)
 

Ghost

No problem at all; as I said I really appreciate the effort you went through. (nod)

SMF spam blocked by CleanTalk