Last active
August 29, 2015 13:56
-
-
Save Crystalwarrior/8920100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function WeaponImage::doDuelRaycast(%this, %obj, %slot, %damage, %type, %range, %width, %typemasks, %ignore) | |
| { | |
| if(%range $= "") { | |
| %range = 5; | |
| } | |
| if(%typemasks $= "") { | |
| %typemasks = | |
| $TypeMasks::playerObjectType | | |
| $TypeMasks::fxBrickObjectType | | |
| $TypeMasks::vehicleObjectType | | |
| $TypeMasks::ShapeBaseObjectType | | |
| $TypeMasks::TerrainObjectType; | |
| } | |
| %losPoint = %obj.getMuzzleLOSPoint(%typemasks, %range); | |
| %basePoint = %obj.getMuzzlePoint(%slot); | |
| %baseVector = vectorNormalize(vectorSub(%losPoint, %basePoint)); | |
| %end = vectorAdd(%basePoint, vectorScale(%baseVector, %range)); | |
| %cast = containerRayCast(%basePoint, %end, %typemasks, %ignore); | |
| if(isObject(%col = getWord(%cast, 0)) && !(%col.getType() & $TypeMasks::playerObjectType)) { | |
| %datablock = %this.swingExplosionProjectile; | |
| %p = new Projectile() | |
| { | |
| dataBlock = %datablock; | |
| sourceObject = %obj; | |
| client = %obj.client; | |
| sourceSlot = 0; | |
| initialPosition = getWords(%cast, 1, 3); | |
| originPoint = getWords(%cast, 1, 3); | |
| }; | |
| %p.explode(); | |
| } | |
| initContainerRadiusSearch(%basePoint, %range / 30, %typemasks); | |
| echo(%range / 30); | |
| while (isObject(%col = containerSearchNext())) { | |
| if (!(%col.getType() & $TypeMasks::playerObjectType)) continue; | |
| %dot = vectorDot(%baseVector, vectorNormalize(vectorSub(%col.getHackPosition(), %obj.getHackPosition()))); | |
| if (%dot < %width) continue; | |
| if (%col == %obj) continue; | |
| if (miniGameCanDamage(%obj, %col)) { | |
| %col.damage(%obj, %pos, %damage, %type); | |
| } | |
| %start = %obj.getHackPosition(); | |
| %end = %col.getHackPosition(); | |
| %ray = containerRayCast(%start, %end, %typemasks, %ignore); | |
| %pos = getWords(%ray, 1, 3); | |
| if (%col.getType() & $TypeMasks::playerObjectType) { | |
| %datablock = %this.swingBloodExplosionProjectile; | |
| %p = new Projectile() | |
| { | |
| dataBlock = %datablock; | |
| sourceObject = %obj; | |
| client = %obj.client; | |
| sourceSlot = 0; | |
| initialPosition = %pos; | |
| originPoint = %pos; | |
| }; | |
| %p.explode(); | |
| } | |
| } | |
| } | |
| package duelingWeaponsPackage | |
| { | |
| function WeaponImage::onFireFast(%this, %obj, %slot) | |
| { | |
| if(!%this.isDuelMelee) | |
| %obj.playThread(3, plant); | |
| serverPlay3D(WooshFastestSound,%obj.getPosition()); | |
| %this.doDuelRaycast(%obj, %slot, %this.swingFastDamage, %this.damageType, %this.swingFastRange, %this.swingFastRangeRangeWidth, "", %obj); | |
| } | |
| function WeaponImage::onFireMedium(%this, %obj, %slot) | |
| { | |
| %this.doDuelRaycast(%obj, %slot, %this.swingMediumDamage, %this.damageType, %this.swingMediumRange, %this.swingMediumRangeRangeWidth, "", %obj); | |
| } | |
| function WeaponImage::onFireStrong(%this, %obj, %slot) | |
| { | |
| %this.doDuelRaycast(%obj, %slot, %this.swingStrongDamage, %this.damageType, %this.swingStrongRange, %this.swingStrongRangeRangeWidth, "", %obj); | |
| } | |
| function WeaponImage::onCharged(%this, %obj, %slot) | |
| { | |
| %obj.playThread(2, plant); | |
| serverPlay3D(DuelChargedSound,%obj.getHackPosition()); | |
| } | |
| function WeaponImage::onSwing(%this, %obj, %slot) | |
| { | |
| %obj.playThread(2, plant); | |
| serverPlay3D(WooshFastestSound,%obj.getHackPosition()); | |
| } | |
| // function WeaponImage::onMount(%this, %obj, %slot) | |
| // { | |
| // parent::onMount(%this, %obj, %slot); | |
| // } | |
| // function WeaponImage::onUnMount(%this, %obj, %slot) | |
| // { | |
| // parent::onUnMount(%this, %obj, %slot); | |
| // } | |
| }; | |
| activatePackage(duelingWeaponsPackage); | |
| //support | |
| function Player::getMuzzleLOSPoint(%this, %mask, %dist) | |
| { | |
| %muzzlePoint = %this.getMuzzlePoint(0); | |
| %muzzleVector = %this.getMuzzleVector(0); | |
| %endPoint = vectorAdd(%muzzlePoint, vectorScale(%muzzleVector, %dist)); | |
| %ray = containerRayCast(%muzzlePoint, %endPoint, %mask, %this); | |
| if (%ray) | |
| { | |
| return getWords(%ray, 1, 3); | |
| } | |
| return %endPoint; | |
| } | |
| //debug | |
| datablock staticShapeData( cubeShapeData ) | |
| { | |
| shapeFile = "./cube.dts"; | |
| }; | |
| function createLine( %a, %b, %size, %color ) | |
| { | |
| if ( !strLen( %size ) ) | |
| { | |
| %size = 0.05; | |
| } | |
| if ( !strLen( %color ) ) | |
| { | |
| %color = "1 1 1 1"; | |
| } | |
| %offset = vectorSub( %a, %b ); | |
| %normal = vectorNormalize( %offset ); | |
| %xyz = vectorNormalize( vectorCross( "1 0 0", %normal ) ); | |
| %pow = mRadToDeg( mACos( vectorDot( "1 0 0", %normal ) ) ) * -1; | |
| %obj = new staticShape() | |
| { | |
| a = %a; | |
| b = %b; | |
| datablock = cubeShapeData; | |
| scale = vectorLen( %offset ) SPC %size SPC %size; | |
| position = vectorScale( vectorAdd( %a, %b ), 0.5 ); | |
| rotation = %xyz SPC %pow; | |
| }; | |
| missionCleanup.add( %obj ); | |
| %obj.setNodeColor( "ALL", %color ); | |
| return %obj; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment