Basically if I were to shoot toward a player, if it came close enough to the player, then it would go toward him.Is this possible? If so, how?
function HomingRocketImage::onFire(%this,%obj,%slot){ %initPos = %obj.getEyeTransform(); %muzzleVector = %obj.getMuzzleVector(%slot); %objectVelocity = %obj.getVelocity(); %muzzleVelocity = VectorScale(%muzzleVector, 20); %p = new Projectile() { dataBlock = HomingRocketProjectile; initialVelocity = %muzzleVelocity; initialPosition = %initPos; sourceObject = %obj; sourceSlot = %slot; client = %obj.client; }; %p.target=ContainerRayCast(vectoradd(%initPos,vectorscale(%muzzleVector,2)),vectoradd(%initPos,vectorscale(%muzzleVector,500)),$TypeMasks::PlayerObjectType); schedule(400,0,"projectilehome",%p); MissionCleanup.add(%p); return %p;}function projectilehome(%projectile){ if(!isobject(%projectile.target))return;//if the projectile is gone, it will return nothing, and nothing is NOT an object. this also checks the target, so it is actually faster if(isObject(%obj.client.minigame)) commandtoclient(%client,'bottomPrint',"Homing!.",1); %pos=%projectile.getposition(); %targ=vectoradd(%projectile.target.getposition(),"0 0 1.5"); %diff=vectorsub(%targ,%pos); %p = new Projectile() { dataBlock = HomingRocketProjectile; initialVelocity = vectorscale(%diff,10/vectorlen(%diff)); initialPosition = %projectile.getposition(); sourceObject = %projectile.sourceObject; sourceSlot = %projectile.sourceSlot; client = %projectile.client; }; %p.target=%projectile.target; %p.event=schedule(200,0,"projectilehome",%p); %projectile.delete(); return; %projectile.initialVelocity=vectorscale(%diff,10/vectorlen(%diff)); schedule(200,0,"projectilehome",%projectile); %projectile.initialPosition=%projectile.getposition(); commandtoclient(%client,'bottomPrint',"No target found.",1);}function HomingRocketProjectile::damage(%this,%obj,%col,%fade,%pos,%normal){ if(%this.directDamage <= 0) return; //direct damage doubles for crouching players %damageType = $DamageType::Direct; if(%this.DirectDamageType) %damageType = %this.DirectDamageType; if(%col.getType() & $TypeMasks::PlayerObjectType) { %col.damage(%obj, %pos, %this.directDamage, %damageType); %projectile.delete(); } else { %col.damage(%obj, %pos, %this.directDamage, %damageType); %projectile.delete(); }}
Please no. People Aloshi has released like two of these, and they just lag the server to hell when more than two people use them at once. The engine isn't cut out for that sort of thing, it's really not. If you want to do this sort of stuff just start an e-petition to get Badspot to add a projectile-tracking resource.
Quote from: Azerath on April 02, 2008, 05:42:04 PMBasically if I were to shoot toward a player, if it came close enough to the player, then it would go toward him.Is this possible? If so, how?Here this is my projectile home I used for my homing rocket launcher;Code: [Select]Note that is does not delete the projectile on collision, also it homes when you aim dead on them, you can change anything you need/want to.[/quote]I used this... but it doesn't seem to want to explode unless the player or thing its homing on, dies. How can I fix this?
Note that is does not delete the projectile on collision, also it homes when you aim dead on them, you can change anything you need/want to.[/quote]I used this... but it doesn't seem to want to explode unless the player or thing its homing on, dies. How can I fix this?
Quote from: Ephialtes on April 02, 2008, 06:01:23 PMPlease no. People Aloshi has released like two of these, and they just lag the server to hell when more than two people use them at once. The engine isn't cut out for that sort of thing, it's really not. If you want to do this sort of stuff just start an e-petition to get Badspot to add a projectile-tracking resource.
Quote from: Ephialtes on April 08, 2008, 10:00:42 AMQuote from: Ephialtes on April 02, 2008, 06:01:23 PMPlease no. People Aloshi has released like two of these, and they just lag the server to hell when more than two people use them at once. The engine isn't cut out for that sort of thing, it's really not. If you want to do this sort of stuff just start an e-petition to get Badspot to add a projectile-tracking resource.Why should they no do it because you said not to?
Quote from: MrPickle on April 13, 2008, 01:16:16 PMQuote from: Ephialtes on April 08, 2008, 10:00:42 AMQuote from: Ephialtes on April 02, 2008, 06:01:23 PMPlease no. People Aloshi has released like two of these, and they just lag the server to hell when more than two people use them at once. The engine isn't cut out for that sort of thing, it's really not. If you want to do this sort of stuff just start an e-petition to get Badspot to add a projectile-tracking resource.Why should they no do it because you said not to?Because as I stated, schedule-intense weapons cause servers to lag. Servers lagging makes playing on them kind of boring. Plus all the homing weapons i've seen so far are awful. Don't let your hatred of me cloud your common sense (if you have any?)
Azerath; in the projectile's onCollision function simply delete the object.
function YourProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal){ //delete object here}
Quote from: MrPickle on April 14, 2008, 05:55:06 AMAzerath; in the projectile's onCollision function simply delete the object.Can't find "onCollision". :/