Server Help

Misc User Apps - MervGen

tansey - Fri Feb 02, 2007 10:51 pm
Post subject: MervGen
MervGen is a visual tool for creating Merv-based bots. Bots have many common design patterns (timers, votes, ship constraints, etc) that are then mixed and matched to create specific event bots. Since my master's thesis is on automatic program generation, and I was very bored for a couple weeks over winter break, I thought I'd give this project a shot.

I had been holding back on posting this, since it's still very early in the development process. However, I'm currently busy with my real life projects so I don't have much time to work on this, which is unfortunate because I think it's a really good idea.

So I'm going to adopt the Google method and just post the last stable build here, and label it a beta version for now. :)

Current Functionality in bold
Partial functionality (though not released yet) in italics
No functionality (or no design in mind yet) in regular text

Features MervGen Supports:
- Loading files from variables (will create a stub .ini as well)
- Votes (call method "startVote_name()" to start it)
- Timers (set it to value > -1 to start, will call name_Done() when timer reaches 0)
- Stats tracking, including creating variables that can be used later in the tool
- Ship Constraints, (I have functionality for this, but I think I need to rework the general approach)
- Team size constraints
- Team/Arena starting positions
- Sequential starting actions
- Custom triggers (i.e. powerful event->action statements)
- Specifying ending conditions

Any input you guys have is really appreciated. Also, bug reports are welcome, but keep in mind only the bold parts should be bug-free. If you notice any better way to do one of the patterns, let me know.

MervGen Website

Trigger Editor Features (idea list)
Teams:
- Team 0
- Team 1
- Team 2
- ...
- Team 10
- Any Team

Conditions:
- team/player enters region
- timer reaches time
- team/player controls boolean operator amount flags

Actions:
- Grant prize to team/player
- Grant amount points to team/player
- Reset timer
D1st0rt - Sun Feb 04, 2007 3:27 am
Post subject:
Wow, I thought I there was only one other person that played this game in Blacksburg...

This looks interesting btw, I don't suppose I could convince you to switch to either TWCore or ASSS eh?
Chambahs - Sun Feb 04, 2007 7:43 am
Post subject:
"However, I'm currently busy with my real life projects so I don't have much time to work on this, which is unfortunate because I think it's a really good idea."
CypherJF - Sun Feb 04, 2007 10:13 am
Post subject:
I had this idea too so glad someone else had the time to develop this type of application!
tansey - Mon Feb 05, 2007 11:06 am
Post subject:
D1st0rt wrote:
Wow, I thought I there was only one other person that played this game in Blacksburg...

This looks interesting btw, I don't suppose I could convince you to switch to either TWCore or ASSS eh?


Glad there's another fellow hokie on here. =)

I've never used either of the other APIs. What would be nice is a uniform approach that could make it easy to convert this to any API (relatively) quickly.

The current implementation is just a quick-and-dirty proof of concept that can get a few features up and running, however it doesn't generate particularly readable code. I think a better way to go might be to make a general library addition then generate a smaller, better structured file which is used in conjunction with the library. Seems like that would make things easier for everyone.

I expect that over the summer I'll have time to refactor all of the code. For now, it's kind of just a good idea and a proof of concept. I'm interested more in feedback and ideas/criticisms.

P.S. d1st0rt--are you a CS major/grad student?
tansey - Mon Feb 05, 2007 11:10 am
Post subject:
CypherJF wrote:
I had this idea too so glad someone else had the time to develop this type of application!


Just the opposite, sadly. I don't have the time to develop it, as I'm working right now on generating MPI code for high performance compute clusters, which is really killing me.

Maybe a better way to do this would be to create a plug-in architecture and just let people write their own bits of code?

Nice Gosling quote btw. =)
D1st0rt - Mon Feb 05, 2007 1:18 pm
Post subject:
I'm a sophomore CS minor (majoring in mechanical)

I can't currently think of an easy way to swap out APIs, following conventions in each core would probably require a complete code generator for each.
tansey - Mon Feb 05, 2007 4:08 pm
Post subject:
D1st0rt wrote:
I'm a sophomore CS minor (majoring in mechanical)

