Author Topic: REQUEST: Event_Mounttobrick  (Read 1245 times)

Would be a good add-on for sitting and whatnot (sorry for all the suggestions but im getting some ideas)

wouldn't setplayertransform do this?

wouldn't setplayertransform do this?
SetPlayerTransform wouldn't hold the player in place like mounting one would.

I like this idea.
It should have the parameter of what direction the player should face like setPlayerTransform does.
And right clicking dismounts like in vehicles.

No more needs to awkwardly try to move in the correct center of the chair.
Or needing to hold a button so you only move your head instead of spinning around.
Just click the chair and you'll sit perfectly.

« Last Edit: July 11, 2016, 01:15:29 PM by jes00 »

Might do it.
If you don't end up doing it, I did this a long time ago and I can just release it.

If you don't end up doing it, I did this a long time ago and I can just release it.
I was going to put in an option to have their rotation locked or not.

But if you've already made it, go ahead. I don't have that much code done for it yet anyways.
Code: [Select]
datablock ItemData(itemMountToBrickData)
{
category = "Weapon";
className = "Weapon";

shapeFile = "base/data/shapes/empty.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

uiName = "";
iconName = "";
doColorShift = false;

image = "";
canDrop = false;
};

datablock PlayerData(playerMountToBrickData : PlayerStandardArmor)
{
jumpForce = 0;
canJet = 0;

isInvincible = 1;

uiName = "";
};

function playerMountToBrickData::onAdd(%data, %player)
{
%player.setPlayerScale(0.2);
%player.hideNode("ALL");
}

registerOutputEvent("fxDTSBrick", "mountPlayerToBrick", "list Relative 0 North 1 East 2 South 3 West 4" TAB "bool", 1);

function fxDTSBrick::mountPlayerToBrick(%brick, %dir, %canRotate, %client)
{
if(!isObject(%client) || !isObject(%player = %client.player))
{
return;
}

if(isObject(%brick.playerMountObj))
{
%brick.playerMountObj.delete();
}

switch(%dir)
{
case 0:
%rot = getWords(%player.getTransform(), 3, 6);

case 1:
%rot = "1 0 0 0";

case 2:
%rot = "0 0 1 1.57079";

case 3:
%rot = "0 0 1 3.14159";

case 4:
%rot = "0 0 1 -1.57079";
}

%brick.playerMountObj = new (%canRotate ? "AIPlayer" : "item")()
{
datablock = %canRotate ? "playerMountToBrickData" : "itemMountToBrickData";
position = vectorAdd(%brick.getPosition(), %canRotate ? "0.4 0.4 0.4" : "0.2 0.2 0.2");
rotation = %rot;
scale = "1 1 1";

rotate = false;
static = !%canRotate;
canPickup = !%canRotate;
};

missionCleanup.add(%brick.playerMountObj);

%slot = %canRotate ? 8 : 0;
%brick.playerMountObj.mountObject(%player, %slot);

if(%canRotate)
{
//%player.setTransform(%player.getPosition SPC %rot);
}
}

package mountPlayerToBrick
{
function playerMountToBrickData::onNewDataBlock(%data, %player)
{
%player.setPlayerScale(0.2);
%player.hideNode("ALL");

parent::onNewDataBlock(%data, %player);
}

function armor::onUnMount(%data, %player, %obj, %slot)
{
parent::onUnMount(%data, %player, %obj, %slot);

if(%obj.getDataBlock().getName() $= "playerMountToBrickData")
{
//%obj.schedule(500, delete);
}
}
};
activatePackage(mountPlayerToBrick);