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

Messages - geork

#101
To the best of my knowledge, the objects accessed are the ones in the current room. Otherwise you've hit the nail on the head. You call
Code: AGS
object[i].Name //or whatever

where "i" is the index of the object and just use it as if it where a normal object. You may, however, never call
Code: AGS
oObjectName.Name

Where "oObjectName" is the name of the object, in the global script.

I don't think there is a way to call objects from a different room...

Hope that helps :)
#102
Put a bracket behind the "if" clause, and remember to finish the whole function with a bracket
Code: AGS

function Painting_UseInv()
{
  if (cBert.ActiveInventory == iPscraper){ //this is where the bracket was missing
  //stuff
  }
  else{
  //other stuff
  }
}//to close the function


That should do it :)
#103
Haha! I can't believe I did that! :D
Thankyou very much Krus, that should do it :)
#104
Hey all!
I've been recently been playing around with with different dialog methods, and I have a question concerning a particular piece of code which I would like to use for efficiencies sake. Basically, each conversation stores it's options, and if any new ones need to be added the next time the conversation is opened the code should do that without losing the old ones. I've tried to do it this way:
//in room
Code: AGS

function hBody_Talk()
{
 CurrentDialog = 0;
 if(player.HasInventory(iPoster)) CreateNewOption(5, 24);
 if(player.HasInventory(iGun)) CreateNewOption(6, 29);
 StartDialog(0);
}

and global script
Code: AGS
function CreateNewOption(int index, int sprite){//Add a new index
  if(Game.DoOnceOnly(String.Format("&d,&d,&d", CurrentDialog, index, sprite))){
    //do all the adding dialog stuff
  }
}

Unfortunatly, the code only executes once, despite the string value in Game.DoOnceOnly being different. Have I misunderstood the nature of that function? I searched the forums prior and I found an earlier example using this sort of logic...
Thanks!
#105
The problem with AreThingsOverlapping(thing1,thing2) is that it makes a rectangular check around the graphic: If there are any transparent regions in the sprite it will count those too.

This module should have you covered though, as far as I can tell.

It's possible to do this mathematically too, but the risk is that that only works with individual cases. Measuring the distance between the center of both characters, for example, only works if they are both perfect circles (otherwise modifiers are needed)

Just a quick note (because I like to be picky :P) instead of going
Code: AGS
if (GetGlobalInt(2)==100){
//stuff
}
 if (GetGlobalInt(2)!=100){
//stuff
}

You can do
Code: AGS
if (GetGlobalInt(2)==100){
//stuff
}
else{
//stuff
}

As the else function would be called whenever GetGlobalInt(2) does not return 100
#106
About the error: It should be
Code: AGS
phone_number[ePNContact1] = "867-5309";
not
Code: AGS
phone_number[ePNContact1] == "867-5309";
(the single and double equals signs are a programming ****  :P)

Conceptually speaking: Khris is linking the item's name to an "index" he has created, so when the list box is checked, it will be the item's name, not index, which matters. He creates his own "index" here:
Code: AGS
enum Contact {
  ePNContact1,
  ePNContact2,
  ePNContact3,
  ...
};

(which is the same as:)
Code: AGS
enum Contact {
  ePNContact1 = 1, //Wierdly the first one is 1, not 0
  ePNContact2 = 2, 
  ePNContact3 = 3,
  ...
};

Then he gives everyone of his phone_number[] variables a value:
Code: AGS
phone_number[ePNContact1] = "867-5309";

(again, same as:)
Code: AGS
phone_number[1] = "867-5309";]

Hence, when you want to check which phone number has been selected, you call GetContact() which iterates through all the phone_number variables (from phone_number[0] to phone_number[14]) and tries to find whether the string phone_number[number] = the string (i.e. name) of the currently selected list box item: If so it returns the current number
Code: AGS
if (phone_number[i] == listPhoneNumbers.Items[listPhoneNumbers.SelectedIndex]) return i; //return terminates the function too

So when Khris calls next:
Code: AGS
Contact c = GetContact();
he is checking whether the number returned corresponds with any of the items in Contact (e.g. if 1 is returned, c = ePNContact1 as ePNContact1 = 1)