I can't currently think of an easy way to swap out APIs, following conventions in each core would probably require a complete code generator for each.


Well I can easily generate an XML file representation of what needs to be generated. Maybe I'll look into the ASSS code, but DSB uses Merv, so that's my primary target platform.
CypherJF - Mon Feb 05, 2007 5:46 pm
Post subject:
tansey wrote:
[..]
...
Nice Gosling quote btw. =)


Thank-you, I love his blog. biggrin.gif
Cerium - Mon Feb 05, 2007 5:50 pm
Post subject:
Neat project. If you really want to help the non-developers, look at the trigger system in Blizzard's RTS games. If you implemented something like that... damn.
Animate Dreams - Mon Feb 05, 2007 5:56 pm
Post subject:
Cerium wrote:
Neat project. If you really want to help the non-developers, look at the trigger system in Blizzard's RTS games. If you implemented something like that... damn.


You're basically talking about a new bot-core now, I think. Although, couldn't this conceivably be done(with a complete recode) in AS3?
CypherJF - Mon Feb 05, 2007 6:43 pm
Post subject:
Cerium wrote:
Neat project. If you really want to help the non-developers, look at the trigger system in Blizzard's RTS games. If you implemented something like that... damn.
Blizzard maps/triggers were pretty sweet back in Starcraft/Warcraft. Haven't played anything new lately from them.
tansey - Mon Feb 05, 2007 6:55 pm
Post subject:
Cerium wrote:
Neat project. If you really want to help the non-developers, look at the trigger system in Blizzard's RTS games. If you implemented something like that... damn.


Link?
Animate Dreams - Mon Feb 05, 2007 8:11 pm
Post subject:
CypherJF wrote:
[..]

Blizzard maps/triggers were pretty sweet back in Starcraft/Warcraft. Haven't played anything new lately from them.


New? The only thing Blizzard has done since then is World of Warcraft.
CypherJF - Mon Feb 05, 2007 8:33 pm
Post subject:
Animate Dreams wrote:
[..]
New? The only thing Blizzard has done since then is World of Warcraft.


Ah good I'm not that old then. icon_smile.gif
Cerium - Mon Feb 05, 2007 10:23 pm
Post subject:
tansey wrote:
[..]
Link?


None required, really.

This is something I wanted to implement long ago, but I was too inexperienced at the time. It would be very cool to see this finished. May even breathe some new life into this dying game.

Basically, the system worked something like this:
There was a dropdown list of actions. Like "player moves to ____" and upon selection, the user would fill in the blank. In the case of Starcraft or Warcraft, the blank would be the name of a region on the map.
Anyway, after the action was set, the reaction would be set, based off another dropdown list of actions. The language that was used in all of the action/reaction sets was plain english. No symbols or programming lingo.

The key here is that each "trigger" could have multiple actions/reactions. It was a very simplistic system that everyone could adapt to quickly without any programming experience, but could still make powerful maps and subevents.

Some examples that could be good for SS (The underlined text represents sub-options the user would select after choosing the action/reaction):

any player enters region region1 -> grant prize fullcharge to active player
Timer timer1 reaches 5 seconds AND team1 controls atleast 2 flags -> grant 500 points to team1; reset timer timer1



Edit:
Some images of the GUI from Starcraft can be viewed here: http://hybrid.shanky.com/sctriggers
L.C. - Mon Feb 05, 2007 10:46 pm
Post subject:
Now that's cool. biggrin.gif Almost just like pseudonyms (right? icon_surprised.gif).
Samapico - Mon Feb 05, 2007 11:25 pm
Post subject:
im guessing in the case of asss this could all be converted to region code?

that would be a cool thing to do in DCME tongue.gif
Animate Dreams - Tue Feb 06, 2007 12:59 am
Post subject:
Samapico wrote:
im guessing in the case of asss this could all be converted to region code?


