Inside3D tutorials.

Inside3D
 • Front Page
 • Articles
 • Downloads
 • Forums
 • Hosting
 • Help Wanted
 • Interviews
 • Reviews
 • Staff

 
Allied Sites
 - AI Cafe
 - Bot Epidemic
 - Dark Places
 - Flat Earth
 - FrikBot
 - Ghoulish Art
 - Kilbert3D
 - Quake Info Pool
 - QSG: Quake Standards
 - Rusted Fork
 - Stroggs Gone Mad
 - More...
 
Quake
 - Getting Started
 - QuakeC Specs v1.0
 - QuakeC Tutorials
 - Quake Mod Index
 
Quake II
 - Getting Started
 - dll Sourcecode
 - Coding Tutorials
 
.dll Central
 - Getting Started
 - Learning
 - dll Primer
 - dll in C
 - dll in Delphi
 - Compilers
 
Jedi Knight
 - Getting Started
 - COG Specs
 - Sound Specs
 - Tutorials
 
Level Editing
 - Tutorials/Tips
 
 
Telefragged!!!
Created By: ShockMan
eMail: shockman@brutality.com
Difficulty Scale: Medium


Step 1
In this tutorial, you will learn how to make a FLASHLIGHT! Kewl stuff. So, like.. let's get started ;) First, create a file caled flash.qc, and place this QC code in it.
void() W_SetCurrentAmmo;void() flash_update =
{
        // The Player is dead so turn the Flashlight off
        if (self.owner.deadflag != DEAD_NO)
                self.effects = 0;

        // The Player is alive so turn On the Flashlight
        else                                
                self.effects = EF_DIMLIGHT;  

        // Find out which direction player facing
        makevectors (self.owner.v_angle);

        // Check if there is any things infront of the flashlight
        traceline (self.owner.origin , (self.owner.origin+(v_forward * 500)) , FALSE , self);

        // Set the Flashlight's position

        setorigin (self, trace_endpos+(v_forward * -5));

        // Repeat it in 0.02 seconds...
        self.nextthink = time + 0.02;
};

void() flash_on =
{
        // Make a new entity to hold the Flashlight
        local entity myflash;

        // spawn flash
        myflash = spawn ();
        myflash.movetype = MOVETYPE_NONE;
        myflash.solid = SOLID_NOT;
        // this uses the s_bubble.spr, if you want it to be completly
        // invisible you need to create a one pixel trancparent spirit
        // and use it here...
        setmodel (myflash, "progs/s_bubble.spr"); 
        setsize (myflash, '0 0 0', '0 0 0');

        // Wire Player And Flashlight Together
        myflash.owner = self;
        self.flash = myflash;
        
        // give the flash a Name And Make It Glow
        myflash.classname = "flash";
        myflash.effects = EF_DIMLIGHT;
        
        // Set Start Position
        makevectors (self.v_angle);
        traceline (self.origin , (self.origin+(v_forward * 500)) , FALSE , self);
        setorigin (myflash, trace_endpos);

        // Start Flashlight Update
        myflash.think = flash_update;
        myflash.nextthink = time + 0.02;
};


void () flash_toggle =
{
        // If Off, Turn On
        if (self.flash_flag == FALSE)
        {       
                self.flash_flag = TRUE;
                flash_on();
        }

        // If On, Turn Off
        else
        {
                self.flash_flag = FALSE;
                W_SetCurrentAmmo ();
                self.flash.think = SUB_Remove;
                self.flash.nextthink = time + 0.1;
        }
};


Step 2
Ok, now open up defs.qc and add to the end:

.float flash_flag; // On/off for the flashlight
.entity flash;   // flash entity


Step 3
then open up weapons.qc and find ImpulseCommands and before:

self.impulse = 0;

add:

if (self.impulse == 30) 
        flash_toggle();


Step 4
Now, what we have to do, is to add the flash.qc to the progs.scr file. Do that by adding flash.qc in under defs.qc.


Step 5
Now complie the patch and run it, type impulse 30 at the consol and there you go... cool, huh? =)






The Inside3D content and design is copyrighted by the Inside3D team, and may not be re-produced or copied without proper consent. All rights reserved. Any work credited to any author not part of InsideQC is copyrighted by that author. If you have any feedback, suggestions or flames please send it in to the author. Inside3D is hosted by telefragged and the design was originated by project-9.