| Blockland Forums > Modification Help |
| Random bullet projectiles |
| << < (2/3) > >> |
| Treynolds416:
--- Quote from: Lørd Tøny on April 23, 2011, 03:43:36 AM ---Yes that but I don't know how to add it into the current codeblock. If I try I end up having something broken. --- End quote --- It's always good to save a copy of the original so you can forget it up and not worry about it. All you have to do is the following: -Paste Blastdown's code at the bottom (position doesn't matter though) -Change all instances of "minigun" to "rifle" -Change the number after %spread to whatever you want -Add the following two lines, after the first { and before %obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-1"))); --- Code: --- if(%obj.getDamagePercent() < 1.0) %obj.playThread(2, plant); --- End code --- Note: if you don't want recoil, remove this line completely: --- Code: ---%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-1"))); --- End code --- |
| Lørd Tøny:
--- Code: ---// Script function RifleImage::onFire(%this,%obj,%slot) { if(%obj.getDamagePercent() < 1.0) %obj.playThread(2, shiftAway); parent::onFire(%this, %obj, %slot); if(%obj.getDamagePercent() < 1.0) %obj.playThread(2, plant); %obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-1"))); } --- End code --- This? |
| Lørd Tøny:
It still doesn't randomize the projectile. |
| rkynick:
--- Quote from: Treynolds416 on April 23, 2011, 03:17:52 PM --- -Paste Blastdown's code at the bottom (position doesn't matter though) -Change all instances of "minigun" to "rifle" -Change the number after %spread to whatever you want --- End quote --- Looks like you missed 75% of the steps, tony. |
| Lørd Tøny:
Well now I just get nothing but syntax errors. --- Code: ---// Script function SFRevolverImage::onFire(%this,%obj,%slot) { if(%obj.getDamagePercent() < 1.0) %obj.playThread(2, shiftAway); %projectile = %this.projectile; %spread = 0.00185; %shellcount = 1; 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; --- End code --- |
| Navigation |
| Message Index |
| Next page |
| Previous page |