Possible to move/bind a waypoint?

Post your scripting questions / solutions here

Moderator: Moderators

BirdsofaFeather
Sergeant
Posts: 72
Joined: Sun Aug 24, 2003 3:49 am

Possible to move/bind a waypoint?

Post by BirdsofaFeather »

I've already tried to bind a waypoint to an object, no luck, so I'm not sure if I'm just doing it wrong or if it's not possible at all. The waypoint just doesn't move for some reason. If it's not possible, is there something I could use that is movable/bindable? I'm basically just trying to be able to tell an object to move to an exact place, and be able to move that place around.
Look! Up in the sky! It's a Bird! It's a Plane! It's......oh wait it's a bird.

<Your MOHAA Mapping Friend in the Sky ;)>
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

a script_origin. what is it you want to do?
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Or an info_splinepath node
Image
BirdsofaFeather
Sergeant
Posts: 72
Joined: Sun Aug 24, 2003 3:49 am

Post by BirdsofaFeather »

I have a siege weapon i've made, and it throws rocks along a waypoint path that I've made (the path is calculated exactly for gravity, pretty cool actually). But I want to be able to rotate the siege weapon and not have to make a new path for the rocks. I want the path to rotate with the weapon, I figured I could bind the waypoints to the weapon no problem, but it didn't work. You think an info_splinepath would work?

*edit* now that I think of it, all I'm using are simple moveto commands, a script origin should work just fine right?
Look! Up in the sky! It's a Bird! It's a Plane! It's......oh wait it's a bird.

<Your MOHAA Mapping Friend in the Sky ;)>
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

bind

Post by tltrude »

I don't think you can bind a path because it is not one entity. Maybe you can bind all the little path nodes (every entity targetname) to the catapult. Or, bind the first one and then bind the second one to the first, the third to the second, and so on.
Tom Trude,

Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

yes all the nodes or scirpt origin will have to be bound . Another way to do it is to use physics to do it but that is harder to set up but looks more normal because if a rock has physics it will be effected by gravity and will bounce when it lands.
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

which i nfact may not be such a bad thing. as long as it doesn't bounce too high this may be the best course of action.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
BirdsofaFeather
Sergeant
Posts: 72
Joined: Sun Aug 24, 2003 3:49 am

Post by BirdsofaFeather »

Bdbodger, what luck. I just did a search on physics to find out how to do just what you said with the rock, and I found this topic that I forgot about. How do you turn on physics for the rock? I have found that this is really my only good option now. I used physics to create the path acurately anyway, but it's too limiting now. Physics would be killer, thanks for all the other posts too you guys.
Look! Up in the sky! It's a Bird! It's a Plane! It's......oh wait it's a bird.

<Your MOHAA Mapping Friend in the Sky ;)>
BirdsofaFeather
Sergeant
Posts: 72
Joined: Sun Aug 24, 2003 3:49 am

Post by BirdsofaFeather »

Ok, forget how to turn physics on for the rock, I know how to do that. I need to know how to give it a starting velocity and cardinal direction. I tried turning on physics after I released (unbinded) it from the siege weapon, and it stopped in midair. I also tried turning on physics before I started the throw, but then I couldn't move the rock manually, and couldn't bind it to the weapon. Anyone tried this before?
Look! Up in the sky! It's a Bird! It's a Plane! It's......oh wait it's a bird.

<Your MOHAA Mapping Friend in the Sky ;)>
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

AI

Post by tltrude »

Is it possible that true game physics only work for players and AI? Maybe you can make your rock an AI, or try firing an AI guy with it.

There is a "func_fallingrock" that is pretty cool. But I have never gotten it to follow a path--just fall streight down and bounces. Here is the code if you want to add "fallingrock.cpp" to your main/code folder.

Code: Select all


/*QUAKED func_fallingrock (0.75 0.65 0.1) ? AUTO_RESET NO_RANDOMNESS REMOVE_ON_GROUND
Scorpios comments/information:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Description:
------------

Creates a rock that, when triggered, begins falling and bounces along a path
specified by targetname.  Use info_waypoint for the path.

Values:
=======

"targetname" the path to follow.
"dmg" how much damage to cause creatures it hits (default 20).
"speed" how fast to move (default 200).
"wait" how long to wait before falling when triggered (default 0).
"noise" sound to play when rock touches the world
"start" Starts rock falling.
"bounce" sent to entity when touched.

AUTO_RESET - when done falling, automatically return to the start
NO_RANDOMNESS - don't use any randomness when making the rocks fall
REMOVE_ON_GROUND - remove the rocks when done.

******************************************************************************/

Tom Trude,

Image
BirdsofaFeather
Sergeant
Posts: 72
Joined: Sun Aug 24, 2003 3:49 am

Post by BirdsofaFeather »

