Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - bx83

#41
I'm trying to have the Transparency for 12 objects bob between 0 and 100, so they act like lights dimming and growing fuller. Each should have a sin wave pattern: growing stronger, growing weaker, growing stronger, etc.
For this example I've only picked the 10th object.

Everything except the last few lines acts as expected.


The code:

Code: ags
function room_RepExec()
...
  transCtr++;
  //every 5th loop, run this code
  if (transCtr > 5) {
    transCtr=0;
    
    //load out temporarily
    for (int z=0;z<12;z++) {
      stars[z]=object[z+6].Transparency;
      if (z==10) Display("load out: for %d, dir %d trans %d",z, stardir[z], stars[z]);
    }
    
    //do calculations
    for (int x=0; x<12; x++) {
      
      if (x==10) Display("b4 for %d, dir %d trans %d",x, stardir[x], stars[x]);
      
      if (stars[x]+stardir[x]<0) {
        stars[x]=0;
        stardir[x]=1;
      }
      if (stars[x]+stardir[x]>100) {
        stars[x]=100;
        stardir[x]=-1;
      }
      
      stars[x]+=stardir[x];
      if (x==10) Display("a4 for %d, dir %d trans %d",x, stardir[x], stars[x]);
    }
    
    //load back in
    for (int y=0;y<12;y++) {
      object[6+y].Transparency=stars[y];
      if (y==10) Display("%d %d ?",object[6+y].Transparency, stars[y]);
      if (y==10) Display("load back in: for %d, dir %d trans %d",y, stardir[y], stars[y]);
      if (y==10) Display("so %d is now trans %d - matching %d?",y, object[6+y].Transparency, stars[y]);
    }
    
    Display("trans %d", os11.Transparency);
  }
...




Example output:

note: dir, or stardir[counter], is direction - growing weaker or stronger by having 1 or -1 added to transparency.


load out: for 10, dir 1 trans 96 <--load values into array
b4 for 10, dir 1 trans 96          <--before doing calculations
a4 for 10, dir 1 trans 97          <--after doing calculations
98 97 ?                                  <-- is the value of object 10's transparency (that we got the value out of) equal to value 10 of the array of transparency counters, after we made it equal to it? Nope - wtf?
load back in: for 10, dir 1 trans 97   <-- put damaged value back in object 10, etc.
so 10 is now trans 98 - matching 97?
trans 98

load out: for 10, dir 1 trans 98
b4 for 10, dir 1 trans 98
a4 for 10, dir 1 trans 99
100 99 ?
load back in: for 10, dir 1 trans 99
so 10 is now trans 100 - matching 99?
trans 100.  <-- loop doesn't grow weaker

load out: for 10, dir 1 trans 100
b4 for 10, dir 1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100

load out: for 10, dir -1 trans 100
b4 for 10, dir -1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100

load out: for 10, dir -1 trans 100
b4 for 10, dir -1 trans 100
a4 for 10, dir -1 trans 99
100 99 ?
load back in: for 10, dir -1 trans 99
so 10 is now trans 100 - matching 99?
trans 100

ad infinitum


The problem seem to be, 1 is added always to object[6+y].Transparency on the last 4 Display() lines, but I can't see how. For instance, it's object[10].Transparency=stars[y], not object[10].Transparency+=stars[y], so i don't see how it could have happened.

note: 6+y just means object indexes are 6 more than the counter, so the 10th object (which is actually object 11 out of 12 not using zero index), is object[16]. I included this pointless complexity because I obviously don't know what's the code's doing, and you might :/

????
#42
I remove all the items in the inventory, updateinventory(), don't show the user; add a couple of item back, updateinventory(), don't show user.

Finally, when the user clicks the inventory and makes it visible, the inventory is 'up' 1 row; it doesn't sit with the first line of items at the top, rather they are one row upwards, hidden. How can I manually update and reposition it so the first row sits flush and can be seen?
#43
I have a picture. I can turn it into a dynamic sprite, and draw it wherever I want.
But I can't delete it, as it's burnt into the background.
I can take a square of background from before drawing and re-apply it to hide the sprite - but if it's the background is being animated at the time I take the copy, this will write back the wrong image.
What do I do? Is there any way of showing/hiding an image without just using the GUI/Object 'Visible' method?
#44
ZOrder doesn't exist for DynamicSprites, but here me out...
I'm using the SpeechBubble module, and want to alter it so that a speech bubble appears above the Inventory GUI (ZOrder=2) when it appears. This way, speechbubbles are not covered up by the GUI, which has a solid background.
However, I don't know how I can do this?
#45
I've tried in repeatedly_execute() and repeatedly_execute_always() - doesn't matter, it seems to go to a place that exists only in the dDialog. I have debugging in the global script under repexec(), it simply stops checking when it enters a dialog (dDialog.Start() )
I have something which detects the current speech frame a character you're talking to is on; I can't access the character.
#46
I feel stupider even saying this, but how is this possible?

