Weapons MountPoints - A question.
by Lee Wickham · in Torque 3D Professional · 09/22/2011 (10:09 pm) · 7 replies
Hi every one, hoping someone will know the answer to this question.
Currently the way things are set up you designate what mountPoint the weapon will mount to within the weaponImage, while this work well enough I'm beginning to see problems with this way of mounting.
As you can see from the example above you can now use the same weapon image multiple times and simply tell the engine where is it to be added without having to duplicate code.
and secondly does anyone have any ideas about where to look and how to go about implementing this change ?
Any suggestions or thoughts on this guys ?
Thank You
- Lee
Description
I'm looking to move or re-write the portion of (I'm assuming source) code that handles weapon mounting via mountPoints on to player characters and vehicles.Currently the way things are set up you designate what mountPoint the weapon will mount to within the weaponImage, while this work well enough I'm beginning to see problems with this way of mounting.
Problem - Duplicating code:
This applies were you have a vehicle or player that has 2 or more main (identical) weapons that are mounted to two or more mountPoints simultaneously, instead of being able to use the same weaponImage you now have to duplicate that image to be able to specify that is to be mounted on a different mountPoint to the first primary.Solution:
A solution to this would be to move or re-write the function that handles mounting the weapon/s to a mountPoint, specifically the section that deals with looking for the mountPoint designator in the weaponImage, this could be moved to the onAdd function of the player or vehicle, or actually to the player or vehicle's main datablock.Solution Example - onAdd:
function VehicleName::onAdd(%data, %obj)
{ //mount weapon on add
%obj.mountable=true;
%obj.mountImage(VehicleWeaponIamge,mountPoint2,0);
%obj.mountImage(VehicleWeaponIamge,mountPoint3,1);
... rest of code ...As you can see from the example above you can now use the same weapon image multiple times and simply tell the engine where is it to be added without having to duplicate code.
My question is as follows:
Firstly is this possible via editing the source code ?and secondly does anyone have any ideas about where to look and how to go about implementing this change ?
Any suggestions or thoughts on this guys ?
Thank You
- Lee
About the author
A Founder of IGD Studios
#2
09/29/2011 (3:51 am)
I know there is a resource for something like this but I can't remember what the name, something with mountimage with mountpoint or something like that. Hope this will help you.
#3
I think. I could be talking out of the wrong end. Seems like this would save much effort and testing, though.
<edit> I said you "could" add the value back on the script side, but I guess I meant "must" or the image wouldn't mount at all....
<edit again> And you'd have to add the dynamic value to the image datablock of course, not the image itself.
Man - I should finish my first cup of coffee before posting on half-familiar subjects....
09/29/2011 (6:49 am)
Or you could remove the mountPoint variable from the data and add it back on the script side as a dynamic value. Then you could just assign the value on the fly to the mountable object and the mounting object should place the mountable object where you want it with minimal fuss. If you want to mount a second identical image to the next mountPoint you'd see if the first mountPoint already had an image mounted and just assign the next point to the value.I think. I could be talking out of the wrong end. Seems like this would save much effort and testing, though.
<edit> I said you "could" add the value back on the script side, but I guess I meant "must" or the image wouldn't mount at all....
<edit again> And you'd have to add the dynamic value to the image datablock of course, not the image itself.
Man - I should finish my first cup of coffee before posting on half-familiar subjects....
#4
@Richard Ranft i know exactly were ur comming from with the coffee comment, any idea in what section of the source code id have to make thease edits ?
09/29/2011 (7:46 am)
@Richard Marrevee, thanks ill take a look at the resources using that search tearm.@Richard Ranft i know exactly were ur comming from with the coffee comment, any idea in what section of the source code id have to make thease edits ?
#5
The link to the resource:
http://www.garagegames.com/community/resources/view/20539
09/30/2011 (7:37 am)
@Lee:The link to the resource:
http://www.garagegames.com/community/resources/view/20539
#6
I'm going to research this a little and try to get back to you. I believe that ShapeBaseData is where to start, but I'm not certain. After looking at the code I thought I had found the correct field, but upon further reflection I think that
Instead of creating the entire datablock you could use the pseudo-inheritance feature to create the "off-hand" object datablock. This creates a minimum of extra script file bloat as it only actually contains any altered fields. No source modification needed, but not as clean as what you're describing.
09/30/2011 (12:39 pm)
That resource will do it, but he mentions you still have to have a second datablock that specifies the other mountpoint - which was the issue to begin with I take it....I'm going to research this a little and try to get back to you. I believe that ShapeBaseData is where to start, but I'm not certain. After looking at the code I thought I had found the correct field, but upon further reflection I think that
S32 mountPointNode[SceneObject::NumMountPoints]; ///< Node index of mountPointis actually the list of mount points on the object and not the point to which it will mount.
Instead of creating the entire datablock you could use the pseudo-inheritance feature to create the "off-hand" object datablock. This creates a minimum of extra script file bloat as it only actually contains any altered fields. No source modification needed, but not as clean as what you're describing.
datablock ShapeBaseImageData(MainGunImage1)
{
mountPoint = 0;
// other fields
};
datablock ShapeBaseImageData(MainGunImage2 : MainGunImage1)
{
mountPoint = 1;
// other fields are not needed as they are copied on creation from
// the original
};But, as I said this only saves hard drive space essentially. The data is all duplicated in memory.
#7
10/01/2011 (3:44 am)
Cheers guys ill have a play about with things and see what i can come up with.
Lee Wickham
IGD Studios
Any one have any ideas at all, even if its a "Not its not possible" or "Yes it is, just dont know how to do that"