Yeah, I tried having my rock move along a specified waypoint, and then turning physics on in midair, but then it behaves exactly like that func_falling rock, it just stops, falls, and bounces. I even tried turning on physics before launching the rock, and having my siege weapon physically move it, but the weapon wouldn't move. It seems for some reason once physics is on for the rock, I can't manipulate it anymore. But if you think about it, the rock is basically going to act the same as a exploder_chunk, going off at a specific speed and direction. I'm gonna check the original scr for the exploder thread and see if they use physics for the pieces there. If anyone else knows how to do this, please post.
Look! Up in the sky! It's a Bird! It's a Plane! It's......oh wait it's a bird.

<Your MOHAA Mapping Friend in the Sky ;)>
BirdsofaFeather
Sergeant
Posts: 72
Joined: Sun Aug 24, 2003 3:49 am

Post by BirdsofaFeather »

Here is the code for the exploderchunk script, he did indeed use physics, and some properties to set vectors. I don't understand how he set the initial speed though.

Code: Select all

phyvel local.vec:
	self physics_velocity ( local.vec )
	wait 0.2
	self physics_on 1
	self physics_velocity ( local.vec )
	

end

rocksound:

		wait (1 + randomfloat(4))
		self playsound ("stonesmall0" + (randomint(5) + 1))
	

end

moveitout local.num:

	local.num = local.num / 15
	local.number = 1
	while (local.number < 20)
	{
		local.number = local.number + 0.4
		local.o = self.origin
		if (local.num > 0)
		local.o[2] = local.o[2] - local.num
		else
		local.o[2] = local.o[2] + local.num

		self.origin = local.o
		waitframe
	}

end


explodetouch:
self waittill touch

// if (parm.other == $world)
	if (self != NULL)
		thread moveitout self.velocity[2]
//	self hide
end


explodechunk:
	if (self.pause != NIL)
	wait self.pause

	self show
	self notsolid
	local.vec = (self.origin - self.target.origin)
	local.veclength = vector_length (local.vec)
	local.vec = vector_normalize (local.vec)
	local.vecscale = local.veclength * -1
	local.vec[0] = local.vec[0] * local.vecscale
	local.vec[1] = local.vec[1] * local.vecscale
	local.vec[2] = local.vec[2] * (local.vecscale * 1.5)

	thread phyvel local.vec

	self thread explodetouch
	self thread rocksound

	if (self.anglex == NIL)
	self.anglex = 0

	if (self.angley == NIL)
	self.angley = 0

	if (self.anglez == NIL)
	self.anglez = 0

	if ((self.anglex == 0) && (self.angley == 0) && (self.anglez == 0))
	{
		if (self.origin[0] > self.target.origin[0])
		local.xnum = self.origin[0] - self.target.origin[0]
		else
		local.xnum = self.target.origin[0] - self.origin[0]

		if (self.origin[1] > self.target.origin[1])
		local.ynum = self.origin[1] - self.target.origin[1]
		else
		local.ynum = self.target.origin[1] - self.origin[1]


		self.anglex = randomfloat(local.veclength / 3) * (randomint(3) - 1)
		self.angley = randomfloat(local.veclength / 3) * (randomint(3) - 1)
		self.anglez = randomfloat(local.veclength / 3) * (randomint(3) - 1)
		
		if (local.xnum > local.ynum)
		{ // was 1.5s
			if (self.origin[0] > self.target.origin[0])
				self.anglex = local.veclength * -0.5 - (randomfloat(0.5))
			else
				self.anglex = local.veclength * 0.5 + (randomfloat(0.5))
		}
		else
		{
			if (self.origin[1] > self.target.origin[1])
				self.anglez = local.veclength * 0.5  + (randomfloat(0.5))
			else
				self.anglez = local.veclength * -0.5 - (randomfloat(0.5))
		}

	}

		local.vec[0] = self.anglex
		local.vec[1] = self.angley
		local.vec[2] = self.anglez

		self rotatex local.vec[0]
		self rotatey local.vec[1]
		self rotatez local.vec[2]

	local.break = 0
	local.breaker = 1.2

//	self thread removetouch


	wait 0.5
	local.inc = 10.0 + (randomint(15))
	local.x = local.vec[0] / local.inc
	local.y = local.vec[1] / local.inc
	local.z = local.vec[2] / local.inc

//	thread moveitdown
	
	for (local.i = 0; local.i < local.inc; local.i++)
	{
		if (local.vec[0] > 0)
		local.vec[0] = local.vec[0] - local.x
		else
		local.vec[0] = local.vec[0] - local.x

		if (local.vec[1] > 0)
		local.vec[1] = local.vec[1] - local.y
		else
		local.vec[1] = local.vec[1] - local.y

		if (local.vec[2] > 0)
		local.vec[2] = local.vec[2] - local.z
		else
		local.vec[2] = local.vec[2] - local.z

		self rotatex local.vec[0]
		self rotatey local.vec[1]
		self rotatez local.vec[2]

		waitframe
	}
	wait 10
	
	if (self != NULL)
		self delete

	
end

