Grapple Hook Question And Help
by Don Weatherby · in Torque Game Engine · 03/17/2007 (12:52 am) · 9 replies
Hi im trying real hard to make a grapple hook and came across a thread that dicusses this im trying to impliment this guys code he posted but im unsure on how to do certain things heres the link
http://www.garagegames.com/mg/forums/result.thread.php?qt=19947
also here is what i have bad trouble with>>>>>>>>
>>>>>>>in next post
http://www.garagegames.com/mg/forums/result.thread.php?qt=19947
also here is what i have bad trouble with>>>>>>>>
>>>>>>>in next post
About the author
#2
thx in advance for all help.
03/17/2007 (12:55 am)
I put in all up to the part where i have to make hookimage and hook projectile and he didnt explain it well and i dont know how to do it.thx in advance for all help.
#3
http://rafb.net/paste/
this will let you cut and paste properly and itwill look a bit more clearly. but as far as i can see all you have is the projectile and hook. the onCollision is see, what errors are you getting on your console.
03/17/2007 (6:04 am)
You should try a paste site, itmakes its alot easier for everyone to read. http://rafb.net/paste/
this will let you cut and paste properly and itwill look a bit more clearly. but as far as i can see all you have is the projectile and hook. the onCollision is see, what errors are you getting on your console.
#4
ive implimented all the physics and network and all else besides the image and projectile along with the associated code listed on
this thread............. http://www.garagegames.com/mg/forums/result.thread.php?qt=19947
i need help on how to make projectiles and images and adding the code for them.
03/17/2007 (2:25 pm)
If you look at the link i posted in the first post im using this (eric ?) guys way of making a grapple hook but he doesent tell me how to make a image called hookimage and a projectile called hookprojectile and how to ad the code to it.ive implimented all the physics and network and all else besides the image and projectile along with the associated code listed on
this thread............. http://www.garagegames.com/mg/forums/result.thread.php?qt=19947
i need help on how to make projectiles and images and adding the code for them.
#5
03/17/2007 (3:58 pm)
You are going to have to manually add in the spaces.function hookImage::onFire(%this, %obj, %slot){ //press enter here to move the text to the next line
%obj.client.player.setHookLen(-1);//press enter here to move to the next line
%projectile = %this.projectile; //Again, move to the next line
// Decrement inventory ammo. The image's ammo state is update
// automatically by the ammo inventory hooks.
//%obj.decInventory(%this.ammo,1);
// Determin initial projectile velocity based on the
// gun's muzzle point and the object's current velocity
%muzzleVector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%muzzleVelocity = VectorAdd( VectorScale(%muzzleVector, %projectile.muzzleVelocity), VectorScale(%objectVelocity, %projectile.velInheritFactor));
// Create the projectile object
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %muzzleVelocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj; sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
return %p;
}See what you have to do? Copy/paste from the forum won't keep the white space, so you have to put that back in on your own. Just look for the ; and // and put in the appropriate white spaces.
#6
03/17/2007 (4:26 pm)
I thought it was pretty easy to add. You're just making a new weapon basically. You can just replace whatever code is in the crossbow functions with the hook functions.
#7
03/19/2007 (12:27 pm)
I was looking at the crossbow and i see the weapon.cfg would this code replace the code in that file to make the grapplehook wep? and about the porjectile there isnt a cfg or .cs file for it just dts files and such so how would i add the code for that?
#8
03/19/2007 (3:48 pm)
If you did want to exchange the crossbow for this, look in crossbow.cs and replace what's inside those functions.
#9
thx
04/13/2007 (10:41 pm)
Yes i see what your saying but what about the projectile "hookprojectile" there is code for that also ill look and see if its in the crossbow file.thx
Torque Owner Don Weatherby
SCRIPT:
Argh this is weak but i gotta go to work.
To get this working, all you need to do now is make a projectile called hookprojectile and add this function
function hookProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal){ //messageall(type, 'projectile collision col = %1', %col); // Apply damage to the object all shape base objects if (%col.getType() & ($TypeMasks::StaticObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::TerrainObjectType)) { %obj.client.player.setHookPos(%pos); %len = vectorSub(%obj.client.player.getPosition(), %pos); echo("hook length = ", vectorLen(%len)); %obj.client.player.setHookLen(vectorLen(%len)); } }
then make a weapon image called hookimage and add this script function
function hookImage::onFire(%this, %obj, %slot){ %obj.client.player.setHookLen(-1); %projectile = %this.projectile; // Decrement inventory ammo. The image's ammo state is update // automatically by the ammo inventory hooks. //%obj.decInventory(%this.ammo,1); // Determin initial projectile velocity based on the // gun's muzzle point and the object's current velocity %muzzleVector = %obj.getMuzzleVector(%slot); %objectVelocity = %obj.getVelocity(); %muzzleVelocity = VectorAdd( VectorScale(%muzzleVector, %projectile.muzzleVelocity), VectorScale(%objectVelocity, %projectile.velInheritFactor)); // Create the projectile object %p = new (%this.projectileType)() { dataBlock = %projectile; initialVelocity = %muzzleVelocity; initialPosition = %obj.getMuzzlePoint(%slot); sourceObject = %obj; sourceSlot = %slot; client = %obj.client; }; MissionCleanup.add(%p); return %p;}