Er, um... the region related ones, I suppose. But I think it would be a bit broader than that, I'm sure it would be very similar to callbacks in AS3, only with a GUI to create them. It sounds like a great idea, but even with the existing callbacks in AS3, I'm sure it would be a ton of work. You also have to think, the first time you compile a new AS3 module, you probably get tons of errors. I think things would have to be quite a bit different for that to ever work. Really nice idea, though....
Cerium - Tue Feb 06, 2007 3:10 pm
Post subject:
Ideally, the module itself wouldn't be written for each bot, rather than there would be a single module which reads a script that the GUI creates.
tansey - Tue Feb 06, 2007 11:57 pm
Post subject:
Cerium wrote:
The key here is that each "trigger" could have multiple actions/reactions. It was a very simplistic system that everyone could adapt to quickly without any programming experience, but could still make powerful maps and subevents.


Very interesting program from the snapshots. I suggested the multi-reaction idea on the MervGen website (that's what the '+' buttons are for in the screen shots), but I like the way they did it in the SC editor a lot better.

I think maybe I was trying to be a little too ambitious by allowing complete generation of any bot. Maybe a (large) subclass would be better if it allows for a more intuitive interface.

I would certainly be willing to work on something like the SC trigger editor if we could flesh out the details. Maybe we could start a list of different Player, Action, and Condition parameters. I'll keep a running tab at the the original post for this thread.
Smong - Wed Feb 07, 2007 4:47 am
Post subject:
Cerium wrote:
Some examples that could be good for SS (The underlined text represents sub-options the user would select after choosing the action/reaction):

any player enters region region1 -> grant prize fullcharge to active player
Timer timer1 reaches 5 seconds AND team1 controls atleast 2 flags -> grant 500 points to team1; reset timer timer1
This layout reminds me of mail filters. I think a code generator like this could be made to work for all bots and asss. You would still need a compiler and header files, which some people are going to have problems setting up. Having a bot/asss plugin read the file and do everything dynamically just sounds a bit flaky and complex.
tansey - Wed Feb 07, 2007 9:50 am
Post subject:
Smong wrote:
[..]

You would still need a compiler and header files, which some people are going to have problems setting up. Having a bot/asss plugin read the file and do everything dynamically just sounds a bit flaky and complex.


If people have visual studio installed (for Merv at least), we can invoke the compiler inside the program, so all they'll get is a DLL.
tansey - Wed Feb 07, 2007 7:57 pm
Post subject:
I updated the OP with a list of the features suggested so far, how about some more?

Think of events you've created and/or want to create, and the triggers they would use.
Samapico - Wed Feb 07, 2007 8:57 pm
Post subject:
teams Even / Odd could be used for some balling games

team/player enters region
could even be
team/player enters region
'enters' could be replaced by 'leaves' or by
'is in' [...] 'for / every' value 'seconds / minutes..etc'

But I guess that,s mostly an interface issue... whether to show 'enters' , 'leaves', etc. as all individual actions, or show a 'regions:' category, in which you can choose the verb

Same thing could apply to about every condition created
Cerium - Thu Feb 08, 2007 12:45 am
Post subject:
@Tansey:
For the team thing, just do "Freq ___" where the user fills in the value or selects "Any freq"

Really, you should head down to gamestop or walmart or something and pickup Starcraft/Warcraft 3. You can get em for like $10 now and you'd be able to check out their trigger system. Or, check one of the popular torrent trackers as I'm sure you can get it there as well.


@Smong:
If that's the case, maybe have an option to auto-compile as well? Remember, a lot of people that will be interested in the result of this project will have minimal programming experience. Forcing them to learn how to compile something is a rather double edged sword.



Some more conditions/actions...

Conditions:
variable is operator value

Actions:
move player at location to location
set variable to value
tansey - Thu Feb 08, 2007 8:14 pm
Post subject:
Samapico wrote:
teams Even / Odd could be used for some balling games

But I guess that,s mostly an interface issue... whether to show 'enters' , 'leaves', etc. as all individual actions, or show a 'regions:' category, in which you can choose the verb

Same thing could apply to about every condition created


I think Even/Odd could be done by the Freq 0 and Freq 1 teams.

Also, I think that for clarity sake, the verbs should static and the nouns should be the options, as a general rule.

Cerium wrote:
Conditions:
variable is operator value

Actions:
move player at location to location
set variable to value


I don't know if we want to go so far down as to allow variable settings. Part of the problem would be that it's confusing to a lot of novice bot makers (i.e. people who don't know how to program), and while it wouldn't be incredibly hard to generate, it would complicate things. I'll add it to the list anyway, since I already have a lot of that functionality generated in the beta.
Cerium - Thu Feb 08, 2007 8:22 pm
Post subject:
Probably. The SC system had things called "Switches" which were basically just boolean variables. There was an action to set/clear/toggle a switch, and a condition to check the status of one. I was just trying to expand on that.
tansey - Wed Apr 18, 2007 12:53 am
Post subject:
Just wanted to let you guys know that I started work on a new MervGen tonight. The new design works on the trigger concept as described earlier, and will use a plug-in architecture so that you can create your own conditions and/or actions.

I just finished debugging the last part of the foundation (plug-in architecture, base classes). Next I'm going to start the actual code generator library that will hopefully make things easier for the plug-in developer.

However, this will have to wait for a week, as I'm a student at Virginia Tech and I am going home for the week to get away from all the craziness here.

I'll keep you all updated and will post a prototype as soon as possible.
Animate Dreams - Wed Apr 18, 2007 2:11 am
Post subject:
Holy crap, I never knew I knew so many people at VTech until now....
tansey - Tue Apr 24, 2007 2:33 am
Post subject:
I thought that before I get too far into this, it would be a good idea to throw out my current proof of concept design and get everybody's feedback.

Like I've said before, this is based on the concept of triggers (if a set of conditions is true, you carry out an associated set of actions). The current view for creating triggers looks like this:

Right clicking on one of the nodes in the tree will give you a context menu which will allow you to add an item. For example, right clicking on Conditions for trigger0 will give you the option to "Add a Condition." That will then pop up the following window to let the user choose a condition to add:

Note the name of the sample condition. Each condition or action is its own plug-in. The plug-in interface has all the properties shown in the example above.

Each plug-in contains a list of phrases, and each phrase contains a specific option for how the user can fill it in. For example, in the above picture there are 6 phrases: "Player ", "player", " enters region ", "region", " and has bounty greater than ", "bty". The "bty" phrase is of the type FillNumber, signifying that the user is able to input only numbers into that field. There is also a FillText type and a Select type (combo box of predefined choices).

The idea is that the application will then call GenerateCode for each plugin, and each plugin will add its own code to the library to be generated.

Thoughts?
Smong - Tue Apr 24, 2007 5:54 am
Post subject:
Would you click the underlined "My Conditon Plugin" to edit the sentence using another dialog (not shown)? Just wondering because one line doesn't look like enough space.

Anyway, here are some screen caps from outlook express:

When you click an underlined word list:

When you click the options button:


I don't think you'll be needing word lists. But you can replace that with say coord selector. So it would be like:
When a player enters 'x1,y1,x2,y2' or 'x1,y1,x2,y2'

Note I didn't underline player, if I was following the outlook express style I would have player/team/arena in the top list.
tansey - Tue Apr 24, 2007 10:35 am
Post subject:
The "Select a Condition" dialog just gives the user a preview of the plugin. Then when you click on it in the tree view in the main MervGen form it will load the info into the panel on the left (currently just blank space in the screenshot) with an editable box among other things. Then clicking on an underlined word will pop up a dialog which allows you to edit that word according to its predefined setting. The pic is below:


I'm not quite sure what you're getting at with the Outlook examples. My idea was based more on chaining together items one-by-one, like this:

In your example:
When a player enters 'x1,y1,x2,y2' or 'x1,y1,x2,y2'
My approach would be to make 1 simpler plugin condition:
When a player enters 'x1,y1,x2,y2'
And then I would have the player add two of them to a trigger.

Would you mind expanding a little more on your idea?
Smong - Tue Apr 24, 2007 5:23 pm
Post subject:
So you're saying one trigger can have many "plugin conditions"? To me it originally sounded like a separate merv plugin for each condition.

Seeing as you already have the real trigger editor to work from just ignore my screenshots, outlook filters can't do everything anyway.
tansey - Wed Apr 25, 2007 10:41 am
Post subject:
I'm almost done with the beta version. I've finalized the first version of the plugin interface, it's just a matter of writing the Merv C++ library code and then writing the generator which will produce the user-created bot.

I'd like your guys' feedback on the plugin interface though. The basic idea is that if you want to create a custom action or condition, you create a new IActionPlugin or IConditionPlugin. Your plugin is responsible for the text the user sees and edits, as well as for generating the required C++ code. I considered making code generation a little more structured, but I decided that this is simple enough that people should be able to follow a convention if it's well-documented.

This is also true for basic stats tracking, which will be automated and the plugins can simply make use of them. I will establish a convention for the variable types/names for each stats field, and methods which need them will know how to access them. The plugin is required to specify which stats it requires, and then MervGen will only generate the ones which are needed.

The PluginInterface is listed below:

Code: Show/Hide
public interface IPlugin
    {
        IPluginHost Host { get;set;}

        string Name { get;}
        string Description { get;}
        string Author { get;}
        string Version { get;}

        /// <summary>
        /// A string containing the code required to call this plugin's main method.
        /// The method call should start with "mervgen." since it will be placed inside
        /// of a class (MervGen) which will have an instantiated object named mervgen.
        ///
        /// i.e.: "mervgen.[name]([parameters])"
        /// </summary>
        string CallMethod { get;}

        /// <summary>
        /// A string containing the signature of this plugin's main method.
        ///
        /// i.e.: "[return type] [name]([parameters]);"
        ///
        /// Note that conditions should return bool and actions should return void by convention.
        /// </summary>
        string MethodSignature { get;}

        /// <summary>
        /// A string containing the definition of this plugin's main method.
        ///
        /// i.e.: "[return type] MervGen::[name]([parameters]) { [body] }"
        /// </summary>
        string MethodDefinition { get;}

        /// <summary>
        /// The list of phrases which will be displayed to the user.
        /// </summary>
        List<Phrase> Phrases { get;}

        /// <summary>
        /// The built-in stats that this plugin uses.
        /// </summary>
        List<Stats> RequiredStats { get;}

        /// <summary>
        /// The valid locations that this method can be called from.  This is used
        /// to determine where the method call(s) will be inserted in the generated
        /// code.
        ///
        /// For instance, a plugin which is concerned with where a player moves
        /// would likely have a single entry (PlayerMove) as its valid placement.
        /// </summary>
        List<Events> ValidPlacements { get;}

        void Initialize();
        void Dispose();

        /// <summary>
        /// Instructs the plugin to generate all source code based on the
        /// current state of its Phrases list.  The code to be generated is:
        ///
        /// - MethodSignature
        /// - MethodDefinition
        /// - Any extra methods, includes, or variables.
        ///
        /// MethodSignature and MethodDefinitions should be generated to their
        /// corresponding properties in the plugin.  All extra code should be added
        /// to the appropriate location in the PluginHost.
        /// </summary>
        void GenerateCode();
    }

    public interface IActionPlugin : IPlugin
    {
    }

    public interface IConditionPlugin : IPlugin
    {
    }

    public interface ITrigger
    {
        List<IActionPlugin> Actions { get; set; }
        List<IConditionPlugin> Conditions { get; set; }
        string Name { get; set; }
    }

    public interface IVariable
    {
        string Name { get; set; }
        string Type { get; set; }
        string Declaration { get; set; }
    }

    public interface IPluginHost
    {
        /// <summary>
        /// The triggers for this bot.
        /// </summary>
        List<ITrigger> Triggers { get; set; }

        /// <summary>
        /// The method signatures of any additional library methods which may need
        /// to be generated.
        /// </summary>
        List<string> LibraryMethodSignatures { get; set; }

        /// <summary>
        /// The method signatures of any additional library methods which may need
        /// to be generated.
        /// </summary>
        List<string> LibraryMethodDefinitions { get; set; }

        /// <summary>
        /// Any #include's (or #define's) which need to be included in the generated class.
        /// </summary>
        List<string> Includes { get; set; }

        /// <summary>
        /// Any fields which need to be generated in the class.
        /// </summary>
        List<IVariable> Variables { get; set; }
    }

    public enum Events
    {
        All,
        Tick,
        ArenaEnter,
        ArenaSettings,
        ArenaLeave,
        ArenaListEntry,
        ArenaListEnd,
        FlagGrab,
        FlagDrop,
        FlagMove,
        FlagVictory,
        FlagGameReset,
        FlagReward,
        TimedGameOver,
        SoccerGoal,
        BallMove,
        File,
        PlayerEntering,
        PlayerMove,
        PlayerWeapon,
        WatchDamage,
        PlayerDeath,
        BannerChanged,
        PlayerScore,
        PlayerPrize,
        PlayerShip,
        PlayerSpec,
        PlayerTeam,
        PlayerLeaving,
        SelfShipReset,
        SelfPrize,
        SelfUFO,
        PositionHook,
        BrickDropped,
        ObjectToggled,
        CreateTurret,
        DeleteTurret,
        ChatArena,
        ChatPublicMacro,
        ChatPublic,
        ChatTeam,
        ChatTeamPrivate,
        ChatPrivate,
        ChatPlayerWarning,
        ChatRemotePrivate,
        ChatServerError,
        ChatChannel,
        LocalCommand,
        LocalHelp,
        RemoteCommand,
        RemoteHelp,
        Init,
        Terminate
    }

    public enum Stats
    {
        PlayerDeaths,
        PlayerKills,
        PlayerShipChanges,
        PlayerFlagGrabs,
        PlayerFlagDrops,
        PlayerFlagVictories,
        PlayerFlagPoints,
        PlayerScore,
        PlayerKillPoints,
        PlayerDamageDealt,
        PlayerDamageReceived,
        PlayerTeamKills,
        PlayerMVP,
        TeamDeaths,
        TeamKills,
        TeamShipChanges,
        TeamFlagGrabs,
        TeamFlagDrops,
        TeamFlagVictories,
        TeamFlagPoints,
        TeamScore,
        TeamKillPoints,
        TeamDamageDealt,
        TeamDamageReceived,
        TeamTeamKills,
        TeamMVP,//Tracks the player with the most points in each team
        TeamMVT //Tracks the team with the most points
    }

tansey - Wed Apr 25, 2007 1:11 pm
Post subject:
Here is an example condition plugin (the one I used in the screenshots in earlier posts):

Code: Show/Hide
public class MyCondition : IConditionPlugin
    {
        #region IPlugin Members
        IPluginHost host = null;
        private string name = "My Condition Plugin";
        private string author = "Wes";
        private string description = "This is a test plugin to see if the MervGen plugin architecture works";
        private string version = "1.0";
        private List<Phrase> phrases = new List<Phrase>();
        private List<Stats> stats = new List<Stats>();
        private string callMethod = "mervgen.myConditionPlugin()";
        private string methodSignature = "bool myConditionPlugin();";
        private string methodDefinition = "bool MervGen::myConditionPlugin(){ return true; }";
        private List<Events> validPlacements = new List<Events>();

        public List<Events> ValidPlacements
        {
            get { return validPlacements; }
            set { validPlacements = value; }
        }

        public string MethodDefinition
        {
            get { return methodDefinition; }
            set { methodDefinition = value; }
        }

        public string MethodSignature
        {
            get { return methodSignature; }
            set { methodSignature = value; }
        }
       
        public string CallMethod
        {
            get { return callMethod; }
            set { callMethod = value; }
        }

        public IPluginHost Host
        {
            get { return host; }
            set { host = value; }
        }

        public string Name
        {
            get { return name; }
        }

        public string Description
        {
            get { return description; }
        }

        public string Author
        {
            get { return author; }
        }

        public string Version
        {
            get { return version; }
        }

        public List<Phrase> Phrases
        {
            get { return phrases; }
        }

        public List<Stats> RequiredStats
        {
            get { return stats; }
        }


        public void Initialize()
        {
            phrases.Add(new Phrase("Player "));
            List<string> options = new List<string>();
            options.Add("any player");
            options.Add("freq 0 player");
            phrases.Add(new Phrase("player", options));

            phrases.Add(new Phrase(" enters region "));

            options = new List<string>();
            options.Add("region1");
            options.Add("region2");
            phrases.Add(new Phrase("region", options));
            phrases.Add(new Phrase(" and has bounty greater than "));
            phrases.Add(new Phrase("bty", OptionType.FillNumber));

            validPlacements.Add(Events.All);
        }

        public void Dispose()
        {
           
        }

        public void GenerateCode()
        {
           
        }

        #endregion
    }

tansey - Thu Apr 26, 2007 5:49 pm
Post subject:
I've been reading up on the way ASSS plugins work and I think it could be possible to apply this system to both Merv and ASSS...would there be any interest in this?
Animate Dreams - Thu Apr 26, 2007 9:08 pm
Post subject:
Definitely. A lot of developers are scared of AS3, and something like this might really help to change that.
Smong - Fri Apr 27, 2007 5:00 am
Post subject:
Ok a few questions now.
- What does myConditionPlugin() get used for? Some time during code generation?

- Would it be better to initialise phrases = new List<Phrase>(); inside Initialize() incase it gets called twice?

- What does validPlacements.Add(Events.All); do? Would it have been ok to use just movement and bounty change events for this particular condition?

- What does #region IPlugin Members and #endregion do?
tansey - Fri Apr 27, 2007 9:59 am
Post subject:
Smong wrote:
Ok a few questions now.
- What does myConditionPlugin() get used for? Some time during code generation?


Kind of. The idea is that each plugin generates a method which will be called at the specified event. By convention, an action plugin returns void and a condition plugin returns a bool. So wherever the trigger that MyConditionPlugin belongs to is going to check its conditions, it will call myConditionPlugin() in the generated code.

So if this was the only condition to the trigger, then the generated code would have (assuming its valid placement was player move and bounty change like you pointed out below):
Code: Show/Hide
case EVENT_PlayerMove:
      {
         Player *p = (Player*)event.p[0];
         if(mervgen.myConditionPlugin())
         {
            ...(actions for the trigger called here)
         }
      }


And you'd have an identical setup for the bounty changed event.

Smong wrote:

- Would it be better to initialise phrases = new List<Phrase>(); inside Initialize() incase it gets called twice?


Yes. This was just a very quick and dirty solution. In reality, Initialize should only be called once by the container, but I suppose that a good practice would be to assume it could be called more than once.

Smong wrote:

- What does validPlacements.Add(Events.All); do? Would it have been ok to use just movement and bounty change events for this particular condition?


Yes. I just threw that in to show how you add valid placements. If this were a real plugin, it would make more sense to put it in those 2 events instead.

Smong wrote:

- What does #region IPlugin Members and #endregion do?


The code is C#. #region and #endregion define sections that you can collapse/expand in visual studio. It really helps to clean up code.
tansey - Mon Jul 09, 2007 2:51 pm
Post subject:
If anyone is interested in this project still, I can post it on CodePlex. I know how to resolve all the issues I had a few months ago, it's just a matter of interest at this point.
Anonymous - Sat Sep 08, 2007 10:17 am
Post subject: Yes
I was reading this whole post, thinking to myself, "wish this was for AS3, wish this could make Python modules"

Please do!
Anonymous - Sat Sep 22, 2007 2:11 am
Post subject:
WORK ON THIS
tcsoccerman - Sat Sep 22, 2007 8:40 am
Post subject:
Quote:
WORK ON THIS

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group