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 - Egmundo Huevoz

#1
Hi everyone! After a 3+ year abscence, I decided to come back and make yet another game! Glad to see the forums still alive.

I have a work in progress game in which I, with a loooooot of help (like 95%), managed to make a shop GUI to buy and sell items, which can get grouped by quantity. For example, 6 donuts, you click once, and buy 1 donut, so the shopkeeper has 5 and you have 1. That's working fine. The problem is, if I have 2 or more donuts, my inventory only shows one (I disabled "group inventory items"). Somebody (I think it was Khris) helped me to show the inventory item quantity in said GUI shop, but I couldn't translate the code to work in the regular inventory. And now I mostly forgot everything about everything, so I'm trying to reverse engineer things. But it seems I couldn't do it even at my best, according to the last answer I made in the original post.

The original post: https://www.adventuregamestudio.co.uk/forums/index.php?topic=55564.msg636577866#msg636577866

The part of the shop's code which (I think) displays item quantities:

Code: ags

void DrawQuantities(DrawingSurface* ds, InvWindow* iw) {
  InventoryItem* ii;
  Character* c;
  int i = iw.TopItem, iq, w, h;
  String s;
  for (int y = iw.Y; y < iw.Y + iw.Height; y += iw.ItemHeight) {
    for (int x = iw.X; x < iw.X + iw.Width; x += iw.ItemWidth) {
      ii = iw.ItemAtIndex[i];
      if (ii != null) {
        c = iw.CharacterToUse;
        if (c == null) c = player;
        iq = c.InventoryQuantity[ii.ID]; 
        if (iq > 1) {
          s = String.Format("x%d", iq);
          w = GetTextWidth(s, shopFont);
          h = GetTextHeight(s, shopFont, 1000);
          ds.DrawingColor = 0;
          ds.DrawString(x + iw.ItemWidth - w, y + iw.ItemHeight - h, shopOutlineFont, s);
          ds.DrawingColor = 31;
          ds.DrawString(x + iw.ItemWidth - w, y + iw.ItemHeight - h, shopFont, s);
        }
      }
      i++;
    }
  }
}



void ShowQuantities() {
  if (quantities == null) quantities = DynamicSprite.Create(gShop.Width, gShop.Height, true);
  DrawingSurface* ds = quantities.GetDrawingSurface();
  ds.Clear(COLOR_TRANSPARENT);
  btnShopQuantities.Height = 1;
  DrawQuantities(ds, invShopPlayer);
  DrawQuantities(ds, invShopMerchant);
  btnShopQuantities.Height = gShop.Height;
  ds.Release();
  btnShopQuantities.NormalGraphic = quantities.Graphic;
}



Any help in how to do this would be greatly appreciated!
#2
Hello, everyone. Continuing with my previous post about making an isometric game... I've got almost everything resolved. Instead of trying to explain how it works and what my problem is, here is a demo game:

Isometric test game

As you can see, the walls become transparent when the player is inside the building (I know there are some minor issues, but I can solve them in the near future). The thing is, that I want to click the hotspots behind those walls (like, for example, the outside chair behind the western wall). If I make the wall unclickable as well as transparent, my whole code goes through the toilet, because it needs the player to be colliding with the wall, so if I make the wall unclickable, no collision occurs, and then the wall just blinks from on to off indefinitely.

Tl;dr: I need to be able to click a hotspot behind a transparent object (wall) without making said object unclickable. Or make it unclickable, but without ruining the rest of the code. I've been a couple hours at it and I can't think of a solution.

Thanks in advance for any kind of help or insight.
#3
Hello, everyone! I've been thinking of making my game with an isometric view, like classic old RPGs like Diablo or Fallout. I have a couple questions:
1) Is this recommended? I've read every post about this in the forums, and I seem to recall somebody saying there could be trouble with baselines.
2) Is there any way to be able to see through an obstacle when the character is behind it? Like this:

