Any1 kinda enough to help a newbie
by Andy Vickers · in RTS Starter Kit · 04/17/2005 (1:36 pm) · 5 replies
Having purchased torque i have found it incredibly hard to get to grips with, i have only been able to modify a few simple things, anyways.
My question is this:
Using the World Domination mod add to spawn a building along with the 4 peon units
i just can not for the life of me figure it out, instead of just getting nowhere and wasting my $100 investment i ask for help.
I noticed that when a building button is clicked in the gui it runs "startPlaceBuilding(\"townCenter\");"
but can not figure out how i have a building placed along with the peons at start up (this would be the HQ main base building)
Thanks in advance for any help given
Andy.
My question is this:
Using the World Domination mod add to spawn a building along with the 4 peon units
i just can not for the life of me figure it out, instead of just getting nowhere and wasting my $100 investment i ask for help.
I noticed that when a building button is clicked in the gui it runs "startPlaceBuilding(\"townCenter\");"
but can not figure out how i have a building placed along with the peons at start up (this would be the HQ main base building)
Thanks in advance for any help given
Andy.
#2
%conn--the connection of the player wanting to place the building
%store--the resource store to be used to get the supplies for the building (note: we won't use that here)
%transform--the location and rotation of the building, received from the client after they finish the building placement.
%data--the datablock name for the building you want to place
%zTweak--currently unused in the mod
Now, the code that is important to you is the following:
What you want to do here is to take the functionality of this code block, provide the correct information that determines what building to place, and where to place it, and place it where Ben said above: In RTSConnection::onClientEnterGame, probably after the peons are spawned.
The above code isn't going to be "plug and play"--you'll need to come up with the values for the %data, %transform, and make sure you are using the correct %client variable.
If you get stuck on a particular part of this, let me know, but I think it's a much better learning experience if you drop in and give it a shot, so I don't normally provide "plug and play" solutions right off the bat--certainly willing to help more however if you have specific questions!
04/17/2005 (3:47 pm)
In the script file building.cs (server script), you'll see the function serverCmdPlaceBuilding(), which takes the following parameters:%conn--the connection of the player wanting to place the building
%store--the resource store to be used to get the supplies for the building (note: we won't use that here)
%transform--the location and rotation of the building, received from the client after they finish the building placement.
%data--the datablock name for the building you want to place
%zTweak--currently unused in the mod
Now, the code that is important to you is the following:
%b = new RTSBuilding()
{
datablock = %data;
scale = "1 1 1";
};
%b.setTransform( %transform );
%b.client = %conn;
%b.setTeam(%conn.getTeam());
%b.setControllingConnection(%conn);
%conn.buildings.add(%b);
%b.playRootAnimation();
// Note: using schedule is a very basic example. In a real game, adding the supply
// to the store would probably be dependent on some form of game event, like
// a working returning a load of carried supplies to a player's building
// for example, how the villagers work. As you increase your building's capabilities,
// most (if not all) will not be supply type buildings.
echo("serverCmdPlaceBuilding()--building (" @ %b @ "):");
%b.initBuildingActions();What you want to do here is to take the functionality of this code block, provide the correct information that determines what building to place, and where to place it, and place it where Ben said above: In RTSConnection::onClientEnterGame, probably after the peons are spawned.
The above code isn't going to be "plug and play"--you'll need to come up with the values for the %data, %transform, and make sure you are using the correct %client variable.
If you get stuck on a particular part of this, let me know, but I think it's a much better learning experience if you drop in and give it a shot, so I don't normally provide "plug and play" solutions right off the bat--certainly willing to help more however if you have specific questions!
#3
I am pretty confident in c++ and have helped a couple of people with problems and always don't just tell them straight off the solution but let them think about it so they understand and learn, so i argee with you it is better to learn from experience rather they just have the code given to you.
However i am really having trouble getting into torque script.
so i know that in function RTSConnection::onClientEnterGame() is the place to call serverCmdPlaceBuilding() as i have played around with peons already making them spawn and move to a waypoint and back on game start.
However.
typing
serverCmdPlaceBuilding(%conn, %store, %transform, %data, %zTweak);
i as u said need the values for these variables. so do i define them as
%conn=this.getClientIndex();
%store="LOCAL";
%transform=("0 0 250", 2);
%data= what is the data block name for a building?
then call the function
serverCmdPlaceBuilding(%conn, %store, %transform, %data, %zTweak);
:( this is embaressing
04/18/2005 (4:13 am)
Hi! first of all thanks for the help, unfortunatly i am still unclear on how to get this working. I am pretty confident in c++ and have helped a couple of people with problems and always don't just tell them straight off the solution but let them think about it so they understand and learn, so i argee with you it is better to learn from experience rather they just have the code given to you.
However i am really having trouble getting into torque script.
so i know that in function RTSConnection::onClientEnterGame() is the place to call serverCmdPlaceBuilding() as i have played around with peons already making them spawn and move to a waypoint and back on game start.
However.
typing
serverCmdPlaceBuilding(%conn, %store, %transform, %data, %zTweak);
i as u said need the values for these variables. so do i define them as
%conn=this.getClientIndex();
%store="LOCAL";
%transform=("0 0 250", 2);
%data= what is the data block name for a building?
then call the function
serverCmdPlaceBuilding(%conn, %store, %transform, %data, %zTweak);
:( this is embaressing
#4
You should copy the code block I gave you into your RTSConnection::onClientEnterGame(), making sure that you give it the right values in the fields I listed.
I really should have encapsulated the actual functionality of spawning a building out of the serverCmd, and used the serverCmd simply as a wrapper, but I didn't!
%conn in RTSConnection::onClientEnterGame() is %this
%store isn't needed for the code block
you will have to play around with %transform, since it is depending on where you are letting the player start in your map. You are confusing the parameters sent to createPlayer()--which is a transform and an index to say which player to spawn, and a simple transform, which is of the form:
"xPos yPos zPos xRot yRot zRot" (note: I honestly don't remember the exact format for the rotation portion in a script based transform, but I -think- the previous is correct. Doesn't matter in this case anyway).
of which you can leave off the Rot values..making your transform something like:
%transform = "0 0 250";
%data is whatever you want it to be, depending on which of the buildings you want to be placed. If, for example, you wanted a town center to be placed, you would use:
%data = townCenterBlock;
And as I said above, just put the code block inline in your onClientEnterGame function. If you wanted to get fancy, write it as it's own separate function, and have serverCmdPlaceBuilding call it, as well as onClientEnterGame call it, but that's not necessary to get what you want.
Final note: ignore the comments in that code block...they are a bit misleading, since for the mod I took out any schedule at all, so it doesn't apply directly, and certainly not in your particular case.
04/18/2005 (5:43 am)
No, you cannot call serverCmdPlaceBuilding from another server script (well, you can, but that's not how it's designed!). serverCmd's are designed specifically as a remote call from the client(s), to act as a handler/dispatcher for client requested actions. In this particular case, you aren't actually wanting to place this particular building as a result of a client's request, but as a result of the onEnterGame startup sequence.You should copy the code block I gave you into your RTSConnection::onClientEnterGame(), making sure that you give it the right values in the fields I listed.
I really should have encapsulated the actual functionality of spawning a building out of the serverCmd, and used the serverCmd simply as a wrapper, but I didn't!
%conn in RTSConnection::onClientEnterGame() is %this
%store isn't needed for the code block
you will have to play around with %transform, since it is depending on where you are letting the player start in your map. You are confusing the parameters sent to createPlayer()--which is a transform and an index to say which player to spawn, and a simple transform, which is of the form:
"xPos yPos zPos xRot yRot zRot" (note: I honestly don't remember the exact format for the rotation portion in a script based transform, but I -think- the previous is correct. Doesn't matter in this case anyway).
of which you can leave off the Rot values..making your transform something like:
%transform = "0 0 250";
%data is whatever you want it to be, depending on which of the buildings you want to be placed. If, for example, you wanted a town center to be placed, you would use:
%data = townCenterBlock;
And as I said above, just put the code block inline in your onClientEnterGame function. If you wanted to get fancy, write it as it's own separate function, and have serverCmdPlaceBuilding call it, as well as onClientEnterGame call it, but that's not necessary to get what you want.
Final note: ignore the comments in that code block...they are a bit misleading, since for the mod I took out any schedule at all, so it doesn't apply directly, and certainly not in your particular case.
#5
02/06/2010 (4:23 am)
Add it to the end of the function, so it properly adds the teams resources first or it will fail. (assuming tge152 and world domination mod)// ok try to add a Town Center for the player
// serverCmdPlaceBuilding(%conn, %store, %transform, %data, %zTweak);
serverCmdPlaceBuilding(%this, "LOCAL",(%startX + 30 ) SPC (%startY + 30) SPC "250", "townCenterBlock", "0.0");
echo("RTSConnection::onClientEnterGame - Adding townCenter for this player at" SPC (%startX + 30 ) SPC (%startY + 30) SPC "250");
Associate Kyle Carter