removetouch:
	local.lastvelocity = self.velocity
	local.lastvelocity2 = self.velocity

	local.break = 0
	local.amount = 50
	while (local.break == 0)
	{
		local.v = self.velocity
		local.count = 0
		for (local.i=0;local.i<3;local.i++)
		{
			if ((local.v[local.i] > local.amount * -1) && (local.v[local.i] < local.amount))
				local.count++
		}
		if (local.count > 2)
			local.break = 1

		if (self.velocity == ( 0 0 0))
			println "NO VELOCITY"

		local.lastvelocity2 = local.lastvelocity
		local.lastvelocity = self.velocity
//		println self.velocity
		waitframe
	}
	self delete

end


moveitdown:

	wait (2 + randomfloat(1.5))
	local.number = 1
	while (local.number < 20)
	{
		local.number = local.number + 0.4
		local.o = self.origin
		local.o[2] = local.o[2] - local.number
		self.origin = local.o
		waitframe
	}

end
Look! Up in the sky! It's a Bird! It's a Plane! It's......oh wait it's a bird.

<Your MOHAA Mapping Friend in the Sky ;)>
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Well you need to do the two things as you know

$rock physics_on
$rock physics_velocity(?? ?? ??)

The velocity it the change in oringin xy and z over 1 game frame * 20 I understand from JV . That contains speed and direction .

Ok first for the xy . Make your script_object rock and machine so that the front of the objects faces 0 the right side of the editor . This is important to set the angle of the objects at 0 . In script you will be rototeing the objects to the yaw you want them at but you need to have it start a 0 for forward . To set the xy of the volicity you can then use $myrock.forwardvector no matter what angle you rotated it to . To find the z part of the veleocity you can use the origin of the rock and add to it's z value .

So to do this you need the origin of the rock and a point that is ahead of the rock and above it at the angle you want it to start going at . Forward vector will give you 1 unit in the directon the rock is faceing upvector will give you 1 unit above the rock but that may be too steep of an angle so you may have to change this but try it first .

local.vec = ($myrock.origin +( $myrock.forwardvector + $myrock.upvector) ) * ?)

The ? is the part you will have to play with to get it at the right speed and you turn on physics at the point that the rock leaves the machine start with ? set at 20 or so and adjust from there

$myrock unbind
$myrock physics_on
$myrokc physics_velocity ( local.vec)
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

I think I will make a test map I had an idea while I was at work that may work better I thought that maybe if the rock is bound to the machine then it's forwardvectory probably will change as you rotate it you probabaly can use the forwardvector of the machine but this way may be better I also think that maybe you don't add the rock origin to the formula . My idea is if lets say your machine is like a catapult then you will probably be rotateing x useing a time setting so take the velocity of the rock before you unbind it like this .

local.time = 3 // adjust for speed

$rock bind $car_arm

$cat_arm time local.time

$cat_arm rotatexupto 90;$cat_arm move

wait (local.time - .25) // 1/4 second before it hits the top release the rock

local.velocity = $rock.velocity

$rock unbind

$rock physics_on

$rock physics_velocity ( local.velocity)

Some thing like that may work because you can take the velocity of the rock while it is moveing and before you unbind it then use that velocity when you apply the physics .
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Well I was right the first time . It was possible to do the second idea but proved to be a bit difficult . I mean timeing it to get the velocity at the right time etc it seemed that on the first throw the crate I used in the test just fell straight down but was ok on the second throw . Then if you change the angle of the throw arm it happened again . So I used the forwardvector of the arm . You can get the pk3 I made Here

Here is the script I used it rotates the arm's yaw then throws and rotates another 10 degrees and throws again it keep doing that in a circle . You will probably bind the arm to your machine and rotate the machine but in this test there was no machine just an arm .


main:
wait 5

$crate_spot bind $cat_arm // bind script origin to arm

$crate.origin = $crate_spot.origin // move crate to script_origin origin

$crate.angles = $crate_spot.angles // set crate angles to script_origin angles

$crate bind $crate_spot

while(1)
{

local.time = .3 // adjust for speed

$cat_arm time local.time

local.ang = $cat_arm.angles

local.ang[1] += 10

if(local.ang[1] == 360)
local.ang[1] = 0

$cat_arm rotateyupto local.ang[1];$cat_arm waitmove

local.velocity = (($cat_arm.forwardvector * 1000 ) + ( 0 0 500))

$cat_arm rotatexupto 90 ;$cat_arm waitmove

$crate unbind

$crate physics_on

$crate physics_velocity (local.velocity)

$crate waittill touch

wait 2

exec global/model.scr $crate.origin

$crate explode 500

$crate hide

$cat_arm rotatexdownto 0;$cat_arm waitmove

$crate.origin = $crate_spot.origin // move crate to script_origin origin

$crate.angles = $crate_spot.angles // set crate angles to script_origin angles

$crate physics_off

$crate bind $crate_spot

$crate show

wait 1

}
end
Image
Post Reply