PLUGIN: Flashlight plugin v1.2

Started by a-v-o, Wed 21/09/2005 20:53:14

Previous topic - Next topic

a-v-o

Hello everybody who was waiting for this great new feature  :o  in the flashlight plugin:

In version 1.2 the state of lighting is saved and restored with the game, so after restoring a saved game the lighting will be exactly as it was when it was saved. No more scripting is needed.

OK, I confess: I just added these few lines of code and changed the version number which was the most difficult part of the update.  ;D

And thanks to all who voted for this plugin.

Download here

Download other AGS scripts and plugins: http://ags.freie-ressourcen.de/

JD

Hurrah a new version! :D I love this plugin, though there is one thing which I'd love to see: multiple lightspots. So you could have a fixed lightspot, and a moveable flashlight spot in the same room :)
Keep up the good work!

Mordalles

i cant get the flashlight plugin to work with version 2.7. i read something about only working with 16bit? my game is 32 bit. is that it?

anyway, i was just wondering the guy who wrote the flashlight plugin used? tints? or rawdraw? or what. i want to try my own, but dont have any time since im doing it for mags. i just need a headsup.  ;D  :-\

"It's a fairy! She's naked! Curse these low-res graphics!" - Duty and Beyond

DoorKnobHandle

I don't know what the creator of that plug-in used (chances are he didn't even use AGS's native drawing functions but other ones that are available only when you are writing a plug-in for AGS), but the simple flashlight effect is quite easy to simulate anyways -- just create a GUI with a black rectange that has a transparent circle in it and position this GUI so, that the center of the circle is always where the mouse currently is. That's just a bit of playing around with offset values, and then you can enable or disable your flashlight by showing or hiding this GUI.

Additionally (if your game is 32-bit), you could add alpha transparency which is going to improve the look of your flashlight effect even more.

Was that understandable? If not, feel free to ask again!

a-v-o

The flashlight plugin was programmed in Delphi without using the AGS script functions. Parts of the plugin are written in assembler.

Mordalles

thanks, dkh! it was understandeable!  ;D

i wanna use it for mags, so that sounds like a perfect solution.

in delphi you say? didn't know you guys wrote the plugins with other languages. is the source code available, since i know delphi pretty well.  8)
what is the best language to write plugins in? c++ or delphi?

"It's a fairy! She's naked! Curse these low-res graphics!" - Duty and Beyond

Scorpiorus

In theory, you can write a plugin in any language that is capable of building a Windows DLL file.

Practically though, there are two templates (for C++ and Delphi) available to use.

Also bear in mind, only C++ (using Microsoft Visual C++ compiler) is officially supported.

Here is the link to plugin page (with templates and API reference):

http://www.adventuregamestudio.co.uk/acplugin.htm

a-v-o

You can find the delphi plugin template on:
http://ags.freie-ressourcen.de/
It is for following AGS version:
  AGS    : v2.60.450 (2.6)
  Editor : v1
  Engine : v12

The engine is now in version 18, so some functions must be added.

You can download the source code for the flashlight plugin with the following link:
http://ags.freie-ressourcen.de/plugins/ags_flashlight_1_2_source.zip



petaglair

hi
i would like to know if i could use this plugin with ags version 2.72

Thanx

Pétaglair
Avec Nutricrotte° je voie là  differanse j'est même developper du mucsle

Candle

#9
It does. well it did for me.

Da_Elf

#10
I'm trying to give this a try but when i go to save the room it says it doesnt like the code. it says error (line 207): undefined symbol 'GetPlayerCharacter' in this code


Code: ags

SetFlashlightFollowCharacter (GetPlayerCharacter (), 0, -20, 20, 10);


did it change in 2.72 to something else and if so what did it change to. ive tried looking around the help manual but cant seem to find it.

actually when i check properties in the plugin al the tabs like syntax basic/tint etc are all empty. am i supposed to paste the code from the tutorial.txt file into those spaces?

opps. my backgrounds are 32bit so I'm guessing it wont work anyhow :(

EDIT

does anyone know of a way i can do this for a 32bit game? i have a character walking around in a cave with a flaming torch and i need to get the same effect this plugin seems to want to do.

Kweepa

Quote from: Da_Elf on Thu 30/11/2006 17:09:25
i have a character walking around in a cave with a flaming torch and i need to get the same effect this plugin seems to want to do.

Quote from: dkh on Thu 13/04/2006 21:17:25
the simple flashlight effect is quite easy to simulate anyways -- just create a GUI with a black rectange that has a transparent circle in it and position this GUI so, that the center of the circle is always where the mouse currently is. That's just a bit of playing around with offset values, and then you can enable or disable your flashlight by showing or hiding this GUI.

Additionally (if your game is 32-bit), you could add alpha transparency which is going to improve the look of your flashlight effect even more.
Still waiting for Purity of the Surf II

Da_Elf

yeah but is it possible to have a gui follow the possition of the character. also is it possibly to have a gui component (like the circle only) follow the character where as the black rectangle part remains where it is?

Rui 'Trovatore' Pires

Quoteposition this GUI so, that the center of the circle is always where the mouse currently is.

If you can do it with the mouse, why shouldn't you be able to do it with the character?

As for your other question, no, not as far as I know. Why isn't the whole rectangle good enough for you?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Da_Elf

