Posted By: Blobfist
sharing shade-c EVO flashlight - 05/02/18 20:05
I have been playing around with this for a while and finally figured out how to make an functioning flashlight with shade-c EVO
Behold:
To use, after setting up shade-c EVO (which I presume you did, otherwise you wouldn't be interested in having a flashlight using shade-c EVO), simply create an empty entity in your Player action/function:
Or simply place "hero_flashlight()" in wed somewhere.
With F you can switch the flashlight on and off, with a nice "click" sound if you want to.
Behold:
Code:
///////////////////////////////////////////////////////////////////// SOUND* click = "click.wav"; ///////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------- // Flashlight //-------------------------------------------------------------------- var flashlighton = 0; function attach_light(ENTITY* flashlight) { if(flashlight) { if(flashlighton == 1) { vec_set(flashlight.x, camera.x); flashlight.z = camera.z; flashlight.pan = camera.pan; flashlight.tilt = camera.tilt; sc_light_update(flashlight); } } } /////////////////////////////////////////////////////////////////////////////// action hero_flashlight() { var lightcreated = 0; wait(-1); set(my,INVISIBLE|PASSABLE); wait(1); ENTITY* flashlight = NULL; while(heroEnt.health>0) { if(key_f) { if(flashlighton == 0){flashlighton = 1;} else{flashlighton = 0;} while(key_f) { if(flashlight){attach_light(flashlight);} wait(1); } } ////////// if(flashlighton == 1 && lightcreated == 0) { snd_play(click,100,0); lightcreated = 1; wait(3); flashlight = sc_light_create(vector(camera.x, camera.y, camera.z), 1000, vector(50,25,0), SC_LIGHT_SPOT | SC_LIGHT_SPECULAR | SC_LIGHT_SHADOW , vector(0, -25, 0), 45); wait(1); } if(flashlighton == 0) { if(lightcreated == 1) {lightcreated = 0;/*snd_play(click,100,0);*/} sc_light_remove(flashlight); flashlight = NULL; } if(flashlight){attach_light(flashlight);} wait(1); } wait(1); lightcreated = 0; flashlighton = 0; sc_light_remove(flashlight); flashlight = NULL; }
To use, after setting up shade-c EVO (which I presume you did, otherwise you wouldn't be interested in having a flashlight using shade-c EVO), simply create an empty entity in your Player action/function:
Code:
ent_create(NULL, camera.x, hero_flashlight);
Or simply place "hero_flashlight()" in wed somewhere.
With F you can switch the flashlight on and off, with a nice "click" sound if you want to.