A whole new functions in Patch 9

Started by ptanhkhoa, April 23, 2010, 07:32:16 AM

Previous topic - Next topic

ptanhkhoa

At first i'm very disappoint in Patch 9 because the AI don't run but affter take a look carefully at the core.base, i see that they change a lot with a new very interesting function, not only helpful for map maker but also our AI developer as well.

In the natives.galaxy

First, the problem how to receive player message now resolved with this :

Quoteconst int c_invalidConversationId           = 0;
const int c_invalidReplyId                  = 0;

const int c_conversationReplyStateUnread    = 0;
const int c_conversationReplyStateRead      = 1;
const int c_conversationReplyStateOld       = 2;

native int          ConversationCreate (bool visible);
native int          ConversationLastCreated ();
native void         ConversationDestroy (int intId);
native void         ConversationDestroyAll ();

native void         ConversationShow (int intId, playergroup to, bool visible);
native bool         ConversationVisible (int intId, int player);

native int          ConversationReplyCreate (int intId, text inText);
native int          ConversationReplyLastCreated ();
native void         ConversationReplyDestroy (int intId, int replyId);
native void         ConversationReplyDestroyAll (int intId);

native void         ConversationReplySetText (int intId, int replyId, text inText);
native text         ConversationReplyGetText (int intId, int replyId);

Interesting right, so we can use this to make a command function to make the AI to to do what we want, for example, starting a specific opening.



now, another previous problem about the coordinate, take a look at this guy, now we can make them build at any place, so walling should be no problem ( damn, I should waiting for this patch, all the time I thinking to build wall now useless >.< ).

Quotenative point Point (fixed x, fixed y);
native point PointWithOffset (point p, fixed x, fixed y);
native point PointWithOffsetPolar (point p, fixed distance, fixed angle);
native point PointFromId (int id);

native fixed PointGetX (point p);
native fixed PointGetY (point p);
native void  PointSet (point p1, point p2);

native fixed PointGetFacing (point p);
native void  PointSetFacing (point p, fixed inFacing);

native fixed PointGetHeight (point p);
native void  PointSetHeight (point p, fixed inHeight);

native bool  PointsInRange (point p1, point p2, fixed range);

native fixed AngleBetweenPoints (point p1, point p2);
native fixed DistanceBetweenPoints (point p1, point p2);

native int   PointPathingCost (point p1, point p2);
native fixed PointPathingCliffLevel (point p);
native bool  PointPathingPassable (point p);
native bool  PointPathingIsConnected (point p1, point p2);
native point PointReflect (point source, point dest, fixed angle);

Not only building, but also strategy too, the pathing problem now solved easily. not to mention some math function like

Quotenative fixed SquareRoot (fixed x);
native fixed Pow (fixed x, fixed power);
native fixed ModF (fixed x, fixed m);
native fixed MinF (fixed x1, fixed x2);
native fixed MaxF (fixed x1, fixed x2);
native fixed AbsF (fixed x);

native int   ModI (int x, int m);
native int   MinI (int x1, int x2);
native int   MaxI (int x1, int x2);
native int   AbsI (int x);

// Trigonometry
// Note: All angles are in degrees
native fixed Sin (fixed degrees);
native fixed Cos (fixed degrees);
native fixed Tan (fixed degrees);
native fixed ASin (fixed x);
native fixed ACos (fixed x);
native fixed ATan (fixed x);
native fixed ATan2 (fixed y, fixed x);


Imagine that, with this we could make the Transport Medievac to enemy base, if it discover an anti-air, it can change direction to get out the range of that anti-air.


Not only the point, put the region has some nice function too
Quotenative region RegionEmpty ();
native region RegionEntireMap ();
native region RegionPlayableMap ();
native void RegionPlayableMapSet (region r);

native region RegionRect (fixed minx, fixed miny, fixed maxx, fixed maxy);
native region RegionCircle (point center, fixed radius);
native region RegionFromId (int id);

native void RegionAddRect (region r, bool positive, fixed minx, fixed miny, fixed maxx, fixed maxy);
native void RegionAddCircle (region r, bool positive, point center, fixed radius);
native void RegionAddRegion (region r, region regToAdd);

native void  RegionSetOffset (region r, point offset);
native point RegionGetOffset (region r);

native bool RegionContainsPoint (region r, point p);

// RegionRandomPoint attempts to find a random point somewhere within the region.  For regions
// containing only a single positive shape, this is guaranteed to work, but for more complex
// sets of shapes it may give up after a maximum number of tries and return (0, 0).
//
native point RegionRandomPoint (region r);

native point RegionGetBoundsMin (region r);
native point RegionGetBoundsMax (region r);
native point RegionGetCenter (region r);

// Setting the center will adjust the offset such that
// the region becomes centered on the given point.
//
native void RegionSetCenter (region r, point p);

// RegionAttachToUnit will attach the region to the given unit such that the region center
// is always at the unit's position plus the given offset.  Use a null unit to detach the region
// from whatever unit it may already be attached to.
//
native void RegionAttachToUnit (region r, unit u, point offset);
native unit RegionGetAttachUnit (region r);

So we can actually make a unit don't run out of the region and return to center when necessary, that good when making AI for terran, where we get Siege Tank at the center and the soldier should not go far for it, notice that we can plus 2 region together so that mean, 2 siegetanks means 2 circle.
I think with this, we can add our drop location, not depend on the LastDropLocation fuction anymore  :thumbsup: .

And much much more interesting function that make develop AI more convenient.


ev-

nice job! looking forward to GT 0.5  :cheers:

eaon21

..just a little curious..what programming language is that and what program are u using to open that kind of data?

Vernam7

isnto a language its a text script that looks like c# in the syntax thought.


the editor its just a simple notepad if needit.


to get those file and edit, thats an other all other story :P