and so, instead of checking 
Code: AGS
if (listPhoneNumbers.SelectedIndex==0])
you check
Code: AGS
if (c == ePNContact1){


Sorry if this is a bit long winded, or if you knew most of that already. But I hope this clears up any conceptual things you found difficult to follow!
#107
Oops, my bad :P

Crimson's solution is way more elegant. If we can assume that the objects are bound by rectangles, then a slight amendment could work maybe?
Code: AGS
Object *GetFirstFoundObjectInArea(int StartX, int StartY, int EndX, int EndY){
  int index = 0;
  while(index < Room.ObjectCount){
    Object *o = object[index];
    DynamicSprite *f = DynamicSprite.CreateFromExistingSprite(o.Graphic);
    int Xfactor = f.Width;
    int Yfactor = f.Height;
    f.Delete(); // I don't know whether the above 2 are needed, but want to delete the sprite before the function is cut off
    if((o.X >= StartX || o.X + Xfactor >= StartX) && 
       (o.X <= EndX || o.X + Xfactor <= EndX) &&
       (o.Y >= StartY || o.Y + Yfactor >= StartX) &&
       (o.Y >= EndY || o.Y + Yfactor <= EndY)) return o;
    index ++;
  }
  return null;
}

I tested this on an object which was only partially covered (ie not the XY coordinate) by the box and it seemed to work well enough. I guess for extra safety one could put brackets around the o.X/Y + f.Width/Height

This ain't pixel perfect though.
#108
I've scripted a short piece of code which should work to this:
Code: AGS
//Somewhere
bool GetObjectsInArea(int StartX, int StartY, int EndX, int EndY){
  bool FoundObject = false;
  while(StartX != EndX && StartY != EndY){
    if(Object.GetAtScreenXY(StartX, StartY) != null) FoundObject = true;
    if(StartX != EndX) StartX ++;
    if(StartY != EndY) StartY ++;
  }
  return FoundObject;
}
//Somewhere else
if(GetObjectsInArea(X, Y, X2, Y2) == true){
}


I've tested this very roughly, but it seems to be working. I guess to store the objects found you can make an array and add an item every time the Object.GetAtScreenXY condition is true.

Hope that works!
#109
I dunno how viable these suggestions are, being not very familiar with the internal working of AGS (I should start one day), they are to do with arrays

.2d arrays. so like
Code: AGS
int myArray[5][5]


.being able to create the number of array slots based on existing variables. so
Code: AGS
int myArray[myVar];
#110
Quote from the manual:

QuoteIf this [the blocking width] is set to 0 (the default), then the blocking rectangle is automatically calculated to be the character's width, and 5 pixels high.

Hope that answers it!
#111
Although I am unfamiliar with this module, I think I can see what's up. If these are custom properties, there's a way to edit the schema so there's a default value. Double click on any item, go to properties, click "edit schema", find the property you want (eg "Custom_Look") and double click. Then in the default value type something like "Inventory Item" or whatever generic message you want to be displayed.

I hope that works!
#112
The Rumpus Room / Re: The Game Idea Thread
Sat 04/08/2012 11:53:36
A detective game where you will never know if you really got the right guy (you can arrest anyone and everyone) where all areas are accessible. Furthermore, the game will block you from playing again thanks to text files (would probably need multiple mysteries)

This probably exists in flash form but I've never seen this in "bigger" games

For more flavour, the detective could also be mildly delirious 
#113
Sorry for the late reply, I hope I'm still in time!

QuoteThis helps in a way but doesn't really help how I needed because you are still using "player.AddInventory(iItem);" and the game can only have a total of 300 iItems. I'm talking about a way one could avoid several items for each different stage of a reaction such as iRobo (cough syrup), iSyr_Amm (syrup and ammonia), iSyr_Amm_Nap (syrup, ammonia, and naphtha), etc...

Oops, sorry, I misunderstood that :S Not that I can see: But there are ways to circumnavigate this problem. The easiest I can see is, instead of having 1 item per chemical, is to have maybe 10 items called iChemical1, iChemical2 etc. etc. and then assign they're names, properties, quanties and so on via either item properties or structs (personally I prefer structs, as you may have noticed :P) for each game. So in game 1, iChemical1 would by Robo, iChemical2 would be NH3 or whatever you assign to them. This way you can have potentially limitless number of chemicals.
This approach needs something along the lines of Khris' code to function however. Although instead of checking InventoryItems, you'd instead check Chemical Names (Strings).

QuoteAnd for that code, how would that help? Wouldn't I have to call that for every step of the extraction since it discusses mixing 2 specific chems with each other to make a 3rd? And would I still have to use it twice so that you can use both items to start the reaction

@(Anyone) is it possible to use an unhandled_event(5,3) function (i.e use inventory on another) and still know both items involved?
Otherwise: I can see no way of minimizing on that, you'll have to use both functions. Or you could find another way around. For example you could make a GUI which displays the inventory items you click on with a "combine" button - that way you only have one function to put everything in (the one that's linked to the button)

