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 - Crimson Wizard

#13401
Can be this because of space in "Haydutlar 4" folder name?
#13402
Quote from: Monsieur OUXX
Oh yes, I didn't notice the "ProcessClick".
That's definitely the reason.
I think reason is not "ProcessClick" but "on_mouse_click(event);" call (couple of lines above).

But not only that, I fear this sort of algorythm can cause unlimited recursion: if player will continiously click mouse it will go like

on_mouse_click->movingToXY->on_mouse_click->movingToXY-> etc etc

which may finally lead to stack overflow, or something.
You need better algorythm.
#13403
Quote from: AndFisher on Sun 20/06/2010 23:29:16

The problem is, if my customs function is defined above the on mouse click function I get an undefined token error when I try to compile
Please, post related part of your code here. It would be nearly impossible to guess what's wrong there without actual code. It can be a mistake in your code, a simple typo, etc.

Quote
I have programmed in other OO languages before, and it seems alien to me that a function must be defined before it is referenced anywhere else in the script. Of course it should be defined before a call to it is executed however. Unless I have totally missed something
Yes, in AGS script the called function body should be defined before it's called first.
#13404
Hmm, I want to make this clear once again: do you need TAB be pressed all the time for mouse cursor to be limited to certain area, or do you need it be pressed once to set this behavior on, and then later another time to set it off?
I ask again, because your boolean value is called "pressingTAB", which sounds like it meant be pressed continiously.

Anyway, regarding the code and assuming TAB toggles the mode on/off.

First of all, you are making classic mistake there, by not using wonderful NOT operator :)

Here how it should look like:
Code: ags

function on_key_press(eKeyCode keycode){

  if (keycode == eKeyTab) pressingTAB = !pressingTAB;

}


This will simply "invert" boolean variable to opposite value.

Your second mistake is that you set mouse bounds every tick in rep_exec. You shouldn't do it. Instead, put that in the key_press as well, like:
Code: ags

function on_key_press(eKeyCode keycode){

  if (keycode == eKeyTab) pressingTAB = !pressingTAB;
  if (pressingTAB) {
      //Cursor fixed to viewscreen
      mouse.SetBounds(208, 130, 588, 355);
        }
  else
    mouse.SetBounds(0, 0, 0, 0);
  }

}


What should be left in rep_exec is perhaps this:
Code: ags

if (pressingTAB) {
      //Mouse Steer
      if (mouse.x <= 221) cEgo.x = cEgo.x - 6;
      if (mouse.x >= 575) cEgo.x = cEgo.x + 6;
      if (mouse.y <= 143) cEgo.y = cEgo.y - 6;
      if (mouse.y >= 342) cEgo.y = cEgo.y + 6;
        }
  }


Now... I honestly can't see what can not work here. If it still doesn't work as expected, maybe you can give more details about what happens?
#13405
Before even checking your code posted above, I want to ask, why do you use "IsKeyPressed" function at all if TAB toggles some mode on and off? For such behavior it is much better to catch key presses in on_key_press function.

EDIT: As for the code - yes, I can see mistakes there, but first I'll wait for your answer, because it may appear that this code is not needed at all :)
#13406
I remember playing NetWars when I was at school.

No, it's definitely not the one you seek.  ;D
#13407
Quote from: SteveMcCrea on Sun 20/06/2010 16:56:33
Interesting...
I'm not sure how useful the UInt32 functions are since you can't work with them in AGS.
Yeah, that's true. I guess it was rather formal addition (same as various "skip" functions that skip same number of bytes, but may be used to simply help user distinguish which sorts of data he skips).


Quote from: SteveMcCrea on Sun 20/06/2010 16:56:33
I would recommend having a global function to set the endianness, rather than having to pass an extra parameter in each function. You could have a separate reading endianness and writing endianness. Or perhaps you could set the endianness on each FILE - that would probably slow things down too much though, looking up the endianness inside each read/write function.
I am not sure it is wise to use global endianness setting here, because there's no guarantee that end-user will not open 2 or more files at a time, one of which would need little-endian reading order and another big-endian one. I know that the chance this will happen is quite low, but it is still possible.
It is also impossible to set endianess for FILE (unfortunately), at least with current implementation, since these functions are extender methods of internal File class. To do so I would need a custom struct, which would store File reference, endiannes setting and whatnot else. Will this be better way to implement this? I am not sure atm.

Anyway, you only need to pass this parameter explicitly if you need big endian order, becuase little endian is passed as a default value.



EDIT:  Regarding speed. These functions are obviously slower than common File.Read/WriteInt ones. But you will start to feel the difference when amount of data is really large.
I tested writing 1 million of 4 byte integers in the file. When using File.WriteInt it takes roughly 2 seconds, with File.WriteInt32 it takes 9 seconds.
Writing 100.000 integers takes <1 and about 1.5 sec correspondingly.
Writing 10.000 integers takes imperceptible amount of time in both cases.
#13408
Quote from: Monsieur OUXX on Sun 20/06/2010 13:29:33
That'll come handy for me. I started writing similar stuff, but didn't have time to polish the result, while working on everything else.
Why, it's good to know someone will need this :) make sure to report any bugs!
#13409
This module adds a number of extender functions to AGS File class, allowing to read and write "precisely sized" integer values from/to the file (naturally).

For scripting weirdos only.

List of functions in the Version 1.0:

ReadInt8
ReadUInt8
ReadInt16
ReadUInt16
ReadInt32
ReadUInt32

SkipBytes
SkipInt8
SkipUInt8
SkipInt16
SkipUInt16
SkipInt32
SkipUInt32

