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 - Calin Leafshade

#121
Is it possible to check if some dialog options are being displayed whilst in a dialog?

#122
HI!

ok so i'm trying to write a function which replaces a colour in a sprite.

that part is easy but i get these sprites from a view frame and set the dynamic sprite back to the viewframe.

Now, when I do this it obviously changes the viewframe and the next time the function comes round the colour will no longer be there and/or it will crash when it tries to get a new sprite from viewframe because the vf points to a dynamic sprite.

So i need to set the sprite to the vf but save the spriteslot so I can reset the viewframe back once the animation has moved onto the next frame.

The code below *kinda* works but the colours flicker because i'm not resetting the viewframes properly and its alternating between a fixed sprite and the original.

can anyone see the flaw in my logic?

(If a variable is not declared explicitly in the code then its a global)

Code: ags


function DoEyes(){
  
  
  ViewFrame *vf = player.GetViewFrame();
  if (Prevf != null && (Prevf.View != vf.View || Prevf.Loop != vf.Loop || Prevf.Frame != vf.Frame)) Prevf.Graphic = PrevSprite;
  
  
  PrevSprite = vf.Graphic;
  Prevf = vf;
  
  PlayerSprite = DynamicSprite.CreateFromExistingSprite(vf.Graphic, true);
  DrawingSurface *ds = PlayerSprite.GetDrawingSurface();
  int x, y;
  while (y < PlayerSprite.Width){
    
    while (x < PlayerSprite.Height){
      int colour = ds.GetPixel(x, y);
      if (colour == 59360){
        ds.DrawingColor = EyeColor;
        ds.DrawPixel(x, y);
          
        
      }
        
      x++;
    }
    x = 0;
    y ++;
  }
  ds.Release();
  
  
  vf.Graphic = PlayerSprite.Graphic;
  
  
}

#123
I know this was addressed a while ago but it seems its still not 100% fixed.

I've built a little lightmap tinting engine and it works fine in DD mode but in Dx9 mode it seems to be rather unhappy with certain values..

for example... 232 184 80 RGB seems to tint a kind of purpley colour but 240 184 87 RGB tints an orangey colour (which is correct).

The colours are pretty much identical to the eye so surely they should tint the same?

Edit by strazer:

Fixed in AGS v3.2.1:  - Fixed D3D tints not working properly (3.2 regression) (Nefasto)
#124
I'm not sure if anyone can help me here and this may be one of those 'CJ issues' that only CJ can fix but it can't hurt asking in case we have any advanced DirectX coders here.

The plugin API exposes the D3D device via a pointer passed by an engine hook. ('data' in the below function)

So this is the code I attempted to use


Code: ags

int AGS_EngineOnEvent (int event, int data) {
  if (event == AGSE_PREGUIDRAW) {
    
	IDirect3DDevice9 *dev = (IDirect3DDevice9 *)data;
	
	
	HRESULT hRes;
				
	IDirect3DPixelShader9* lpPixelShader = NULL;
	LPD3DXBUFFER pCode = NULL;
	LPD3DXBUFFER pErrorMsgs = NULL;

	hRes = D3DXAssembleShaderFromFile(L"simple_texture_map.ps",  
						NULL,		    
						NULL, 
						0,
						&pCode, 
						&pErrorMsgs);
	
	hRes = dev->CreatePixelShader((DWORD*)pCode->GetBufferPointer(), 
                                         &lpPixelShader); //the problem line
	
	hRes = dev->SetPixelShader(lpPixelShader);
	

  }
  return 0;
}



However the CreatePixelShader routine throws an access violation exception and i'm not entirely sure why, the code looks fine to me.

Anyone see my error?
#125
General Discussion / A hardware survey!
Tue 03/08/2010 15:46:49
I'm doing alot of fairly intense graphical stuff at the moment and I want to know what kind of hardware people are playing their games on.

So i did a survey!

If i've missed any hardware off or anyone is having any difficulty with the questions let me know

http://spreadsheets.google.com/viewform?formkey=dHd3bGs5M2JlXzRRZzV6Yy1iMXVVcnc6MQ
#126
ok so i've written a blurring algorithm for an AGS plugin and it works ok on *some* images but not on all.