Code: ags
function GetString()
{
  String s;
  switch(Random(2)) {
    case 0: s="this is text"; break;
    case 1: s="This is also some text"; break;
    case 2: s="some more text"; break;
  }
  return s;
}


"Error (line 9): Type mismatch: cannot convert 'String*' to 'int'"

I'm missing something. Do people actually using callback arguments for this?
#47
I've noticed that if I add or delete a variable, save-games made before that change are no longer compatible with the new .exe file.
Some experimentation has shown that it's the number of variables, not the name or type. Is this true?
What, other than deleting essential rooms or characters, will make a save-game incompatible?
#48
My question's so simple today you'll scoff before you've finished reading it.
How do I write code that reflects...

"If the player has an active inventory, and the active inventory is iABC, and he left clicks while the cursor is over a non-transparent part of object oXYZ, then do something."

Thank you.
#49
I've had some trouble with the on_mouse_click() function recently.
This error is runtime and intermittent - it's happened twice so far.

The rules for mouse clicks logic in the inventory window are:

Right click
  Are you over a non-null item (ie. you're not clicking on an empty area)?
    Can this item have a Useinv interaction run on it?
      If so, load the item you just clicked on as the activeinventory item.

Left click
  Is there an item loaded as the activeinventory item?
    Yes - combine the activeinventory item with the object you just clicked on (ie. activeinventory=key; useinv key with door)
    No - LOOK at the inventory object you just clicked on
    if the inventory item you just clicked wasn't there (ie. you clicked an empty area), then do nothing.

Here's the code:

Code: ags
...

InventoryItem *tInv;
tInv = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
    
    if (button == eMouseRightInv) {
      if (tInv!=null && tInv.IsInteractionAvailable(eModeUseinv)) {
        player.ActiveInventory=inventory[game.inv_activated];
        player.ActiveInventory.CursorGraphic=inventory[game.inv_activated].CursorGraphic;
      }
    }
   
if (button == eMouseLeftInv) {
  if (player.ActiveInventory) {
    if (tInv!=null) {
      tInv.RunInteraction(eModeUseinv);
      mouse.Mode=eModeLookat;
      RemoveActiveInventory=true;
    }
} else {
    mouse.Mode=eModeLookat;
    player.ActiveInventory=null;
    tInv.RunInteraction(eModeLookat);
  }
}

...


The error is: null pointer referenced.

My thoughts are that it has something to do with line 4: tInv is defined. Because the position is defined a second before the if statement catches it, I think that the rare situation when it references a null pointer has something to do with the user moving the mouse sharply, and clicking on an item when they were just over a point that was empty?.. ie. they pass a null pointer, when they thought they were clicking on an actual item?.......  No idea to be honest :/

Can anyone see any obvious mistakes, improper code, or the runtime error itself? It's definitely in the above logic, just no idea where :/
#50
I’m publishing a game soon, and I’d like it to be a success (no way of knowing if it will make $500k or $57.80, but hey).
I’ll be putting out a demo - how long should it be? Should I even bother with one, and just put an enticing video/screenshot package?

It’s being sold on Steam, windows exe (er, when I can be bothered getting a publisher); Gameplay is about 3.5 hours at the quickest, full dialogue.

What’s a good length for a demo? 30min, 15min, 1 hour? Should I leave them hanging or make it obvious when the demo is done? And do I even need one?

Seeking your sage advice ;)
#51
I’m creating 3 game parts, through 3 different exe’s. All share the same code/rooms.
Can you do this with save games? Or through progressive parts + save games? Eg.

Part 1, room 1-10
part 2, rooms 1-20
part 3, rooms 1-30
(As opposed to part 1 rooms 1-10, part 2 room 11-20 etc)

