Problem with lflare

Posted By: FatherGuido

Problem with lflare - 08/02/07 16:00

Hello. I'm new to GS and this is my first post so I hope I'm putting it in the right place. Anyhow, I'm working with the A7 Demo and creating an adventure type project (3rd person) and using the day/night script by loopix. I keep getting this error while running the game. Crash in flare_place:(c_trace(camera.x,temp2.x,trace_mode)!=0) which is the modified lflare wdl.
Does anyone know a fix for this? I've tried playing around with the camera clip distance and everything else and keep getting the same result. It happens during run time at random. Usually when models are between player biped and the sun panel. Please let me know how to fix this if you have any insight. Thanks very much.

Sorry, I forgot to post this info:

Project Manager: 1.7
Template: Template 6
Type: WDL Script
Date: 061011
Vers: 6.7
Req: 6.50.0

Main Script: D:\Game Studio v7\projects\j3\a_level_01.wdl

gid01.wdl (5.0) (061011)
*display00.wdl (5.0) (061011)
cameraSelect.wdl (5.0) (061011)
cameraTarget.wdl (5.0) (061011)
*camera3rd01.wdl (5.0) (061011)
plSelect.wdl (5.0) (061011)
*miscInput01.wdl (5.0) (061011)
*plBipedInput01.wdl (5.0) (061011)
*bipedPhy01.wdl (5.0) (061011)
*bipedAnim01.wdl (5.0) (061011)
bipedSnd01.wdl (5.0) (061011)
*plBiped01.wdl (5.0) (061011)
*material.wdl (5.0) (061011)
trigger00.wdl (5.0) (061011)
particle00.wdl (5.0) (061011)
fxa01.wdl (5.0) (061011)
teleport00.wdl (5.0) (061011)
*MtlTerrainMulti.wdl (5.0) (061011)
*multitex4.wdl (USER)
forcefield01.wdl (5.0) (061011)
*cameraFX00.wdl (5.0) (061011)
props00.wdl (5.0) (061011)
weaponfx00.wdl (5.0) (061011)
default.fx (USER)
mtlFX.wdl (1.4) (060902)
lift01.wdl (5.0) (061011)
*camera1stPerson01.wdl (5.0) (061011)
*mywater.wdl (USER)
fxGore01.wdl (5.0) (061011)
*weapons00.wdl (5.0) (061011)
*aiFPS01.wdl (5.0) (061011)
!movement.wdl (USER)
*plBipedHUD01.wdl (5.0) (061011)
*plBipedWeap00.wdl (5.0) (061011)
*plBipedWeapHUD01.wdl (5.0) (061011)
traps00.wdl (5.0) (061011)
aiFixed01.wdl (5.0) (061011)
startup01.wdl (5.0) (061011)
aiDumbBiped01.wdl (5.0) (061011)

Posted By: D3D

Re: Problem with lflare - 08/03/07 10:43

What do you mean with "the modified lflare wdl."?
Posted By: FatherGuido

Re: Problem with lflare - 08/03/07 14:50

This is the comment in the lflare1.wdl script file which is used in place of lflare.wdl There are some minor modifications in the script file in order for it to work with the dn_cycle.wdl script


// Modified Template6 file (by David Lancaster and Loopix)
////////////////////////////////////////////////////////////////////////
// File: lflare.wdl
// WDL code for lens flare and lighting effects
////////////////////////////////////////////////////////////////////////

(I hope this all makes sense lol)

Posted By: D3D

Re: Problem with lflare - 08/03/07 22:04

Post the complete code or demo of the script that cause the error. I have Loopix day/night code working. Don't know anything about lflare.wdl though.
Posted By: FatherGuido

Re: Problem with lflare - 08/04/07 18:51

code from lfare1.wdl (problematic function is highlighted in red) Hitting ok will temporarily resume the game until it happens again (which is until the player moves a little bit at a time out of the inflicting area).
see Image of problem

// Modified Template6 file (by David Lancaster and Loopix)
////////////////////////////////////////////////////////////////////////
// File: lflare.wdl
// WDL code for lens flare and lighting effects
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
//var temp2[6];
//var temp3[6];

var sun_offset_x = 0;
var sun_offset_y = 0;
var sun_offset_z = 0;
var flare_range = 0;
//var flare_alpha = 60;

var lensvisibility = 0;

var flare_trace_mode; // used to trace to the sun

var qLensFlare = -1; // -1 == not created
// 0 == off
// 1 == on
// otherwise == turning off


string str_skytex = "sky"; // if the first part of the texture scanned matches this, it is sky

// use the skill1 parameter to store a number in a sprite entity
// The pivot distance is the percent distance between the screen center
//(where pivot_dist = 0) and the sun (pivot_dist = 1).
define pivot_dist,skill1;

// this is the sun itself
entity flareSun_ent
{
type = <sun_grey2.tga>; // uses a sprite
// type = <sun2.bmp>; // uses a sprite
view = CAMERA; // same camera parameters as the default view
layer = 3; // displayed beneath other entity layers
pivot_dist = 1; // distance factor from 'pivot point', must be 1 for sun
scale_x = 6; // sun is two times as large as the flares
scale_y = 6;
}

entity sunshine
{
type = <sunrays2.tga>;
view = CAMERA;
layer = 3;
pivot_dist = 1;
scale_x = 12;
scale_y = 12;
}



// Desc: this function takes an entity as parameter.
function flare_init(flare_ent)
{
my = flare_ent; // necessary because function parameters have no type
my.visible = off; // start with flares off
if (video_depth > 8) // D3D mode?
{
ent_alphaset(0,10); // create an alpha channel (won't work with standard edition)
my.bright = on;
my.flare = on;
}
else
{
my.transparent = on; // looks lousy in 8 bit, though
}
}


