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 - miguel

#1281
Code: AGS
if (!stbandit[i].Char.Moving) stbandit[i].Char.Walk(...);


I should have known this bit by now. Crimson advice was the same when he told me about checking if a character was animating and so on.
Enemies not following the player is not really a problem as long as they meet him and collide. The problem I'm facing now is that when the fight occurs it gets engaged super fast. I tried to counter this with a function that "pushed" character away a few pixels if they are hit:

Code: AGS
function bpushed() {
  int i=closestenemy;
  stbandit[i].Char.FollowCharacter(null);
  if (stbandit[i].name=="Bandit") {
  if (stbandit[i].Char.x > stHero.Char.x) {
    if (!stbandit[i].Char.Moving) {
    stbandit[i].Char.Move(stbandit[i].Char.x + 8, stbandit[i].Char.y, eNoBlock, eWalkableAreas);  
    AudioChannel* bhurt = abandit_hurt.Play();
    }
  }
  if (stbandit[i].Char.x < stHero.Char.x) {
    if (!stbandit[i].Char.Moving) {
    stbandit[i].Char.Move(stbandit[i].Char.x + 8, stbandit[i].Char.y, eNoBlock, eWalkableAreas);  
    AudioChannel* bhurt = abandit_hurt.Play();
    }
  }
  }
  if (stbandit[i].name=="Rat") {
    if (stbandit[i].Char.x > stHero.Char.x) {
    if (!stbandit[i].Char.Moving) {
    stbandit[i].Char.Move(stbandit[i].Char.x + 8, stbandit[i].Char.y, eNoBlock, eWalkableAreas);  
    AudioChannel* rpain = arat_pain.Play();
    }
  }
  if (stbandit[i].Char.x < stHero.Char.x) {
    if (!stbandit[i].Char.Moving) {
    stbandit[i].Char.Move(stbandit[i].Char.x + 8, stbandit[i].Char.y, eNoBlock, eWalkableAreas);  
    AudioChannel* rpain = arat_pain.Play();
    }
  }
  }
  mood=death;
}


My goal was to prevent characters from always colliding and it worked fine (not 100%) when I was using followcharacter; now the fights run super fast even if the "push" functions are being called.
Is the answer adding more checks to slow things down?
#1282
Yes kconan, I do hope that dictators understand that with internet/smartphones the world can see human rights violations in real time.
But that's one thing. The civilized World will condemn and maybe even send troops to take out the regime but they can't stay there forever as the population will claim the territory again and eventually consider their saviours as the oppressive regime.
Democracy is something as natural to us as going to the supermarket and find stuff that we can buy. But for those countries, democracy has to be learned and that takes generations and culture changes most of the time. Many countries still have clans and leaders as region rulers, while we have mayors and don't carry AK47's around in a 4x4 van...

Armageddon: it's not the US fault that capitalism fails from time to time. In 2008 everybody had their fingers in the honey pot, the clever ones took them away before the pot blew.
#1283
Back again!

I decided to change the behaviour of my enemies when chasing the player. I was using follow character before.
After the change, enemies "walk" without leaving the spot.
Here is the code, you can see where I changed:

Code: AGS
function enemydetection() {
  int closestEnemy = -1;
  int maxRange = 700;
  int xDiff; int yDiff; int enemyDistance;
  int i=1;
  while (i< 7) {
  xDiff = stHero.Char.x - stbandit[i].Char.x;
  yDiff = stHero.Char.y - stbandit[i].Char.y;
  enemyDistance = xDiff*xDiff + yDiff*yDiff;
  if (enemyDistance < maxRange) {
    if (stbandit[i].health > 0) {
      mood=ataking;
//    stbandit[i].Char.FollowCharacter(stHero.Char, 0, 0);
    stbandit[i].Char.Walk(stHero.Char.x, stHero.Char.y, eNoBlock, eWalkableAreas);
    closestenemy=i;
//    return;
    }
  }
  else if (enemyDistance > maxRange) {
    mood=free;
    closestenemy=0;
//    stbandit[i].Char.FollowCharacter(null);
    stbandit[i].Char.StopMoving();
  }
i++;
  }
}


mood set to attacking runs a collision function, and set to free runs the function above;
#1284
Quotethe increased transparency of whats going in other countries, which can help topple dictator(s)
I'm afraid that we don't have a clue of what is really happening on the "Arabian Spring" countries. It looks to me that they are replacing dictators for...dictators?

Quotebecause contrary to popular opinion, everything gets better everywhere, even in extremely underdeveloped countries
I think so, humans everywhere struggle to get better. Although, I believe that most 3rd world countries will not have the "chance" to become developed. In 100 years we'll see African nations disappear under bigger neighbour countries. Some African nations exist solely for their resources and black market weapon trade. Once a democracy is set up on those countries, they will have to deal with half of the population being related to crime and corruption - making new politicians tied to strong characters in order to win elections. It takes generations to lower corruption levels IF they ever accomplish it.

Then there's overpopulation, of course. There's simply no way Europe can maintain their "open borders" policy. This sounds right-wing I know, but I've seen the damage done to Portugal in the past 10 years. Today, not even half of foreign people are still in the country. And we're left with social security debts to our necks, low pay checks related to foreign work and thousands of blond, blue-eyed children who don't have a clue of what Portugal or being Portuguese is.
This said, if I can still name the US as a free country for all, even with their border policy, then I hope you understand that I can talk about a European border policy without being called fascist.
#1285
QuoteUnfortunately, the future depends upon USA too much.

