Blockland Forums > Modification Help
Spawning a bot next to you instead of at your exact position
takato14:
What I need to do is spawn a bot alongside the player when they right click. GameFandan's CopyMod spawns them overtop of the player, like this:
What I need is for it to spawn BESIDE the player, like this:
What I have tried so far is below. This script spawns 3 bots at the origin of the map (0, 0, 0) whenever I right click instead of overtop of me, as it should be doing in its current state.(And I already asked GameFandan if I could use his code before doing this, so dont worry)
--- Code: ---function FourLinkArmor::onTrigger(%this,%obj,%slot,%val)
{
Parent::onTrigger(%this,%obj,%slot,%val);
%postion = %obj.getTransform();
//All position values are set to zero until I can get the system itself working, so ignore that
//1st copy's position
%x1 = 0;
%y1 = 0;
%z1 = 0;
%mat1 = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector1 = matrixAddVector(%mat1, %position);
//2nd copy's position
%x2 = 0;
%y2 = 0;
%z2 = 0;
%mat2 = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector2 = matrixAddVector(%mat2, %position);
//3rd copy's position
%x3 = 0;
%y3 = 0;
%z3 = 0;
%mat3 = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector3 = matrixAddVector(%mat3, %position);
if(isObject(%obj.client.bot))
{
%obj.client.bot.delete();
}
%bot1 = new AIplayer(%bot)
{
datablock=PlayerStandardArmor; position = %vector1;
};
%bot2 = new AIplayer(%bot)
{
datablock=PlayerStandardArmor; position = %vector2;
};
%bot3 = new AIplayer(%bot)
{
datablock=PlayerStandardArmor; position = %vector3;
};
MessageClient(%obj.client,0,"\c3You have cloned yourself.");
$copyBots[$copyTotal] = %bot;
$copyTotal++;
%bot.isCopy = 1;
%client.bot = %bot;
%rawr = %obj.client.player;
%obj.client.player = %bot;
%obj.client.applyBodyParts();
%obj.client.applyBodyColors();
%client.player = %rawr;
%bot1.setScale("1 1 1");
%bot1.setMoveObject(%obj.client.player);
%bot1.setShapeName(%obj.client.name);
%bot2.setScale("1 1 1");
%bot2.setMoveObject(%obj.client.player);
%bot2.setShapeName(%obj.client.name);
%bot3.setScale("1 1 1");
%bot3.setMoveObject(%obj.client.player);
%bot3.setShapeName(%obj.client.name);
}
--- End code ---
The only thing Im getting from the console is "unable to find function matrixAddVector." If matrixAddVector isnt the name of the function I'm looking for, then what is? (I need to add the x/y/z values to the corresponding values of the vector. I do know matrixMulVector is a function, but I dont want to multiply the two. How can I add them instead?)
Be merciful -- Im not that good, so what Im trying is probably stupid and way off from what I actually need. Help would, however, be greatly appreciated.
takato14:
I hate slow boards. Bump.
Xalos:
%vectSum = vectorAdd(%vect1, %vect2);
takato14:
--- Quote from: Xalos on July 08, 2011, 05:32:22 PM ---%vectSum = vectorAdd(%vect1, %vect2);
--- End quote ---
But is a matrix a vector? :/
EDIT: Tried it anyways, console errors stopped but the bots are still spawning at the origin.
Also once I right click it becomes impossible to Self Delete, swap images, or drop the weapon, any clue as to why that is? When I press f7, I respawn and it leaves a duplicate client/player ._.
New code:
--- Code: ---function FourLinkArmor::onTrigger(%this,%obj,%slot,%val)
{
Parent::onTrigger(%this,%obj,%slot,%val);
if(%slot == 4 && %val)
{
%postion = %obj.getTransform();
//All position values are set to zero until I can get the system itself working, so ignore that
//1st copy's position
%x1 = 0;
%y1 = 0;
%z1 = 0;
%mat1 = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector1 = vectorAdd(%mat1, %position);
%bot1 = new AIplayer(%bot)
{
datablock=PlayerStandardArmor; position = %vector1;
};
//2nd copy's position
%x2 = 0;
%y2 = 0;
%z2 = 0;
%mat2 = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector2 = vectorAdd(%mat2, %position);
%bot2 = new AIplayer(%bot)
{
datablock=PlayerStandardArmor; position = %vector2;
};
//3rd copy's position
%x3 = 0;
%y3 = 0;
%z3 = 0;
%mat3 = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector3 = vectorAdd(%mat3, %position);
%bot3 = new AIplayer(%bot)
{
datablock=PlayerStandardArmor; position = %vector3;
};
//Don't think I need this VV
//if(isObject(%obj.client.bot))
//{
//%obj.client.bot.delete();
//}
MessageClient(%obj.client,0,"\c3You have cloned yourself.");
$copyBots[$copyTotal] = %bot;
$copyTotal++;
%bot.isCopy = 1;
%client.bot = %bot;
%rawr = %obj.client.player;
%obj.client.player = %bot;
%obj.client.applyBodyParts();
%obj.client.applyBodyColors();
%client.player = %rawr;
%bot1.setScale("1 1 1");
%bot1.setMoveObject(%obj.client.player);
%bot1.setShapeName(%obj.client.name);
%bot2.setScale("1 1 1");
%bot2.setMoveObject(%obj.client.player);
%bot2.setShapeName(%obj.client.name);
%bot3.setScale("1 1 1");
%bot3.setMoveObject(%obj.client.player);
%bot3.setShapeName(%obj.client.name);
}
}
--- End code ---
Headcrab Zombie:
--- Quote from: takato14 on July 08, 2011, 07:44:58 PM ---Also once I right click it becomes impossible to Self Delete, swap images, or drop the weapon, any clue as to why that is? When I press f7, I respawn and it leaves a duplicate client/player ._.
--- End quote ---
Because of this:
--- Code: ---%obj.client.player = %bot;
--- End code ---
You're setting %player to %bot, so whenever any function tries to access player, it uses %bot.
Also, I don't see anywhere where %bot is defined