Blockland Forums > Modification Help
How to mount an image to a player?
Brixmon:
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: ---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");
}
--- End code ---
Kyuande:
Try changing up the state values: - This is ripped off from my shield add-on
--- Code: ---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;
};
--- End code ---
Brixmon:
--- Quote from: Kyuande on October 24, 2017, 10:28:39 PM ---Try changing up the state values: - This is ripped off from my shield add-on
--- Code: ---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;
};
--- End code ---
--- End quote ---
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: ---function PlayerCauchemar::onNewDatablock(%data, %obj)
{
Parent::onNewDatablock(%data, %obj);
%obj.unmountImage(2);
%obj.mountImage(CauchemarImage,2);
%obj.setNodeColor("ALL", "0 0 0 0");
}
--- End code ---
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!
Kyuande:
By the way you do not need to unmount an image, that's already done for you when you mount a different one
Brixmon:
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...