Maybe make that south wall to be an object, but then... I don't know how would I approach it, and if it's even possible.
3) Is it possible to make a grid system with such a view? So I can move characters around this imaginary grid, etc. For example, Fallout used a hex system. I only want a square grid. Recently, I've made (with help) a grid system for a map room, but that's more straight forward, because it was just a plain aerial view, not isometric.

Thanks!
#4
Skip to the end for my code. Not really necessary to read it, and I don't expect anybody to, since it's long. But I post it just in case.

Hello, everybody. I'm making a maze-generator script, because I searched the forums, and even though there are a few posts about this, there isn't any that helps me (either because I couldn't understand java, or links are down, or some other reason). So I embarked myself on doing one. It's "simple": I use a single room, 4 objects as doors, with appear at random when the player enters/leaves the room. When you interact with the top door, you spawn at the bottom door (I make sure the opposite door always spawns; also at least 1 door). You can look at my script a little bit down, but first, my explanation. I tried to make a function that kept track of the previous room. So:
1) I made a struct with a couple bools (door_up, down, left and right), which turn true if the player interacts with the corresponding door.
2) I combined the struct with an array called Dungeon_room (for now, 100), and also made a global int called dungeon_room_number.
3) Made a bool inside the struct, called been_in_room, which turned true when the player left a room. So if been_in_room was false, I randomized the doors. Otherwise, the doors weren't randomized.
4) I was about to keep writing the script so I could return to the previous room. The doors' locations were being kept by the array (as I knew by some test labels I have), so I just had to make the connection. I probably can do that on my own. But then it hit me. I started imagining an already made maze, and the coming back to previous rooms, and I thought of this situation:



You leave room 1 through the top door, then you go to room 3, and 4, and then... If there happens to be a left door in room 4, and you take it, with my code, you'll just end up in a new room 5, instead of the previous room 1, as you should. I can't figure out HOW to make this happen.



Moreover, If one where to backtrack to room 2, and take a left, he would wound up in room 6, then going down to 7, and going right, instead of back to 1, you would go to room 8... So, I started worrying that maybe I can't solve this with my code. So instead of banging my head against the keyboard for 10 hours searching for a solution that might not exist, I'm posting this here.

In dungeon generator.ash:
Code: ags
struct Stats_dungeon_room{ //dungeon room's stats
  bool door_left;
  bool door_right;
  bool door_up;
  bool door_down;
  bool been_in_room;
};

import Stats_dungeon_room Dungeon_room[100];


In dungeon generator.asc:
Code: ags
Stats_dungeon_room Dungeon_room [100];
export Dungeon_room;


In the dungeon room's script (number 66):
Code: ags

function Spawn (this Object*){ //decides whether or not the door will be visible
  door_spawn=Random(1);
  if (door_spawn==1){
    this.Visible=true;
  }
  else{
    this.Visible=false;
  }
}

function door_randomize(){ //generates 1-4 doors.
  oDown.Spawn();
  oLeft.Spawn();
  oRight.Spawn();
  oUp.Spawn();
  if ((oDown.Visible==false)&&(oUp.Visible==false)&&(oRight.Visible==false)&&(oLeft.Visible==false)){
    door_randomize(); //in case no doors spawn, the function runs again, generatin 1-4 doors.
  }
}

//GRAPHICS

function TopBaseline(this Object*){
  this.Baseline=Game.SpriteHeight[this.Graphic];
}

function door_baselines(){ //guarantees you won't be drawn behind a door
 oDown.TopBaseline();
 oRight.TopBaseline();
 oLeft.TopBaseline();
 oUp.TopBaseline();
}


function walk_to_object(this Object*){ //ensures the player walks to the MIDDLE of the door (instead of it's XY corner)

  if ((this==oLeft)||(this==oRight)){
    door_middle=(this.Y-(Game.SpriteHeight[this.Graphic]/3));
    player.Walk(this.X, door_middle, eBlock);    
  }
  if ((this==oDown)||(this==oUp)){
    door_middle=(this.X+(Game.SpriteWidth[this.Graphic]/2));
    player.Walk(door_middle, this.Y, eBlock);
  }
}

