Frictional Games Forum (read-only)

Full Version: [SCRIPT / MDL ED] Replace an entity / Creating a lamp
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: ny8t5j.jpg]

I have been trying to make a sword start to glow while you're holding it in your hands. I have created two entities in the model editor, a regular sword, and a glowing one (with billboards etc). The main problem is to change the regular sword into a glowing one without dropping the sword to the ground. I have so far not found anything helpful in the "Engine scripts", and therefore asking you if you know any good methods to replace an entity with another one. If it's not possible to replace an entity with another one with Engine scripts, please tell me.

Another method I was thinking of was creating a grabbable sword-lamp (a sword entity with lamp-settings). When the sword is lit - the billboards appears and etc. I'm not sure if that will work tho, and even if it does, I'm not used to create lamps and do not really know how to do. I have been trying to connect the billboards to the sword, but I can't get it to work - nothing happens when you lit/unlit the sword. So, if you know how to create a lamp, or if it exists any custom-lamp-creating tutorials, please post a comment Shy
There might be a way to replace the entity. I'd rather not type it all out, so I'll try out some ideas I've had.
Got it working. Here's what you do.


In the model editor, create your entity with a light attached to its body. Make sure this light's name is "PointLight_1". In your map script, add these two following two lines to OnStart().

PHP Code:
// in this script, your sword is named "sword_light_1"
void OnStart()
{
    
FadeLightTo("sword_light_1_PointLight_1"0001, -11.5f);
    
SetEntityPlayerInteractCallback("sword_light_1""PickSword"false);


Next, add this function to the main body of your script

PHP Code:
void PickSword(string &in entity)
{
    
FadeLightTo(entity+"_PointLight_1"1111, -11.5f); 
    
SwordPickLoop(entity);
}
void SwordPickLoop(string &in timer)
{
    if(!
GetPropIsInteractedWith(timer))    
    {
        
FadeLightTo(timer+"_PointLight_1"0001, -11.5f);
           return;
     }
     
AddTimer(timer0.0166f"SwordPickLoop");


Then, you're good to go! The sword's light will fade in/out over 1.5 seconds when the player picks it up or drops it. Enjoy.
(03-06-2012, 11:17 PM)palistov Wrote: [ -> ]Then, you're good to go! The sword's light will fade in/out over 1.5 seconds when the player picks it up or drops it. Enjoy.
.
You are awesome, thanks! Shy