Aller au contenu

Photo

Adjusting Location while Spawning a Projectile


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages

I am putting the final touches on a throwable item for someone's campaign and one of the adjustments I'd like to make is to have the spawned projectile target be at the creature's chest area rather than hitting at their feet.  There are effects like beam that allow you to select a body part node, which would be ideal, but lacking that for the spawning projectile function I thought I might be able to check the creature race, find their height in some 2da, and then increase the location z-axis by half the height.  If the creature/race height is not in a 2da then I would just pick a number to increase by figuring that most enemies are somewhere between goblin and giant height. My searching so far has not been effective though.

 

So does anyone have an example of how to adjust the height in a location?  And does anyone already have a way to get creature height?

 

Regards



#2
kevL

kevL
  • Members
  • 4 078 messages
Appearance.2da has a HEIGHT parameter.

I haven't played with projectiles (other than Beams) but it looks like you might define a spell and use a special effect for its trajectory. I believe the SEF would allow a body-node to be targeted.

~

#3
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
I'll consider that. Probably too much effort for a minor visual issue though.

Thanks

#4
kevL

kevL
  • Members
  • 4 078 messages

So does anyone have an example of how to adjust the height in a location?


i'm not sure if you've played around with vectors

a Location is comprised of an Area and a Vector(x,y,z) and a float for Facing

three functions grant access:
vector vLoc = GetPositionFromLocation(lLoc);
object oArea = GetAreaFromLocation(lLoc);
float fFace = GetFacingFromLocation(lLoc);
and to put them back together:
location lLoc = Location(object oArea, vector vPosition, float fOrientation);

so try
location lDestination = ; // define endpoint

object oArea = GetAreaFromLocation(lDestination);
float fFace = GetFacingFromLocation(lDestination);
vector vEndpoint = GetPositionFromLocation(lDestination);

float fHeight = ; // get height from Appearance.2da

vEndpoint.z += (fHeight / 2.f);

lDestination = Location(oArea, vEndpoint, fFace);

  • andysks aime ceci

#5
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages

I have not messed with vectors before.  I created the following generic functions to help with this and it is working as I'd hoped.  Thanks much.

float GetLocationHeight (location lLoc)
{
	// Get the height element from a location
	// For invalid locations returns 0.0f
	// By Kaldor Silverwand, August 2016
	// Thanks to KevL for his help with vectors
	
	if ( GetIsLocationValid(lLoc))
	{
		vector vPosition = GetPositionFromLocation(lLoc);
		return (vPosition.z);
	}
	return 0.0f;
}

location SetLocationHeight (location lLoc, float fHeight = 0.0f)
{
	// Set the height of a location
	// Returns the new location or if invalid the original location
	// By Kaldor Silverwand, August 2016
	// Thanks to KevL for his help with vectors

	if ( GetIsLocationValid(lLoc))
	{
		object oArea = GetAreaFromLocation(lLoc);
		float fFacing = GetFacingFromLocation(lLoc);
		vector vPosition = GetPositionFromLocation(lLoc);
		
		vPosition.z = fHeight;
		location lNewLoc = Location(oArea, vPosition, fFacing);
		return lNewLoc;
	}
	return lLoc; // return the original location if not valid
}

Regards



#6
4760

4760
  • Members
  • 1 217 messages
Isn't the default height of a new area 0.0? I mean, couldn't a valid location return a height of 0?

#7
kamal_

kamal_
  • Members
  • 5 260 messages

Isn't the default height of a new area 0.0? I mean, couldn't a valid location return a height of 0?


Yes, and yes.

#8
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages

The function is returning 0.0 if the location is invalid otherwise the valid amount, which could certainly be 0.0.  The point of the function isn't to replace the GetIsLocationValid function, just to extract the height value.

 

Regards



#9
kamal_

kamal_
  • Members
  • 5 260 messages

kevL's spell idea is probably the best way to do it. If you want to muck around with vector math, try looking at my dynamic jumping, as I had to do a lot of vector math in there, and it includes a vector include someone made that could make things easier.



#10
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages

Appearance.2da has a HEIGHT parameter.

I haven't played with projectiles (other than Beams) but it looks like you might define a spell and use a special effect for its trajectory. I believe the SEF would allow a body-node to be targeted.

~

 

Turns out that that height column seems accurate for the player character types (human, elf, dwarf, etc.) but is not correct for creatures.  A frost giant height for example is 5 meters, which seems correct, but a fire giant height is only 1 meter, which is clearly incorrect.

 

For the creature I'm going to use the TARGETHEIGHT column instead, which is just H or L.  Close enough for horseshoes and atom bombs though.


Modifié par Kaldor Silverwand, 06 août 2016 - 08:43 .