Thread Rating:
  • 3 Votes - 4.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API Knowledgebase
Author Message
AcersEleven Offline
Community Manager
*****

Posts: 1,646
Joined: Mar 2012
Post: #1
API Knowledgebase
Dear Community,

in this Thread you will find all the information that we can give you as well as a kind of FAQ. We will try to keep it as up to date as possible, but we can’t update it daily, so bear with us.

This is our official API:

Code:
var city = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity();
var ownCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentOwnCity();
ownCity.get_CityArmyFormationsManager().set_CurrentTargetBaseId(city.get_Id());
ClientLib.Vis.VisMain.GetInstance().get_Battleground().SimulateBattle();
var app = qx.core.Init.getApplication();
app.getPlayArea().setView(webfrontend.gui.PlayArea.PlayArea.modes.EMode_CombatRe​play, city.get_Id(), 0, 0);


Issue 1:
var curCity = ClientLib.Data.MainData.GetInstance().get_Cities().get_CurrentCity();
curCity.get_CityBuildingsData ().GetUniqueBuildingByTechName (ClientLib.Base.ETechName techName);

This code is done when inside an enemy base.
It returns null always!
Even though I used instead of techName - Construction_Yard or Defense_Facility for example.

Answer 1:

It currently works only with GDI and NOD, because it uses the Faction from the current City and for forgotten there are special faction for Camps, Outposts and Bases and these Factions weren’t taken in account in this function.

I fixed it so it will return for Camps, Outposts and bases the right building too, will be available in the next patch.


Issue 2:
var battleground = ClientLib.Vis.VisMain.GetInstance().get_Battleground();
battleground.SimulateBattle();


battleground.get_Replay().getReport();

The code is done when inside an enemy base.
returns null always!

Answer 2:

get_Replay() should only work if you are watching a Replay from a Combat Report or a simulated Battle. And only if you watch a Replay from a Combat Report there should be a Report.

If you only watching the city there isn’t anything in this variable.


Issue 3:
The Constructors of things like ClientLib.Vis.ViewModeChange & ClientLib.Data.CityPreArmyUnitsChanged on the API shows the following: System.Void .ctor (System.Object object ,System.IntPtr method).

However it doesn't work as System.Void remove_ArmyChanged (ClientLib.Data.CityPreArmyUnitsChanged value) & System.Void add_ViewModeChange (ClientLib.Vis.ViewModeChange value) will not accept them.

For example:

var add_ViewModeChange = new ClientLib.Vis.ViewModeChange(this, onViewChange);
ClientLib.Vis.VisMain.GetInstance().add_ViewModeChange(add_ViewModeChange);

returns error.


I managed to bypass it by using:
var add_ViewModeChange = new ClientLib.Vis.ViewModeChange();
add_ViewModeChange.i=[{o:_this,f:onViewChange}];
ClientLib.Vis.VisMain.GetInstance().add_ViewModeChange(add_ViewModeChange);

Please check if something is wrong there, or maybe I am doing something wront?

Answer 3:

For this events we use a helper function:

webfrontend.Util.attachNetEvent(ClientLib.Vis.VisMain.GetInstance(), "MouseToolChange", ClientLib.Vis.MouseToolChange, this, this._onMouseToolChange);

webfrontend.Util.attachNetEvent(/*instance of object which calls the event*/, /*name of the event*/, /*type of the event*/, /*context object*/, /*callback function*/);


Issue 4:

In General, I am lookin for a way to get buildings data from battleground after simulating.
In older versions of the scripts we took data from entities within the battleground, however since the update they are nowhere to be found.
Please point me to the right direction.

Answer 4:

This will be supported in the next patch.

01-10-2012 03:01 PM
 Search 


Forum Jump:


User(s) browsing this thread: