|
|
|
Editor: RED is code, YELLOW is original code, keywords in CYAN.The creation of temporary entities requires some basic knowledge on communication between the server and client dlls, if you want more information on communication go to 2's tutorial on Wavelength. So I am going to say a little about that first To initialize the communication you start by writing something like
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); MESSAGE_BEGIN just says that it is going to be starting to communcate with the client dll. The MSG_PAS just says what the message is, called the message initializer. There are eight initalizers. MSG_BROADCAST unreliable to all MSG_ONE reliable to one (msg_entity) MSG_ALL reliable to all MSG_INIT write to the init string MSG_PVS Ents in PVS of org MSG_PAS Ents in PAS of org MSG_PVS_R Reliable to PVS MSG_PAS_R Reliable to PASOkie, those are all of the ways you can message with a short description of them. The next thing is the SVC_TEMPENTITY that is saying what the message name is. SVC_TEMPENTITY is used when spawing temporary entities like sprites and all sorts of good stuff :). pev->orgin is where it starts from, on MSG_ONE you would set something like pPlayer->pev for that one player. Take a look on 2's tutorial on Wavlength for more information on communication between client and server dlls.
Now onto the more temporary entity related code. WRITE_BYTE( TE_EXPLOSION );Is what KIND of temporary entity is, this is temp ent specific and not for other communication between the client and server dlls. There are MANY different ones, this will be the biggest part! I am going to list my personal favorites and give a breif description on how to use them. After you do the WRITE_BYTE to say what the special effects of it will be there are several different things that you have to tell the client those will also be listed.
The TE_GUNSHOT is a particle effect plus ricochet sound, like when a bullet hits a wall WRITE_COORD() WRITE_COORD() WRITE_COORD() //position TE_EXPLOSION is an additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps WRITE_COORD() WRITE_COORD() WRITE_COORD() position WRITE_SHORT() sprite index WRITEBYTE() scale in 0.1's WRITE_BYTE() framerate WRITE_BYTE() flags Now here are the different flags that TE_EXPLOSION has TE_EXPLFLAG_NONE all flags clear makes default Half-Life explosion TE_EXPLFLAG_NOADDITIVE sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) TE_EXPLFLAG_NODLIGHTS do not render dynamic lights TE_EXPLFLAG_NOSOUND do not play client explosion sound TE_EXPLFLAG_NOPARTICLES do not draw particles TE_SMOKE creates an alphablend sprite, move vertically 30 pps WRITE_COORD() WRITE_COORD() WRITE_COORD() position WRITE_SHORT() sprite index WRITE_BYTE() scale in 0.1's WRITE_BYTE() framerate TE_TRACER is tracer effect from point to point WRITE_COORD() WRITE_COORD() WRITE_COORD() start position WRITE_COORD() WRITE_COORD() WRITE_COORD() end position TE_SPARKS consists of 8 random tracers with gravity, ricochet sprite WRITE_COORD() WRITE_COORD() WRITE_COORD() //position TE_SPRITE is an additive sprite, and plays 1 cycle of the animation WRITE_COORD() WRITE_COORD() WRITE_COORD() position WRITE_SHORT() sprite index WRITE_BYTE() scale in 0.1's WRITE_BYTE() brightness TE_SHOWLINE is line of particles every 5 units, dies in 30 seconds but gives a nift effect :) WRITE_COORD() WRITE_COORD() WRITE_COORD() //start position WRITE_COORD() WRITE_COORD() WRITE_COORD() //end position TE_PROJECTILE Makes a projectile (like a nail) (this is a high-priority tent) WRITE_COORD() WRITE_COORD() WRITE_COORD() //position WRITE_COORD() WRITE_COORD() WRITE_COORD() //velocity WRITE_SHORT() //modelindex WRITE_BYTE() //life WRITE_BYTE() //owner projectile won't collide with owner (if owner == 0, projectile will hit any client). TE_FIREFIELD makes a field of fire. WRITE_COORD() //origin WRITE_SHORT() //radius (fire is made in a square around origin. -radius, -radius to radius, radius) WRITE_SHORT() //modelindex WRITE_BYTE() //count WRITE_BYTE() //flags WRITE_BYTE() //duration (in seconds) * 10) (will be randomized a bit The flags: TEFIRE_FLAG_ALLFLOAT all sprites will drift upwards as they animate TEFIRE_FLAG_SOMEFLOAT some of the sprites will drift upwards. (50% chance) TEFIRE_FLAG_LOOP if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. TEFIRE_FLAG_ALPHA if set, sprite is rendered alpha blended at 50% else, opaque TEFIRE_FLAG_PLANAR if set, all fire sprites have same initial Z instead of randomly filling a cube. That is definatly not all of them! There are LOTS LOTS LOTS more, but those are the ones I thought people would use the most. After you write all the bytes, shorts, coords, etc. you need to tell the dll that you are done sending so after that stuff put MESSAGE_END(); Some of those had bytes taking sprite indexes and model indexes, so you cant just put the location of where it is. Now we get into the last part of nifty effects :) indexing. Open up weapons.h go to the line extern DLL_GLOBAL short g_sModelIndexBloodSpray; and underneath that insert this line extern DLL_GLOBAL short g_sModelIndexMyIndex; Right now u can call g_sModelIndexMyIndex for a sprite or model index, the only problem is no sprites or models will show up where you want them to. You can close up weapons.h now and open up weapons.cpp find the line DLL_GLOBAL short g_sModelIndexBloodSpray; under that put the line DLL_GLOBAL short g_sModelIndexMyIndex; Now for the part where you can actually use the model or sprite, find the line g_sModelIndexBloodDrop = PRECACHE_MODEL ("sprites/blood.spr"); Underneath that put the line g_sModelIndexMyIndex = PRECACHE_MODEL ("sprites/poison.spr"); Just replace the poison.spr with whatever model or sprite you want for that index. For some more details on temporary ents refer to the header file const.h it has the full listing for all the TE_'s
Any questions or suggestions should be sent to me:
british@epix.net