WriteInt8
WriteUInt8
WriteInt16
WriteUInt16
WriteInt32
WriteUInt32


Supports both Little Endian and Big Endian byte order.

Requires AGS 3.0+

Download
Download mirror
#13410
Critics' Lounge / Re: ignore this
Sun 20/06/2010 08:53:54
Quote from: TerranRich on Sun 20/06/2010 07:02:32
I did a paintover. Here is my interpretation:
Looks more like an Uzi now  :-\
#13411
Monkey, I was actually trying to understand internal module algorythms, and found them way too complex. I can be wrong, ofcourse, or missing something; but I usually prefer most simple way to do things (which are not always perfectly safe, perhaps), and your code there makes me shudder :). I have already tested this Stack in my "Shooting Gallery" tech demo, and so far it never slowed it down, even though game required reading/writing Stack elements every single tick. So, it's not that module works slow. It's just that I don't understand why it should be so complex.

My main doubt is related to the method of spawning a dynamic array and populating it with elements from Data String every time Stack needs to read or write an element. Couldn't you just find a corresponding substring from the Data String directly and use it?
I tried to write my own "vector" module with "lighter" implementation (as mentioned above), and it seem to work nicely... what do I miss? if anything?

PS. BTW, I wrote 2 "classes" for user-friendly reading and writing of custom structs from/into String. I wonder, if you can find it a possibly useful contribution to your module?
#13412
Here's my little contribution. Discuss?
Code: ags

// String.IndexOfInstance extender function
// Seeks for Nth instance of given substring sample in the string, starting from the given character

int IndexOfInstance(this String*, String needle, int instance, int from)
{
  int i = from;
  int char_match;
  int instance_found;
  int found_from = -1;
  
  while (i < this.Length)
  {
    if (this.Chars[i] == needle.Chars[char_match])
    {
      if (found_from == -1) found_from = i;
      char_match++;
      if (char_match == needle.Length)
      {
        if (instance_found == instance)
        {
          return found_from;
        }
        
        instance_found++;        
        char_match = 0;
        found_from = -1;
      }
    }
    else
    {
      char_match = 0;
      found_from = -1;
    }
    
    i++;
  }
  
  return -1;
}


This may be useful IMO if you have a long (or potentially long) String with lots of instances of the same sample and do not want to spawn substrings to find the Nth instance.
#13413
I noticed there are no help topics which sould cover "advanced" script keywords like "protected", "writeprotected" (I knew that one exists only after getting monkey_05_06's Stack module), "managed" etc. Maybe some other things are missing in the manual too. It would be nice if they are added there.
#13414
Well, I already did use the Stack module... and maybe it's a working workaround... but I don't feel like using it right now. Workaround, I mean, not Stack module.
#13415
Monsieur OUXX, I am not blaming monkey, I was just being sarcastic. Or having fun. :)

From what I understood, AGS needs a support for pointers to custom type objects. That should fix the problem in some way.
#13416
Try searching for "patrol" :)

Sample topic link: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=40122.0
#13417
You cannot add variables to existing classes and structs; what you can is:

a) create a custom struct, extending existing class/struct with new variables and methods; but that is not usable in your case.
b) add extender functions to existing class/struct.

I believe you already tried this, but made a mistake in function declaration.
Instead of
Code: ags

bool IsInventoryFull(Character*);

write:
Code: ags

bool IsInventoryFull(this Character*)
{
    // do inventory check and return true or false
}

#13418
monkey, I'll take your answer as "you can but you better not do" :P

Quote from: Monsieur OUXX on Fri 18/06/2010 10:57:56
Correct me if I'm wrong. In your code sample, in order to be able to call the original version of "SetData" (the one originally defined for "Parent"), you actually store copies of all the parents. However, don't the chidren contain their own value of the the member "data"?
Yep, they do.

Quote from: Monsieur OUXX on Fri 18/06/2010 10:57:56
Why doing all this duplication, instead of just keeping one and only instance of a "Parent" object that you'd call whenever you want to borrow its "SetData" ?
The whole code above is a screwed workaround which does not make much sense and has an effeciency close to zero. :P
#13419
Hah, Wyz, I wanted to mention that idea. :)

Okay, then, here's another one. Make it twist, let player control zombie character being pursued by angry villagers. Depict the horror of realizing your soul and consciousness are locked in the rotten, crumbling body, and that no one will gonna help you, at least not before he shoots your brain.  :P
#13420
Quote from: ddq on Wed 16/06/2010 23:01:11
If your game is going to have a big evil antagonist, what form is most effective in terms or horror? As far as I can figure, there are three big types of horror antagonists. First, some sort of murdering psychopath or something, but grounded in reality with no supernatural ties. Second, a powerful, unknowable evil, like an Eldritch abomination. Or finally, a middle ground, like a cult of ordinary psychopaths that worship/get their power from the evil power. I personally think that cults have been overdone, but that could be because they are the most effective.
Thoughts?

I think that there's really a way to make a man of political power both evil and scary. More, the society that he rules can be very scary. As anian mentioned just before - "Unkown is scary, being vurnerable is scary, things that we can't control are scary". Being a little man in the society governed by cynical money-makers (for example), who control corrupted goverment brunches, and knowing they can do to you anything and you have no - absolutely no - certain way to hide/defend from them, - can be very scary.

Not sure how this may be used in game though. I just wanted to point out there could be other sorts of horror stories besides "classic" maniac/ghost/monster ones.
SMF spam blocked by CleanTalk