Page 1 of 1
Useable Torch problems! SOLVED
Posted: Wed Jun 20, 2012 10:53 pm
by EvilDraggie
Hello RF-folks!
Together with my mate ive just started work on a horror-game in RF.
Now for added atmosphere we want to have the following:
Torches that can be picked up, used on command after wich a torch burns for say: 20 minutes. After that it becomes useless (and ofcourse dissapears from your inventory).
Flashlight version
I have been tinkering with the flashlight scripts and made a working torch (flame and light effects) however aside from the effects it cant be picked up or used for a time.
I do have seen a topic on the forums here, wich used a different flashlight script wich was adapted to be key-triggered and wich would be rendered useless after a while. However i have not been able to implement this system so far.
And i wonder if a flashlight can be made an Attribute (like weapon pickups etc)
The topic can be found here:
viewtopic.php?f=8&t=490&hilit=torch
The flashlight can be found here:
viewtopic.php?t=242
Weapon version
So i got the idea to make it a weapon. I have modified the flamethrower to fire for 10 seconds before depleting. However the light effect (wich is linked to the flamethrower's projectile) stays at the spot where you fired the weapon. I tried linking the effect to the Player-actor's weapon bone but this had no effect.
The weapon version would work for me in terms of pickup, use, drop systems etc, but the effects hardly work. The Flashlight version looks promising effect and use wise, but how do i do the pickup and drop? Plus RF crashes everytime i try to use that modified flashlight script.
If any of you (seasoned?) RF-ers could help this newb out, thanks!
Re: Useable Torch problems!
Posted: Mon Jun 25, 2012 2:24 pm
by QuestOfDreams
There are many ways to achieve a goal in RF. So the first thing to do is to clear up, what exactly it is you want to achieve:
Do you want to use a spotlight or is a point light sufficient?
In case of a spotlight, does it need to adjust to the yaw only or the yaw and the pitch (when looking up/down)?
Is the torch to be represented by an actor or just the light effect?
Does it have to work in 1st and 3rd person view or just for one of them?
Does it have to appear in your inventory?
Should it be activated by picking it up, selecting it from the inventory, or pressing a special key?
Re: Useable Torch problems!
Posted: Mon Jun 25, 2012 5:09 pm
by Agentbromsnor
QuestOfDreams wrote:There are many ways to achieve a goal in RF. So the first thing to do is to clear up, what exactly it is you want to achieve:
Do you want to use a spotlight or is a point light sufficient?
In case of a spotlight, does it need to adjust to the yaw only or the yaw and the pitch (when looking up/down)?
Is the torch to be represented by an actor or just the light effect?
Does it have to work in 1st and 3rd person view or just for one of them?
Does it have to appear in your inventory?
Should it be activated by picking it up, selecting it from the inventory, or pressing a special key?
It has to be a 'realistic' torch, so the light is emitted from the entity, and thus around the player (no spotlight, think more along the lines of the lantern in Amnesia: The Dark Decent). The torch's model is just for visual representation.
Our game is going to be first person, so it mainly has to look good in first person.
The way of activating is done by grabbing the torch of the wall (so by pressing use), thus effectively swapping a static light for a dynamic light around the player
Our game is going to have strong survival-elements, so the torch should just be held in-hand by the player like a weapon. We're still working on the idea to use the torch as a melee-weapon as well, but we want the torch to first work as a pick-up light.
What is the best way to accomplish this?
Re: Useable Torch problems!
Posted: Tue Jun 26, 2012 11:06 pm
by QuestOfDreams
OK, this seems a bit tricky. I've come up with something but I'm not sure if it's the best way to do it.
For this solution you need
- a Pawn representing the torch with a bone to attach the light/flame effect to
- a Flame entity for the initial light/flame effect
- a predefined explosion consisting of a predefined light/spray effect for the timed light/flame effect
- a LogicGate entity to switch between the 2 when picking up the torch
Example setup:
pawn.ini
Code: Select all
[torch]
actorname = torch.act
actorrotation = 0 0 0
actorscale = 1
fillcolor = 155 155 155
ambientcolor = 255 255 255
subjecttogravity = false
boundingboxanimation = nocollide
shadowsize = 0
effect.ini
Code: Select all
[torchspray]
type = spray
bitmapname = flame03.bmp
alphamapname = a_flame.bmp
angles = 0 0 0
colormax = 255 255 255
colormaxalpha = 255
colormin = 255 255 255
colorminalpha = 255
sourcevariance = 0
destvariance = 4
gravity = 0 10 0
maxscale = 0.3
minscale = 0.2
maxspeed = 40
minspeed = 15
maxunitlife = 0.3
minunitlife = 0.15
particlecreationrate = 0.015
totallife = 20
bounce = false
[torchlight]
type = light
colormax = 255 255 232
colormin = 255 217 217
radiusmax = 190
radiusmin = 175
intensity = 1
totallife = 20
explosion.ini
Code: Select all
[torch]
effect0 = torchlight
delay0 = 0
offset0 = 0 0 0
effect1 = torchspray
delay1 = 0
offset1 = 0 0 0
Flame entity
Code: Select all
AlphaName a_flame.bmp
Angles 0 0 -90
BmpName flame03.bmp
BoneName joint2
ColorMax Value 255 255 255
ColorMin 255 255 255
DestVariance 4
EntityName torch
GCastShadows True
GColorMax 255 255 232
GColorMin 255 217 217
GIntensity 1.0
GRadiusMax 190.0
GRadiusMin 175.0
Gravity 0.0 10.0 0.0
MaxScale 0.3
MaxSpeed 40.0
MaxUnitLife 0.3
MinScale 0.2
MinSpeed 15.0
MinUnitLife 0.15
Model <null>
origin -192 56 56
ParticleCreateRate 0.015
Scale 1
SourceVariance 0
szEntityName
TotalLife 0
TriggerName flamelogic
UseWind False
LogicGate entity
Code: Select all
Amount 0
Delay 0
origin -189 0 8
szEntityName flamelogic
Trigger1Name flametrigger
Trigger2Name
Type 2
Pawn entity
Code: Select all
Angle 0 0 0
ChangeMaterial
ConvOrder
ConvScriptName
HideFromRadar True
origin -216 16 8
PawnType torch
ScriptName torch.s
SpawnOrder Spawn
SpawnPoint
SpawnTrigger
szEntityName torch
Pawn script (torch.s)
Code: Select all
{
DROP_KEY[38] // L
USE_KEY[22] // U
USE_RANGE[80]
Spawn[()
{
//Console(true);
Scale(0.9);
Gravity(false);
SetNoCollision();
LowLevel("pickup");
}]
pickup[()
{
if(self.player_range < USE_RANGE)
{
if(self.key_pressed = USE_KEY)
{
self.yaw_speed = 1000;
self.pitch_speed = 1000;
SetEventState("flametrigger", true);
AddExplosion("torch", "joint2", 0, 0, 0);
self.think = "follow_player";
}
}
}]
follow_player[()
{
self.ThinkTime = 0.0;
if(self.key_pressed = DROP_KEY)
{
Gravity(true);
self.ideal_pitch = 1.35;
self.think = "drop";
}
// do some "clever" positioning for 1st person view
PositionToPlayer(8, 45 + self.camera_pitch * 15, 17 + self.camera_pitch * 15, true, false);
self.ideal_pitch = -self.camera_pitch * 0.5; // rotate a bit
self.ideal_yaw = self.player_yaw;
ChangeYaw();
ChangePitch();
}]
drop[()
{
self.ThinkTime = 0.1;
self.ideal_pitch = 1.35;
ChangePitch();
}]
}
Torch actor I've quickly created for testing:
Re: Useable Torch problems!
Posted: Tue Jun 26, 2012 11:26 pm
by EvilDraggie
Woah, thanks so much for the info!
Love it when people really get into helping others <3
I'm gonna play around with this idea, see if i can make something nice out of this.
Re: Useable Torch problems!
Posted: Thu Jun 28, 2012 10:19 pm
by EvilDraggie
Well, seems i got everything working.
Only wierd thing is, is that the keycodes 22, 39 do not resemble U & L but rather P and something else.
I set them to 19 & 20 now wich is Y and U for drop and pickup.
can it be the keycodes differ from pc to pc?
Re: Useable Torch problems!
Posted: Thu Jun 28, 2012 10:53 pm
by QuestOfDreams
Oops, I guess that's because I tested this with the current dev version of RF where I've completely replaced the input system with a new one.
Keycodes should be the same on all computers with the same keyboard layout (German and English keyboards have swapped Z/Y keys for example)
Re: Useable Torch problems! SOLVED
Posted: Tue Jul 10, 2012 10:50 am
by Agentbromsnor
Now I'm curious!
Are there more differences from your version compared to ours?
Re: Useable Torch problems! SOLVED
Posted: Tue Jul 10, 2012 12:05 pm
by Allanon
Agentbromsnor wrote:Now I'm curious!
Are there more differences from your version compared to ours?
Check out his post in the programming forum:
viewtopic.php?f=9&t=3597