I hope that helps! Tell me if I should be clearer (Sometimes things make sense in my head but not on paper, as it were... :S apologies in advance)
#114
Quote
QuoteAlso, while you're checking player.ActiveInventory in the first function, you stop doing it in the other ones. You need to check the quantity in addition to which item was used, not instead of.

Could you expand on this?
As in: in some of your functions you are checking what the players active inventory is, but in some of them you are not. It's probably best to check this in all combining objects functions.

QuoteAlso, is there a way to use this script array to avoid creating several different inventory items during chemistry, as each game can only contain 300 items and they will surely fill fast if not.

Yes, absolutely, and this is where structs can come in handy. Instead of having 30 inventory items for a single chemical, have one, and attach the amount of the chemical onto a variable. So for example, instead of:
Code: AGS
player.InventoryQuantity[iItem] += 60;
UpdateInventory();
 
have:
Code: AGS
player.AddInventory(iItem);
chems[iItem.ID].quantity += 60; // Have the chems ID match the item ID, it makes everything super simple

You can always check whether the quantity becomes 0, in which case the player should lose that inventory item.

As a general rule (probably a general rule, anyway) - if you have lots of repeated code you can usually stick that into your own function and call it with specific parameters. as far as I can see, every time you lose two chemicals and gain one, with a message, so you could write a function:
Code: AGS
function MixChems(InventoryItem *item1, InventoryItem *item2, InventoryItem *product){
  int ProductAmount = chems[item1.ID].quantity + chems[item2.ID]; //so you get how much chemical is made
  chems[item1.ID].quantity = 0;
  player.LoseInventory(item1);
  chems[item2.ID].quantity = 0;
  player.LoseInventory(item2);
  if(chems[produce.ID].quantity == 0) player.AddInventory(produce); // in case the player already has it
  chems[produce.ID].quantity += ProductAmount;
}
//other code
function iNH3_UseInv(){
  if (player.ActiveInventory == iRobo){
  Display ("You basify 30mL of cough syrup with 30mL of ammonia.");
  MixChems(iNH3, iRobo, iSyr_Amm); //Call the function
 }
}  //etc. etc.

You'll find that creating functions like these should save you a lot of time

Hope that helps!
#115
Hmmm, it doesn't seem like that's possible...I've tried using both waypoints and the repeatedly_execute_always() function (a custom one you can call in the global script) which usually ignores blocking functions, but with zero success.

I guess a loophole would be to make a custom GUI screen which will display the message you want it to but without blocking the scripts...so copying your text onto a label and making the GUI visible. It takes a wee bit longer, but certainly do-able!
#116
Wouldn't it be possible to use a boolean value to check whether the player has already been told to walk left/right, which only needs to be changed when the mouse changes from left to right or the mouse is no longer held. That should stop the player from spazzing out when the mouse button is held... something like:
Code: AGS

