Blockland Forums > Modification Help
help needed on raycasts
<< < (2/2)
Space Guy:
To make a weapon use raycasting, you put the script file Support_RaycastingWeapons.cs in with your Add-On (can be found in various places e.g. TF2 Basic Guns, Tier+Tactical), exec() it then add several of these attributes to the ShapeBaseImageData weapon you want to use it:

raycastWeaponRange - Required. The distance it fires for e.g. flashlight doesn't work at long distances.

raycastWeaponTargets - What it collides with. Use this to make it go through players and only shine on walls:

--- Code: ---   raycastWeaponTargets =
                   $TypeMasks::StaticObjectType |
                   $TypeMasks::TerrainObjectType |
                   $TypeMasks::VehicleObjectType |
                   $TypeMasks::FXBrickObjectType;
--- End code ---

raycastExplosionProjectile - A Projectile datablock. You cannot directly spawn "Explosion" objects for particles/lighting effects so if needed use a 10-20ms lifetime projectile.

raycastDirectDamage - Unimportant for a flashlight.
raycastDirectDamageType - Same.

raycastSpreadAmt - This causes the ray to have a random spread.
raycastSpreadCount - Number of rays to fire per shot.

raycastTracerProjectile - Optionally fires a different projectile datablock down the path of each shot.

This affects WeaponImage::onFire so if your gun uses a modified firing method (e.g. the Gun's "move hand up" animation) then you must call Parent::onFire(%this,%obj,%slot) or it won't work.

You can also adjust your weapon's ::onHitObject or ::onRaycastDamage functions (arguments %this,%obj,%slot,%col,%pos,%normal,%shotVec) similarly to Badspot's Projectile::onCollision/onDamage functions to have different effects on hit.


One thing is that the last flashlight made in this way (with a short-lived explosion with a light radius wherever you aimed it) kept flickering if there was any lag at all.
Dy mar:
there's got to be a way to create one light, almost like a projectile that never disappeared, and teleport it to the raycast. that would work.

anyways, thanks Space Guy.
Navigation
Message Index
Previous page

Go to full version