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

#41
Yeah CW, I used objects because I can see exactly where they're gonna begin in the room, and quickly move them. But I'm gonna change them to characters right now. Do you know any way to trigger some code when ANY character reaches the bottom of the screen?
#42
Thanks a lot, Khris! But I've encountered a problem. When I try to run it, it says "undefined symbol: Math". Maybe I pasted that last bit on the wrong function? I pasted it on the room's "on_mouse_click".
#43
Yeah, you're right! I did do that after a while. But how do I trigger that with any object reaching the end of the room? Say, if I had 20 or 30 zombies...

And as for the 641, that was an error of my part (laugh) Luckily it wasn't game breaking.

EDIT: if it's easier, I can replace the objects with characters. As long as I can make a more general function so when any zombie reaches the bottom of the screen, I die.
#44
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);

}

#45
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.


#46
AGS Games in Production / Re: The Package
Mon 25/12/2017 13:51:37
When I finish my chase/combat systems, I'll post the scripts here, or send you a PM ;)
As for your background example, I think you should at least pixelate more the "real" background, otherwise, it just contrasts too much with the drawn part.

Or you can do as I did, and just paint over it:

Spoiler




[close]
#47
AGS Games in Production / Re: The Package
Sun 24/12/2017 21:59:46
I'm working on a combat system myself. With help. Like, A LOT of help (laugh) If I ever finish it, I'll gladly give you the code. What sort of combat do you have in mind?
As for the cars, I think the narrower the walkable area, the more difficult it is to turn in the corners. I think I'm just gonna use the mouse, but instead of clicking, just holding the button.
BTW, I don't know if I told you already, but your drawings are GREAT. Do you draw on top of a picture, or is it all imagination? Either way, it's amazing.
#48
Yeah Khris, your way is much neater, lol. But I still wanted to know the reason for the error, and now I too, thanks to you, too (laugh) Thank you!
BTW, and I don't mean to insist, just that I still don't know how notifications work on the forums. Did you get my last message about the shop system?

P.s: I don't know much of anything, but let me know if I can help you out somehow. You're helping me too much, and I'm starting to feel bad about it :-[ I can translate from English to Spanish, for example. Or help with a latin accent for voice acting :-D
#49
I can't for the life of me adapt the quantities to the player's inv. I tried for hours and the farthest I got is to duplicate the quantities label inside the shop (in the position where it should be on the inventory window), but that's it. :(
#50
Quote from: Cassiebsg on Sun 24/12/2017 08:30:36

Shooting(cTarget);

Shooting(cBadguy);

