Difference between revisions of "HowTo:Edit Missions:Python:Bindings:CPP"

From VsWiki
Jump to: navigation, search
m
m (Universe_util.h)
Line 3: Line 3:
  
 
===Universe_util.h===
 
===Universe_util.h===
 +
 +
Declaration in: src/universe_util.h<br>
 +
Definition in: src/universe_util_generic.cpp<br>
 +
Usage from Python: VS.functionName()<br>
 +
 
<pre>
 
<pre>
 
//this function sets the "current" system to be "name"  where name may be something like
 
//this function sets the "current" system to be "name"  where name may be something like
Line 12: Line 17:
 
  //this function restores the active system.... there must be an equal number of pushSystems
 
  //this function restores the active system.... there must be an equal number of pushSystems
 
  //and popSystems or else Vega Strike may behave unpredictably
 
  //and popSystems or else Vega Strike may behave unpredictably
 +
 
         void popSystem ();
 
         void popSystem ();
 +
 
  //This function gets the current system's official name
 
  //This function gets the current system's official name
 +
 
         string getSystemFile();
 
         string getSystemFile();
 +
 
  //this function gets the current system's nickname (not useful)
 
  //this function gets the current system's nickname (not useful)
 +
 
         string getSystemName();
 
         string getSystemName();
 +
 
  //this function gets an iterator into the units in the current system... do NOT keep an iterator
 
  //this function gets an iterator into the units in the current system... do NOT keep an iterator
 
  //across a frame--it may get deleted!
 
  //across a frame--it may get deleted!
 +
 
         un_iter getUnitList();
 
         un_iter getUnitList();
 +
 
  //This function gets a unit given a number (how many iterations to go down in the iterator)
 
  //This function gets a unit given a number (how many iterations to go down in the iterator)
 +
 
         Unit *getUnit(int index);
 
         Unit *getUnit(int index);
 +
 
  //this function launches a wormhole or ajump point.
 
  //this function launches a wormhole or ajump point.
 +
 
         Unit *launchJumppoint(string name_string,
 
         Unit *launchJumppoint(string name_string,
 
                         string faction_string,
 
                         string faction_string,
Line 33: Line 49:
 
                         string squadlogo,
 
                         string squadlogo,
 
                         string destinations);
 
                         string destinations);
 +
 
  //this function launches a normal fighter  the name is the flightgroup name, the type is the ship type,
 
  //this function launches a normal fighter  the name is the flightgroup name, the type is the ship type,
 
  //the faction is who it belongs to, the unittype is usually "unit" unless you want to make asteroids or
 
  //the faction is who it belongs to, the unittype is usually "unit" unless you want to make asteroids or
Line 39: Line 56:
 
  //the position is a tuple (x,y,z) where they appear and the squadlogo is a squadron image...you can leave
 
  //the position is a tuple (x,y,z) where they appear and the squadlogo is a squadron image...you can leave
 
  //this the empty string '' for the default squadron logo.
 
  //this the empty string '' for the default squadron logo.
 +
 
         Unit* launch (string name_string,string type_string,string faction_string,string unittype,
 
         Unit* launch (string name_string,string type_string,string faction_string,string unittype,
 
                 string ai_string,int nr_of_ships,int nr_of_waves, QVector pos, string sqadlogo);
 
                 string ai_string,int nr_of_ships,int nr_of_waves, QVector pos, string sqadlogo);
 +
 
  //this gets a random cargo type (useful for cargo missions) from either any category if category is ''
 
  //this gets a random cargo type (useful for cargo missions) from either any category if category is ''
 
  //or else from a specific category  'Contraband'  comes to mind!
 
  //or else from a specific category  'Contraband'  comes to mind!
 +
 
         Cargo getRandCargo(int quantity, string category);
 
         Cargo getRandCargo(int quantity, string category);
 +
 
  //This gets the faction name of an index
 
  //This gets the faction name of an index
 +
 
         string GetFactionName(int index);
 
         string GetFactionName(int index);
 +
 
  //this gets an index given a faction name
 
  //this gets an index given a faction name
 +
 
         int GetFactionIndex(string name);
 
         int GetFactionIndex(string name);
 +
 
  //this gets a relationship between two factions
 
  //this gets a relationship between two factions
 +
 
         float GetRelation(string myfaction,string theirfaction);
 
         float GetRelation(string myfaction,string theirfaction);
 +
 
  //this changes the relaationship based on the rank and how mad or happy they are (the relationship
 
  //this changes the relaationship based on the rank and how mad or happy they are (the relationship
 
  //is between 0 and 1... so a adjustment of .01 with a rank of 1 is QUITE significant.
 
  //is between 0 and 1... so a adjustment of .01 with a rank of 1 is QUITE significant.
 +
 
         void AdjustRelation(string myfaction,string theirfaction, float factor, float rank);
 
         void AdjustRelation(string myfaction,string theirfaction, float factor, float rank);
 +
 
  //this gets the number of factions in game
 
  //this gets the number of factions in game
 +
 
         int GetNumFactions ();
 
         int GetNumFactions ();
