Raised This Month: $32 Target: $400
 8% 

[REQ - CSS] Throw Knife


Post New Thread Reply   
 
Thread Tools Display Modes
Xp3r7
SourceMod Donor
Join Date: Jul 2006
Old 02-28-2010 , 11:47   Re: [REQ - CSS] Throw Knife
Reply With Quote #21

Nice, glad to see some progress on this!

Anyway to make the knives look like they are actually thrown in real life (like twirling in the air) instead of just looking like a knife floating in mid-air?

I think the eventscripts script I linked to in my 1st post does it.

Maybe you could look through the script or have Greyscale see if he remembers the code.

Just looks kinda funny right now, thats it, but awesome progress and I do appreciate the work on it!

Also maybe a cvar to limit the knives a player can throw?

I can see the players on my server just walking around throwing a million knives. lol
__________________

Last edited by Xp3r7; 02-28-2010 at 11:51.
Xp3r7 is offline
Send a message via MSN to Xp3r7
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 02-28-2010 , 13:03   Re: [REQ - CSS] Throw Knife
Reply With Quote #22

Its early progress my idea is that you would have to throw your own knife and then if you want it back you would need to pick one up. I couldnt get the knives to rotate at all i was trying to make one rotate so it didnt face the wrong way and i tried a few ways and couldnt get it to work. If greyscale can point me in the right direction on that then i can do it. Also i already got damage working correctly, but the way i did my array's sometimes throw index errors dont know why so i got to narrow that down.
Dr!fter is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 02-28-2010 , 13:44   Re: [REQ - CSS] Throw Knife
Reply With Quote #23

My knives never rotated either :/ I wasn't sure how to apply a torque on the knife, still don't know if it's possible. Maybe SM can make better use of http://developer.valvesoftware.com/wiki/Phys_torque

I tried to use it in ES but no luck. Possibly a logical entity?

My knives also would have been lethal sliding on the ground ;P, no one really notices. But you can prevent that by checking the rate of change in the z axis.

Code:
if (FloatAbs(lastpos[2] - newpos[2]) < 20.0)
I don't know the exact number for "20.0" you might have to play around with that. Just take advantage of the fact that the z-axis velocity should always be decreasing in free-fall, simple physics.

EDIT: Actually the above might have false positives at max height of the knife's projection.

Instead you can use a traceray to detect how close it is to the ground. Just start the trace from the knife's position and aim it straight down, and then measure the distance between the old and the current, if it's ~0 then de-lethalize it.
__________________

Last edited by Greyscale; 02-28-2010 at 13:56.
Greyscale is offline
Xp3r7
SourceMod Donor
Join Date: Jul 2006
Old 03-01-2010 , 20:51   Re: [REQ - CSS] Throw Knife
Reply With Quote #24

Ah, I thought they did spin or something.

Maybe cause (if I remember right), when you used the left mouse button to throw (cause thats what I used instead of binding a key), you had the knife swing and then the knife came from it maybe giving it spin sometimes.

This wont be a one hit kill will it?
__________________
Xp3r7 is offline
Send a message via MSN to Xp3r7
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 03-01-2010 , 22:09   Re: [REQ - CSS] Throw Knife
Reply With Quote #25

The knife swing just triggered a knife to be projected, the swinging knife wasn't the knife thrown.

With his method of dealing damage, the damage done should be easily configurable.
__________________
Greyscale is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 03-02-2010 , 16:39   Re: [REQ - CSS] Throw Knife
Reply With Quote #26

Yea it will be easily configured. Thanks greyscale for the info to stop the knife from sliding and killing someone so for the traceray i would just set the end position same first 2 positions but the 3 position something like -1000? i never used traceray so im not sure how it even works.
Dr!fter is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 03-02-2010 , 17:01   Re: [REQ - CSS] Throw Knife
Reply With Quote #27

No you would create the traceray at the origin of the knife, and then aim it straight down:

Code:
new Float:ang[3] = {90.0, 0.0, 0.0};  // pitch, yaw, roll.  pitch is the up/down part, so 90.0 is straight down.
TR_TraceRay(knifepos, ang, MASK_SOLID, RayType_Infinite);

if (!TR_DidHit())
    return;  // the knife doesn't have the world beneath it, meaning it can't hit any players, so delethalize it here.

new Float:endpos[3];
TR_GetEndPosition(endpos);

if (knifepos[2] - endpos[2] < 10.0)
{
    The knife is about to hit the ground (it's less than 10 units above the ground) so delethalize it.
}
Tracerays are basically just invisible lines drawn from one point to another, or from one point in a certain direction. You can set them to hit certain types of the world. Here I set it to only hit solid things, such as the world. You can set them to collide with players or only certain entities using a filter callback.
__________________

Last edited by Greyscale; 03-02-2010 at 17:04.
Greyscale is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 03-02-2010 , 18:49   Re: [REQ - CSS] Throw Knife
Reply With Quote #28

ahhh cool thanks traceray might be useful for something else im working on too.
Dr!fter is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 03-05-2010 , 15:40   Re: [REQ - CSS] Throw Knife
Reply With Quote #29

you can use the prop "m_vecAngVelocity" to make entities spin, i use it in my homing missiles. when the knife touches an entity that isn't a player you could change the movetype to none which will stop it dead in its track so it doesn't slide around, this will also make it look the knife is embedded in that entity. at this point you could also stop it damaging players.

if you don't want it to spin you could also make the blade always point in the direction its heading in with GetVectorAngles, pass it the entities speed vector and it will give you an angle. again i use this in homing missiles to make the missiles face the direction they head
blodia is offline
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 03-05-2010 , 16:01   Re: [REQ - CSS] Throw Knife
Reply With Quote #30

Quote:
Originally Posted by blodia View Post
you can use the prop "m_vecAngVelocity" to make entities spin, i use it in my homing missiles. when the knife touches an entity that isn't a player you could change the movetype to none which will stop it dead in its track so it doesn't slide around, this will also make it look the knife is embedded in that entity. at this point you could also stop it damaging players.

if you don't want it to spin you could also make the blade always point in the direction its heading in with GetVectorAngles, pass it the entities speed vector and it will give you an angle. again i use this in homing missiles to make the missiles face the direction they head
Fantastic info ! I'm sure that'll help alot.

If the dev can, he could make it so that the knife actually inflicts damage to where it hits even if it wasn't a Player, obviously requiring it did hit something which can be destroyed with enough damage.
__________________
Links to posts I received Karma from:
Big thanks to all who gave Karma
rautamiekka is offline
Send a message via ICQ to rautamiekka Send a message via AIM to rautamiekka Send a message via MSN to rautamiekka Send a message via Yahoo to rautamiekka Send a message via Skype™ to rautamiekka
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 14:30.


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