Two potential answers, depending on how much you care about the precise shape.
Easy way:
// Get the first object in nShape
// - nShape: SHAPE_*
// - fSize:
// -> If nShape == SHAPE_SPHERE, this is the radius of the sphere
// -> If nShape == SHAPE_SPELLCYLINDER, this is the length of the cylinder
// Spell Cylinder's always have a radius of 1.5m.
// -> If nShape == SHAPE_CONE, this is the widest radius of the cone
// -> If nShape == SHAPE_SPELLCONE, this is the length of the cone in the
// direction of lTarget. Spell cones are always 60 degrees with the origin
// at OBJECT_SELF.
// -> If nShape == SHAPE_CUBE, this is half the length of one of the sides of
// the cube
// - lTarget: This is the centre of the effect, usually GetSpellTargetLocation(),
// or the end of a cylinder or cone.
// - bLineOfSight: This controls whether to do a line-of-sight check on the
// object returned. Line of sight check is done from origin to target object
// at a height 1m above the ground
// (This can be used to ensure that spell effects do not go through walls.)
// - nObjectFilter: This allows you to filter out undesired object types, using
// bitwise "or".
// For example, to return only creatures and doors, the value for this
// parameter would be OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR
// - vOrigin: This is only used for cylinders and cones, and specifies the
// origin of the effect(normally the spell-caster's position).
// Return value on error: OBJECT_INVALID
object GetFirstObjectInShape(int nShape, float fSize, location lTarget, int bLineOfSight=FALSE, int nObjectFilter=OBJECT_TYPE_CREATURE, vector vOrigin=[0.0,0.0,0.0])
Use a SHAPE_CONE or SHAPE_SPELLCONE.
More complex answer:
Look at goaneng's
Pentagrams and Summoning Circles. He has a hemisphere, which you can rotate in any direction on any axis (x, y, or z). While that code is only for vfx, the inc_draw include has all the vector math already done for you, and very elegantly. You should be able to adapt it pretty easily. As an added plus, he includes a demo module. When I was coding special effects for some of HG's portals, I simply added certain areas from HG to the demo mod and tinkered with the effects until I got exactly what I wanted. In any event, the testing room he provides should help you figure out rotation etc.
[Edit] Doh, just read the latter half of your post, where you do what I usually ask people to do: say what they're going to use it for. This
recent thread was extremely helpful when it came to vector math, and had a very similar problem, though he wanted a deflection area in FRONT of the target in that case.
Funky
Modifié par FunkySwerve, 12 septembre 2013 - 11:04 .