function ChangeroomDoor(this Object*){
  if ((this==oLeft)||(this==oRight)){
    door_middle=(this.Y-(Game.SpriteHeight[this.Graphic]/2));
    player.ChangeRoom(66, this.X, door_middle);
  }
  if ((this==oDown)||(this==oUp)){
    door_middle=(this.X+(Game.SpriteWidth[this.Graphic]/2));
    player.ChangeRoom(66, door_middle, this.Y);
  }
}

function door_create_opposite(){ //guarantees the opposing door will be created (e.g if you entered throught the right door, there will be a left door in the next room
  if (door_entered_left==true){
    oRight.Visible=true;
  }
  if (door_entered_right==true){
    oLeft.Visible=true;
  }
  if (door_entered_down==true){
    oUp.Visible=true;
  }
  if (door_entered_up==true){
    oDown.Visible=true;
  }
}



function Enter(this Object*, Object *opposite_door, String opposite_door_string){
  this.walk_to_object();
  
  opposite_door.ChangeroomDoor();
  
  door_entered_right=false;
  door_entered_left=false;
  door_entered_up=false;
  door_entered_down=false;
  if (opposite_door_string=="left"){
    door_entered_left=true;
  }
  if (opposite_door_string=="right"){
    door_entered_right=true;
  }
  if (opposite_door_string=="up"){
    door_entered_up=true;
  }
  if (opposite_door_string=="down"){
    door_entered_down=true;
  }

}



//SETTING IT UP AND INTERACTIONS



function oRight_AnyClick()
{
 oRight.Enter(oLeft, "right"); 
}

function oLeft_AnyClick()
{
 oLeft.Enter(oRight, "left"); 
}

function oUp_AnyClick()
{
 oUp.Enter(oDown, "up"); 
}

function oDown_AnyClick()
{
 oDown.Enter(oUp, "down"); 
}


function room_Load()
{

  door_baselines();
  door_create_opposite();
  player.SetWalkSpeed(30, 30);
  mouse.Mode=eModeInteract; 
  
  if (Dungeon_room[dungeon_room_number].been_in_room==false){
    door_randomize();
  }
  
  if (Dungeon_room[dungeon_room_number].been_in_room==true){
  dungeon_room_number--;
  }
  
}

function room_Leave()
{

Dungeon_room[dungeon_room_number].door_down=oDown.Visible;  /*AKA current room*/
Dungeon_room[dungeon_room_number].door_up=oUp.Visible;
Dungeon_room[dungeon_room_number].door_left=oLeft.Visible;
Dungeon_room[dungeon_room_number].door_right=oRight.Visible;
Dungeon_room[dungeon_room_number].been_in_room=true;


dungeon_room_number++; //going to the next room, so room 1 turns room 2, etc.
}

function room_FirstLoad()
{
dungeon_room_number=1;
}



#5
Hello, everyone. I'm trying to make an extender function to place my characters randomly in any given room, and later call it from on_event. If all my rooms where the game resolution, it wouldn't be a problem. But I want this to work with my many scrolling rooms, so i figured I would use the Room.Width and Height commands. The thing is, I don't know how to convert an int (Character.Room) to a "Room*" (so I can use Room.Width/Height). Maybe there's even a better way to approach this, but I can't figure this out.

Code: ags
function PlaceRandomly(this Character*){
  Room* room_number = this.Room; // <--- This is my problem: Type mismatch: cannot convert 'int' to 'Room*'
  this.x=Random(room_number.Width);
  this.y=Random(room_number.Height);
  this.PlaceOnWalkableArea();
}
#6
Hello, i'm making a map with a grid system. In each of the grids, different things happen. I track the grid the player is in with the int "grid_current". The thing is, I can't figure out how to make the grid_current change according to the player's coordinates. I mean, I do, but manually. And I don't want to have to write 250 of those, I'm sure there's an easier way.