//at the top
bool ToldToMove = false; //Checking Whether the player has been told to move
bool MovingRight = false; //Checking the direction the player is moving in 
//then:
function repeatedly_execute()
{  
    if (mouse.IsButtonDown(eMouseLeft)) 
    {    
        if (!player.Moving)    
        {      
            int x = mouse.x - (player.x - GetViewportX());      
            if (x >= 0)
            { 
                x = Room.Width; // mouse was clicked at or to the right of player, walk to the right.
                if(!MovingRight)
                {
                    MovingRight == true;
                    ToldToMove = false; //to reset the walkpath
                }
            }      
            else
            {
                x = 0; // mouse was clicked to left of player, walk to the left
                if(MovingRight)
                {
                    MovingRight == false;
                    ToldToMove = false; //to reset the walkpath
                }
            }      
            if(ToldToMove == false)
            {
                player.Walk(x, mouse.y, eNoBlock, eWalkableAreas);  
                ToldToMove = true;
            }  
        }  
    }  
    else if (player.Moving)
    {
         player.StopMoving();
         ToldToMove = false;
    }
}

    This is untested as I am away from home, but see if that works... You can of course replace the boolean MovingRight with a loop check but I cannot for the life of me remember which loop counts for what direction :P
    Obviously this code doesn't account for the y parameter, but I'm not sure if this code is fully functional yet...I'm sure it's implementanal.
    Hope that helps!
#117
For the walking issue:
Do you want the character to be able to move from the seated position? if not, you can use:

Code: AGS
RemoveWalkableArea(Walkable_Area_Number);


To stop him being able to move on the walkable area defined which should fix that problem. You can always use

Code: AGS
RestoreWalkableArea(Walkable_Area_Number);


To allow him to move again on that walkable area.

However, if you want him to switch back into his walking view when he is told to walk from the seated position, you're going to have to go into the global script. In GlobalScript.asc you should find the function "on_mouse_click", which does what it says on the label. Something along the lines of:

Code: AGS
function on_mouse_click(MouseButton button) {
  // Some stuff here about the game being paused
  else if (button == eMouseLeft) //this should already be there
  {
    if(Mouse.Mode == eModeWalkto && cEGO.View == 17){ //if the user clicks in walk mode and the view of the character is 17
      cEGO.UnlockView();
    }
  }
}


This will make him go back to his normal view once he is asked to walk. If you want to check whether the character is also in loop 0 and frame zero, simply put:

Code: AGS
if(Mouse.Mode == eModeWalkto && cEGO.View == 17 && cEGO.Loop == 0 && cEGO.Frame == 0)


instead of the earlier statement.

I don't know about your second problem, but I hope this solves the first one!
#118
This might be a long shot (I'm not in a condition to test this atm) but would it be possible to set the inventory item's inventory graphic (not curser graphic!) to blank and move it's index in the inventory window to the last position? The graphic can be restored once the item is no longer selected and, if necessary, restored to it's original inventory index.

I dunno if this helps, it's still a bit of a hassle...
#119
I dunno if this is helpful but if you want to be an artist (and maybe story writer) of an Indiana Jones style game (I never played the original :( ), you can always look into the Recruitment forums:

http://www.adventuregamestudio.co.uk/yabb/index.php?board=20.0

Maybe there will be some other people who want to work on a project like this who are more into the programming side!

Otherwise: what the others said: relax and slide into programming, it's lots of fun once you have a grip on it! :)
#120
Hey all! I searched this through the forums, but no-one seems to have this specific problem.

I'm fooling around with some RTS-ish style mechanics (purely for programming practice) and I noticed that solid characters seem to walk on top of each other. Every character is declared solid and has a blocking height and width of 50. However, when I ask them all to move to the same spot, they all hurry towards it and all move into that exact spot. Sometimes some will pause and then continue 1 by 1 as the first reaches it's destination. The nex time I ask them all to move somewhere else, they politely wait for one to go at a time, but nevertheless end up in the exact same spot as the others.

I dunno if it's possible for characters to merely get blocked by others, and stop there, or if they will invariably end up in the same place. It doesn't seem like a character.Moving check will work as they are under a move() command.

Any ideas?

Thanks!
SMF spam blocked by CleanTalk