Blockland Welcome, Guest. Please login or register.
Did you miss your activation email?
June 20, 2018, 08:21:27 PM

Home Help Login Register
+  Blockland Forum
|-+  Blockland Forums
| |-+  Modification Help
| | |-+  anyway of having two muzzle points?
Pages: [1]
Author Topic: anyway of having two muzzle points?  (Read 534 times)
Protoss Dragoon

« January 10, 2018, 10:11:19 PM »

is this even possible? to perhaps make a double barreled weapon ?

Logged
Ad Bot

Full members do not see ads

Masterlegodude

« January 10, 2018, 10:26:24 PM »

You can probably just get away with centering the muzzlePoint between the barrels and using the multi-projectile and projectile spread script from Ephialtes' shotgun
[table][tr][td]
Code:
%projectile = %this.projectile;
%spread = 0.0015;
%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;
[/td][/tr][/table]
Logged
Protoss Dragoon

« January 10, 2018, 10:27:27 PM »

You can probably just get away with centering the muzzlePoint between the barrels and using the multi-projectile and projectile spread script from Ephialtes' shotgun
thanks
Logged
Swollow

« January 11, 2018, 05:33:14 PM »

put the muzzle point in the middle
when creating projectiles just do a little bit of math to create a projectile or projectiles at 2 locations

Code:
function gunImage::onFire(%db,%pl,%slot)
{
%upHack = %pl.getUpVectorHack();
%muzBase = %pl.getMuzzlePoint(%slot);
%forward = %pl.getMuzzleVector(%slot);
%muzPos0 = vectorAdd(%muzBase,vectorRelativeShift(%forward,%upHack,0 SPC -1 SPC 0));
%muzPos1 = vectorAdd(%muzBase,vectorRelativeShift(%forward,%upHack,0 SPC 1 SPC 0));

%proj = %db.projectile;
%pvel = %pl.getVelocity();
%vel = vectorAdd(%proj.muzzleVelocity,vectorScale(%pvel,%proj.velInheritFactor));
for(%i=0;%i<=1;%i++)
{
%p = new projectile()
{
dataBlock = %proj;
initialVelocity = %vel;
initialPosition = %muzPos[%i];
sourceObject = %pl;
sourceSlot = %slot;
client = %pl.client;
};
missionCleanup.add(%p);
}
}
function vectorRelativeShift(%forward,%up,%shift)
{
return vectorAdd(vectorAdd(vectorScale(%forward,getWord(%shift,0)),vectorScale(vectorCross(%forward,%up),getWord(%shift,1))),vectorScale(%up,getWord(%shift,2)));
}
function vectorAngleRotate(%vec,%ref,%ang)
{
%x = getWord(%vec,0);
%y = getWord(%vec,1);
%z = getWord(%vec,2);
%u = getWord(%ref,0);
%v = getWord(%ref,1);
%w = getWord(%ref,2);
%cos = mCos(%ang);
%sin = mSin(%ang);
return %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%x*%cos+(%v*%z-%w*%y)*%sin SPC %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%y*%cos+(%w*%x-%u*%z)*%sin SPC %u*(%u*%x+%v*%y+%w*%z)*(1-%cos)+%z*%cos+(%u*%y-%v*%x)*%sin;
}
function player::getUpVectorHack(%pl)
{
%muz = MatrixMulVector(%pl.getSlotTransform(0),"0 1 0");
%forward = %pl.getForwardVector();
%up = %pl.getUpVector();
return vectorAngleRotate(%muz,vectorCross(%forward,%up),$PI/2);
}

this would create two projectiles when the gun fires, one shifted 1 unit to the left and the other shifted 1 unit to the right
obviously if you wanted to create some projectiles spreading you could use some spread code to create multiple projectiles at each point

the bottom 3 functions are just support functions and you don't need to worry about anything in them
the only thing you need to tinker with is muzPos0 and muzPos1 and the projectile creation part
« Last Edit: January 11, 2018, 05:52:19 PM by Swollow » Logged
Gytyyhgfffff

« January 11, 2018, 05:42:23 PM »

that version of vectorRelativeShift forgets up when you aim upwards so don't use it. use this stuff instead

Code:
function vectorRelativeShift(%forwardVector, %shift)
{
%rightVector = VectorNormalize(VectorCross(%forwardVector, "0 0 1"));
%upVector = VectorNormalize(VectorCross(%rightVector, %forwardVector));
%shiftX = getWord(%shift, 0);
%shiftY = getWord(%shift, 1);
%shiftZ = getWord(%shift, 2);

%result = "0 0 0";
%result = VectorAdd(%result, VectorScale(%rightVector, %shiftX));
%result = VectorAdd(%result, VectorScale(%forwardVector, %shiftY));
%result = VectorAdd(%result, VectorScale(%upVector, %shiftZ));

return %result;
}
this correctly transforms the muzzle position. for %shift, x is left/right, y is forward/backwards, and z is up/down
Logged
Swollow

« January 11, 2018, 05:46:18 PM »

that function definitely works right, notice my usage of getUpVectorHack
but your function looks better since you don't need as many reference angles

however it would be nice if you renamed your function so it didn't forget up other people's addons
nameplay apache attack helicopter and my weapons pack etc, which all implement that version of vectorRelativeShift correctly
« Last Edit: January 11, 2018, 05:48:35 PM by Swollow » Logged
Gytyyhgfffff

« January 11, 2018, 05:49:36 PM »

that function definitely works right, notice my usage of getUpVectorHack
but your function looks better since you don't need as many reference angles

however it would be nice if you renamed your function so it didn't forget up other people's addons
nameplay apache attack helicopter and my weapons pack etc, which all implement that version of vectorRelativeShift correctly
my bad, i've seen the same function used in bushido's add-ons which had the problems i described
Logged
Swollow

« January 11, 2018, 05:50:51 PM »

the reason that it forgets up is because people just use getUpVector which always returns "0 0 1" unless you are in a vehicle, since its not getting the upward vector of your aim rather the upwards vector angle of how your player object is rotated
Logged
jeprimer

« January 11, 2018, 09:38:02 PM »

i have an idea that's kinda hacky... what if you were like:

Code:
stateName[3] = "fire1";
stateEmitter[3] = GunFlashEmitter;
stateEmitterTime[3] = 0.175;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3]            = 0;
stateTransitionOnTimeout[3]     = "fire2";

stateName[4] = "fire2";
stateEmitter[4] = GunFlashEmitter;
stateEmitterTime[4] = 0.175;
stateEmitterNode[4] = "muzzleNode2";
stateTimeoutValue[4]            = 0.1;
stateTransitionOnTimeout[3]     = "reload";

but in reality only launch projectiles from one of them, using the spread code above... that way it would appear it's firing out of both?
Logged
Swollow

« January 13, 2018, 02:55:22 AM »

you can't have a timeout value of 0 can you?
Logged
Pages: [1]  


Login with username, password and session length

Powered by SMF 1.1.20 | SMF © 2013, Simple Machines
Page created in 0.017 seconds with 19 queries.