Scaling a weapon
by Matt Cuda · in Technical Issues · 01/19/2008 (11:50 am) · 7 replies
I assume this question has been asked many times but my searches were not helping.
I am trying to resize a crossbow.dts either in its datablock or when it is mounted. How can I do this in Torque Script? I have tried to use "scale =" in the ShapeBaseImageData datablock but it had no effect.
Could someone please help me with this? I am starting to get frustrated.
Thanks,
I am trying to resize a crossbow.dts either in its datablock or when it is mounted. How can I do this in Torque Script? I have tried to use "scale =" in the ShapeBaseImageData datablock but it had no effect.
Could someone please help me with this? I am starting to get frustrated.
Thanks,
About the author
#2
My script does compille correctly when using the "scale=" syntax but it has no effect on the crossbow.
01/20/2008 (3:15 pm)
Actually I did try this, but I wonder if it is in the wrong function or datablock.My script does compille correctly when using the "scale=" syntax but it has no effect on the crossbow.
#3
datablock ShapeBaseImageData(BowImage)
{
// Basic Item properties
shapeFile = "~/data/shapes/medievalweapons/crossbow.dts";
emap = true;
scale="0.5 0.5 0.5";
// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 0;
eyeOffset = "0.1 0.4 -0.6";
// When firing from a point offset from the eye, muzzle correction
// will adjust the muzzle vector to point to the eye LOS point.
// Since this weapon doesn't actually fire from the muzzle point,
// we need to turn this off.
correctMuzzleVector = false;
// Add the WeaponImage namespace as a parent, WeaponImage namespace
// provides some hooks into the inventory system.
className = "WeaponImage";
// Projectile && Ammo.
item = Bow;
ammo = BowAmmo;
projectile = BowProjectile;
projectileType = Projectile;
// Images have a state system which controls how the animations
// are run, which sounds are played, script callbacks, etc. This
// state system is downloaded to the client so that clients can
// predict state changes and animate accordingly. The following
// system supports basic ready->fire->reload transitions as
// well as a no-ammo->dryfire idle state.
// Initial start up state
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";
// Activating the gun. Called when the weapon is first
// mounted and there is ammo.
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.6;
stateSequence[1] = "Activate";
// Ready to fire, just waiting for the trigger
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "Fire";
// Fire the weapon. Calls the fire script which does
// the actual work.
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 0.2;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = BowFireSound;
// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.8;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
stateSound[4] = BowReloadSound;
// No ammo in the weapon, just idle until something
// shows up. Play the dry fire sound if the trigger is
// pulled.
stateName[5] = "NoAmmo";
stateTransitionOnAmmo[5] = "Reload";
stateSequence[5] = "NoAmmo";
stateTransitionOnTriggerDown[5] = "DryFire";
// No ammo dry fire
stateName[6] = "DryFire";
stateTimeoutValue[6] = 1.0;
stateTransitionOnTimeout[6] = "NoAmmo";
stateSound[6] = BowFireEmptySound;
};
01/20/2008 (6:56 pm)
Here is my datablock...datablock ShapeBaseImageData(BowImage)
{
// Basic Item properties
shapeFile = "~/data/shapes/medievalweapons/crossbow.dts";
emap = true;
scale="0.5 0.5 0.5";
// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 0;
eyeOffset = "0.1 0.4 -0.6";
// When firing from a point offset from the eye, muzzle correction
// will adjust the muzzle vector to point to the eye LOS point.
// Since this weapon doesn't actually fire from the muzzle point,
// we need to turn this off.
correctMuzzleVector = false;
// Add the WeaponImage namespace as a parent, WeaponImage namespace
// provides some hooks into the inventory system.
className = "WeaponImage";
// Projectile && Ammo.
item = Bow;
ammo = BowAmmo;
projectile = BowProjectile;
projectileType = Projectile;
// Images have a state system which controls how the animations
// are run, which sounds are played, script callbacks, etc. This
// state system is downloaded to the client so that clients can
// predict state changes and animate accordingly. The following
// system supports basic ready->fire->reload transitions as
// well as a no-ammo->dryfire idle state.
// Initial start up state
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";
// Activating the gun. Called when the weapon is first
// mounted and there is ammo.
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.6;
stateSequence[1] = "Activate";
// Ready to fire, just waiting for the trigger
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "Fire";
// Fire the weapon. Calls the fire script which does
// the actual work.
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 0.2;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = BowFireSound;
// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.8;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
stateSound[4] = BowReloadSound;
// No ammo in the weapon, just idle until something
// shows up. Play the dry fire sound if the trigger is
// pulled.
stateName[5] = "NoAmmo";
stateTransitionOnAmmo[5] = "Reload";
stateSequence[5] = "NoAmmo";
stateTransitionOnTriggerDown[5] = "DryFire";
// No ammo dry fire
stateName[6] = "DryFire";
stateTimeoutValue[6] = 1.0;
stateTransitionOnTimeout[6] = "NoAmmo";
stateSound[6] = BowFireEmptySound;
};
#4
01/21/2008 (6:11 am)
Well, there's no sort of "setScale" function for images, but it resizes when the player does. The codes in there somewhere, it most likely needs to be exposed to script though.
#5
01/21/2008 (7:06 am)
It is strange because no one seems to have a definitive answer on this. Mabye I am going about it totally wrong. I would think there would be a way to get a reference to the dts object while it is mounted or before it is mounted on the player. Then set "scale=0.5 0.5 0.5"
#6
01/21/2008 (7:06 am)
If you can set the scale of a dts object in the world editor then you should be able to set it in code for the weapon.
#7
Here's a list of all the ShapeBaseImageData functions that I found on TDNtdn.garagegames.com/wiki/Torque_Console_Objects_12#ShapeBaseData And I can't see an example of Scale: on here.
01/21/2008 (8:52 am)
Not exactly, just because you can do something with the dts object doesn't mean it can be done through the same work with the ShapeBaseImage. ShapeBaseImage's are rendered differently, client-side only, etc. Here's a list of all the ShapeBaseImageData functions that I found on TDNtdn.garagegames.com/wiki/Torque_Console_Objects_12#ShapeBaseData And I can't see an example of Scale: on here.
Torque 3D Owner Morrock