grid_width is another int which tracks the, well... grid's width (laugh) I have another one for grid_height, but right now I'm making the 1st row of grids. I'm sure I can extrapolate from the width.

My code so far is this:
Code: ags
  
if ((player.x>=grid_width*1-1)&&(player.x<=grid_width*1)){ //the player is in grid 1. his X coordinate is bigger than the left side of the grid, and smaller than the right side of the grid.
    grid_current=1;
  }
else if ((player.x>=grid_width*(2-1))&&(player.x<=grid_width*2)){
    grid_current=2;
  }
else if ((player.x>=grid_width*(3-1))&&(player.x<=grid_width*3)){
    grid_current=3;
  }


I call the function in room_repexec. It works, but as I said, I'm sure there's a way to make it automatic.

Thanks in advance.
#7
I've tried calling it from on_event (i'm using this function correctly, as it does other things for me) and it didn't work. Then I tried with a specific room_load function within the room, didn't work either. I even tried with "room after fade in".
After testing a while, it worked. Then it stopped working again, and I didn't even change anything. Now it only works in certain rooms and not in others (roll). Not even a new room, which shouldn't have any conflicting code. ???
It doesn't place him on a walkable area, not with the F6 debug function, not with a custom key made by me, not with anything. :/
#8
I'm making a map room, which is pretty big, and therefore scrolling.
I have this line of code, which I use to get what hotspot the character is currently standing, and then do something else with this information.
Code: ags
Hotspot *player_hotspot = Hotspot.GetAtScreenXY(player.x,player.y);

But it doesn't work properly; the hotspots are circles and the game only knows the player is standing in a hotspot in certain areas of this circle, but not in most of it (I know this because I have a label showing me a variable that changes whether or not the player is standing in a hotspot). I know it's the scrolling room's fault because I imported the room code into another room, put a smaller background so the room isn't a scrolling room, and it works perfectly. I've tried with GetViewport, but that only makes matters worse.

Any insight will be greatly appreciated.
#9
Hello all. I'm making a "map" room, in which the locations are represented by hotspots. I want it to work in a way so that when the character is standing on the location/hotspot AND he clicks it with the interact cursor, then it changes the room. I know how to do either of those separately, but I can't figure out how to do both of them at the same time.
I need this to work like this because the character can just skip the location by walking over it, so just entering the room by standing on the hotspot is not an option. Also, only interacting with it it's not an option either, because when I interact with a hotspot, the character walks toward it while blocking the other scripts (which I need for monster spawning, yadda yadda).

Any other alternatives to my theoretical method are also welcome!

Thanks in advance! :-D
#10
Hi! I've scoured the forums for an answer, but there aren't any satisfactory ones. I'm currently using a TTF font, but I would settle for any type of font, really, as long as it's readable. Right now it's not unreadable, but it could cause problems. Thanks in advance.
#11
Hello! I'm having trouble with a "reloading bullets" script that I made. Some info before we start:
-I call this function from "on_key_press", by pressing R.
-I track the bullets with a GUI that has a button (btnAmmo), which has a picture 120 pixels wide, with 6 bullets with 20 px wide each. That works perfectly.
-I have another function for shooting, which also works perfectly, and deducts 1 from the global var "Bullets", which tracks my remaining bullets outside of the gun. The shooting function also deducts 20px from btnAmmo. If the button is 0 px wide, then the gun is empty.

