Author Topic: Combining Onfire Functions  (Read 1952 times)

I need a way to combine these into one so I can have both effects at the same time. Can anyone help me?
Code: [Select]
function ForceLightningImage::onFire(%this, %obj, %slot)
{
%nrg = %obj.getEnergyLevel();
if(50 <= %nrg) {
%obj.setEnergyLevel(%nrg - 50);
commandtoClient(%obj.client,'bottomprint',"<just:center> \c1 Force Power: [" @ mFloor(%obj.getEnergyLevel()) @ "/" @ %obj.getDataBlock().maxenergy @ "]",2);
}
else {
commandtoClient(%obj.client,'bottomprint',"<just:center> \c1[Not Enough Force Power - " @ mFloor(%nrg) @"/"@ %obj.getDataBlock().maxenergy @"]",2);
return;
}
%obj.playthread(2, armattack);
Parent::onFire(%this, %obj, %slot);
}
Code: [Select]
function ForceLightningImage::onFire(%this,%obj,%slot)
{
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"0")));
%obj.playThread(2, shiftAway);

%projectile = %this.projectile;
%spread = 0.002;
%shellcount = 3;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;

}

Code: [Select]
function ForceLightningImage::onFire(%this, %obj, %slot)
{
%nrg = %obj.getEnergyLevel();
if(50 <= %nrg) {
%obj.setEnergyLevel(%nrg - 50);
commandtoClient(%obj.client,'bottomprint',"<just:center> \c1 Force Power: [" @ mFloor(%obj.getEnergyLevel()) @ "/" @ %obj.getDataBlock().maxenergy @ "]",2);
}
else {
commandtoClient(%obj.client,'bottomprint',"<just:center> \c1[Not Enough Force Power - " @ mFloor(%nrg) @"/"@ %obj.getDataBlock().maxenergy @"]",2);
return;
}
%obj.playthread(2, armattack);
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"0")));
%obj.playThread(2, shiftAway);

%projectile = %this.projectile;
%spread = 0.002;
%shellcount = 3;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}
Parent::onFire() in the first code would call the 'normal' function to do the firing (one projectile straight ahead) so you just replace that with your Ephi's some guy off GarageGames' new spread fire function.
« Last Edit: February 04, 2008, 01:46:34 PM by Space Guy »

Actually, The projectile spread is from a resource on garagegames.

Fixed :cookieMonster:

Code: [Select]
   %x = (1 - 2*getRandom());
   %y = (1 - 2*getRandom());
   %z = (1 - 2*getRandom());
   %aimPoint = vectorAdd(%brick.getTransform(),vectorScale(%vector,80));
   %aimPoint = vectorAdd(%aimPoint,%x SPC %y SPC %z);
   %vector = vectorNormalize(vectorSub(%aimPoint,%brick.getTransform()));

On the topic of spreadfire functions, what does MatrixMulVector actually do? I found this method (get a point far away from the direction it is aiming in, add a random amount XYZ then use homing/aiming code to get a normalized vector to there) to work just as well. (From Wrench Events 'Spread' turret)

Quote from: TDN
Use the MatrixMulVector function to multiply a seven-element transform matrix with a three-element matrix.

I wish TDN was open to everyone, it'd improve the quality of BL add-ons...

A lot of the resources are public, but Garage Games would lose a big draw if they provided all the knowledge for free.

Yeah they would, and thank you Space Guy. You are my favorite modder on Blockland.

I don't know that I'd take it as a compliment when one of the worst modders in Blockland tells me I'm his favorite modder.

You can call me the worst modder because I don't like you as much. I couldn't care less. The main reason I like Space Guy is that he is GOOD and NICE.

I r can retrieve info from TDN, just tell me what you want(however its not a very relieable/updated/remotely-good source. Since its only updated every 4 years or something.

You can call me the worst modder because I don't like you as much. I couldn't care less. The main reason I like Space Guy is that he is GOOD and NICE.

I am nice to non-idiots.  Just ask any of the people with whom I frequently chat and / or play Blockland.

Just because I am not as smart as you doesn't mean  :iceCream:. Ever since you've released your Doors system you have had an ego through the roof...

PS: I'm sure many on the forums would agree with me.

Trader always had an ego.

Quote
ego [noun]

1. egotism; conceit; self-importance.

I never claim to be better than anyone.  No, I won't sugar-coat things I say so idiots don't get their feelings hurt, but you don't see me here praising myself.  In fact, any praise you here for my name comes from other forum members.

Why is Dr Bling an idiot?  I'll tell you.

Whenever I join a server and Dr Bling is there, he spams the chat with questions about modding, directed at me.  Then, when I don't answer him, he attacks me with the hammer.  Instead of doing the logical thing of posting his question on the forum, he makes then choice an idiot would make and proceeds to perform the actions I just listed.  The simple fact that Dr Bling posted this topic on the forum goes to show that my rebuttal of his actions proved to be the correct thing to do.

So don't post all that nonsense about me having an ego.  Very few here understand what I deal with on a daily basis.
« Last Edit: February 05, 2008, 09:58:47 AM by Trader »