Perfectly functioning Flashlight in RF for those who want it
Try as i may I cannot get Jay's script to work for me. Zen's script works fine. I think I may be doing something wrong with the trigger. I set up a trigger to work the dynamic light entity and a model to trip the trigger. This works fine with zen's script and the light triggers when I colide with the model. However when I replace the script with Jay's script the light will neither trigger with collision or the script. I have tried to trigger with SetEventState(TRIGGER_NAME, true); as follows
KEYNUMBER [29] //Add your keynumber...
ON [false]
TRIGGER_NAME [flash] //Add name of the trigger for the light itself...
Spawn[()
{
LowLevel("setup");
}]
setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;
self.think = "update";
}]
update[()
{
self.ThinkTime = 0.0;
SetEventState(TRIGGER_NAME, true);
ON=true
}
and the light still does not trigger even with collison with the model. I even tried the scripts (Jay's and mine) without a model but still nothing.
Any ideas lads??
Thanks.
KEYNUMBER [29] //Add your keynumber...
ON [false]
TRIGGER_NAME [flash] //Add name of the trigger for the light itself...
Spawn[()
{
LowLevel("setup");
}]
setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;
self.think = "update";
}]
update[()
{
self.ThinkTime = 0.0;
SetEventState(TRIGGER_NAME, true);
ON=true
}
and the light still does not trigger even with collison with the model. I even tried the scripts (Jay's and mine) without a model but still nothing.
Any ideas lads??
Thanks.
try changing
PositionToPlayer(0, 30, 10, true);
to
PositionToPlayer(0, 30, 10, true, true);
PositionToPlayer(0, 30, 10, true);
to
PositionToPlayer(0, 30, 10, true, true);
RF2 site: http://realityfactory2.sourceforge.net/
RF2 tasks: http://sourceforge.net/pm/?group_id=179085
RF2 tasks: http://sourceforge.net/pm/?group_id=179085
Works perfectly for me now.
I modified the script so that once lit it burns until exhausted after a set time period. You can have as many torches as you like depending on the limit you set in player.ini file.
{
KEYNUMBER [29] //Add your keynumber...ONKEY
ON [false]
TRIGGER_NAME [flash] //Add name of the trigger for the light itself...
TIM [0] // timer
LENGTH [180] // Length of time torch can remain lit in seconds...
Spawn[()
{
LowLevel("setup");
}]
setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;
self.think = "update";
}]
update[()
{
self.ThinkTime = 1;
if(GetAttribute("torch","player") > 0) //Check if player has torch!
{
self.think = "fll";
}//HAVE TORCH
}]
fll[ ()
{
if(ON) //if torch is lit...
{
self.ideal_yaw = self.player_yaw;
ChangeYaw();
PositionToPlayer(0, 30, 10, true);
self.ideal_pitch = self.camera_pitch*(-1);
ChangePitch();
}//ON
if(self.key_pressed=KEYNUMBER) //if torch-key is being pressed
{
if(ON = false)//if torch is off
{
SetEventState(TRIGGER_NAME,true);
ON = true;
TIM=self.time;//Start timer
}//OFF
}//ON KEYPRESSED
if(ON=true)//if torch lit
{
if(self.time >TIM+LENGTH)//if torch exhausted after set time
{
ModifyAttribute("torch" , -1 , "player");
SetEventState(TRIGGER_NAME,false);
ON = false;
}//EXHUSTED
}//LIT
if(GetAttribute("torch","player") = 0) //Player lost torch...
{
SetEventState(TRIGGER_NAME,false);
ON = false;
self.think = "update";
}//HAVE NO TORCH
}]
} //SCRIPT END
I modified the script so that once lit it burns until exhausted after a set time period. You can have as many torches as you like depending on the limit you set in player.ini file.
{
KEYNUMBER [29] //Add your keynumber...ONKEY
ON [false]
TRIGGER_NAME [flash] //Add name of the trigger for the light itself...
TIM [0] // timer
LENGTH [180] // Length of time torch can remain lit in seconds...
Spawn[()
{
LowLevel("setup");
}]
setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;
self.think = "update";
}]
update[()
{
self.ThinkTime = 1;
if(GetAttribute("torch","player") > 0) //Check if player has torch!
{
self.think = "fll";
}//HAVE TORCH
}]
fll[ ()
{
if(ON) //if torch is lit...
{
self.ideal_yaw = self.player_yaw;
ChangeYaw();
PositionToPlayer(0, 30, 10, true);
self.ideal_pitch = self.camera_pitch*(-1);
ChangePitch();
}//ON
if(self.key_pressed=KEYNUMBER) //if torch-key is being pressed
{
if(ON = false)//if torch is off
{
SetEventState(TRIGGER_NAME,true);
ON = true;
TIM=self.time;//Start timer
}//OFF
}//ON KEYPRESSED
if(ON=true)//if torch lit
{
if(self.time >TIM+LENGTH)//if torch exhausted after set time
{
ModifyAttribute("torch" , -1 , "player");
SetEventState(TRIGGER_NAME,false);
ON = false;
}//EXHUSTED
}//LIT
if(GetAttribute("torch","player") = 0) //Player lost torch...
{
SetEventState(TRIGGER_NAME,false);
ON = false;
self.think = "update";
}//HAVE NO TORCH
}]
} //SCRIPT END
Are you talking to me about the position to player, Andy?
because it didn't help, still points west only.
//flashpawn.s
{
Spawn[()
{
LowLevel("setup");
}]
setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;
self.think = "update";
}]
update[()
{
self.ThinkTime = 0.0;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
PositionToPlayer(0, 30, 10, true,true);
self.ideal_pitch = -(self.camera_pitch);
ChangePitch();
}]
}
because it didn't help, still points west only.
//flashpawn.s
{
Spawn[()
{
LowLevel("setup");
}]
setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;
self.think = "update";
}]
update[()
{
self.ThinkTime = 0.0;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
PositionToPlayer(0, 30, 10, true,true);
self.ideal_pitch = -(self.camera_pitch);
ChangePitch();
}]
}
Hi all,
thanks very much for this flashlight thingy... I've been thinking very long how to get scripted weapons (including inaccuracy etc...) until now... You gave me the tools to make my perfect weapons.
Thank you for this idea.
And... I had that problem too. The light was facing the wrong direction but changing the light entity's Y-axis rotation to -68.011719 in the level editor worked for me.
thanks very much for this flashlight thingy... I've been thinking very long how to get scripted weapons (including inaccuracy etc...) until now... You gave me the tools to make my perfect weapons.
Thank you for this idea.
And... I had that problem too. The light was facing the wrong direction but changing the light entity's Y-axis rotation to -68.011719 in the level editor worked for me.
Pain is only psychological.
Thanks for the tipoff Juutis,that Y-Axis rotation of the DSpotlight was the problem..I've tried your value first but still didnt get it right,but after rotating it in such a way that its direction is parallel to the direction of "playerStart" ,I got it working [Angles >> X=0,Y=180,Z=0]
Thx for the wonderful script Andy,ZenBuddha and QOD
But,this doesnt seem to be working "properly" on Normalmapped entities...plz see these screens :
The position of the light is affecting the model's lighting[which is really cool] but the model is being lit even when the flashbeam is away from it...destroying the illusion of darkness.....Is it possible to fix this ? Or is there any setting for my model that i need to toggle to get it right ?Or has it got anything to do with the Specular map of my model I couldnt get the "Stencil Shadows" to work either...I did enable the option in the ini and I did try setting FSAA option to 0....but the shadow doesnt showup for my model[I did enable StencilShadows for it,and enabled "cast shadows" for the light in the editor and added the EnvironmentSetup entity,configured it as mentioned in RFFAQ] How di I get Stencil Shadows ?
Also,it'd be cool if there is a projection[decal] of a bitmap onto the walls [similar to the one we have in Doom 3's flashlight]...is this possible ?
Thx for the wonderful script Andy,ZenBuddha and QOD
But,this doesnt seem to be working "properly" on Normalmapped entities...plz see these screens :
The position of the light is affecting the model's lighting[which is really cool] but the model is being lit even when the flashbeam is away from it...destroying the illusion of darkness.....Is it possible to fix this ? Or is there any setting for my model that i need to toggle to get it right ?Or has it got anything to do with the Specular map of my model I couldnt get the "Stencil Shadows" to work either...I did enable the option in the ini and I did try setting FSAA option to 0....but the shadow doesnt showup for my model[I did enable StencilShadows for it,and enabled "cast shadows" for the light in the editor and added the EnvironmentSetup entity,configured it as mentioned in RFFAQ] How di I get Stencil Shadows ?
Also,it'd be cool if there is a projection[decal] of a bitmap onto the walls [similar to the one we have in Doom 3's flashlight]...is this possible ?
- QuestOfDreams
- Site Admin
- Posts: 1520
- Joined: Sun Jul 03, 2005 11:12 pm
- Location: Austria
- Contact:
Code: Select all
update[()
{
self.ThinkTime = 0.0;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
PositionToPlayer(0, 30, 10, true,true);
self.ideal_pitch = -(self.camera_pitch);
ChangePitch();
}]
Code: Select all
update[()
{
self.ThinkTime = 0.0;
PositionToPlayer(0, 30, 10, true, false);
self.ideal_yaw = self.player_yaw + 3.1415;
ChangeYaw();
self.ideal_pitch = -self.camera_pitch;
ChangePitch();
}]
-
- Posts: 320
- Joined: Sat Mar 11, 2006 11:41 pm
Flashlight vertical?
This script allows the flashlight to work horizontally. How would one make it work vertically as well, to look everywhere the player does?
{
Spawn[ ()
{
SetNoCollision();
FadeOut(0, 0);
LowLevel("Update");
//MoveForward("Idle", 10000, 10000, "");
}]
Update[ ()
{
MatchPlayerAngles();
PositionToPlayer(0, 0, 0);
PositionToPlayer(0, 0, GetCollideDistance("Bip01", 0, 0, 500000)-20, true);
RestartOrder();
}]
}
I have also tried the script below and it produced no light at all:
{
Spawn[()
{
LowLevel("setup");
}]
setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;
self.think = "update";
}]
update[()
{
self.ThinkTime = 0.0;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
PositionToPlayer(0, 30, 10, true);
self.ideal_pitch = -(self.camera_pitch);
ChangePitch();
}]
}
Can someone please shed some light on the subject.
Get it?
Light.
It was a joke I say.
I kill me!!! Hah!!!!!!!!!
{
Spawn[ ()
{
SetNoCollision();
FadeOut(0, 0);
LowLevel("Update");
//MoveForward("Idle", 10000, 10000, "");
}]
Update[ ()
{
MatchPlayerAngles();
PositionToPlayer(0, 0, 0);
PositionToPlayer(0, 0, GetCollideDistance("Bip01", 0, 0, 500000)-20, true);
RestartOrder();
}]
}
I have also tried the script below and it produced no light at all:
{
Spawn[()
{
LowLevel("setup");
}]
setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;
self.think = "update";
}]
update[()
{
self.ThinkTime = 0.0;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
PositionToPlayer(0, 30, 10, true);
self.ideal_pitch = -(self.camera_pitch);
ChangePitch();
}]
}
Can someone please shed some light on the subject.
Get it?
Light.
It was a joke I say.
I kill me!!! Hah!!!!!!!!!
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.
I can't get the light to move vertically either. I tried both the dynamic light and the dSpotLight...
Code: Select all
{
Spawn[()
{
Console(true);
Gravity(false);
LowLevel("Setup");
}]
Setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed=100000;
self.pitch_speed=100000;
self.think="ShineOn";
}]
ShineOn[()
{
self.ThinkTime = 0.0;
PositionToPlayer(0,20,300,true,false);
self.ideal_yaw=self.player_yaw + 3.1415;
ChangeYaw();
self.ideal_pitch = -self.camera_pitch;
ChangePitch();
}]
}
I should add that using debug(self.current_pitch) reveals that the flashlight actor is in fact changing its pitch, but the attached D-light's pitch won't rotate with it. Horizontally, the light rotates fine, but vertically, it's as if the pitch of dynamic lights cannot be dynamically altered... ?
Since Zen, at one point, had this working, did something change in the code for 075 which could have affected this?
Since Zen, at one point, had this working, did something change in the code for 075 which could have affected this?
You mean of the DLight itself? It is an omni light, it does not need to have it's rotation changed to work, it shines in all directions.Ransom wrote:I should add that using debug(self.current_pitch) reveals that the flashlight actor is in fact changing its pitch, but the attached D-light's pitch won't rotate with it. Horizontally, the light rotates fine, but vertically, it's as if the pitch of dynamic lights cannot be dynamically altered... ?
Since Zen, at one point, had this working, did something change in the code for 075 which could have affected this?
RF2 site: http://realityfactory2.sourceforge.net/
RF2 tasks: http://sourceforge.net/pm/?group_id=179085
RF2 tasks: http://sourceforge.net/pm/?group_id=179085
- QuestOfDreams
- Site Admin
- Posts: 1520
- Joined: Sun Jul 03, 2005 11:12 pm
- Location: Austria
- Contact:
No, he means the DSpotlight entity
I've looked into this issue again and found out that it depends on the actor file you are using. If you use for example the Xanibot3.act it works fine, if you use the proj.act it doesn't work. The reason for this is that the root bones of the actors have a different initial rotation. So with the wrong actor the spotlight's cone will rotate around its symmetric axis, which you can't see.
I think I have some code now, which allows you to compensate this effect by giving the spotlight entity an initial rotation (this currently doesn't work). Will be in the next release...
I've looked into this issue again and found out that it depends on the actor file you are using. If you use for example the Xanibot3.act it works fine, if you use the proj.act it doesn't work. The reason for this is that the root bones of the actors have a different initial rotation. So with the wrong actor the spotlight's cone will rotate around its symmetric axis, which you can't see.
I think I have some code now, which allows you to compensate this effect by giving the spotlight entity an initial rotation (this currently doesn't work). Will be in the next release...
Oh, sorry about that! I got confused because the original version used a point light not a spotlight and I havn't been following the changes since then.QuestOfDreams wrote:No, he means the DSpotlight entity
RF2 site: http://realityfactory2.sourceforge.net/
RF2 tasks: http://sourceforge.net/pm/?group_id=179085
RF2 tasks: http://sourceforge.net/pm/?group_id=179085