//this gets the current time in seconds
+
 
         float GetGameTime ();
+
///this gets the current game time since last start in seconds
 +
 
 +
         float GetGameTime();
 +
 
 +
///this gets the current absolute startime in seconds
 +
 
 +
        float getStarTime();
 +
 
 
  //this sets the time compresison value to zero
 
  //this sets the time compresison value to zero
 +
 
         void SetTimeCompression ();
 
         void SetTimeCompression ();
 +
 
  //this gets a string which has in it a space delimited list of neighmoring systems
 
  //this gets a string which has in it a space delimited list of neighmoring systems
 +
 
         string GetAdjacentSystem (string str, int which);
 
         string GetAdjacentSystem (string str, int which);
 +
 
  //this gets a specific property of this system as found in universe/milky_way.xml
 
  //this gets a specific property of this system as found in universe/milky_way.xml
 +
 
         string GetGalaxyProperty (string sys, string prop);
 
         string GetGalaxyProperty (string sys, string prop);
 +
 
  //this gets the number of systems adjacent to the sysname
 
  //this gets the number of systems adjacent to the sysname
 +
 
         int GetNumAdjacentSystems (string sysname);
 
         int GetNumAdjacentSystems (string sysname);
 +
 
  //this adds a playlist to the music and may be triggered with an int
 
  //this adds a playlist to the music and may be triggered with an int
 +
 
         int musicAddList(string str);
 
         int musicAddList(string str);
 +
 
  //this plays a specific song
 
  //this plays a specific song
 +
 
         void musicPlaySong(string str);
 
         void musicPlaySong(string str);
 +
 
  //this plays msuci from a given list (where the int is what was returned by musicAddList)
 
  //this plays msuci from a given list (where the int is what was returned by musicAddList)
 +
 
         void musicPlayList(int which);
 
         void musicPlayList(int which);
 +
 
  //this gets the difficutly of the game... ranges between 0 and 1... many missions depend on it
 
  //this gets the difficutly of the game... ranges between 0 and 1... many missions depend on it
 
  //never going past .99 unless it's always at one.
 
  //never going past .99 unless it's always at one.
 +
 
         float GetDifficulty ();
 
         float GetDifficulty ();
 +
 
  //this sets the difficulty
 
  //this sets the difficulty
 +
 
         void SetDifficulty (float diff);
 
         void SetDifficulty (float diff);
 +
 
  //this plays a sound at a location...if the sound has dual channels it will play in the center
 
  //this plays a sound at a location...if the sound has dual channels it will play in the center
 +
 
         void playSound(string soundName, QVector loc, Vector speed);
 
         void playSound(string soundName, QVector loc, Vector speed);
 +
 
  //this plays an image (explosion or warp animation) at a location
 
  //this plays an image (explosion or warp animation) at a location
 +
 
         void playAnimation(string aniName, QVector loc, float size);
 
         void playAnimation(string aniName, QVector loc, float size);
 +
 
  //this ends the mission with either success or failure
 
  //this ends the mission with either success or failure
 +
 
         void terminateMission(bool term);
 
         void terminateMission(bool term);
 +
 
  //this gets the player belonging to this mission
 
  //this gets the player belonging to this mission
 +
 
         Unit *getPlayer();
 
         Unit *getPlayer();
 +
 
  //this gets a player number (if in splitscreen mode)
 
  //this gets a player number (if in splitscreen mode)
 +
 
         Unit *getPlayerX(int which);
 
         Unit *getPlayerX(int which);
 +
 
  //this gets the number of active players
 
  //this gets the number of active players
 +
 
         int getNumPlayers ();
 
         int getNumPlayers ();
 +
 
  //this adds an objective for the cockpit to view ("go here and do this')
 
  //this adds an objective for the cockpit to view ("go here and do this')
 +
 
         int addObjective(string objective);
 
         int addObjective(string objective);
 +
 
  //this sets the objective's completeness (the int was returned by add objective)
 
  //this sets the objective's completeness (the int was returned by add objective)
 +
 
         void setObjective(int which, string newobjective);
 
         void setObjective(int which, string newobjective);
 +
 
  //this sets the completeness of a particular objective... chanigng the color onscreen
 
  //this sets the completeness of a particular objective... chanigng the color onscreen
 +
 
         void setCompleteness(int which, float completeNess);
 
         void setCompleteness(int which, float completeNess);
 +
 
  //this gets that completeness
 
  //this gets that completeness
 +
 
         float getCompleteness(int which);
 
         float getCompleteness(int which);
 +
 
  //this sets the owner of a completeness
 
  //this sets the owner of a completeness
 +
 
         void setOwner(int which,Unit *owner);
 
         void setOwner(int which,Unit *owner);
 +
 
  //this gets an owner of a completeness (NULL means all players can see this objective)
 
  //this gets an owner of a completeness (NULL means all players can see this objective)
 +
 
         Unit* getOwner(int which);
 
         Unit* getOwner(int which);
 +
 
  //this sends an IO message... I'm not sure if delay currently works, but from, to and message
 
  //this sends an IO message... I'm not sure if delay currently works, but from, to and message
 
  //do :-) ... if you want to send to the bar do "bar" as the to string... if you want to make
 
  //do :-) ... if you want to send to the bar do "bar" as the to string... if you want to make
 
  //news for the news room specify "news"
 
  //news for the news room specify "news"
 +
 
     void IOmessage(int delay,string from,string to,string message);
 
     void IOmessage(int delay,string from,string to,string message);
 +
 
  //this gets a unit with 1 of each cargo type in it
 
  //this gets a unit with 1 of each cargo type in it
 +
 
         Unit *GetMasterPartList ();
 
         Unit *GetMasterPartList ();
 +
 
  //this gets a unit with a faction's contraband list... may be null (check with isNull)
 
  //this gets a unit with a faction's contraband list... may be null (check with isNull)
 +
 
         Unit *GetContrabandList (string faction);
 
         Unit *GetContrabandList (string faction);
 +
 
  //this sets whether or not a player may autopilot.  Normally they are both 0 and the autopiloting
 
  //this sets whether or not a player may autopilot.  Normally they are both 0 and the autopiloting
 
  //is allowed based on if enemies are near... if you pass in 1 then autopilot will be allowed no
 
  //is allowed based on if enemies are near... if you pass in 1 then autopilot will be allowed no
 
  //matter who is near... if you set -1 then autopilot is never allowed.  global affects all
 
  //matter who is near... if you set -1 then autopilot is never allowed.  global affects all
 
  //players... player just affects the player who accepted the mission.
 
  //players... player just affects the player who accepted the mission.
 +
 
         void SetAutoStatus (int global_auto, int player_auto);
 
         void SetAutoStatus (int global_auto, int player_auto);
 +
 