if the image is square it blurs it 100% fine
if the image is taller than it is wide then it blurs a weird box in the corner with some artifacts
if the image is wider than it is tall it crashes with an access violation (i.e i've accessed a part of the array that i havent allocated)

So theres obviously a pretty elementary error with the way i calculate the array indices but i cant see it.

It's extremely difficult to debug plugins since you cant add breakpoints or watch values or step through code so i need help

heres my algorithm:

(btw i *know* this is not a quick way to do blurring butI'm just getting to grips with the c++ first then i can alter the algorithm however i please.)

Code: ags

int xytolocale(int x, int y, int width){
    
 return (y * width + x);   
    
    
}
int BlurHorizontal (int Sprite, int radius) {
             
    BITMAP* src = engine->GetSpriteGraphic(Sprite);
    long srcWidth, srcHeight;
    
    engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, NULL);

    unsigned char **srccharbuffer = engine->GetRawBitmapSurface (src);
    unsigned long **srclongbuffer = (unsigned long**)srccharbuffer;
    int negrad = -1 * radius;
    
    //use a 1Dimensional array since the array is on the free store, not the stack
    Pixel32 * Pixels = new Pixel32[(srcWidth + (radius * 2)) * (srcHeight + (radius * 2))]; // this defines a copy of the individual channels in class form.
    Pixel32 * Dest = new Pixel32[(srcWidth + (radius * 2)) * (srcHeight + (radius * 2))]; // this is the destination sprite. both have a border all the way round equal to the radius for the blurring.
    

             
    int arraywidth = srcWidth + (radius * 2); //define the array width since its used many times in the algorithm


    for (int y = 0; y<srcHeight; y++){ //copy the sprite to the Pixels class array
         
         for (int x = 0; x<srcWidth; x++){
             
             int locale = xytolocale(x + radius, y + radius, arraywidth);
             
             Pixels[locale].red = getb32(srclongbuffer[x][y]);
             Pixels[locale].green = getg32(srclongbuffer[x][y]);             
             Pixels[locale].blue = getr32(srclongbuffer[x][y]);
             Pixels[locale].alpha = geta32(srclongbuffer[x][y]);  
                                                     

         
         }
         
     }    
            // start of the blurring 
     int numofpixels = (radius * 2 + 1) * (radius * 2 + 1);
         for (int y = 0; y < srcHeight; y++) {
            for (int x = 0; x < srcWidth; x++) {
                int totalr = 0;
                int totalg = 0;
                int totalb = 0;                
                int totala = 0;

                for (int ky = negrad; ky <= radius; ky++){
                    for (int kx = negrad; kx <= radius; kx++){
                        int locale = xytolocale(x + kx + radius, y + ky + radius, arraywidth);
                        totalr += Pixels[locale].red; //add the pixel values for the surrounding pixels to a total
                        totalg += Pixels[locale].green;
                        totalb += Pixels[locale].blue;
                        totala += Pixels[locale].alpha;                                                
                        
                    }
                }
                int locale = xytolocale(x + radius, y + radius, arraywidth);
                Dest[locale].red = totalr / numofpixels; // take an average and assign it to the destination array
                Dest[locale].green = totalg / numofpixels;
                Dest[locale].blue = totalb / numofpixels;
                Dest[locale].alpha = totala / numofpixels;                            
            }
        }
        
         
     
        for (int y = 0; y<srcHeight; y++){
             
             for (int x = 0; x<srcWidth; x++){
                int locale = xytolocale(x + radius, y + radius, arraywidth);
                srclongbuffer[x][y] = makeacol32(Dest[locale].blue, Dest[locale].green, Dest[locale].red, Dest[locale].alpha); //write the destination array to the main buffer

             }
             
         } 
        
        engine->ReleaseBitmapSurface(src);
}


any ideas?
#127
AGSBlend 1.0

Fixes alot of the bugs and adds some error checking. the function will return 0 on success and 1 if the coordinates are invalid (probably still a good idea to clamp them just incase though)

Allegro dependency has been removed.

binaries: http://svn.thethoughtradar.com/svn/AGSBlend/bin/

source: http://svn.thethoughtradar.com/svn/AGSBlend/src/

Includes the following functions:

int DrawAlpha(int destination, int sprite, int x, int y, int transparency)
Draws sprite source onto sprite destination at x, y with transparency

int GetAlpha(int sprite, int x, int y)
returns the alpha value for the pixel at x,y

int PutAlpha(int sprite, int x, int y, int alpha)
writes to the alpha channel at x, y

int Blur(int sprite, int radius)
box blurs a sprite with radius radius.

int HighPass(int sprite, int threshold)
High passes a sprite (useful for bloom and other effects.)

int DrawAdd(int destination, int sprite, int x, int y, float scale)
Draws a sprite additively


AGSBlend Alpha 0.1

Ok i'm putting this out for speedtests and giggles.

the plugin has three functions:

int DrawAlpha(int Dest, int Sprite, int y, int x, int trans)

This draws the sprite at slot "Sprite" on the sprite at slot "Dest" at coordinates x and y in relation to the destination sprite.
the trans value is between 0 and 100 (0 being full opacity and 100 being completely transparent)

all the alpha channel information is preserved so you can use it for particle effects on object and any gui composition you want.

int GetAlpha(int sprite, int x, int y)

This returns the alpha value (0-255) of pixel x,y on the sprite at slot 'sprite'

int PutAlpha(int sprite, int x, int y, int alpha)

This writes an alpha value ('alpha) to the sprite in slot 'sprite' at x,y

The above two features are really if you want to use the plugin for your own advance special fx. standard AGS functions can fiddle with the RGB values.

I'm also including a demo game. I'd be interested to see how far people can push it and still get 40fps.

I managed about 500 (big) particles on my 2.4ghz laptop so it seems pretty fast.

My blending algorithm was kinda just made up so i'm sure i can optimise it a little with some bitwise ops.

Currently the plugin requires the allegro DLL (which i have included) but its not really needed so i'll strip out all the references and rewrite the funcionality that it provides eventually.

I also plan to add Additive blending and other blending modes too.

CAVEATS: THE PLUGIN CONTAINS VERY LITTLE ERROR CHECKING SO BE CAREFUL WHEN USING IT. DO NOT DRAW OUTSIDE THE BOUNDS OF A SPRITE AND ONLY PASS 32-BIT SPRITES TO THE FUNCTIONS. Thank you :D

Plugin: http://www.thethoughtradar.com/AGS/AGSBlendPlugin.zip

Demogame http://www.thethoughtradar.com/AGS/AGSBlendDemoGame.zip

Have fun


#128
Does anyone know of any AGS plugins that are open source?

Or is anyone willing to let me see the source of their plugin for educational purposes?
#129
General Discussion / Left 4 Dead 2
Sun 18/07/2010 14:19:43
Does anyone play? Some people from the irc channel often play so if anyone would like to join us then feel free to join the AGS steam group or add me on steam (user steviepolts)

It's alot of fun.

#130
Advanced Technical Forum / Compiling a plugin
Tue 13/07/2010 15:35:03
I've been trying to compile the plugin template that CJ provides and i'm not having much luck.

I know very little about C++ and compilers so i might be doing something obviously wrong.

I'm using g++ to compile for windows under minggw (directly from Dev-C++).

Is this ok or does it *have* to be a MS-Visual C++ compiler?

here's my error log for fun

Code: ags

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing  make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe -c ags_template.cpp -o ags_template.o -I
"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include
/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -DBUILDING_DLL=1 

In file included from ags_template.cpp:10:
agsplugin.h:38: error: conflicting declaration 'typedef int HWND'
C:/Dev-Cpp/include/windef.h:292: error: 'HWND' has a previous declaration as `typedef struct HWND__*HWND'
agsplugin.h:38: error: declaration of `typedef int HWND'
C:/Dev-Cpp/include/windef.h:292: error: conflicts with previous declaration `typedef struct HWND__*HWND'
agsplugin.h:38: error: declaration of `typedef int HWND'
C:/Dev-Cpp/include/windef.h:292: error: conflicts with previous declaration `typedef struct HWND__*HWND'

ags_template.cpp: In function `void AGS_EngineStartup(IAGSEngine*)':
ags_template.cpp:97: error: invalid conversion from `int (*)(int, int)' to `void*'
ags_template.cpp:97: error:   initializing argument 2 of `virtual void IAGSEngine::RegisterScriptFunction(const char*, void*)'

ags_template.cpp:98: error: invalid conversion from `int (*)(int, int)' to `void*'
ags_template.cpp:98: error:   initializing argument 2 of `virtual void IAGSEngine::RegisterScriptFunction(const char*, void*)'

make.exe: *** [ags_template.o] Error 1

Execution terminated
#131
So i've recently started looking into the AGS plugin API and i have a question on the best way to do this..

Basically I want AGS to run a MYSQL command on a server.

So I have 2 thoughts..

a) use the MYSQL++ library to run the command directly through ags.

b) pass the variables to a php script and let the webserver do the work.

obviously option b would be better and simpler but is it possible to get a c++ program to send a php request to a server silently?

Edit: On further searching it seems libcurl could be used for what i want right?

help me?
#132
So I have just finished coding a custom Say function to allow lipsyncing in Lucas Arts speech but it occurs to me that its going to make things very annoying when i have to do dialog since i cant write Ego: blah blah I have to write cEgo.iSay("blah blah");

Now I know that sounds kinda trivial but it would be nice if we could override certain functions that have built in functionality (like the walk and say functions).

Just a thought.
#133
Is there a way to set the distance from the top of that screen that sierra style portraits display?

So i can have them at the bottom instead of the top.
#134
So I've been thinking about reflections on uneven surfaces and how to model them and I can't quite get my head around it.

Now I know this has been discussed before and it was decided it would be very slow.. but that was modelling distortion on a whole background.. what if it's just a characters reflection that's modelled?

Basically I see it like this:

1, You have a greyscale reflection/height map for your surface,
2, you project a reflection onto that surface,
3, then you somehow 'transpose' that greyscale reflection map onto the position values of the sprites pixels
4, draw the sprite

I can handle steps 1,2 and 4 but step 3 is puzzling me a little :P

It doesnt have to be very accurate since we are talking about a 2D plane with a static camera, but it has to look convincing.

any help?

SteveMcCrea, GarageGothic, Khris, I'm looking at you.
#135
would it be possible to add the following code to the forums stylesheet?

Code: ags

img[src$=".gif"] { image-rendering: -moz-crisp-edges; -ms-interpolation-mode: nearest-neighbor; }
img[src$=".png"] { image-rendering: -moz-crisp-edges; -ms-interpolation-mode: nearest-neighbor; }


I have it running globally so sprites dont look blurry but it's not really very useful for non pixel art sites so having it locally in the bigbluecup stylesheet seems like a good plan.

EDIT: or perhaps a better solution would be to give us a different forum tag something like [ pixel ] which applied the css
#136
I've just upgraded the version of linux on my netbook and now i have a program called gbrainy which shows a series of puzzles so i thought I would share one with you.

BAM!

#137
Critics' Lounge / Help with a female sprite.
Fri 11/06/2010 00:09:04
I have trouble with female sprites on account of all the curvy bits (which are awesome by the way) so I decided to practice and have a go at spriting a sexy zombie lady (based on Sylvanas Windrunner) in a non-straight pose..

I went for a kind of slanty hip type pose with the weight on a single leg but she just looks like shes unfit and slouching.

Also I find faces very difficult so any tips there would be helpful too.

I would like help to get better. ^_^

My sprite:




and here's a link to my reference (the one on the right)
http://images3.wikia.nocookie.net/__cb20081126041112/wowwiki/images/7/75/Sylvanas_model_comparition.jpg

help?
#138
Hello!

When should skipping be allowed?

I've set mccarthy in such a way that he can skip the walking stage when he is heading to an exit but not when he is heading to other hotspots which are not exits.

this seems like a good balance between practicality and 'realism'.

What are other people's thoughts?
#139
My game (McCarthy2) has a feature whereby double clicking skips the walking part on blocking commands..

however I use a custom script for playing my footstep sounds and using this SkipUntilCharacterStops(player.ID) command causes a load of footstep sounds to be played since they are triggered in the script. Is there anyway to check to see if this command has been run?

#140
So I need a software suggestion.

I need something that is essentially a web based file access system.

Basically users log on and can download files from the system.

The only caveat is that users must only be able to access the set of files that they are given permissions for.

so some user can access file set A & C, another user can access A & B, and another user can acces B & C and so on.

I know this is basically an FTP server but does anyone have any suggestion for something that looks a little more corporate with a web based design?
SMF spam blocked by CleanTalk