Jump to content


Photo

Feature Manager


  • Please log in to reply
6 replies to this topic

#1 Tsukihime

Tsukihime

    Advanced Member

  • Ace Member
  • 7,120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 12 October 2012 - 08:01 AM

Feature Manager

This is a plugin-based scripting system that allows you to quickly define features and add them to RPG::BaseItem objects. Then you define the behavior of the feature and then tag your database objects.

Download

Get it at HimeWorks

Examples

A couple scripts I've written for samples

Add_Param: http://db.tt/IK2zP73V. Allows you to increase basic parameters using a constant value rather than using percents.
Add_Equip: http://db.tt/SATgIdx8. Allows you to specify which weapons/armors your actor can equip, by database ID

Usage

To add a feature to a feature object, simply note-tag with a feature tag. The general syntax for a feature tag is

<ft: name arg1 arg2 ... >
Where
  • `name` is the name of the feature you wish to add
  • `arg1 arg2 ...` are a list of arguments that the plugin requires
You may specify conditional features as well, using the following note-tag

<cond_ft: name "cond" arg1 arg2 ... >
Where

`cond` is a ruby exp<b></b>ressi&#111;n that evaluates to true or false. The condition must be surrounded by quotation marks.

Conditional features can be applied to any feature that is supported by this
system.

For Developers

Four step process

Step 1

Register your feature. Choose a name that will unique identify your feature
You can also pass in a version number if your script requires a specific version of the script.

You can check the version of the feature manager in the "import" line. It probably will be 1.0 for awhile so you can just omit it.

FeatureManager.register(IDSTRING, api_version=1.0)
Step 2

Define an "add_feature" method for your plugin. You will need to tell the feature manager how you want to setup your RPG::Feature. Keep in mind that all data ID's and values must be integers. For now, features only support integer values.

class RPG::BaseItem
def add_feature_IDSTRING(code, data_id, args)
data_id = args[0].to_i
value = args[1].to_i
add_feature(code, data_id, value)
end
end
Step 3

Define the behavior of your feature.
You will probably be aliasing methods defined in Game_BattlerBase, Game_Battler, Game_Actor, or Game_Enemy.

Step 4

Write instructions for tagging your database objects
The format of the note tag is as follows

<ft: IDSTRING arg1 arg2 arg3 ...>
Where IDSTRING is the name of your plugin you registered and a list of args that you will ask your users to give you.

Notes

For now I am simply following what the default scripts do.

I am releasing this now because I feel this is something that would be developed much more effectively if there are people actually using it and trying to implement their ideas.

If you have an idea for a feature but my system does not allow you to write it (for example, if you want to use string values or something), just describe how you are planning to use it and I will see whether I want to make the values less restrictive.

Similarly, if you need more ways of checking whether your actor has a particular feature or not, just describe it. I have added two methods that I think are essential

# Returns a set of all values for the given feature code
def features_value_set(code)
features(code).inject([]) {|r, ft| r |= [ft.data_id] }
end

# Returns a set of all values for the given feature code, filtered by data ID
def features_value_set_with_id(code, data_id)
features_with_id(code, data_id).inject([]) {|r, ft| r |= [ft.value]}
end
A lot of other methods are available.

Edited by Tsukihime, 30 March 2016 - 10:15 AM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#2 KilloZapit

KilloZapit

    FAIRY DUST! FAIRY DUST FOR EVERYONE! WHEE!

  • Ace Member
  • 2,557 posts
  • LocationFairyland!
  • RM Skill - Coder

Posted 14 October 2012 - 09:14 PM

Neato! I wondered if you were gonna do this... It should be useful!

#3 Tsukihime

Tsukihime

    Advanced Member

  • Ace Member
  • 7,120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 14 October 2012 - 09:29 PM

Ya I've already written about 10 scripts for it. Really simple when you don't have to set everything up again and again.
All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#4 Tsukihime

Tsukihime

    Advanced Member

  • Ace Member
  • 7,120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 07 November 2012 - 11:54 PM