etc... ;)
But if I had 120 characters, I would have to do that 120 times... I managed to make it so the game knows what character is under the mouse. The problem is I can't make it into a function.
#51
AGS Games in Production / Re: The Package
Sun 24/12/2017 08:21:11
Actually I arrived at the same code, the only difference being that I use "Arethingsoverlapping". Do you use the mouse to move around? Because I find the arrow keys (at least how they're configured from default) to be too choppy, and often instead of turning in the street corner, i just collide against the buildings.

I'm guessing your fighting script is still a work in progress. Would be amazing if you posted it after you finish it.

Thanks for your replies, man. I'll keep an eye out for your game.
#52
Thank you, Khris, it worked. Yeah, I quoted the entire post by mistake, I thought I was editing. It was late into the night and I didn't notice (roll)
CW, you're right, I did it like you said. As I was just in a test room filled with a walkable area, I didn't notice the potential problem.

Edit:
So far I got this, and it works:

Code: ags
    
if (mouse.Mode==eModeAttack){
    Character* target = Character.GetAtScreenXY(mouse.x, mouse.y);
    cBullet.ChangeRoom(player.Room, player.x, player.y);
    cBullet.Move(GetViewportX() + mouse.x, GetViewportY() + mouse.y, eNoBlock, eAnywhere
    if (target!=null){
      target.Say("You killed me!");
      target.ChangeRoom(0);}
}


But then I decided I might want that to happen in other scripts, so I tried making a function called "shooting" at the top of the global script, looking like this:
Code: ags

function Shooting(Character* target){
  target = Character.GetAtScreenXY(mouse.x, mouse.y);
  cBullet.ChangeRoom(player.Room, player.x, player.y);
  cBullet.Move(GetViewportX() + mouse.x, GetViewportY() + mouse.y, eNoBlock, eAnywhere);
  if (target!=null){
    target.Say("You killed me!");
    target.ChangeRoom(0);}
}

No errors until then, but then, under the "on_mouse_click", I try to call it:
Code: ags

if (mouse.Mode==eModeAttack){
    Shooting(Character* target);
}


And it says this:
GlobalScript.asc(602): Error (line 602): static non-property access: internal error

I know I'm doing something wrong, but can't figure out what :P
#53
Quote from: Egmundo Huevoz on Fri 22/12/2017 12:07:56
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?

Edit: also, if I were to click on a character, how would I make it so the bullet goes to THAT character? I know it has something to do with "Character*" but I can't get it to work :(
#54
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?
#55
AGS Games in Production / Re: The Package
Fri 22/12/2017 10:01:35
This game looks really nice, I hope you release it soon!
Would it be too much to ask for the code of the combat system and/or car chase?
#56
I managed to do it! I feel less of a noob now. (laugh) Thanks, Khris! As I read somewhere else before, I don't know what the forums would do without you.

Code: ags
function on_mouse_click(MouseButton button){
if (button == eMouseLeftInv){
  InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  if (mouse.Mode==eModeLookat)
    inventory[game.inv_activated].RunInteraction(mouse.Mode);
  else if ((i != null) && (mouse.Mode==eModeInteract)
    player.ActiveInventory = i;
  else if (mouse.Mode==eModeUseinv)
    inventory[game.inv_activated].RunInteraction(mouse.Mode);
  }
}
#57
Quote from: Snarky on Tue 19/12/2017 11:46:20
When writing code that can apply to several different characters, the key is to use a character pointer (Character*) as a variable. A character pointer is a variable you can set to refer to ("point to") any character. E.g. like this:

Code: ags
#define CP_HITPOINTS "HitPoints"
#define ATTACK_MAX_DAMAGE 10

// Returns whether the character is still alive after the attack
bool attackCharacter(Character* targetChar)  // <--- HERE'S THE KEY BIT! "Character* targetChar" lets us pass any character to this function
{
  int hitPoints = targetChar.GetProperty(CP_HITPOINTS);  // We've added a custom "HitPoints" character property

  int damage = Random(ATTACK_MAX_DAMAGE);
  hitPoints -= damage;
  // If the damage brings hitPoints to 0.... 
  if(hitPoints <= 0)
  {
    // ... die!
    targetChar.SetProperty(CP_HITPOINTS, 0);
    playDeathAnimation(targetChar);  // Helper function to play the death animation
    return false;    // character is dead
  }
  // otherwise, just update the hitPoints
  targetChar.SetProperty(CP_HITPOINTS, hitPoints);
  return true;    // character remains alive
}


Now you can call this function on any character. For example if you want to attack a character when you click on them:

Code: ags
function cEnemy_Interact()
{
  attackCharacter(cEnemy);
}


Actually, if you can attack many characters, it's better to have a single function you link to all their interactions. It might look something like:

Code: ags
function character_InteractAttack()
{
  Character* clickedChar = Character.GetAtScreenXY(mouse.x, mouse.y);
  if(clickedChar != null)
  {
    bool alive = attackCharacter(clickedChar);
    // More stuff depending on whether they were killed or survived.
  }
}


Now you can link this function in all the relevant characters' interact events.
Thanks a lot! This looks great. I think with a few tests, I can make it work (laugh) (Still learning these kind of things). I'm gonna take a good look in a couple days, right now I'm studying for a final exam on thursday. I'll be back with more feedback once I test it.
#58
Quote from: Khris on Mon 11/12/2017 02:23:06

(I don't know other ways to tag you)

Bro, sorry to bother you, but as I was progressing with my game, I noticed something. I can't grab, nor look at items in my inventory. Could you help me? Also, it doesn't show inventory quantities in the inventory, as it does in the shop.
#59
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.
#60
Thanks a lot, @Crimson Wizard. I'm just gonna make that room again from scratch (a couple minutes, tops). Everything else seems to be working fine (laugh) Be well.
SMF spam blocked by CleanTalk