Basically, can you do 3 (progressive) exe’s with a progressive save game; or will the different save games be incompatible within the 3 parts?
#52
I recently made a function which is just like AudioChannel.SetRoomLocation(), but allow you to choose the area in which the sound exists (as opposed to the entire screen, which would only see the volumes go to 0 if you're at the edge of the screen).

My code:

Code: ags
function soundPlayLocation (int x, int y, float r, AudioClip* soundSample, int residual)
{
	float d=0.0;
	int 	p=0;
	int 	sp=0;
	
	if (soundPlayer1==null) {
		sp=1;
		soundPlayer1=soundSample.Play(eAudioPriorityNormal, eRepeat);
	} else {
		if (soundPlayer2==null) {
			sp=2;
			soundPlayer2=soundSample.Play(eAudioPriorityNormal, eRepeat);
		} else {
			if (soundPlayer3==null) {
				sp=3;
				soundPlayer3=soundSample.Play(eAudioPriorityNormal, eRepeat);
			} else {
				Display("more than 3 sound samples.");
				return -1;
			}
		}
	}
	
	float dx = IntToFloat(abs(player.x - x));
	float dy = IntToFloat(abs(player.y - y));
		
	d=Maths.Sqrt((dx * dx) + (dy * dy));
	
	if (d>r) {
		switch (sp) {
			case 1: soundPlayer1.Volume=residual;
			case 2: soundPlayer2.Volume=residual;
			case 3: soundPlayer3.Volume=residual;
		}
	} else {
		p=FloatToInt( 100.0-((d/r)*100.0) );
		if (p<residual) p=residual;
		switch(sp) {
			case 1: soundPlayer1.Volume = p;
			case 2: soundPlayer2.Volume = p;
			case 3: soundPlayer3.Volume = p;
		}
	}	
}


Typical calling code:
Code: ags
soundPlayLocation(415, 610, 50.0, aFlys2, 10);


This focuses on a circle, who's center point is x,y, with a radius of r, and a residual sound so that it will always play no lower than 'residual's volume, even when you're outside the circle.
It works fine; but when it comes to playing more than 1 sample, it doesn't work.

I thought I would make a version with 3 global AudioChannel* variables, and find the newest one and assign soundSample to it, allowing for 3 positions in the room the play from.

However as soon as I load the game, I get this error:
Code: ags
		switch (sp) {
			case 1: soundPlayer1.Volume=residual;  <--THIS LINE - 'null pointer referenced'
			case 2: soundPlayer2.Volume=residual;
			case 3: soundPlayer3.Volume=residual;
		}

...despite the fact that it first loads soundSample into soundPlayer1 at beginning:
Code: ags
if (soundPlayer1==null) {
		sp=1;
		//if (soundPlayer1.PlayingClip!=soundSample)
		soundPlayer1=soundSample.Play(eAudioPriorityNormal, eRepeat);
...


What have I done wrong?
#53
If I include 5 voice samples with Say() In the code, but then copy 500 to Speech/, how many will be compiled into speech.vox?
#54
I've recently sort to edit my code to give the options a left indent of 11px.

Here's the code:
Code: ags
//----------------------------------------------------------------------------------------------------------------------
// DIALOGUE
//----------------------------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------------------------
// Dialogue Options Get Dimensions
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_get_dimensions(DialogOptionsRenderingInfo* info)
{
	ConversationIsOn=true;
	//sprtFloatingText.Delete();
	
// Create a 1366x96 dialog options area at (0,704)
  dialog_left=11;

  info.X = dialog_left;
  info.Y = 672;
  info.Width = 1366;
  info.Height = 96;
}

//----------------------------------------------------------------------------------------------------------------------
// Draw Dialog Options
//----------------------------------------------------------------------------------------------------------------------

function DrawDialogOptions(DrawingSurface* ds, DialogOptionsRenderingInfo* info)
{
	int i = 1, ypos = 0, xpos = 0;  
  ds.Clear(COLOR_TRANSPARENT);
  while (i <= info.DialogToRender.OptionCount)
  {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn)
    {
      String str = info.DialogToRender.GetOptionText(i);  //get glyph number from option text
      int cur_img = str.AsInt;                            //current image is that number
      ds.DrawImage(xpos, ypos, cur_img);                  //draw this glyph
      xpos = xpos + 96;                                         //xpos+=width of glyph
    }
    i++;
  }
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Render
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_render(DialogOptionsRenderingInfo* info)
{

  DrawDialogOptions(info.Surface, info);
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Repeat Exec
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_repexec(DialogOptionsRenderingInfo* info)
{
  int i = 1, xpos = 0;
  while (i <= info.DialogToRender.OptionCount)
  {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn)
    {
      if (	 mouse.y >= info.Y
					&& mouse.x >= xpos
					&& mouse.x <= xpos+96)
      {
        info.ActiveOptionID = i;
        
        //transplanted in from dialogue_options_mouse_click() to get rid of background/old buttons in real time
        MyDynamicSpriteForTheFakeGUI = DynamicSprite.Create(info.Width, info.Height, true);
        DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
        DrawDialogOptions(ds, info);
        ds.Release();
        
        return;
      }
      xpos += 96;
    }
    i++;
  }
  gFakeDialogOptions.Visible = false;
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Mouse Click
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_mouse_click(DialogOptionsRenderingInfo* info, MouseButton button)
{
	//ConversationIsOn=true;
	
  if (info.ActiveOptionID > 0)
  {
    MyDynamicSpriteForTheFakeGUI = DynamicSprite.Create(info.Width, info.Height, true);
    DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
    DrawDialogOptions(ds, info);
    ds.Release();

    gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
    gFakeDialogOptions.Visible = true;
    info.RunActiveOption();
  }
}


// END DIALOG FUNCTIONS


I expect all options to be drawn with an initial 11px indent. However, once I choose an option, it defaults to 0px indent; then when speech is over, it flips constantly between 11px and 0px indent.

Video:

https://bluekeystudios.com/img/conversation_error.mov

How can I get it to have an 11px indent at all times, including when selecting an option (ie. selection isn't always off by 11px if I click near the border)?
I think it's something in dialog_options_repexec() doing this weird overdrawing, but not sure. I've tried a few things, nothing works.

Bonus question: I'm thinking of having a large background image to frame the conversation icons -- where do I put the drawing code, once in dialog_options_render()?
#55
Space for images to use in these forums? You get some.
Page to display your game and lead to a sales domain or PayPal? You get these.
One central place for buying and selling upcoming and produced adventure games? All here.
Walk through? All the walk throughs.

Your thoughts?
#56
Hi all

I have an object on screen. It's visible and clickable. I have a method for interact. I've tried it with baseline being where it is, and baseline being 768 (max height of screen). I can't get it to respond with any click, and with interact, the cursor icon doesn't change (indicating that it doesn't have a 'Interact' interaction... except it does). It doesn't even come up with it's own title (all objects in the game with a Description property have it displayed in the upper screen when moused-over). It doesn't have any hotspot's on top of it. It doesn't have a menu on top of it (the menu is invisible anyway).

Why is it not clickable, or doesn't even respond to anything?
#57
I've tried defining a global const; no option for this in global variables.
I've tried defining one in-script, except then it's not global.
Tried defining a readonly int in global.h, but it says I need to enter a literal value like 2 rather than a function like Random(2); (I think)
I've tried searching google and the forums, but nothing obvious shows.
I've tried to look up the manual, but nothing in there.

So what do I do?
#58
I have this code:
Code: ags

switch (player.Room) {
		1:  candleobjnum=3; break;
		2:  candleobjnum=7; break;
...
		55: candleobjnum=1; break;
		58: candleobjnum=-1; break;//no candlelight object
	}


I tells the system what object number the "CandeLight" object was for each room. (next time I'm using a GUI :/)

When I run, I get the error: "improper argument '1' for Switch statement." or something of the like.

What is wrong with this? I thought 'switch (result of numer operation) { .... }' was the *only* argument you could put in there anyway?
#59
Here's the deal: I want to get the script-referenced name 'iKey'
However, when I go:

Code: ags
String item_Name=inventory[125].Name;


It simply produces 'A Magical Key' rather than 'iKey'

I've tried GetTextProperty("Description"), and etc, and nothing works and/or just produces 'A Magical Key'

I've had a look at Kris' comment in https://www.adventuregamestudio.co.uk/forums/index.php?topic=49878.0 , but it's confusing me (and my easily-confused brain) even more.

So question stands: how do I get 'iKey'?
#60
I'm trying to manually animate something. This means counting up the delay in room_RepExec, then going through each animation frame of the view/loop I'm using, then looping back to 0 when I reach the end of the view.

However, I'm finding it impossible to go and get the image number of the next (or Xth also) frame of an animation. I can check which frame I'm on, but not set the frame, or find out the image number.

How do I do any of these things?
SMF spam blocked by CleanTalk