Author Topic: How to mount an image to a player?  (Read 2289 times)

I just can't seem to get this to work. Like my previous two threads (I sincerely hope I'm not spamming...), I figure the problem must be simple, but it doesn't seem to work.
I cannibalized code from Ability Bots ( https://forum.blockland.us/index.php?topic=292925.0 ), specifically the Phase C bot, to try to get a similar effect.
I want a playertype that's phased and has an emitter attached to it, but the actual process of mounting the image seems different for players than bots.

Sorry to bother you again, forum! But can you help?

Code: [Select]
datablock PlayerData(PlayerCauchemar : PlayerStandardArmor)
{
uiName = "Cauchemar";
canJet = 0;
rechargeRate = 0;
showEnergyBar = false;
maxdamage = 9999;
};

datablock ParticleData(CauchemarParticle)
{
textureName          = "base/data/particles/dot";
dragCoefficient      = 0.0;
gravityCoefficient   = 0.0;
inheritedVelFactor   = 0.0;
windCoefficient      = 0;
constantAcceleration = 0;
lifetimeMS           = 1250;
lifetimeVarianceMS   = 0;
spinSpeed     = 0;
spinRandomMin = -90.0;
spinRandomMax =  90.0;
useInvAlpha   = false;

colors[0] = "0.32 0 1 1.0";
colors[1] = "0.49 0 1 0.85";
colors[2] = "0.74 0 1 0.0";

sizes[0] = 0.2;
sizes[1] = 0.15;
sizes[2] = 0.1;

times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};

datablock ParticleEmitterData(CauchemarEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = -10.0;
   velocityVariance = 0.0;
   ejectionOffset   = 10.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 720;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "CauchemarParticle";

   //useEmitterColors = True;
   useEmitterColors = False;

    uiName = "Cauchemar";
};

datablock ShapeBaseImageData( CauchemarImage )
{
shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = 7;//$HeadSlot; //i want it to spawn the emitter on his torso, so instead of "4", a foot, it's "2", the torso
//alternatively i can set it to "7" for his pants

offset = "0 0 0";
rotation = "1 0 0 180";

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.1;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Ready";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 0.1;
stateEmitter[1] = CauchemarEmitter; //wandExplosionEmitter; //PlayerJetEmitter;
//this is the only thing i'll change probably
//you can change the "A" to letters A-F
//those are all the emitters.
stateEmitterTime[1] = 1000;

// stateName[2] = "Done";
// stateScript[2] = "onDone";
};

function PlayerCauchemar::onAdd(%this,%obj)
{
armor::onAdd(%this,%obj);

%obj.mountImage( CauchemarImage, 2);

GameConnection::ApplyBodyParts(%obj);
GameConnection::ApplyBodyColors(%obj);

//this is the glitchy phase effect
//allows the bot to be a portal to the skybox
%obj.setNodeColor("ALL", "0 0 0 0");
}
« Last Edit: October 24, 2017, 07:03:50 PM by Brixmon »

Try changing up the state values: - This is ripped off from my shield add-on
Code: [Select]
datablock ShapeBaseImageData(YourImage : PlayerTeleportImage)
{
shapeFile = "shapefile.dts";
colorShiftColor = "0.0000 0.0000 0.0000 0.0000";
doColorShift = false;

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "Check";
stateTimeoutValue[0] = 0.1;

stateName[1] = "Check";
stateTransitionOnTimeout[1] = "Check";
stateWaitForTimeout[1] = true;
stateTimeoutValue[1] = 0.05;
stateEmitter[1] = "your emitter here";
stateEmitterTime[1] = 1;
//stateScript[1] = "onCheck";

mountPoint = $HipSlot;
};

Try changing up the state values: - This is ripped off from my shield add-on
Code: [Select]
datablock ShapeBaseImageData(YourImage : PlayerTeleportImage)
{
shapeFile = "shapefile.dts";
colorShiftColor = "0.0000 0.0000 0.0000 0.0000";
doColorShift = false;

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "Check";
stateTimeoutValue[0] = 0.1;

stateName[1] = "Check";
stateTransitionOnTimeout[1] = "Check";
stateWaitForTimeout[1] = true;
stateTimeoutValue[1] = 0.05;
stateEmitter[1] = "your emitter here";
stateEmitterTime[1] = 1;
//stateScript[1] = "onCheck";

mountPoint = $HipSlot;
};
Thanks, gonna try that, but I should also mention that the phase effect didn't work either. How can I apply that and have it stay?
EDIT: Heeey! The phase works now! Here's the code:
Code: [Select]
function PlayerCauchemar::onNewDatablock(%data, %obj)
{
    Parent::onNewDatablock(%data, %obj);
    %obj.unmountImage(2);
    %obj.mountImage(CauchemarImage,2);
    %obj.setNodeColor("ALL", "0 0 0 0");
}

I used this for a different playertype to turn it invisible, but that one lost the invisibility partially every so often. If that happens with Cauch here, how do I keep it there/refresh it periodically?

Edit: By now I think it's safe to say my problem has been solved. Thanks for the help, though!
« Last Edit: October 25, 2017, 05:26:45 PM by Brixmon »

By the way you do not need to unmount an image, that's already done for you when you mount a different one

Okay, well, is there a way to refresh the appearance data/re-hide nodes every time the player uses the options menu? I don't want it to lose the phase effect...

That sounds like a weird bug. I think that only happens on nondedicated servers.

That sounds like a weird bug. I think that only happens on nondedicated servers.
No, I'm using a dedi to test this. I'm pretty sure it resends the player's appearance data whenever I save options, meaning that it would unhide nodes and change colors, causing the phase effect to vanish.

Oh my bad I wasnt paying attention to the code above. Yea when you close options it sends an avatar change - there are 2 ways of fixing this:
In the image example I gave you can use that onCheck to set the node color
OR
package the command to send avatar bodyparts and colors, see if player exists, if so, check if they have the image mounted, if so, prevent them from sending new requests