And China, India, Russia, Middle East, EU,...everybody will constantly "battle" for market dominance and resource monopoly.

EDIT: What Calin said
#1286
In 100 years time we will have major political changes in the world.
There's no room for small countries and their independence as their dept are never to be paid.
Territory occupation (non-military in Europe, I believe) will happen again. This doesn't have to be dramatic (WWII) and cultural absorption would likely start with economical regional federations.
I think that in the next 50 years we'll see southern European countries (Portugal,Spain,Italy and Greece) forging a political and economic space. The same will happen with countries that were former soviet regions.
And yes, capitalism will eventually collapse again, and again, and again. Enforcing rules to keep markets from collapsing may delay future crisis but not for long.
Again, this doesn't have to be bad, people will adapt. At least the ones living in the safe zone.
#1287
Yeah, and the main character is OSD...With Jena Jameson! That would spice up sales!
#1288
I now declare that I'll only buy the second bake sale IF Icey does the thing is talking about!
#1289
Completed Game Announcements / Re: Patchwork
Sat 19/01/2013 22:31:15
Playing it right now. Fantastic art from a great artist. Everything else is looking and feeling very professional.
Congratulations Ilyich!
#1290
Thanks, now I understand it.
It turns out I did the mistake of using return where it should not be used, a old and bad habit of wrapping things up with return...
This "lessons" were most helpful to me.
#1291
Okay, I understand that,
but when a function is inside a if?
#1292
Quoteif you're talking about calling several functions in rep_exe
- yes that's what I meant.
About the speed, I wonder if anybody can back this behaviour with similar experiences.

But, you're saying that in a big if with several if's, when return (with no return value, thanks for the tutorial :smiley:) is called, it exits the if condition but stays on the one where it was first included?
Like (not real code):

Code: AGS
if (a > b) {
  if (b==3) {...code
    if (d==b) {...code...; return;
    }
  }
  if (b==4) {...code
  }
}


When return is called the code goes back to if (b==3) {...code?
-------------------------------------------------------------------------------

Crimson, I was about to post this when I noticed your post, this is becoming interesting!
#1293
Khris, I wouldn't dare defy your expertise, it's obvious that I now very little of this. I did think I got it working doing it the way I did.
Consequentially my error reminded Crimson of that "speed" enhancement.

Anyway, you do agree that breaking the code into functions allows to organize things better, no? I understand that rep_exe is a chain of events that continuously loop and splitting code into functions and then call them back into the loop is the same thing. But, "my method" should make things slower, right?

Question here: if everything runs inside the loop and all is coded in rep_exe, calling return to stop a function would also break the chain? If done on functions outside rep_exe, it would go back to the following chain function? Would the outcome be exactly the same?
 
I'm learning here, and more questions come up with every change I make to the code.
#1294
QuoteIs this something that you see in practice?
Yes, at least to my limited knowledge. Splitting the code into small but objective functions allowed me to run all the stuff happening without the player being blocked. It was my main goal when I started this little exercise. A big rep_execute with dozens of if's would have made me quit half way. Well, if you didn't explain me the ropes I would have quit either way.
I believe that I can brake it even more and will do it.
And of course none of my functions include any complex algorithms, they are but simple while loops and such.
This is what my rep_exe_alws looks like: 

Code: AGS
function repeatedly_execute_always() 
{
  if (gamestart==true) {
  if (mood==free) {
    Label11.Text="free";
    enemydetection();
  }
  if (mood==ataking) {
    Label11.Text="atacking";
    colision1();
  }
  if (mood==fighting) {
    Label11.Text="fighting";
    combat();
  }
  if (mood==taking) {
    badtakedamage();
  }
  if (mood==giving) {
    herotakedamage();
  }
  if (mood==heropushed) {
    hpushed();
  }
  if (mood==banditpushed) {
    bpushed();
  }
erasebadguys();
showinterface();
checkdeath();
kill();
  }
}


There's still room for more function simplification.
All this time I thought that this was the correct way to do it, but
QuoteI would not say anything like that for any programming language
made me realize how specific AGS scripting is.
#1295
Yup, comments would be a gift from the gods!
Enemy AI is the next step on my list.

Anyway, is it safe to say that (in Rep_Execute) the more I split the code into small chunks the better it runs?

#1296
Crimson, I've just finished examining your works and I find it inspiring...in a Dwarf Fortress sense.
It's really too much information at one go and I'll be going there from now on for sure. It's great to actually look at the stuff I read from you, monkey, khris and the rest. I admire you guys. And thank you for your patience.

P.S: my little dungeon runs fine, not as smooth as your demo (impressive) and I've been adding enemies and chests, keys and doors...It feels nice.
#1297
Yes, locking the view was a bad mistake due to being doing it for years!
But mouse click is fine to change the view back to the walking cycles. Using changeview after the non-blocking animation would cut it short, no?

Thanks for the files, I'm sure it's a great way to study ags coding.
#1298
Okay, I defined states for every little bit of what's happening in the game and yes, I've got it running towards what I had in mind.
My issue here is where do I unlockview of the characters after animating? Unlocking it is making the game freeze.

Edit: I'm using on_mouse_click to unlock views now, it's working. Is this the best approach? The only one?
#1299
Got it, I'll dive into it right now.
#1300
You are right about the topic title being misleading.
I understand what you're saying. Should I use global variables to set bool states and Rep_Execute to keep checking it?
A "iniciative" function could do the check, like after the non-blocking animation finishes it checks again for who has the iniciative?

Downloaded your demo, would be great to have the code.

SMF spam blocked by CleanTalk