1 registered members (AndrewAMD),
1,454
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Handles?
#200030
04/02/08 09:45
04/02/08 09:45
|
Joined: Oct 2007
Posts: 116
sydan
OP
Member
|
OP
Member
Joined: Oct 2007
Posts: 116
|
I've read the help files and tried to work it out but I don't really get handles, being a bit of a newbie. Can anyone give a simple explanation?
Last edited by sydan; 04/02/08 09:45.
For some reason, my ambition always seems to beat my ability.
|
|
|
Re: Handles?
[Re: sydan]
#200134
04/02/08 18:02
04/02/08 18:02
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
A handle is something very simple, it's just a number identifying a certain engine object, like a view, a panel or an entity. Every engine object got such a handle (i.e.) and it consists of two components.
1. A simple number starting with 1 and being incremented by one for every new entity. 2. A number identifying the type of the engine object, e.g. panel or entity. These two numbers are simply binary added, i.e. handle = entity type | number. I f you don't get the point here, that's not so important in the beginning.
What you should know is: 1. A handle identifies any engine object. 2. A handle is even valid after a game load. 3. Contrary to handles pointers loose their validity after a game load. 4. You can retrieve the pointer to an engine object if you got the handle by using ptr_for_handle(). 5. You can retrive the handle of any object by using the handle() instruction.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Handles?
[Re: Uhrwerk]
#200135
04/02/08 18:23
04/02/08 18:23
|
Joined: Oct 2007
Posts: 116
sydan
OP
Member
|
OP
Member
Joined: Oct 2007
Posts: 116
|
Okay. You've solved all of my problems in one. I can see the power of handles, If had known what they were before I would have been able to do alot more with my games! So their simply an ID number for each entity. I wanted to know to see if I could use them to attach weapons and other objects to individual entities, which could be easily done with handles.
Thank you very much for your help! Sydan
>>>
PS if you have time could you give me a quick summary of how to use them, or does the help files do that well enough? If so don't worry about it.
For some reason, my ambition always seems to beat my ability.
|
|
|
Re: Handles?
[Re: sydan]
#200142
04/02/08 19:26
04/02/08 19:26
|
Joined: Oct 2006
Posts: 106
i_program_games
Member
|
Member
Joined: Oct 2006
Posts: 106
|
Here is an example of extreme handle use this code allows you to create an unlimited amount of weapons. However, this is C-Script and not lite-c. I will be changing it in the near future.
///////////////////////////////////////////////////////////////////////////// //WeapActUtil.wdl // //Desc: header file used to assist in making guns // contains some "standard" functions for // guns and helper functions for making them // /////////////////////////////////////////////////////////////////////////////
//NOTE //Fix these useless defines //define maxAmmo = skill6; define weaponMuzzleX = skill1; define weaponMuzzleY = skill2; define weaponMuzzleZ = skill3; define shotScale = skill4; define shotSkin = skill5; define ammoCount=skill6; define shotSpeedX = skill8; define shotSpeedY = skill9; define shotSpeedZ = skill10; //define weaponDamage = skill16; define hsMuzzleFlash = skill18; //define hfMuzzleFlash = skill19; //new define used to store a handle for our muzzle flash function define muzzleLightRed = skill20; define muzzleLightGreen = skill21; define muzzleLightBlue = skill22; define muzzleLightRange = skill23; define hfMuzzleFlashAction = skill24; //new define used to store a handle for our flashup action define hsGunshotModel = skill25; //new define used to store a handle for our fireball define hfGunshotAction = skill26; //new define used to store a handle for our flashup action //define roundsFired = skill27; define hfGunfireSound = skill28; define hfGunfire = skill29; define hfGunshell = skill30; define hfHitPointEffect = skill31; define shellMap = skill32; //define gunEmptySound = skill33; define shotLightRed = skill34; define shotLightGreen = skill35; define shotLightBlue = skill36; define shotLightRange = skill37; define hfShotHitSound = skill38; define hfHitExplosion = skill39; //define hOwner = skill40;
//var vecWeaponMuzzle[3]; var scatterNumber=6;
action* pfMuzzleFlashAction; //points to your Flashup function action* pfFireModelAction; action* pfGunSound; action* pfGunfire; action* pfGunShell; action* pfHitPointEffect; //NOTE //Add this along with the function //action* pfEmptySound; action* pfShotHitSound; action* pfHitExplosion;
string* psMuzzleFlash; //string for our gun flash string* psGunshotModel; //string for our fireball
//NOTE //Was used by hitPointEffect commented out below //string* psHitSparkModel;
//NOTE //Do something with this? //string* psShotHitBmap;
bmap* pShellBmap;
function setHitPoint(nTraceRange); function fireModel(); function fireScatter(); //function FireLASER(); function emit2dShell(); //function GunShellMDL(); //function hitPointEffect(); function playSoundOnce(sndString,volume,balance); function scatterShot(nShotSpread,nScatterNumber); function set2dShotShell(bmapShell,fShell); function setShotLight(nRed,nGreen,nBlue,nRange); function setGunfire(fGunfire); //function setGunshot(fGunShotMDL,fGunShotAction); function setGunshot(sGunShotMDL,fGunShotAction,nShotScale,nShotSkin); function setGunfireSound(fGunSound); function setHitExplosion(fHitExplosion); function setHitPointEffect(fhitPointEffect); function setHitPointSound(fHitPtSound); function setMuzzleFlash(sMuzzleFlash,standardMuzzleFlash); function setMuzzleLight(nRed,nGreen,nBlue,nRange); function setShotSpeed(nSpeedX,nSpeedY,nSpeedZ); //function standardExplosion(); function modelShotAction(); function standardShotEvent(); function standardVertexShot(); function fireFromVertex(); function setWeaponPointers(); function fireWeapon(); function fireTrace(); function objectToMuzzle(); function moveShot(); function bullet_hole(); ///////////////////////////////////////////////////////////////////////////// //function setHitPoint(nTraceRange); // //Desc: function used to set the target variable to place impact decals // (bullet holes, char marks, blood stains etc. on the wall where a modle is facing) // //Use: Use in a projectiles event // // Use this function like this: // // if(event_type == event_block //collided with a surface of the level // || event_type == event_stuck) //caught in the corner during a move instruction // { // wait(1);// added to avoid Dangerous instruction // exclusive_entity; // terminate other actions, to stop moving // my.event = null; // // setHitPoint(100);//used to set the target variable to // //place pit map on wall at hit point // // //target is now set so we can do this // create(psShotHitBMap,target,bullet_hole); // } // // Note: This function is used by standardShotEvent(); // /////////////////////////////////////////////////////////////////////////////
function setHitPoint(nTraceRange) { vec_set(temp,my.x);//store our projectiles vector
temp.x += (cos(my.pan)*nTraceRange); //calculate x coordinate nTraceRange quants in front of projectile temp.y += (sin(my.pan)*nTraceRange);// calculate y coordinate nTraceRange quants in front of projectile temp.z += (tan(my.tilt)*nTraceRange);// calculate z coordinate nTraceRange quants in front of projectile //set trace mode trace_mode = ignore_me + ignore_passable + activate_shoot + scan_texture; //this sets the target variable to the surface hit by the trace trace(my.x,temp); // subtract vertical distance to ground }
///////////////////////////////////////////////////////////////////////////// //function fireModel(); // //Desc: function used to fire models // //Use: my.hsGunshotModel and my.hfFireModelAction MUST be set prior to // using this function. // // Use this function like this: // // setGunshot(yourModel,ModelFunction);//sets my.hsGunshotModel and my.hfGunshotAction // setGunfire(fireModel);//set our GunFire function // /////////////////////////////////////////////////////////////////////////////
function fireModel() {
//set the global pointer psGunshotModel to our hsGunshotModel psGunshotModel = ptr_for_handle(my.hsGunshotModel);
//set the global pointer pfGunShotAction to our hfGunshotAction pfFireModelAction = ptr_for_handle(my.hfGunshotAction);
//create the model being fired with the appropriate action //this essentially fires the model from the gun
ent_create(psGunshotModel,my.weaponMuzzleX,pfFireModelAction); }
///////////////////////////////////////////////////////////////////////////// //function fireScatter(); // //Desc: function used to fire "invisible bullets" shot gun style // //Use: setGunfire(fireScatter);//set our GunFire function // /////////////////////////////////////////////////////////////////////////////
function fireScatter() { scatterShot(2,scatterNumber); }
///////////////////////////////////////////////////////////////////////////// //function gunGrassFunction(); // //Desc: generic function for spitting out 2d shells // this is particle_gunbrass from the template // files with a few changes // //Use: // With helper function: SetGunShell(YourBMAP,emit2dShell); // Without helper function: my.hfGunshell = handle(emit2dShell); // ///////////////////////////////////////////////////////////////////////////// function emit2dShell() { if(my_age == 0) { my_speed.x = random(6)-6; // -3 to 3 my_speed.y = random(6)-6; // -3 to 3 my_speed.z = random(3)+8; // 8 to 11
my_size = 150; my_map = pShellBmap;//gbrass_map; my_color.red = 245; my_color.green = 200; my_color.blue = 80;
return; }
if(my_speed.z > -16) { my_speed.z -= 2 * time; }
// Remove old particles if(my_age >= 35) { my_action = null; } }
///////////////////////////////////////////////////////////////////////////// //function hitPointEffect(); // //Desc: function used to create and effect when the bullet hits a wall // //Use: //Without helper function: my.hfHitPointEffect = handle(hitPointEffect); //With helper function: setHitPointEffect(hitPointEffect);//set our Hit Point Effect // ///////////////////////////////////////////////////////////////////////////// //NOTE /* This appears to be a stand alone function as their is a handler capable of storing individual hitPointEffect functions. Think this out. function hitPointEffect() { create(psShotHitBMap,target,bullet_hole); create(psHitSparkModel,target,fHitSpark); emit(10,target,fHitSmoke); //NOTE //Need to use a general particle function //emit(10,target,particle_scatter); //NOTE //Need to create a general gib function //create(<smallGib.mdl>, target, _gib_action); // create bullet hole } */ ///////////////////////////////////////////////////////////////////////////// //function playSoundOnce(sndString,volume,balance); // //Desc: helper function used to stop sounds from overlapping // //Use: playSoundOnce(gun_click,50,0); // /////////////////////////////////////////////////////////////////////////////
function playSoundOnce(sndString,volume,balance) { var hSnd=0; if(snd_playing(hSnd)) { return; } hSnd = snd_play(sndString,volume,balance); }//set our sounds volume etc. }
///////////////////////////////////////////////////////////////////////////// //function scatterShot(nShotSpread,nScatterNumber); // //Desc: helper function used to simulate a shot gun // //Use: scatterShot(2,scatterNumber); // /////////////////////////////////////////////////////////////////////////////
function scatterShot(nShotSpread,nScatterNumber) { var vecTarget[3]=0; var shotCount=0; var scatterRand=160;//scatter width var scatterHalfRand=80; // set vecTarget vecTarget.x = nShotSpread*my.shotSpeedX + my.weaponMuzzleX; vecTarget.y = nShotSpread*my.shotSpeedY + my.weaponMuzzleY; vecTarget.z = nShotSpread*my.shotSpeedZ + my.weaponMuzzleZ;
//vec_set(_gun_shot_temp.x, vecTarget.x); // save base vecTarget
while(shotCount < nScatterNumber) { // offset each shot by a random amount vecTarget.x += random(scatterRand)-scatterHalfRand; vecTarget.y += random(scatterRand)-scatterHalfRand; vecTarget.z += random(scatterRand)-scatterHalfRand; /* vecTarget.x = _gun_shot_temp.x + (random(scatterRand)-scatterHalfRand); vecTarget.y = _gun_shot_temp.y + (random(scatterRand)-scatterHalfRand); vecTarget.z = _gun_shot_temp.z + (random(scatterRand)-scatterHalfRand); */ fireTrace(); shotCount += 1; }
//vec_set(vecTarget.x, _gun_shot_temp.x); // restore vecTarget
}
///////////////////////////////////////////////////////////////////////////// //function set2dShotShell(bmapShell,fShell); // //Desc: function used to set the model to be used for the funs shot // along with its action. The first argument is the model the second // is its action // // //Use: // // setGunshot(Your_mdl,Your_model_action);//set our model to shoot along // //with it's action /////////////////////////////////////////////////////////////////////////////
function set2dShotShell(bmapShell,fShell) { my.shellMap = handle(bmapShell); my.hfGunshell = handle(fShell); }
///////////////////////////////////////////////////////////////////////////// //function setShotLight(nRed,nGreen,nBlue,nRange); // //Desc: function used to set the light of the bullet // that is emitted when the gun fires // //Use: //setShotLight(255,0,0,100);//set the light to red with a radius of 100 // /////////////////////////////////////////////////////////////////////////////
function setShotLight(nRed,nGreen,nBlue,nRange) { my.shotLightRed = nRed; my.shotLightGreen = nGreen; my.shotLightBlue = nBlue; my.shotLightRange = nRange; }
///////////////////////////////////////////////////////////////////////////// //function setGunfire(fGunfire); // //Desc: helper function used to store a handle for our gun fire function // //Use: setGunfire(YourGunFireFunction); // /////////////////////////////////////////////////////////////////////////////
function setGunfire(fGunfire) { my.hfGunfire = handle(fGunfire); }
///////////////////////////////////////////////////////////////////////////// //function setGunshot(fGunShotMDL,fGunShotAction); // //Desc: function used to set the model to be used for the guns shot // along with its action. The first argument is the model the second // is its action // // //Use: // // setGunshot(Your_mdl,Your_model_action);//set our model to shoot along // //with it's action /////////////////////////////////////////////////////////////////////////////
function setGunshot(sGunShotMDL,fGunShotAction,nShotScale,nShotSkin) { my.hsGunshotModel = handle(sGunShotMDL); my.hfGunshotAction = handle(fGunShotAction); my.shotScale=nShotScale; my.shotSkin=nShotSkin; }
///////////////////////////////////////////////////////////////////////////// //function setGunfireSound(fGunSound); // //Desc: helper function used to store a handle for our gun sound function // //Use: setGunfireSound(YourGunSoundFunction); // /////////////////////////////////////////////////////////////////////////////
function setGunfireSound(fGunSound) { my.hfGunfireSound = handle(fGunSound); }
///////////////////////////////////////////////////////////////////////////// //function setHitExplosion(fHitExplosion); // //Desc: helper function used to store a handle for our hit explosion function // //Use: setHitExplosion(hitPointEffectFunction); // /////////////////////////////////////////////////////////////////////////////
function setHitExplosion(fHitExplosion) { my.hfHitExplosion = handle(fHitExplosion); }
///////////////////////////////////////////////////////////////////////////// //function setHitPointEffect(fhitPointEffect); // //Desc: helper function used to store a handle for our hit point effect function // //Use: setHitPointEffect(hitPointEffectFunction); // ///////////////////////////////////////////////////////////////////////////// function setHitPointEffect(fhitPointEffect) { my.hfHitPointEffect = handle(fhitPointEffect); }
///////////////////////////////////////////////////////////////////////////// //function setHitPointSound(fHitPtSound); // //Desc: // //Use: // ///////////////////////////////////////////////////////////////////////////// function setHitPointSound(fHitPtSound) { my.hfShotHitSound = handle(fHitPtSound); }
///////////////////////////////////////////////////////////////////////////// //function setMuzzleFlash(sMuzzleFlash); // //Desc: function used to set the model or sprite to be used for the muzzle flash // along with it's action. // // //Use: //Without helper function: my.sMuzzleFlash = handle(hitPointEffect); // //set our weapon's flash to a model or sprite and action //With helper function: setMuzzleFlash(myModelOrSprite,myMuzzleFlashAction); /////////////////////////////////////////////////////////////////////////////
function setMuzzleFlash(sMuzzleFlash,standardMuzzleFlash) { my.hsMuzzleFlash = handle(sMuzzleFlash); my.hfMuzzleFlashAction = handle(standardMuzzleFlash); }
///////////////////////////////////////////////////////////////////////////// //function setMuzzleLight(nRed,nGreen,nBlue,nRange); // //Desc: function used to set the light that is emitted when the gun fires // //Use: //setMuzzleLight(255,0,0,100);//set the light to red with a radius of 100 // ///////////////////////////////////////////////////////////////////////////// function setMuzzleLight(nRed,nGreen,nBlue,nRange) { my.muzzleLightRed = nRed; my.muzzleLightGreen = nGreen; my.muzzleLightBlue = nBlue; my.muzzleLightRange = nRange; }
///////////////////////////////////////////////////////////////////////////// //function setShotSpeed(); // //Desc: // //Use: // ///////////////////////////////////////////////////////////////////////////// function setShotSpeed(nSpeedX,nSpeedY,nSpeedZ) { my.shotSpeedX = nSpeedX; my.shotSpeedY = nSpeedY; my.shotSpeedZ = nSpeedZ; }
///////////////////////////////////////////////////////////////////////////// //function standardExplosion(); // //Desc: // //Use: // ///////////////////////////////////////////////////////////////////////////// function* pfExplosionSound; function 2dMorphExplosion(explodingEnt,bitMap,&scanVector,explosionSound) { var hfExplosionSound=0; hfExplosionSound=handle(explosionSound); pfExplosionSound=ptr_for_handle(hfExplosionSound); me=explodingEnt; ent_morph(me,bitMap); my.event=null; //my.facing=on; my.passable=on; my.material=mat_model; // //temp.pan=360; //temp.tilt=360; //temp.z=1000; proc_kill(1); wait(1); scan_entity (my.x, scanVector);
hfExplosionSound=pfExplosionSound();
vec_set(temp,camera.x); vec_sub(temp,my.x); vec_to_angle(my.pan,temp); // now MY looks at YOU
while(MY.CYCLE <= 17) { MY.CYCLE +=1;// TIME; waitt(1); }
while(snd_playing(hfExplosionSound)) { wait(1); }
ent_remove(me); }
function 2dMorphExplosionLight(bmapEntity,totalBmapFrames,lightUpDown,&vecColorChange) { me=bmapEntity; totalBmapFrames*=0.5; //my.lightrange=0; while(me) { if(my.cycle<totalBmapFrames) { my.lightrange+=lightUpDown; } else { my.lightrange-=lightUpDown; } my.red+=vecColorChange[0]; my.green+=vecColorChange[1]; my.blue+=vecColorChange[2]; waitt(1); //my.green-=7; //my.red-=7; } }
//function standardExplosion() //{ // breakpoint; /* var nint = 0;
MY.FACING = ON; // face the camera MY.NEAR = ON; MY.FLARE = ON; MY.PASSABLE = ON; // don't push the player through walls //MY.FRAME = 1; wait(1); */ //PLAY_ENTSOUND ME,explo_wham,1000; //MY.LIGHTRANGE += 500; //waitt(1); /* // use the new sprite animation while(nInt < 1000000) { wait(1); MY.LIGHTRANGE += 50; MY.LIGHTRED += 20 * TIME; // fade to red MY.LIGHTBLUE -= 20 * TIME; nInt+=1; //MY.FRAME += TIME; } waitt(16); */ //remove(ME); //} ///////////////////////////////////////////////////////////////////////////// //function modelShotAction(); // //Desc: // //Use: // /////////////////////////////////////////////////////////////////////////////
function modelShotAction() {
//set light values my.LIGHTRED = you.shotLightRed; my.LIGHTGREEN = you.shotLightGreen; my.LIGHTBLUE = you.shotLightBlue; my.lightrange = you.shotLightRange; my.scale_x=you.shotScale; my.scale_y=you.shotScale; my.scale_z=you.shotScale; my.skin=you.shotSkin;
//set event handler my.event = standardShotEvent;
//var vecDist[3]=0;
//vec_scale(my.scale_x,actor_scale); // use actor_scale
vec_set(my.shotSpeedX,you.shotSpeedX);
//my.flare = ON; //my.bright = ON;
objectToMuzzle();
moveShot();
}
function moveShot() { var MY_POS[3]=0; //events my.enable_block = ON; //Collision with a surface of the level during a move instruction. my.enable_entity = ON;//Collision with another entity during move. my.enable_stuck = ON; //Caught in a corner during move, unable to move further. my.facing = ON; // in case of 2d sprite //proc_kill(1); while(my.near != ON) { wait(1); // wait at the loop beginning, to let it appear at the start position
temp.x = my.shotSpeedX * time;//temp; temp.y = my.shotSpeedY * time;//temp; temp.z = my.shotSpeedZ * time;//temp;
ent_move(temp,nullvector); } }
///////////////////////////////////////////////////////////////////////////// //function standardShotEvent(); // //Desc: // //Use: // ///////////////////////////////////////////////////////////////////////////// //NOTE replace this function call embedded within other functions with //a handle to a shot event or something. Look as moveShot function standardShotEvent() { // check for all collision events if(event_type == event_block //collided with a surface of the level || event_type == event_stuck) //caught in the corner during a move instruction { /**/ wait(1);// added to avoid Dangerous instruction proc_kill(1); // terminate other actions, to stop moving my.event = null; //NOTE what is this? setHitPoint(100);//used to place hit point bit map if(pfHitExplosion) { pfHitExplosion(); }
if(pfHitPointEffect) { pfHitPointEffect(); } if(pfShotHitSound) { pfShotHitSound(); }
//emit(100,my.pos, particle_scatter); wait(1);
if(me){ent_remove(me);}
return; }
if(event_type == event_entity) //hit another entity during a move //run over by an entity with a higher push { if(pfHitExplosion) { pfHitExplosion(); }
if(pfHitPointEffect) { pfHitPointEffect(); } if(pfShotHitSound) { pfShotHitSound(); } wait(1);
if(me){ent_remove(me);}
return; //emit(100,my.pos, particle_sphere); //wait(1); //remove(me); }
if(me){ent_remove(me);}/**/ }
function standardVertexShot() { var vecDist[3]; SetWeaponPointers(); fireWeapon();
//vec_scale(my.scale_x,actor_scale); // use actor_scale
my.enable_block = ON; my.enable_entity = ON; my.enable_stuck = ON; my.enable_impact = ON; my.enable_push = ON; my.event = standardShotEvent;
my.facing = ON; // in case of fireball //my.pan = you.pan; /* my.LIGHTRED = 0; my.LIGHTGREEN = 0; my.LIGHTBLUE = 0; my.lightrange = 0;
my.ambient = 100;
//my.flare = ON; //my.bright = ON;
my.shotSpeedX = 40; my.shotSpeedY = 0; my.shotSpeedZ = 0; my.weaponDamage = damage;
*/ //my._FIREMODE = fire_mode; /**/ fireFromVertex();
while(1) { vecDist.x = my.shotSpeedX*time; vecDist.y = 0; vecDist.z = 0; ent_move (vecDist.x,nullvector); wait(1); }
}
function fireFromVertex() { var nVertice=0; vec_set(my.pan, player.pan); vec_for_vertex(temp,player,nVertice); // get XYZ position of vertex 248 vec_set(my.x, temp.x); }
function setWeaponPointers() { if(my.hfGunfireSound) { pfGunSound = ptr_for_handle(my.hfGunfireSound); }//my.hfGunfireSound); }//TESTCODE else { pfGunSound = null; } if(my.hsMuzzleFlash) { psMuzzleFlash = ptr_for_handle(my.hsMuzzleFlash); }//TESTCODE else { psMuzzleFlash = null; } if(my.hfMuzzleFlashAction) { pfMuzzleFlashAction = ptr_for_handle(my.hfMuzzleFlashAction); }//TESTCODE else { pfMuzzleFlashAction = null; } if(my.hfGunfire) { pfGunfire = ptr_for_handle(my.hfGunfire); } else { pfGunfire = null; }
if(my.hfHitExplosion) { pfHitExplosion = ptr_for_handle(my.hfHitExplosion); } else { pfHitExplosion = null; }
if(my.hfShotHitSound) { pfShotHitSound = ptr_for_handle(my.hfShotHitSound); } else { pfShotHitSound = null; } if(my.hfHitPointEffect) { pfHitPointEffect = ptr_for_handle(my.hfHitPointEffect); } else { pfHitPointEffect = null; }
if(my.hfGunshell) { pShellBmap = ptr_for_handle(my.shellMap); if(pShellBmap) { pfGunShell = ptr_for_handle(my.hfGunshell); } else { pfGunShell = null; } } }
//////////////////////////////////////////////////////
// Desc: select and handle shot type using 'fire_mode' // // needs gun_muzzle,shot_speed,damage,fire_mode // function fireWeapon() { //NOTE, maybe add a pointer to a "muzzle flash" function instead //this would also allow for using a vertex as opposed to a vector if(psMuzzleFlash && pfMuzzleFlashAction) { ent_create(psMuzzleFlash,my.x,pfMuzzleFlashAction); }//TESTCODE if(pfGunSound) { pfGunSound(); }
if(pfGunfire) { pfGunfire(); }
//NOTE, maybe add a pointer to an "emit shell" function instead //this would allow for 3d shells //if(my.hfGunShell && my.shellMap) //{ emit(1,my.weaponMuzzleX,pfGunShell); } }
///////////////////////////////////////////////////////////////////////////// //function fireTrace(); // //Desc: function used to fire "invisible bullets" shot gun style // //Use: setGunfire(fireTrace);//set our GunFire function // /////////////////////////////////////////////////////////////////////////////
function fireTrace() { var vecTarget[3]=0; vecTarget.x = 2*my.shotSpeedX + my.weaponMuzzleX; vecTarget.y = 2*my.shotSpeedY + my.weaponMuzzleY; vecTarget.z = 2*my.shotSpeedZ + my.weaponMuzzleZ;
trace_mode = ignore_me + ignore_passable + activate_shoot + scan_texture;//TESTING result = trace(my.weaponMuzzleX,vecTarget);
if(result > 0)// hit something? { if(pfHitPointEffect) { if(null==you) { pfHitPointEffect(); }// hit wall (not entity) } } }
function standardMuzzleFlash() { my.passable = on; my.flare=on; my.facing = on; my.LIGHTRED = you.muzzleLightRed; my.LIGHTGREEN = you.muzzleLightGreen; my.LIGHTBLUE = you.muzzleLightBlue; my.lightrange = you.muzzleLightRange; objectToMuzzle(); wait(2); ent_remove(me); }
function objectToMuzzle() { var offset=0; var direction[3]; //offset=110;//you.MAX_X - you.MIN_X;
direction.x=you.weaponMuzzleX; direction.y=0; direction.z=0;// = 100, 0, 0; // direction, pointing straight eastwards in the XYZ coordinate system //breakpoint;// vec_rotate(direction,you.pan); direction.x+=you.x; direction.y+=you.y; direction.z+=you.z;//+=you.z; vec_set(my.x,direction.x); vec_set(my.pan,you.pan); }
var bullet_hole_index = 0; define kMaxBulletHole 100; var h_bullet_hole_array[kMaxBulletHole]; entity* p_bullet_hole_temp;
// Desc: bullet hole // // Mod Date: 07/14/01 // Use new handles to turned it into an FIFO array // Mod Date: 07/16/01 // Fixed index problem with remove (use SKILL4 to store local index) // PROBLEM: 07/26/01 // If you change levels with 'outstanding' bullet holes you will get // 'WDL Crash' errors when this function tries to remove the hole from the // previous level. Solution: clear all bullet_holes before switching levels // by calling 'bullet_hole_remove_all()'. function bullet_hole() { // check for maximum bullet holes at any time if(bullet_hole_index >= kMaxBulletHole) { bullet_hole_index = 0; }
// check to see if its already in use temp = h_bullet_hole_array[bullet_hole_index]; if(temp != 0) { // remove old hole p_bullet_hole_temp = ptr_for_handle(temp); ent_remove(p_bullet_hole_temp); }
// assign this as the new value in the array h_bullet_hole_array[bullet_hole_index] = handle(me); my.skill4 = bullet_hole_index; // save index for removal
bullet_hole_index += 1; // increament index
my.transparent = ON; my.flare = ON; my.passable = ON;
my.oriented = ON;
vec_to_angle(my.pan,normal); // rotate to target normal
waitt(160); // time bullet stays before vanishing
// alpha fade while(my.alpha > 0) { my.alpha -= time; waitt(1); }
h_bullet_hole_array[my.skill4] = 0; // zero out pointer ent_remove(me); }
//NOTE Add Shot Event
//Future Developement
/* function GunShellMDL() { emit(1,my.weaponMuzzleX,emit2dShell); }
function FireLASER { weaponTmpSyn = you; // save YOU value (used for bullet holes) create(<lbeam.mdl>,my.weaponMuzzleX,laser_fire); // uses TARGET & RESULT you = weaponTmpSyn; // restore YOU value } */
//NOTE //should create a particleShotAction and use it in the function below //setGunshot(sBall,modelShotAction);
Chaos is a paradox consistently inconsistent.
|
|
|
Re: Handles?
[Re: sydan]
#200143
04/02/08 19:32
04/02/08 19:32
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
http://www.conitec.net/beta/ain-handle.htm gives a detailed explanation about handles. Here you can even read how to determine an engine objects type by it's handle. http://www.conitec.net/beta/ain-ptr_for_handle.htm tells you about ptr_for_handle() and gives a short example. Roughly spoken you use handles allmost always by saving a handle in an entities skill by "(my->skill)[40] = handle(you);" and retrieve it later by "you = ptr_for_handle((my->skill)[40]);" where "you" can be replaced by any other pointer to an engine object and 40 is to be replaced by any value between 0 and 99. Examples are in Lite-C Syntax.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Handles?
[Re: i_program_games]
#200149
04/02/08 19:51
04/02/08 19:51
|
Joined: Oct 2007
Posts: 116
sydan
OP
Member
|
OP
Member
Joined: Oct 2007
Posts: 116
|
to > 'i_program_games' Woaw! Thanks! That will be handy!
Last edited by sydan; 04/02/08 19:51.
For some reason, my ambition always seems to beat my ability.
|
|
|
Re: Handles?
[Re: sydan]
#200150
04/02/08 19:53
04/02/08 19:53
|
Joined: Oct 2007
Posts: 116
sydan
OP
Member
|
OP
Member
Joined: Oct 2007
Posts: 116
|
to > 'Uhrwerk' thanks for the links and info!
Sydan
For some reason, my ambition always seems to beat my ability.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|