Game Development Community

What does isBallistic do?

by Jeff Trier · in Torque Game Engine · 05/16/2003 (6:41 am) · 23 replies

I can't figure out what variable does for "DataBlock ProjectileData", nor can I find info about it.

EDIT: ADDITION

Also, while I am here and not wanting to flood the MOD section with new topics...

I am working on projectiles as you may have guessed, and I have been reading a bit on inheritance. I read that I could do something like this (cut and pasted from another thread):
datablock ItemData(Spell)
{
bla = 2;
};

datablock ItemData(GreaterHealingSpell : Spell)
{
category = "HealingSpell";
bla2 = 1;
};

But I was wondering if I could then further do something like this:
datablock ItemData(Spell)
{
bla = 2;
};

datablock ItemData(GreaterHealingSpell : Spell)
{
bla2 = 1;
};

datablock ItemData(AreaEffect : GreaterHealingSpell : Spell)
{
bla3 = 1;
};

I would try this out, but I am so new to the workings of inheritance, that I am not sure how to call an inherited datablock after I created it.


Any help would be great!

Thanks,
-Jeff

About the author

Originally a Classical/Metal musician, I've always been attracted to anything involving computers, including: Networking, PC Building and Repair, software design and coding. I've been involved with game design and development for over 10 years.

Page «Previous 1 2
#1
05/16/2003 (8:14 am)
The variable causes the projectile to be affected by gravity.

If it's false, the projectile will follow a straight line, and if true, it will arc towards the ground.

Edit:

The grammar doesn't support the syntax you describe. There can be only one parent block, Highlander.
#2
05/16/2003 (10:09 am)
hehe :)

Thanks for the info.

-Jeff
#3
05/16/2003 (11:47 am)
For your second question,

The correct syntax would be:
datablock ItemData(spell) {
var1 = 2;
};
datablock ItemData(GreaterHealingSpell):spell {
//var1 = 2;  already from (spell)
var2 = 20;
};
datablock ItemData(AreaEffect):GreaterHealingSpell {
//var1 = 2;  already from (spell)
//var2 = 20; already from (GreaterHealingSpell)
var3 = 200;
};

and as for functions... if I'm not mistaken:

function spell::cast(%data) {
//This one gets cast for both spell and GreaterHealingSpell
dosomething();
}
function AreaEffect::cast(%data) {
//This one gets cast for AreaEffect.
parent::cast(%data); //Also do the parent cast; ;)
dosomethingelse();
}

Now all spels get 'dosomething();' and AreaEffect gets 'dosomethingesle' too.


I hope that makes sense.
#4
05/16/2003 (12:34 pm)
Thanks Sebastiaan, I think I understand now.


Thanks!
-Jeff
#5
05/16/2003 (2:07 pm)
Actually it's datablock ItemData(GreaterHealingSpell : spell)

In T2 it was seen in the other way sometimes... maybe both ways work? I've always seen it made this way.
#6
05/16/2003 (4:33 pm)
Thanks for the clarification Xavier.

-Jeff
#7
05/16/2003 (5:20 pm)
The grammar only allows foo(baz:bar).

Also, the actual effect is to copy data values from the parent block (it's not really class inheritence, since no link is formed from the child to the parent namespace). Here is a link to another thread abouth this topic (read the last post):

www.garagegames.com/index.php?sec=mg&mod=forums&page=result.thread&qt=9966

Therefore, it's only possible for datablocks to share a common namespace using the className field besides sharing the namespace of the engine object type (e.g. ShapeBaseImageData) and can have a private namespace for granular function overrides (e.g. spell, GreaterHealingSpell and AreaEffect are all namespaces in the example given). Only objects have explicit superclasses.

The copying would make the actual syntax you described earlier superfluous, since GreaterHealingSpell would copy spell's data, and AreaEffect would copy GreaterHealingSpell's data, effectively getting the data values from spell anyway (I just read the code though, I didn't actually try this out, so you might want to modify your example and give it a shot to confirm this).

Also the parent and child must be the same type of engine object (anything that has a DECLARE_CONOBJECT is a type of engine object) and it appears the copy fails silently if they are not. So you couldn't copy data values between ProjectileData and ShapeBaseImageData.

Confused yet? I've found it easier to think of Torquescript in terms of namespaces. If you understand what constitutes a namespace and how namespaces get linked together, it will be much easier to understand and write Torquescript.

Edit: (I thought of this after posting.)

Contrary to what I said about datablocks only having one way to share a namespace, you could probably do:
datablock ItemData(MyItemData)
{
}

datablock ItemData(NewerItemData)
{
  className = "MyItemData";
}

While that would work, the design pattern more common in existing Torque (and likely the better practise) is a common namespace used in both datablocks.

datablock ItemData(MyItemData)
{
  className = "SharedNamespace";
}

datablock ItemData(NewItemData)
{
  className = "SharedNamespace";
}
#8
05/16/2003 (6:42 pm)
Thanks Brad. You have definatly given me something to study. I haven't a clue as to how namespaces work... Well, I have a clue, I just need to study them a bit more. :) I have read about them in the DOC's, I was just having a hard time grasping it. I will follow through with the link you posted, and do some more digging around.

Thanks a ton!
-Jeff
#9
05/16/2003 (7:06 pm)
What method would you guys suggest I use to make weapons with adjustable effects(like being able to select particle colors, Range, bounce effects, area damage, etc...)?

Everything I need is in the Datablock definitions, but since they aren't instance based it seems my only scriptable option is to make a datablock for every combination of choices. Am I wrong in this?

Thanks again,
-Jeff
#10
05/16/2003 (9:13 pm)
I'm trying to understand the question a little better -- Do you want a single weapon to fire different types of projectiles?
#11
05/17/2003 (4:46 am)
Sorry I wasn't clear.

Basically, in my game there is a Labratory where players can create thier own units, weapons, armor and devices.

When the player creates a weapon, they can choose from the model shape, the rate of fire, fireing path (line, cone, area effect), the type of element that is fired (Ballistic, Heat, Energy, Bio), and some other tweeks as well.

I was thinking I could make a set of datablocks that would contain these attributes, then I could string them together for the complete effect. Ex. PistolShape -> Autox3 -> ConeFirePath -> Ballistic. But this doesn't seem possible to script in this manner. Or is it?


Thanks,
-Jeff
#12
05/18/2003 (9:51 am)
You should be able to chain together datablocks using the parent block. Defining datablocks dynamically is supported by the scripting. The datablock declaration is a normal scripting statement, and can be used anywhere a statement can be used.

But, datablocks are not net objects, and do not replicate to the client automatically. The server sends all datablocks when the client first connects (using transmitDatablocks in common/server/missionDownload.cs). transmitDataBlocks needs to be called again explicitly.

A good resource to look at (because it does the explicit transmitDataBlocks call) is the [url=http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3213"]Particle Editor[/url]. You are basically doing the same thing, except with weapons (ShapeBaseImageData) and projectiles (ProjectileData).

You might want to just define a single datablock dynamically, because otherwise you are creating a lot of intermediate datablocks in the chain but only using the final datablock. Obviously if it is a game, you are going to want something much slicker than a popup dialog box (you'll at least want to dress up the interface :) ), but to start I imagine you could just hack Particle Editor into Weapon & Projectile Editor.
#13
05/18/2003 (10:55 am)
Thanks Brad, thats good to know.

So just to get something clear...

If I change a DataBlock, all things changed within will be reflected upon all objects created with that datablock... But if I was to change/create a variable to an object via "%obj.someVariable = somevalue", it will only effect that object. Is this correct?

If so, how could I gain reference to an objects weaponImage data (there are no item objects for my weapons) to make that change? If this is all posible, I think I am in the gold.

Thanks,
-Jeff
#14
05/18/2003 (2:45 pm)
How the datablock is used by the object is really an internal engine design issue, but many objects use the values in the datablock directly (rather than making a copy). So any change will be visible to all object using the same datablock. Basically you can think of a group of objects having a pointer to the same datablock.

Yes, changing an object's value affects only that particular object.

I think the best way to understand how to create and manage weapons in the game is to understand the inventory system (inventory.cs, item.cs & weapon.cs, and pick either rifle.cs or crossbow.cs for an example). Once you know how weapons are normally created and managed in the player's inventory, you'll be able to customize those mechanics. I think you'll also find that you do need to have items for your custom weapons, because that is the easiest way to tie them into the inventory system, even if you aren't placing the weapon items with the map editor.
#15
05/18/2003 (4:10 pm)
Thanks again Brad.

I have been picking apart the weapons and items (even made a few custom ones). Since my weapons are created by the user, it changes the standard flow of how the datablocks are used (like in crossbow and rifle). But now that I know for certain that datablock created objects can have variables changed on a per object bases, I think I am in the clear on how I want to bring the weapons into the game world (making one generic weapon and changing its variables based on the saved weapon creation data).

Now all I have to do is gain the ability to call/change any variable from any object within any given hierarchy (for instance calling and changing the "projectile" variable located in the objects ShapeBaseImageData upon creation of the weapon). Not sure that was clear...

Anyways, thanks a ton! You have been a great help.
-Jeff
#16
05/18/2003 (6:10 pm)
I was looking at the particle editor, as well as the stock TGE script and I noticed that they can change object variables like so:

%emitter =	new ParticleEmitterNode() {
			position = %position;
			rotation = "1 0 0 0";
			scale = "1 1 1";
			dataBlock = %this.parDataBlock;
			[b]emitter = DefaultEmitter;
			velocity = "1";[/b]
		};


Now when I try this:

%weapon = new Item() {
		dataBlock = %GunType;
		[b]image = RifleImage;[/b]
	};

It doesn't change the objects image. I was assuming before that all variables within the "new" function would pertain to the object that was being created. I am obviously missing something fundamental.

I had also seen another way to change variables for an object:
%car = new WheeledVehicle()
   {
      datablock = DefaultCar;
   };
   %car.mountable = true;
   %car.setEnergyLevel(60);

But when I tried:
%weapon = new Item() {
		dataBlock = %GunType;
		//image = LauncherImage; // test
	};
	%weapon.image = LauncherImage; // test
It didn't work either. Hmm...

I feel lame asking, but could you give me a hint?

Thanks,
-Jeff
#17
05/19/2003 (12:06 pm)
image is defined in ItemData, not Item. So you need to change the field in the datablock.
#18
05/19/2003 (2:00 pm)
Sorry, I am a bit new to calling/setting a variable from a seperate object without effecting the global datablocks. Is there a way to scope up or down on those calls?

I found a way of changing variables in imagedata by going through the onMount function, and changing itemdata by going through the onAdd function. I am not sure if thats the best way, but it's working.

Thanks again,
-Jeff
#19
05/21/2003 (8:01 pm)
I am still having a bit of trouble changing an instance of a datablock in the the units weapon. Here is what I did:

%this.image.projectile.lightRadius = 20;

I was thinking that it would change the variable "lightrange" of the objects instance of projectileData, since it is in the scope of %this(being the datablock ItemData(gun)).

Instead, it will change the global datablock of the projectile datablock the weapon is using... Well, at least I know how to do *that* now. ;)

How could I change the lightrange, or any other variable within an objects scope of datablocks?

EDIT: Clarity

Thanks,
-Jeff
#20
05/21/2003 (10:33 pm)
The object does not have a unique instance of its datablock -- it shares the same instance with every other object using that datablock. There is no scope relationship between an object and its datablock. How you navigate to the datablock reference does not affect scope. The object is just referring to the global data, not creating its own copy (i.e. instance). It's like five people (objects) watching (referencing) the same TV (datablock) -- if one of the people changes the channel, they all see the new program.

The only way to accomplish changes unique to a particular object's associated datablock is to create a new datablock to associate with the object.
Page «Previous 1 2