Offset origin How?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Offset origin How?

Post by Vic Marrow »

I got a Sherman tank moving, turning, stopping. The turrent rotates and fires. I even figured out how to drive it. (big deal for me :roll: ) What I would like to do is glue a tank crew to it I know when you use "glue" You glue one enity origin to another enity origin. How would you offset an origin. I mean what would the script statement look like?
Something like this maybe?

$my_ai.origin glue $tank.origin offset (0 0 0)

I know I will have to play with the numbers (x y z)
I looked through some scripts but got lost as usual.
Thanks for your help!
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

The regular way to do this is by using 'bind' instead of 'glue'. However, when you bind something to a vehicle as a result it will refuse to move :?

Instead, you could make a script bind thread. However as you need to account for the rotation of the vehicle this thread would turn out to become overly complicated. In this case it's probably best to use a system of script_origins and let mohaa do the maths for you:

Code: Select all

glueguytotank local.tank local.offset:
  local.org1 = spawn script_origin
  local.org1 thread glueto local.tank

  local.org2 = spawn script_origin
  local.org2 = local.tank.origin + local.offset
  local.org2 bind local.org1

  self thread glueto local.org2
end

glueto local.other:
  while(self && local.other)
  {
    self.origin = local.other.origin
    self.angles = local.other.angles
    waitframe
  }
end
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

offset

Post by tltrude »

Just leave out the word "offset".

$my_ai.origin glue $tank.origin + ( -32 16 64 )
Tom Trude,

Image
Parts
Sergeant
Posts: 72
Joined: Thu Apr 10, 2003 12:35 pm
Location: UK
Contact:

Post by Parts »

Here's a script that attaches a player to a Truck. This works fine in Spearhead, not sure about MOHAA.

Uses a level variable to decide when to glue and unglue the player

Code: Select all

AttachToTruck local.Player:

	//This model is glued to truck origin
	local.PointGluedToTruck = spawn script_model
	local.PointGluedToTruck glue $truck1
	
	// This model is where you want the players origin to be.
                local.playerPos = spawn script_model
	local.playerPos.origin = local.PointGluedToTruck.origin + (0 0 55)
	
                // Bind these two points together so one follows the other around
                local.playerPos bind local.PointToAttachPlayerTo
	
	local.Player.origin = local.playerPos.origin
	
	if (level.TruckMoving == 1)
	{
		local.Player glue local.playerPos
	
		while (level.TruckMoving == 1)
		{
			wait 1
		}

		local.Player unglue
	}
	
end
[VS-UK]Capt.Parts[BnHQ]
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Post by Vic Marrow »

I tried these and had problems (of course) Probely didn't set'em up right. I tried your way jv_map. I set it up like this:

Code: Select all

	glueguytotank local.tank local.offset: 

	local.tank = $Sherman 
        local.org1 = spawn script_origin 
        local.org1 thread glueto local.tank 
	local.offset = ( -8 -14.5 112)
        local.org2 = spawn script_origin 
        local.org2 = local.tank.origin + local.offset 
        local.org2 bind local.org1 

       self thread glueto local.org2 
end 

       glueto local.other: 
       while(self && local.other) 
       { 
        self.origin = local.other.origin 
        self.angles = local.other.angles 
         waitframe 
        } 
end
My console gave me an error that said self.origin = local.other.origin Can not cast 'vector to listener'


And thats the same error message I get when I try tltrude's way. except I had add brackets around $tank.origin + ( -32 16 64 ) it wouldent parse with out them like this:

Code: Select all

$tankcdr.origin glue ($Sherman.origin + ( -8 -14.5 112))
Parts your way kinda looks like jv_maps way. But I'm not sure how to plug in my variables. Like I know $truck would be replaced by $Sherman and my numbers would replace the numbers, but what about level.TruckMoving? Is that a thread from somewhere else? and where does local.PointToAttachPlayerTo come from? I tried messing with this and sometimes it woulden't parse or I would get the
Can not cast 'vector to listener' or one time the tankcdr was sent to the top of my skybox!
I tried this:

Code: Select all

$tankcdr.origin = ($Sherman.origin + ( -8 -14.5 112))
This put the guy right where I wanted him but the tank woulden't move.

Also what does NIL mean is that a statement that the game can't find or see.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Vic Marrow wrote:My console gave me an error that said self.origin = local.other.origin Can not cast 'vector to listener'.
For debugging it is vital that you mention where the ^ is placed in the error message. This symbol indicates where the error occured.
Image
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Post by Vic Marrow »

Sorry

self.origin = local.other.origin
self.origin = local.other^
^~^~^Script Error: Cannot cast 'vector' to listener
self.origin = local.other.origin
self^
^~^~^Script Error: Cannot cast 'NIL' to vector
self.angles = local.other.angles
self.angles = local.other^
^~^~^Script Error: Cannot cast 'vector' to listener
self.angles = local.other.angles
self^
^~^~^Script Error: Cannot cast 'NIL' to vector

and this message keeps repeating over and over
Vic Marrow
Colour Sergeant
Posts: 95
Joined: Wed Aug 20, 2003 2:31 pm

Post by Vic Marrow »

I got it to work like this:

Code: Select all

	$tankcdr.origin = $Sherman.origin + ( -8 -14.5 80) 
	$tankcdr bind $Sherman
Looks cool to see the Sherman drive by with the commander up in his coupla.
But it still needs some work. I have him exit the tank like this:

Code: Select all

	$nazi_tank waittill death
	$tankcdr unbind
	$tankcdr physics_on
	$tankcdr anim tank_exit_1
	$tankcdr waittill animdone
	$tankcdr runto $wp1
When he goes into the runto command, instead of jumping down to the ground he runs on imangery plane like a straight line was drawn from the turrent to the waypoint. Most of the way to the waypoint he is running in mid-air. (Gotta fix that) Also when he's up in the tank turrent and the gun fires the tank rocks but he dosen't. I tried the physics_off command for him but this didn't help. Another thing I would like to do is have his angles the same as the turrents angles (not the tank base. The turrent will rotate but he does not) It sounds easy but the tank base and the turrent are 2 different tik files. In radient all you see is the Sherman base and the game spawns the turrent. My tanks targetname is $Sherman but how do you call out the turrent. I know when you make the main gun traverse aim and fire its called like this:


TankFire:
local.gun1 = self QueryTurretSlotEntity 0
local.gun1 setAimTarget $nazi_tank
local.gun1 waittill ontarget
local.gun1 startfiring
end


When you call the thread self is $Sherman. So I tried:
$tankcdr.angles = $Sherman.QueryTurretSlotEntity0.angles
But it didn't work. I got to figure how to or whats the targetname for the turrent. Also I noticed in radiant when you bring up the turrent and push the animate button the commander hatch opens and I looked in the files and theres an animation for hatch_open Just got to figure out how to use it. Man this is fun but I feel dizzy and I think I better go to bed now.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

$tankcdr

Post by tltrude »

I think ther is a command:

$tankcdr droptofloor

Or something like that.
Tom Trude,

Image
Post Reply