im assuming the rectangle of the GUI is going to be black to represent the dark area of the cave and the circle will be in the center and this will be transparent. therefore we will be able to see our background where the circle is. if the center of the gui is centered on the character then it means that the rectangle will have to be double the screen size. this way when the character is all the way to the left then the edge of the gui is slightly beyond the edge of the screen on the right. where as if you could get an element of the GUI to follow the character (the circle) then the rectangle can be screen size and will never need to move. I was wondering if this was possible since i wasnt sure if having a huge GUI would slow down the game play

Rui 'Trovatore' Pires

It sounds like a huge slowdown, but it isn't, really, hence my last question.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Lt. Smash

#16
is there a way to make that plugin work with 32bit color?
if not, could the author of that plugin or someone else fix that?

I'm using alpha blended sprites so I can't use 16bit and I need that plugin.


Kweepa

If you read Da_Elf's posts on this page and those following, you will find help.
Still waiting for Purity of the Surf II

monkey0506

I wrote a module to achieve a similar effect which should work with 32-bit games.

beomoud

I can't get the function to work, i used the plugin, i put the "switch flashlight on" part in my code but nothing happens. What could be the problem?

Slasher

#20
I am using Flashlight plugin 1.2.1 by Andreas Vogel and I can't seem to turn it off.

I was ok, if I remember, with and older version.

After using it in a darkened room and then going back to previous room I have the room state set to background 1 and the player back to normal views. However at most I clear the follow character spotlight but the room looks 'washed'.

Tried
Code: AGS
SetFlashlightDarkness (GetFlashlightMaxLightLevel ());


Are you able to assist:

many thanks


Gilbert

#21
(Merged with the plugin's thread.)

I'm not sure as I have never used it, but since the plugin is rather old there may be some compatibility problems (people more familiar with the plugin may be able to share some light on this). You may also try the module version which is a bit newer.

Slasher

#22
Flashlight Version 1.2.1

I was having trouble turning it off.

For those that may come across my scenereo I have made 2 buttons: light on and light off which controls flashlight on and off. I can also switch it on via a light item in the inventory which i use on player. I have 2 backgrounds: black room (background 0) and the main room background 1.

This is what I used:

Code: AGS
function Blighton_OnClick(GUIControl *control, MouseButton button)
{
  SetBackgroundFrame(1);
  
  cELF.ChangeView(40);
  cELF.SpeechView=41;
  cELF.SetIdleView(42, 0);
  
  SetFlashlightDarkness (20);
  SetFlashlightBrightness (GetFlashlightMaxLightLevel ());
  SetFlashlightDarknessSize (50);
  SetFlashlightBrightnessSize (100);
  SetFlashlightFollowCharacter ( (1), 0, -20, 20, 10);
}

    function Blightoff_OnClick(GUIControl *control, MouseButton button)
   {
    cELF.ChangeView(3);
    cELF.SpeechView=4;
    cELF.SetIdleView(12, 0);

    SetBackgroundFrame(0);
    SetFlashlightBrightness (GetFlashlightMaxLightLevel ());
   }



sorted

Julius Dangerous

This is the best (and only) plugin for flashlight, i updated my game to AGS 3.4 and 3.5 and it doesn't works any more :sad: :cry:
___________________________________________________________

Cassiebsg

@Julius, what error does it give?
I'm not sure it works with plugins, but have you tried setting the compatibility to 3.4 version?
There are those who believe that life here began out there...

Crimson Wizard

#25
Quote from: Cassiebsg on Thu 02/01/2020 16:51:16
I'm not sure it works with plugins, but have you tried setting the compatibility to 3.4 version?

No, it does not affect plugins.
EDIT: the only way script version may affect plugin is if plugin's script function matches some of the new engine functions and there's naming conflict.

Julius Dangerous

#26
Quote from: Cassiebsg on Thu 02/01/2020 16:51:16
@Julius, what error does it give?
I'm not sure it works with plugins, but have you tried setting the compatibility to 3.4 version?

no error message, tried with other compatibility script version, but game starts and flash light not working
___________________________________________________________

Crimson Wizard

Quote from: Julius Dangerous on Thu 02/01/2020 22:13:12
no error message, tried with other compatibility script version, but game starts and flash light not working

Have you tried running in Software gfx mode? I have a thought this original plugin may only run with DirectDraw5 (called Software renderer now).

I don't remember how flashlight looks like in this plugin, but maybe it's possible to recreate with just a black GUI with a transparent hole?

Julius Dangerous

#28
Quote from: Crimson Wizard on Thu 02/01/2020 22:48:27
Quote from: Julius Dangerous on Thu 02/01/2020 22:13:12
no error message, tried with other compatibility script version, but game starts and flash light not working

Have you tried running in Software gfx mode? I have a thought this original plugin may only run with DirectDraw5 (called Software renderer now).

I don't remember how flashlight looks like in this plugin, but maybe it's possible to recreate with just a black GUI with a transparent hole?

Thanks for answer. Yes i tried with all modes and with all script compatibility/API version combinations, and 16/32 color depth.
So i made it with a GUI (double of the screen size) with an hole in the middle (png), and added script:

function room_RepExec()
{
gFlashlight.SetPosition(mouse.x-800, mouse.y-600);
}
:cheesy:
___________________________________________________________

SMF spam blocked by CleanTalk