I have implemented conditional features. I have not performed stress tests to see what happens if you have a thousand features though.

Conditional features are features that are only applied if a particular condition has been met.
They are tagged using the note-tag format

<cond_ft: name "cond" arg1 arg2 ... >

Where `cond` is the condition, as a valid ruby exp<b></b>ression that evaluates to true or false.
Note that the condition must be wrapped in quotation marks.

I have reserved the following variables for use in the condition:

a - the battler
v - game variables
s - game switches

All features are supported.
Default features have been aliased with their own feature name, so if you wanted to add a "skill_add" feature, you would just say

<ft: skill_add 34>

This is done because otherwise you would have no way to specify conditional features for the defaults.

For example, suppose you wanted to create a "newbie sword" that adds a special "newbie skill" which has skill ID 125 if your level is below 10.

You would use the tag:

<cond_ft: skill_add "a.level < 10" 125>

This means that if the battler's level is less than 10, then the feature is applied and thus the skill is added. Once the battler reaches level 10 or above, the skill is removed.

Another example is if you require switches to be ON (or OFF) and certain variable numbers

<cond_ft: skill_add "s[23]" 125> # add the skill if switch 23 is ON

<conf_ft: skill_add "v[1].between?(1, 5)" 125> # add the skill if variable 1 is between 1 and 5, inclusive

Anything is possible.

Edited by Tsukihime, 08 November 2012 - 12:01 AM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#5 JANK

JANK

    Music Composer

  • Ace Member
  • 108 posts
  • RM Skill - Musician

Posted 08 November 2012 - 02:01 AM

Sorry for the noob question, but could you list the possible uses of variables and their syntax?
Like how do I make it say "if v[1] increases by 2" or "if v[1] decreases by 1", or "if v[1] is >5", etc...

Specifically I'm trying to use the learnable feature to tag a piece of equipment with:
<cond_ft: learnable "v[1] (being the actor's level, increases by 1)" 55>

And I interpret that to mean, if the tagged equipment is equipped and the actor wearing it gains 1 level he will learn skill 55. Then it doesn't matter if he unequips it, he will still know the skill. Am I correct?

Thanks for your patience, and of course for your awesome script.

edit:
I've tested and tried a couple things and I can't get the "learnable" feature to work.
skill_add works fine but it's only active while the equipment is equipped. Once you remove the equipment you lose the skill.
I've tried listing them as separate tags, for example:
<ft: learnable 55>
<cond_ft: skill_add "v[1]>0" 55>

the skill add part works, but not the learnable part. I've tried switching them around and that doesn't work either.

Edited by JANK, 08 November 2012 - 02:32 AM.

Current project: The Last Werewolf, inspired by the Breath of Fire series: http://www.rpgmakerv...1306#entry71306
My music page: http://www.rpgmakerv...s-music-studio/

#6 Tsukihime

Tsukihime

    Advanced Member

  • Ace Member
  • 7,120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 08 November 2012 - 06:44 AM

And I interpret that to mean, if the tagged equipment is equipped and the actor wearing it gains 1 level he will learn skill 55. Then it doesn't matter if he unequips it, he will still know the skill. Am I correct?


No, because there is no logic for actually learning.
That condition would mean skill 55 is learnable if the actor's level is > some variable.

There is no connection between the learnable feature and the skill add feature.
Learnable simply adds a number to a list somewhere. Another script is supposed to take this number and have you learn the skill.

Edited by Tsukihime, 08 November 2012 - 06:48 AM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#7 JANK

JANK

    Music Composer

  • Ace Member
  • 108 posts
  • RM Skill - Musician

Posted 08 November 2012 - 01:16 PM

Okay thanks for clarifying that. So when are you going to write that script? :P
I'm just kidding. Not trying to be pushy.
Current project: The Last Werewolf, inspired by the Breath of Fire series: http://www.rpgmakerv...1306#entry71306
My music page: http://www.rpgmakerv...s-music-studio/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users