Raised This Month: $ Target: $400
 0% 

Question about showing sprites, etc...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kojiro
Junior Member
Join Date: Nov 2004
Old 11-08-2004 , 03:03   Question about showing sprites, etc...
Reply With Quote #1

I was wondering if there already is a tutorial about how the sprites work in the .sma files, or if someone could write one. They seem pretty hard to figure out.

Also, I had a question about origins... Just in general, how does it work, how does vec and aimvec work, etc... I just need some general explanation that I havn't found in tutorials anywhere. I'm learning little by little from hero .sma files, but there are many things I still need to figure out.
Kojiro is offline
Prowler
Senior Member
Join Date: Nov 2004
Old 11-08-2004 , 04:12  
Reply With Quote #2

Ok, well I will give you a brief tutotial on creating messages, these can be used to create Tracers, lighting, User messages ect ect, basically very many and very varied graphical effects, i will be using Daredevils code as a base. I will also attach the HL SDK const.h for convenience.

First off, let me help you with origins as they are used in most messages.
When creating a origin the first thing you need is a place to save it, this is done with an array, for a origin the array needs 3 slots to place information, therefore we create the array like so:
Code:
new originA[3]
Now you need to get the origin of the player like so:
Code:
get_user_origin(id,originA)
This will then save the origin information for id into the array you just created (originA), This saves the X,Y,and Z values for the id. basically what you end up with is information in all 3 of your slots (remeber 0 is classified as a slot)

originA[0] will have the X origin
originA[1] will have the Y origin
originA[2] will have the Z origin

now that is a basic origin, it will get the exact location of where a player is standing, you can also get origins based on other things. for example
Code:
new originB[3] get_user_origin(id,originB,4)
the number at the end corrisponds to what type of origin you want, amx uses 5 of these (0-4) zero is default, meaning that if you dont put any number it will assume it is zero.
the numbers corrispond to this

0 - current position.
1 - position from eyes (weapon aiming).
2 - end position from player position.
3 - end position from eyes (hit point for weapon).
4 - position of last bullet hit (only CS).

So putting a 4 at the end of that origin will save the co-ordinates of where your last bullet hit, this is useful for things like bullet tracers.

Now, one to Messages, i will give you a line by line help here
Code:
message_begin(MSG_ONE,SVC_TEMPENTITY,originA,id)
+MSG_ONE -> This starts your message, the first part is who you will be sending the message to, in this case its sending the message individually to each player, this is useful if you want only certain people to see the message (people with the super power in question, such as daredevil) Other message types and descriptions are found in the const.h SDK.
+SVC_TEMPENTITY -> This is the type of message you will creating, tempentity is as the name suggests, a temporary entity, which can take the form of many graphical effects. there are more types but this is the most common for graphics, check the const.h for more
+originA -> This is the Origin, as explained above, sometimes it is not needed, and other times a simple {0,0,0} will do (sets X Y and Z to zero, somewhere in the middle of the map)
+id -> this is the player ID that will be messaged
Code:
write_byte( 21 )
-> this byte defines what type of message you are going to be using, 21 refers to TE_BEAMCYLINDER which is a cylinder that expands to max radius over lifetime, this is what daredevil uses for its Ring graphic, there are a large number of differnt types of these messages, check the const.h for more of them.

NOW, it is important to note that everything after this is based entierly on what message type you are using, the const.h file lists what it needs after defining the message type you wish to use, most, if not all messages use differnt bytes,co-ords, shorts etc. i will list a some of them and explain what they do.

These Paticular ones are used by TE_BEAMCYLINDER which im using as an example.
Code:
write_coord(originA[0]) write_coord(originA[1]) write_coord(originA[2] + 16) write_coord(originA[0]) write_coord(originA[1]) write_coord(originA[2] + 600 )
-> The first 3 of these write_coords is the origin at which to start the graphic, in this case using originA means that it will start at the Player we got the origin of earlier the + 16 will add 16 units to the size of origin information already stored there, meaning that it will begin to create a small radius around the player.
-> The Second set of 3 are in fact still using the same origin, but with a differnce, this basically is telling the graphic where you want the final stage of the beamcylinder to be, in this case 600 units (90-100 units is how high a player is as reference) So it will then create the cylindir and expand until it reaches that distance, The time it takes is dependent on the life of the graphic (defined below) if the life is high, the beam will take its time getting to its destination
Code:
write_short( gSpriteWhite )
-> this is actually the sprite, which would have been pre-cached and defined earlier in the plugin, it would then be called here, this is the actual sprite that the graphic will be using, This paticular short refers to sprites/white.spr. the appropriate code for setting up this sprite can be found in daredevil, its relativly straight forward so i dont think it needs explaining
Code:
write_byte( 0 ) // startframe write_byte( 1 ) // framerate write_byte( 6 ) // 3 life 2 write_byte( 8 ) // width 16 write_byte( 1 ) // noise
->As always each message type has its own bytes and what not, it is important to know what byte you are wrighting for what, so keeping the information from the const.h at the rear using // is very helpful in case you forget what byte does what. In this case we have 1 byte whitch defines the frame rate of the cylinder, one for the life of the cylinder, then width, then noise
Code:
write_byte( 100 ) // red write_byte( 100 ) // green write_byte( 255 ) // blue
-> RGB values will most likely be the most common bytes you will encounter for messages. These are basically the colour you want your graphic to be, using a differnt micture of red green and blue it alows you to create a very large array of colours, 0 would be none of that paticular colour, and 255 would be full, if you had 0 red, 0 green 255 blue, it would be completley blue, put 100 red, 100 green and 255 blue (like here) you get a much lighter blue, with green and red mixed into it.
Code:
write_byte( 192 ) //brightness
-> this is how Bright your graphic will be.
Code:
write_byte( 0 ) // speed
-> and this your speed
Code:
message_end()
-> always remeber to finish off your graphic with message_end() as you can have some very weird errors if you dont.

This is relativly brief, as there are alot of other types that are available, mostly if you use your brain and using heros that other people have made you should be able to get a grasp on it relativly quickly
Attached Files
File Type: txt const.h.txt (24.4 KB, 156 views)
Prowler is offline
Kojiro
Junior Member
Join Date: Nov 2004
Old 11-08-2004 , 22:40  
Reply With Quote #3

Perfect.

Perhaps you can repost your tutorial on the site and get it stickied? And of course, keep the included file. Thanks much prowler, I understand now.
Kojiro is offline
Prowler
Senior Member
Join Date: Nov 2004
Old 11-09-2004 , 00:26  
Reply With Quote #4

No problems, its just a pleasure to help someone who actually has some idea of what they are doing

as for the tutorial idea, it was something i had in mind for awhile, i just really needed a subject, and you handed me one

I'll wright a few other tutorials that arent coverd in the ones that are already there, when i have 2 or 3 done i'll post them as a sperate thread, what the mod team wants to do with them after that is up to them
Prowler is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode