Possible Bug With DataBlocks? (AIPlayer.cs)
by Quinn Ebert · in Torque Game Engine · 11/28/2006 (2:44 am) · 6 replies
Greetings,
For the past month or so, I've been working on extending the AI Facilities of Torque for use in my own indie game, and, I've run into a really weird quirk...
To create a different AI setup for each of my characters, I create a new AIPlayer-esque DataBlock, such as the following:
---- CODE BELOW -----
datablock PlayerData(AI_Crissy : PlayerBody)
{
shootingDelay = 33;
shapeFile = "~/data/shapes/player/player_zephyr.dts";
enemy = "NONE";
is_firing = false;
team = "Good";
maxEnergy = 200;
maxDamage = 200;
maxSight = "100";
};
---- CODE ABOVE -----
Later, In a new AIPlayer function I've created (AIPlayer::Think()) I have a line that tries to access the "maxSight" item, like so...
---- CODE BELOW -----
InitContainerRadiusSearch(%this.getPosition(), %this.maxSight, $TypeMasks::PlayerObjectType);
---- CODE ABOVE -----
In this case, InitContainerRadiusSearch() is unable to access the maxSight property of the AIPlayer Object. I have also noticed that the maxSight property of the AIPlayer isn't available elsewhere (IE: echo(Crissy.maxSight); returns absolutely nothing.)
I should apologize in advance for tasking you with what is more likely a problem with my code...but I post this here because I am able to successfully retrieve other properties of the AIPlayer using this method from my AIPlayer::Think() function.
Anyway, any help, criticism, flames, rants, etc, will all be very much appreciated.
Thanks in advance for any help you may be able to offer!
--David Quinn Ebert
--Co-Owner, Beyond-Technical Innovations, Ltd.
For the past month or so, I've been working on extending the AI Facilities of Torque for use in my own indie game, and, I've run into a really weird quirk...
To create a different AI setup for each of my characters, I create a new AIPlayer-esque DataBlock, such as the following:
---- CODE BELOW -----
datablock PlayerData(AI_Crissy : PlayerBody)
{
shootingDelay = 33;
shapeFile = "~/data/shapes/player/player_zephyr.dts";
enemy = "NONE";
is_firing = false;
team = "Good";
maxEnergy = 200;
maxDamage = 200;
maxSight = "100";
};
---- CODE ABOVE -----
Later, In a new AIPlayer function I've created (AIPlayer::Think()) I have a line that tries to access the "maxSight" item, like so...
---- CODE BELOW -----
InitContainerRadiusSearch(%this.getPosition(), %this.maxSight, $TypeMasks::PlayerObjectType);
---- CODE ABOVE -----
In this case, InitContainerRadiusSearch() is unable to access the maxSight property of the AIPlayer Object. I have also noticed that the maxSight property of the AIPlayer isn't available elsewhere (IE: echo(Crissy.maxSight); returns absolutely nothing.)
I should apologize in advance for tasking you with what is more likely a problem with my code...but I post this here because I am able to successfully retrieve other properties of the AIPlayer using this method from my AIPlayer::Think() function.
Anyway, any help, criticism, flames, rants, etc, will all be very much appreciated.
Thanks in advance for any help you may be able to offer!
--David Quinn Ebert
--Co-Owner, Beyond-Technical Innovations, Ltd.
#2
Because I have yet to delve into the engine code, could you possibly point me to a resource or tutorial somewhere that could show me how to go about doing this?
Thanks again for all your help!
--Quinn
11/28/2006 (3:33 am)
Mathieu,Because I have yet to delve into the engine code, could you possibly point me to a resource or tutorial somewhere that could show me how to go about doing this?
Thanks again for all your help!
--Quinn
#3
11/28/2006 (4:45 am)
Could you paste your complete Think() method, I think you've got the %this reference wrong (%this usually refers to the Datablock, but since you are doing %this.getPosition(), I guess %this is holding the AIPlayer object instance, not the datablock...)
#4
Other than that, what Beffy said is probably true if getPosition() has been working for you.
I rarely use the %this name anyway in script and just name it appropriatly instead, like %datablock.
11/28/2006 (6:10 am)
Since you created the variable inside scripts there's no need to make an accessor function.Other than that, what Beffy said is probably true if getPosition() has been working for you.
I rarely use the %this name anyway in script and just name it appropriatly instead, like %datablock.
#5
You may also be using the wrong variable as a reference (%this), so check your code to make sure.
11/28/2006 (6:45 am)
Beffy is on the mark with this one. From the code you've quoted I can see you're trying to find the maxSight value in the ai player object, but it is in the ai player datablock. You will need to use %this.getDatablock().maxSight to retrieve the value, unless you copy it to the ai player object upon creation of the ai player.You may also be using the wrong variable as a reference (%this), so check your code to make sure.
#6
11/28/2006 (7:41 am)
If you want maxSight to be an object member, declare it when you create your object, like this:new Player ()
{
dataBlock = PlayerBody;
maxSight = 23;
}
Torque Owner Mathieu