Raised This Month: $ Target: $400
 0% 

Laser Dot.. how?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
craze
Junior Member
Join Date: Oct 2005
Old 10-25-2005 , 01:09   Laser Dot.. how?
Reply With Quote #1

How would i make a laser dot that goes on whatever wall your aiming at like the rocket launcher from the original half-life?
I just have to get where the user is aiming and spawn a transperent sprite wherever they aim. I think I'd use aimvec or something but im not sure how. Are there any heroes that have this that I can look at? Is it even possible?
I really need to know how to do this. Thanks for your help all.
craze is offline
Send a message via AIM to craze Send a message via MSN to craze
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 10-25-2005 , 02:44  
Reply With Quote #2

Code:
/* Gets origin from player. * Modes: * 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). */ native get_user_origin(index, origin[3], mode = 0);

This is the answer you are looking for.
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
yang
Veteran Member
Join Date: May 2005
Location: galoreservers.net
Old 10-25-2005 , 04:30  
Reply With Quote #3

laser dot:

precache "sprites/laserdot.spr"


use the additive sprite 17.

get the aim vector.

then:

Code:
#define TE_SPRITE     17    // additive sprite, plays 1 cycle 

message_begin(MSG_ ,SVC_TEMPENTITY) //message begin 
write_byte(TE_) 
write_coord() // start position 
write_coord() 
write_coord() 
write_short() // sprite index 
write_byte() // scale in 0.1's 
write_byte() // brightness 
message_end()
__________________
yang is offline
Send a message via AIM to yang
craze
Junior Member
Join Date: Oct 2005
Old 10-25-2005 , 20:04  
Reply With Quote #4

Im kind of having a little trouble with the help you guys gave me, but it did help get me on track some more and i really appreciate it. Thanks.

I found 2 codes (on amxmodx forums) for a laser sight and I dont know which one to use or how to modify them to match what i want. Can someone help me figure out how to do this.

Here's the first example i found:
Code:
ls_dot = precache_model("sprites/laserdot.spr")

Code:
new aimvec[3]     get_user_origin(id,aimvec,3)     //Make the Laser Dot     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)     write_byte( 17 )     write_coord(aimvec[0])     write_coord(aimvec[1])     write_coord(aimvec[2])     write_short( ls_dot )     write_byte( 10 )     write_byte( 255 )     message_end()

And here's the 2nd one (using same precache as above):
Code:
public make_dot(vec[]) {     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)       write_byte( 17 )     write_coord(vec[0])     write_coord(vec[1])     write_coord(vec[2])     write_short( ls_dot )     write_byte( 10 )     write_byte( 255 )     message_end() }

So i guess they both do the same thing and they're just a tad bit different.
Here's the code im thinking of using (written by myself):

Code:
public laserAimLoop() {     for( new id = 1; id <= SH_MAXSLOTS; id++ ){         if( !is_user_alive(id) || !shModActive() || !gHasHeroPower[id] ) return         //Get origin of user         new aimvec[3]         get_user_origin(id,aimvec,3)         //Make laser dot         message_begin( MSG_BROADCAST,SVC_TEMPENTITY)         write_byte( 17 )         write_coord(aimvec[0])         write_coord(aimvec[1])         write_coord(aimvec[2])         write_short( ls_dot )         write_byte( 10 )         write_byte( 255 )         message_end()     } }

would that work? would that make a laser sight for all players that have the hero and have it follow there cursor no matter what? Thanks for your help all.
craze is offline
Send a message via AIM to craze Send a message via MSN to craze
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 10-25-2005 , 20:55  
Reply With Quote #5

edit: nvm, that looks like it should work, why dont you test it yourself?
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
craze
Junior Member
Join Date: Oct 2005
Old 10-25-2005 , 21:05  
Reply With Quote #6

i dont have cs on this computer.
my main computer got messed up and i have to repair windows.

I changed the code around a tiny bit and made the error checking better:
Code:
ls_dot = precache_model("sprites/laserdot.spr") public laserAimLoop() {     if(!shModActive()) return     for( new id = 1; id <= SH_MAXSLOTS; id++ ){     if(!gHasHeroPower[id]) return      if(is_user_alive(id))      {          //Get origin of user                 new aimvec[3]                 get_user_origin(id,aimvec,3)                 //Make laser dot                 message_begin( MSG_BROADCAST,SVC_TEMPENTITY)                 write_byte( 17 )                 write_coord(aimvec[0])                 write_coord(aimvec[1])                 write_coord(aimvec[2])                 write_short( ls_dot )                 write_byte( 10 )                 write_byte( 255 )                     message_end()     }       } }

Does my code remove the laser dot when they die or do I have to add that in? I'm not sure how I would do that.
So do you guys see any errors... do you think it will work the way i want it to?
thanks for all your help guys
craze is offline
Send a message via AIM to craze Send a message via MSN to craze
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 10-25-2005 , 23:04  
Reply With Quote #7

If the user dies, the whole laser thing doesn't get executed at all because you made the check is_user_alive(id). So it's good so far.
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
craze
Junior Member
Join Date: Oct 2005
Old 10-25-2005 , 23:15  
Reply With Quote #8

Quote:
Originally Posted by Gorlag/Batman
it's good so far.
what do you mean so far? that's it. that's all the code right?
craze is offline
Send a message via AIM to craze Send a message via MSN to craze
yang
Veteran Member
Join Date: May 2005
Location: galoreservers.net
Old 10-26-2005 , 00:49  
Reply With Quote #9

if(!shModActive()) return
for( new id = 1; id <= SH_MAXSLOTS; id++ ){
if(!gHasHeroPower[id]) return
if(is_user_alive(id))

you can just do somethign like this and make it look way cleaner:

Code:
    for( new id = 1; id <= SH_MAXSLOTS; id++ ){         if ( !shModActive() || !gHasHeroPower[id] || !is_user_alive(id)         {             // do code           } }

and yes, thats all the code you'll need for laser dot to loop.
__________________
yang is offline
Send a message via AIM to yang
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 10-26-2005 , 08:43  
Reply With Quote #10

yang, wouldnt that make it so it does the loop if sh is off, they dont have the power, or theyre dead?

shouldnt it be like
Code:
    for( new id = 1; id <= SH_MAXSLOTS; id++ ){ 
        if ( shModActive() && gHasHeroPower[id] && is_user_alive(id) )
        {
            // do code
        }
}
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Reply



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 01:01.


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