// Desc: places a flare at temp.x/temp.y deviations from screen center
function flare_place(flare_ent)
{
my = flare_ent;
my.visible = on;
my.transparent = on;

// multiply the pixel deviation with the pivot factor,
// and add the screen center
my.x = temp.x*my.pivot_dist + 0.5*screen_size.x;
my.y = temp.y*my.pivot_dist + 0.5*screen_size.y;
my.z = 1650; // screen distance, determines the size of the flare
IF (my == flareSun_ent) {

vec_set(temp2,sun_pos);

temp2.x += sun_offset_x;
temp2.y += sun_offset_y;
temp2.z += sun_offset_z;

trace_mode = ignore_me + ignore_you + ignore_passents + ignore_passable + ignore_sprites + scan_texture + USE_POLYGON; // ++ added scan_texture
IF (c_trace(camera.x,temp2.x,trace_mode) != 0) {
IF (str_cmpni(tex_name,str_skytex) == 0) {
IF (flareSun_ent.alpha > 0) { flareSun_ent.alpha -= 40 * time; } ELSE { flareSun_ent.alpha = 0; }
}
} ELSE {
IF (camera.pan > sun_angle.pan + 90) || (camera.pan < sun_angle.pan - 90) || (camera.tilt < sun_angle.tilt - 50) || (camera.tilt > sun_angle.tilt + 50) {
IF (flareSun_ent.alpha > 0) { flareSun_ent.alpha -= 40 * time; } ELSE { flareSun_ent.alpha = 0; }
} ELSE {
temp2.x = sqrt(abs(((my.x - (0.5*screen_size.x))*(my.x - (0.5*screen_size.x)))+((my.y - (0.5*screen_size.y))*(my.y - (0.5*screen_size.y)))));
IF (abs(temp2.x) > (0.5*screen_size.x) - flare_range) {
flareSun_ent.alpha = 100 - (abs(temp2.x) - ((0.5*screen_size.x) - flare_range));
IF (flareSun_ent.alpha < 0) { flareSun_ent.alpha = 0; }
} ELSE {
IF (flareSun_ent.alpha < 90) {
flareSun_ent.alpha += 40 * time;
} ELSE {
flareSun_ent.alpha = 90;
}
}
}

}

IF (flareSun_ent.alpha < 0) { flareSun_ent.alpha = 0; }
IF (flareSun_ent.alpha > 90) { flareSun_ent.alpha = 90; }
}
rel_for_screen(my.x,camera);
IF (my == flareSun_ent) {

}
}

// Desc: setup the lens flare effect
function lensflare_create()
{
// set alpha values for each entity

flare_init(flareSun_ent); // <<the sun flare

flare_init(sunshine);

qLensFlare = 0; // start 'off'
}

// Desc: start and animate a lens flare effect as long as qLensFlare == 1
//
starter lensflare_start()
{

// flareSun_ent.invisible = on;
flareSun_ent.transparent = on;

sunshine.transparent = on;

flareSun_ent.passable = on;

sunshine.passable = on;

if(qLensFlare == -1) // create the lens flares
{
lensflare_create();
}

if(qLensFlare == 1) // lens flare already started
{
return;
}

// allow for setup time for "lensflare_create"
//(if it was called right before this function)
wait(1);
qLensFlare = 1; // mark lens flare as on

// place lens flares
while(1)
{
wait(1); // animate each cycle
WHILE (qLensFlare == 0.5) { wait(1); }
//
flareSun_ent.roll -= 0.1 * time;
sunshine.roll += 0.1 * time;


// Animate lens flare
vec_set(temp,sun_pos);
temp.x += sun_offset_x;
temp.y += sun_offset_y;
temp.z += sun_offset_z;


vec_to_screen(temp,camera);
temp.x -= 0.5 * screen_size.x;
temp.y -= 0.5 * screen_size.y;

flare_place(flareSun_ent);

flare_place(sunshine);

// flareSun_ent.alpha = sun_angle.tilt*1.5;

sunshine.alpha = flareSun_ent.alpha*1.2;


IF (sunshine.alpha < 0) { sunshine.alpha = 0; }
IF (sunshine.alpha > 70) { sunshine.alpha = 70; }



}

// Remove lens flares
lensvisibility = 0;
// flare_visible(off);
qLensFlare = 0; // mark lens flare as off
}

// Desc: stop the lens flare effect
function lensflare_stop()
{
qLensFlare = .5; // signal to stop
}
Posted By: D3D

Re: Problem with lflare - 08/04/07 23:16

Looked at the sample and updated the code a little, but I did not receive the error. Try: download, does it work?
Posted By: FatherGuido

Re: Problem with lflare - 08/05/07 16:06

Thanks, it works fine in the demo level you posted but still the same result when running my program. It's not a random problem as it seems that it only happens when between certain objects and the sun. The level I'm using has quite a few models/entities in it. Also, it seems to happen more in the daytime than anytime else. Here Detail image is a new image which I hope will explain more.
Posted By: FatherGuido

Re: Problem with lflare - 08/05/07 19:28

woohoo. me thinks me got it. added ignore_models.
trace_mode = ignore_me + ignore_you + ignore_passents + ignore_passable + ignore_sprites + ignore_models+ scan_texture + USE_POLYGON;
Haven't had problems since and gained 5 - 10 fps

I hope this can help anyone using this script!
© 2024 lite-C Forums