Author Topic: Occasionally mounting to wrong slot  (Read 676 times)

Code: [Select]
function GameConnection::spawnPlayer(%this)
{
Parent::spawnPlayer(%this);
if(isObject(%this.horse))
%this.horse.kill();
%this.horse = new Player()
{
datablock = HorseArmor;
position = %this.player.getPosition();
};
%this.horse.player = %this.player;
%this.horse.mountObject(%this.player,0);
}
This is of course in a package.

Part of something I'm making to try out the gamemode system, when the player spawns they are automatically spawned a horse and mounted to it
The problem is, sometimes the player mounts to slot 1 of the horse, instead of slot 0 (mounting at the side instead of the seat). This is literally the only place that moutObject is called, so I have no idea what could be causing it to mount to the wrong slot. This is also using the new gamemode system, so the way I understand it there are no other add-ons loaded that could be interfering with it.

EDIT: It would seem that slot 0 is the wrong slot and I should be mounting to slot 2. But this still leaves me confused as most of the time I was spawning in the slot I wanted instead of what I was telling it
« Last Edit: August 11, 2012, 01:06:26 AM by Headcrab Zombie »

is it possible that... the player is mounting to the horse on its own? try, perhaps, dismounting the player then remounting them.

I really don't know.

That makes sense....but other than that I don't even know what to think

If I jump on the horse normally, I am in the correct position, and mounted to slot 0 (horse.getMountedObject(0) returns my player, while any other slot is empty)
If I manually call mountObject to mount to slot 0, I am mounted on the side of the horse, yet I am able to control the horses movement normally.
If I do the same, but mount to slot 2, I am mounted in the correct position, but I am unable to control the horses movement.
« Last Edit: August 11, 2012, 01:13:17 AM by Headcrab Zombie »

I have this problem with the hydra aa turret

I made this playertype a while back which might work, try setting the minigame to use it or a variant (if you don't want the dismount/summon thing) or changing the player to it directly.

You should have to use setControlObject to control the horse unless there's a weird override for mounting slot 0 to do with vehicles. You're on its side when doing that becuase slot 0 is your/the horse's main weapon mount.

EDIT: Found it. getMountedObject() isn't using the same ID numbers.

Appendix A
Quote
getMountedObject( slot )

slot – An integer value between 0 and 7 representing a mount slot on this shape.

Returns an integer value equal to the ID of object mounted is slot. If not object is
mounted in this slot, the method returns -1.
Quote
getMountNodeObject( node )

node – A node value between 0 and 31 representing a mount node in the mesh used
by this shape.

Returns an integer value equal to the ID of the object mounted on node. If not object is
mounted at node, this method returns -1.
Quote
Notes
Do not confuse slots with mount nodes. A shape can have up to 32 mount nodes, but only
has eight mount slots. Mount nodes are points on the mesh used by the shape while slots
are used to track how many objects and images are mounted to a shape.

When you jump on a normal horse you are put in mount slot (vehicle seat) 0 which is equivalent to mount node (attach point) 2, so getMountedObject() would say your player is in seat 0.
« Last Edit: August 11, 2012, 07:31:07 AM by Space Guy »

You're on its side when doing that becuase slot 0 is your/the horse's main weapon mount.
I figured this much out after posting the thread, but I was confused about the rest that your post cleared up.
Thanks for the help, I'll look at that playertype whenever I feel like working on the gamemode again.