Author Topic: Projectile scale?  (Read 1081 times)

Trying to change the scale of my projectile.
Code: [Select]
for(%shell=0; %shell<%shellcount; %shell++)
{
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = vectorScale(%obj.getMuzzleVector(%slot), 200);
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
%p.setScale( %scaleFactor @ " " @ %scaleFactor @ " " @ %scaleFactor);
missionCleanup.add(%p);
}
return %p;
No matter what I set the value of %scalefactor to, the projectile is always the same size. What am I doing wrong?

It should adjust it.

To test it, change this line:
%p.setScale( %scaleFactor @ " " @ %scaleFactor @ " " @ %scaleFactor);

to these two:

echo("Scale Factor:" SPC %scaleFactor);
%p.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);




It should adjust it.

To test it, change this line:
%p.setScale( %scaleFactor @ " " @ %scaleFactor @ " " @ %scaleFactor);

to these two:

echo("Scale Factor:" SPC %scaleFactor);
%p.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);




I tried the SPC arrangement before, but it didnt work.

setScale should affect the projectile size, explosion size, trail emitter size, damage values, brick explosion values, etc, correct?

Correct.

Change the projectile to the Pong projectile because it's very slow, has very long longevity, and has noticeable light/particles.

Alright, I figured it out, the script actually isnt spawning a projectile.

The only reason it was firing because I had parent::onFire in the function by mistake.

Code: [Select]
function SLCZImage::onFire(%this,%obj,%slot)
{
%projectile = SLCZProjectile;
%charge_time = getSimTime() - %obj.client.saved_time;
if(%charge_Time <= 1000.0)
{
%scaleFactor = 0.5;
}
if(%charge_Time <= 2000.0)
{
%scaleFactor = 0.75;
}
if(%charge_Time <= 3000.0)
{
%scaleFactor = 1.0;
}
if(%charge_Time <= 7000.0)
{
%scaleFactor = 2.0;
}

%client = %obj.client;
%pos = %obj.getHackPosition();

for(%shell=0; %shell<%shellcount; %shell++)
{
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = vectorScale(%obj.getMuzzleVector(%slot), 200);
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
echo("Scale Factor:" SPC %scaleFactor);
%p.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);
missionCleanup.add(%p);
}
return %p;
}
This seems to have a problem with it as well, as nothing echoed when I fired the weapon, and when I removed parent::onFire no projectile was spawned at all.

Wait, crap. Forgot to specify %shellcount. Fixed it.

New problem: the projectile is always the same scale no matter how long I hold the button.

Yeah that would be a problem.

%shellCount is undefined, meaning it will produce 0 projectiles.

You didn't copy the code over correctly.

Edit: What is the console echo'ing for ScaleFactor

Edit: What is the console echo'ing for ScaleFactor
2.
Edit: I have this function before the onFire one. (The weapon image is based off of the Spear's image)
Code: [Select]
function SLCZImage::onCharge(%this, %obj, %slot)
{
%obj.client.saved_time = getSimTime();
}
« Last Edit: March 21, 2011, 08:56:27 PM by takato14 »

Just replace the entire loop with this.

It should make the projectile a random size every time you fire.

I also put the size rescaling post-group add, but that shouldn't really change anything.

Code: [Select]
for(%shell=0; %shell<%shellcount; %shell++)
{
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = vectorScale(%obj.getMuzzleVector(%slot), 200);
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
missionCleanup.add(%p);

%scaleFactor = getRandom(0, 200) / 100;
%p.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);
}

If this doesn't work I don't know.

Just replace the entire loop with this.

It should make the projectile a random size every time you fire.

I also put the size rescaling post-group add, but that shouldn't really change anything.

Code: [Select]
for(%shell=0; %shell<%shellcount; %shell++)
{
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = vectorScale(%obj.getMuzzleVector(%slot), 200);
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
missionCleanup.add(%p);

%scaleFactor = getRandom(0, 200) / 100;
%p.setScale(%scaleFactor SPC %scaleFactor SPC %scaleFactor);
}

If this doesn't work I don't know.
That's not what I wanted it to do, what I want is the longer you hold the mouse button before firing, the larger/more powerful the blast is. This is in an attempt to avoid several wasteful datablocks.

Probably should've specified that earlier.
« Last Edit: March 21, 2011, 09:00:20 PM by takato14 »

Right, but that's not the point of the script. If it doesn't adjust the projectile size randomly with direct input like that, the problem is beyond my reach.

If it does work, as I suspect it will, you can back track and add more detail to it.

Right, but that's not the point of the script. If it doesn't adjust the projectile size randomly with direct input like that, the problem is beyond my reach.

If it does work, as I suspect it will, you can back track and add more detail to it.
I changed the scale factor of the last check (referring to if(%charge_time <=7000)) to three and the projectile scale echoed as 3 and was larger as well.

Technically the question I had initially asked has been solved, but I dont see a point in making another topic.

Make the model bigger, then. It'd be better to make a huge model and scale it to a range of 0.25-0.75 than to make a model too small.

Make the model bigger, then. It'd be better to make a huge model and scale it to a range of 0.25-0.75 than to make a model too small.
uh, what... The projectile model is empty.dts...

Alright. Here's what I am trying to do with this.

I want a chargeable laser. I have the weapon image set up similarly to the spear.

I store the time the weapon is started charging in the client using getSimTime() as shown in the function below.
Code: [Select]
function SLCZImage::onCharge(%this, %obj, %slot)
{
%obj.client.saved_time = getSimTime();
}
Then, I use the below function to determine how long the client has been charging the weapon. The bolded part is meant to test how long the client has been charging.
Quote
--EPIC SNIP--
The 4 if statements set %scaleFactor to different values depending on how long the client has been charging. half-size for less than a second, 3/4 size for anything above 1.999 seconds, normal scale for 3 seconds, and twice the size at 7 seconds(the projectile is highly destructive).

The scaling works right now, but Im not checking for how long the mouse button has been held correctly. How else can I test for this?

Apparently I actually AM doing it right; The script is simply skipping the lower scales and jumping straight to 1. Then If I hold it for over 7 seconds it shoots a projectile with scale of 2.
« Last Edit: March 21, 2011, 09:56:49 PM by takato14 »

Managed to finally fix it. Locking.