AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need Help with Blood direction! (https://forums.alliedmods.net/showthread.php?t=133328)

CantShoot 07-24-2010 08:18

Need Help with Blood direction!
 
Can anyone please help?
This code is from weaponmod.

When shooting player blood splatter on wall behind attacker not victim.

Code:


create_blood(Float:sourceOrigin[3], target, amount, distance, color=70)
{
 // Get the origin of the target
 new Float:targetOrigin[3]
 pev(target, pev_origin, targetOrigin)
 
 // Show some blood :)
 message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
 write_byte(TE_BLOODSPRITE)
 write_coord(floatround(targetOrigin[0]))
 write_coord(floatround(targetOrigin[1]))
 write_coord(floatround(targetOrigin[2]))
 write_short(g_bloodspray)
 write_short(g_blood)
 write_byte(color)
 write_byte(amount)
 message_end()
 
 // Calculate the direction of the blood
 new Float:traceEnd[3]
 traceEnd[0] = (sourceOrigin[0]-targetOrigin[0])*distance
 traceEnd[1] = (sourceOrigin[1]-targetOrigin[1])*distance
 traceEnd[2] = (sourceOrigin[2]-targetOrigin[2])*distance
 
 // Draw a trace line to get the place for blood on the wall
 new res, Float:wallOrigin[3]
 engfunc(EngFunc_TraceLine, sourceOrigin, traceEnd, 0, target, res)
 get_tr2(res, TR_vecEndPos, wallOrigin)
 
 // Put blood on the walls if they're near enough
 if(wallOrigin[0] != traceEnd[0] || wallOrigin[1] != traceEnd[1] ||
  wallOrigin[2] != traceEnd[2])
 {
  message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  write_byte(TE_WORLDDECAL)
  write_coord(floatround(wallOrigin[0]))
  write_coord(floatround(wallOrigin[1]))
  write_coord(floatround(wallOrigin[2]))
  write_byte(wpn_gi_get_smallblood_decal())
  message_end()
 }
 
 return 1
}


Hunter-Digital 07-24-2010 09:26

Re: Need Help with Blood direction!
 
If you have it from another plugin I think you should look how it's used there.

Also, params and usage are weird, but I think here:

engfunc(EngFunc_TraceLine, sourceOrigin, traceEnd, 0, target, res)

needs to be the targetOrigin... I dunno, never really used traceline.


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

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