The problem is with a function that manages reloading bullets into the gun. The max amount of bullets is 6, tracked by the global var "Maxammo" (I plan to make other guns with more bullets, but for now, it's always 6). I track the missing bullets from the magazine with the global var Empty_ammo (ie, if you shot 4 bullets, Empty_ammo should be =2). It works, but with a "delay", so to speak. I shoot some bullets, let's say 3, for this example, and I reload. My maganize refills (as shown by the GUI), but my remaining bullet count doesn't change (as shown by another GUI). When I reload again, no matter if I shot 1, 6 bullets, or anything inbetween, I lose 3 bullets (the amount I reloaded previously). And so on, it seems like the reloading is out of synch.

Any help will be deeply appreciated. I tried for hours to fix this, but I can't do it on my own.

Code: ags
// new module script
function Reload_gun(){ //important: every bullet is 20 px wide in the GUI, which is the origin of the 20's seen below.

Empty_ammo=Maxammo-(btnAmmo.Width/20); //global var representing bullets missing from the magazine, i.e fired bullets

  if ((btnAmmo.Width!=Maxammo*20)&&(Bullets>0)){ //don't do anything if magazine is full or you don't have bullets
    if (Empty_ammo>Bullets){
      btnAmmo.Width=btnAmmo.Width+Bullets*20;
      Bullets=0;
    }
    else{ //we have enough bullets to fill the magazine no matter what
      Bullets-=Empty_ammo; //lose the amount of bullets missing (1-6)
      btnAmmo.Width=btnAmmo.Width+Empty_ammo*20; //ammo = ammo left + ammo missing
      Empty_ammo=0;
      if (btnAmmo.Width>Maxammo*20){ //so you can't have more bullets than the size of your magazine
        btnAmmo.Width=Maxammo*20; 
      }
    }
    aReloadgun.Play();
  }
  else {
    aEmptygun.Play();
  }
}
#12
Hello! It's me again, lol. I wonder how many posts I can make before I start irritating people (laugh)
I'll cut to the chase: I'm programming a room in which 3 zombies (objects) walk towards the bottom of the screen. When they reach that, if you haven't killed them, you lose. My question is HOW to know when the object has reached that part of the room. I've tried regions and hotspots, to no avail.

The other thing is that right now I have 3 zombies, but I might add some more later on. And I'm sure the code can be optimized so I don't have to write so much. This is the code:
Code: ags
// room script file


function ZShoot(this Object*) {
//if you have bullets, and you hit your target:
if (btnAmmo.Width!=0){
  btnAmmo.Width-=20;
  Score++;
  String Scoretxt = String.Format("Score: %d", Score);
  lblScoreAmmo.Text=Scoretxt;
  aGunshot.Play();
  aZombie.PlayQueued();
  ZHP[this.ID]--; //zombie hit points
  }
//if your magazine is empty
else{
  aEmptygun.Play();}
}

function on_mouse_click(MouseButton button){
if (IsGamePaused() == 1) {
  // Game is paused, so do nothing (ie. don't allow mouse click)
  }
else if (button == eMouseLeft){
  if (mouse.Mode == eModeAttack) { //custom mode I made to shoot things
    Object* o = Object.GetAtScreenXY(mouse.x, mouse.y);
    if (o != null) o.ZShoot();
  }
}
}

function room_RepExec()
{
  
//zombie death
if (ZHP[0]==0)
  oZ0.Visible=false;
if (ZHP[1]==0)
  oZ1.Visible=false;
if (ZHP[2]==0)
  oZ2.Visible=false;
  
//zombie movement
if (!oZ0.Moving){
  oZ0.Move(Random(641), oZ0.Y+100, Velocidad);
}
if (!oZ1.Moving){
  oZ1.Move(Random(641), oZ1.Y+100, Velocidad);
}
if (!oZ2.Moving){
  oZ2.Move(Random(641), oZ2.Y+100, Velocidad);
}

//highlight reticule over target

if (GetLocationType(mouse.x,mouse.y) == eLocationObject){
  mouse.ChangeModeGraphic(eModeAttack, 202);}

else{
  mouse.ChangeModeGraphic(eModeAttack, 197);
}

}


function room_Load()
{
//definition of variables

Score=0;
Reloads=5; //how many maganizes you have
//Objetivo=5; //ignore this
Velocidad=1; //zombie movement speed

//some other useful stuff
player.Clickable=0;
player.Transparency=100;
mouse.Mode=eModeAttack;
mouse.ChangeModeGraphic(eModeAttack, 197);
mouse.ChangeModeHotspot(eModeAttack, 20, 21);
gAmmo.Visible=true;
gScoreAmmo.Visible=true;
String Objetivotxt = String.Format("Objetivo: %d", Objetivo);
lblObjetivoammo.Text=Objetivotxt;
String Reloadtxt = String.Format("Cartuchos restantes: %d", Reloads);
lblAmmoReloads.Text=Reloadtxt;
  
  
//zombies hp, view and animation.
ZHP[0]=1;
ZHP[1]=1;
ZHP[2]=1;
oZ0.SetView(89);
oZ1.SetView(89);
oZ2.SetView(89);
oZ0.Animate(0, 3, eRepeat, eNoBlock);
oZ1.Animate(0, 3, eRepeat, eNoBlock);
oZ2.Animate(0, 3, eRepeat, eNoBlock);

}

#13
Hello! In the game I'm making, I have a room where the character has to shoot (click) the center of a moving target that looks like this:

The thing is, I want it to only be a valid shot when they click the center (the yellow circle). So I figured I'd use 2 objects, like this:



(Blanco1)



(Blanco2)

It looks like this in the room:



The 2nd object is set as unclickable in the room script. Then I plan to make them move randomly in a walkable area.

Code: ags
function room_RepExec()
{
if (!oBlanco.Moving) {
  int walkx = Random (401);
  int walky =  Random (641);
  if (GetWalkableAreaAt (walkx, walky) == 1)
    oBlanco.Move (walkx, walky, 1);
    oBlanco2.Move (walkx, walky, 1);
}
}


It works. But the smaller target (Blanco1) moves elsewhere for some reason, before coordinating its movement with Blanco2.

HERE'S A VIDEO OF IT

Spoiler
[close]

I've read the whole Object section in the manual, I've tried to adjust the first object by adding and substracting the difference in pixels with the 2nd object... All to no avail. Thanks in advance for any help provided.


#14
Hi! I made a new mouse mode with which I want my character to shoot other characters. My idea was to summon a character (cBullet) and check whether or not it was colliding with the command AreThingsOverlapping. It worked as I intended, except for one thing. On the "on_mouse_click" part of the global script, I put this:
Code: ags
    
if (mouse.Mode==eModeAttack){
    cBullet.ChangeRoom(cNacho.Room, cNacho.x, cNacho.y-50); //it spawns where it should
    cBullet.WalkStraight(mouse.x, mouse.y);} //Here's the problem, apparently

Although I THINK it should walk straight from cNacho to my cursor, it doesn't. It walks like 300 pixels above or below the cursor, like the cursor was in a totally different place. Any ideas?
#15
Hi, I've been absent from the AGS world for several years now. I'm currently checking some of my old projects, and one of them had a pretty nice dialog-based battle system. The problem is, I don't know how to change the target. Khris helped me with a shop system which could be used by any character, and I'm trying to reverse-engineer it from there, but to no avail. This was before I knew about arrays or structs (tbh, I'm not an expert about them now), so the code is as messy as it can get. Any help or pointing in the right direction will be greatly appreciated. Thanks in advance.
#16
Hello! I've made a game a few years back, using AGS 3.2. Now, when I try to open it with 3.4, I get a load of errors, which I don't even know what they mean. I don't know where to start "fixing" the game so I can edit it (and build on top of it) on 3.4.

This is the error screen:


"La cadena de entrada no tiene el formato correcto" is spanish, and it means something like "the entry chain doesn't have the right formatting".
"en" means "in".
#17
Hello! As my title says, I'm trying to make a shop for my game. I've been trying by using a list box inside a GUI. My problem is that when I use the "removeitem" function, the numbers of the rest of the items change, rendering the rest of my code, useless. Also, I'm trying to figure out how to be able to sell and item. I.e. have the desired item disappear from my inventory and show up on the merchant's list box. Is there any module for this already done, or can somebody help me? Thanks in advance...
SMF spam blocked by CleanTalk