</pre>
 
</pre>
 
----
 
----
 
[[Category:HowTos|Edit Missions:Python:Bindings:CPP]]
 
[[Category:HowTos|Edit Missions:Python:Bindings:CPP]]
 
[[Category:Development|Edit Missions:Python:Bindings:CPP]]
 
[[Category:Development|Edit Missions:Python:Bindings:CPP]]

Revision as of 17:45, 27 February 2011

thumb_arrow_up.png Bindings

Universe_util.h

Declaration in: src/universe_util.h
Definition in: src/universe_util_generic.cpp
Usage from Python: VS.functionName()

//this function sets the "current" system to be "name"  where name may be something like
 //"sol_sector/sol"  or "vega_sector/vega"   this function may take some time if the system
 //has not been loaded before

        void pushSystem (string name);

 //this function restores the active system.... there must be an equal number of pushSystems
 //and popSystems or else Vega Strike may behave unpredictably

        void popSystem ();

 //This function gets the current system's official name

        string getSystemFile();

 //this function gets the current system's nickname (not useful)

        string getSystemName();

 //this function gets an iterator into the units in the current system... do NOT keep an iterator
 //across a frame--it may get deleted!

        un_iter getUnitList();

 //This function gets a unit given a number (how many iterations to go down in the iterator)

        Unit *getUnit(int index);

 //this function launches a wormhole or ajump point.

        Unit *launchJumppoint(string name_string,
                        string faction_string,
                        string type_string,
                        string unittype_string,
                        string ai_string,
                        int nr_of_ships,
                        int nr_of_waves,
                        QVector pos,
                        string squadlogo,
                        string destinations);

 //this function launches a normal fighter  the name is the flightgroup name, the type is the ship type,
 //the faction is who it belongs to, the unittype is usually "unit" unless you want to make asteroids or
 //nebulae or jump points or planets.  the aistring is either a python filename or "default"  the nr of
 //ships is the number of ships to be launched with this group, the number of waves is num reinforcements...
 //the position is a tuple (x,y,z) where they appear and the squadlogo is a squadron image...you can leave
 //this the empty string '' for the default squadron logo.
 
        Unit* launch (string name_string,string type_string,string faction_string,string unittype,
                string ai_string,int nr_of_ships,int nr_of_waves, QVector pos, string sqadlogo);

 //this gets a random cargo type (useful for cargo missions) from either any category if category is ''
 //or else from a specific category  'Contraband'  comes to mind!

        Cargo getRandCargo(int quantity, string category);

 //This gets the faction name of an index

        string GetFactionName(int index);

 //this gets an index given a faction name

        int GetFactionIndex(string name);

 //this gets a relationship between two factions

        float GetRelation(string myfaction,string theirfaction);

 //this changes the relaationship based on the rank and how mad or happy they are (the relationship
 //is between 0 and 1... so a adjustment of .01 with a rank of 1 is QUITE significant.

        void AdjustRelation(string myfaction,string theirfaction, float factor, float rank);

 //this gets the number of factions in game

        int GetNumFactions ();

///this gets the current game time since last start in seconds

        float GetGameTime();

///this gets the current absolute startime in seconds

        float getStarTime();

 //this sets the time compresison value to zero

        void SetTimeCompression ();

 //this gets a string which has in it a space delimited list of neighmoring systems

        string GetAdjacentSystem (string str, int which);

 //this gets a specific property of this system as found in universe/milky_way.xml

        string GetGalaxyProperty (string sys, string prop);

 //this gets the number of systems adjacent to the sysname

        int GetNumAdjacentSystems (string sysname);

 //this adds a playlist to the music and may be triggered with an int

        int musicAddList(string str);

 //this plays a specific song

        void musicPlaySong(string str);

 //this plays msuci from a given list (where the int is what was returned by musicAddList)

        void musicPlayList(int which);

 //this gets the difficutly of the game... ranges between 0 and 1... many missions depend on it
 //never going past .99 unless it's always at one.

        float GetDifficulty ();

 //this sets the difficulty

        void SetDifficulty (float diff);

 //this plays a sound at a location...if the sound has dual channels it will play in the center

        void playSound(string soundName, QVector loc, Vector speed);

 //this plays an image (explosion or warp animation) at a location

        void playAnimation(string aniName, QVector loc, float size);

 //this ends the mission with either success or failure

        void terminateMission(bool term);

 //this gets the player belonging to this mission

        Unit *getPlayer();

 //this gets a player number (if in splitscreen mode)

        Unit *getPlayerX(int which);

 //this gets the number of active players

        int getNumPlayers ();

 //this adds an objective for the cockpit to view ("go here and do this')

        int addObjective(string objective);

 //this sets the objective's completeness (the int was returned by add objective)

        void setObjective(int which, string newobjective);

 //this sets the completeness of a particular objective... chanigng the color onscreen

        void setCompleteness(int which, float completeNess);

 //this gets that completeness

        float getCompleteness(int which);

 //this sets the owner of a completeness

        void setOwner(int which,Unit *owner);

 //this gets an owner of a completeness (NULL means all players can see this objective)

        Unit* getOwner(int which);

 //this sends an IO message... I'm not sure if delay currently works, but from, to and message
 //do :-) ... if you want to send to the bar do "bar" as the to string... if you want to make
 //news for the news room specify "news"

    void IOmessage(int delay,string from,string to,string message);

 //this gets a unit with 1 of each cargo type in it

        Unit *GetMasterPartList ();

 //this gets a unit with a faction's contraband list... may be null (check with isNull)

        Unit *GetContrabandList (string faction);

 //this sets whether or not a player may autopilot.  Normally they are both 0 and the autopiloting
 //is allowed based on if enemies are near... if you pass in 1 then autopilot will be allowed no
 //matter who is near... if you set -1 then autopilot is never allowed.  global affects all
 //players... player just affects the player who accepted the mission.

        void SetAutoStatus (int global_auto, int player_auto);