Flare Collection - Laws For Map

● ARCHIVED · READ-ONLY
Started by DarknessFalls 26 posts Page 1 of 2 View original ↗
  1. Flare Collections - Laws for Map vs2.0
    Created by DarknessFalls. All Credit must be given to me. Free for commercial use.

     

    Download: Get me

    The script must be named: Flare-LawsForMap.js



    ATTN!

    All code is written in ES6, including classes, static classes and so on. Do not edit the script it's self. You can view the source code here and learn how to build the script for your self here

     

    ScreenShots:

    Spoiler


     









     Welcome to Laws for Map.

    The script allows you to set up a set of laws for a map, these laws are then checked when a player does an action that targets either it's self, another actor or even an enemy. If you say no potions and I use a potion, you bet ill be punished in some way.

    Laws for Map comes with lots of things right out of the bag, lets get into it.

    Setting up laws

    you can have any number of laws on a map, we will only show you three of those laws at any one time. When the player starts up the map either from a new and saved game we will randomize those laws and show a new set of three. The same goes for when a player transfers to a different map and back again.

    Laws are comprised of a couple of things, a short name, a icon, a punishment and a cantUse which is allowed to hold three things in it (any more and I slice them off).

    So lets set up a law:

    <law name:"Attacking Causes Death" punishment:"hp" amount: 1000 icon: 26 cantUse: "attack, potion, heal" description: "I am mandatory and will blow up if I am missing.">
    • name: The name of the law.
    • punishment: The thing to punish on the actor object. (see below)
    • amount: How much do we do when we punish the user?
    • icon: What icon is representing the law?
    • cantUse: What can we not use? (see below)
    • description: Mandatory, used in the law description window.


    ATTN!

    The parser I use will read the tag as is, if you copy and paste it into the map detail window. Also note that codes like \c[9]...\c[0] must be written as \\c[9]..\\c[0] failure to do so could cause errors.

    Duplicate cantUse

    Consider the following example:

    <law name:"Attacking Causes Death" punishment:"hp" amount: 1000 icon: 26 cantUse: "attack, potion, heal" description: "I am mandatory and will blow up if I am missing."><law name:"Minor Health Loss" punishment:"hp" amount: 10 icon: 26 cantUse: "attack, potion, heal" description: "I am mandatory and will blow up if I am missing.">The issue here is that when we process which law you broke, we take the first one we find in the array of laws for the map is the first one we take. In this case Minor Health Loss would never get used because we found Attacking causes death first.

    ​Description must be included in laws

    Because it doesn't make sense to show you law details and have the whole description area empty, I have made this a crashing error. You must include a description with laws.

    Your "can't use" has to be unique like the name of the law.

    Punishment

    punishments are things we do to the player, we take away things like hp, mp, tp or xp. We can even take away gold.

    We cannot take a away items, weapons or armor (equipped or not).

    When we take away xp, we can level down the actor.

    ATTN!

    Laws can kill. if you reduce the hp below 0 or to 0 on a map or in battle it can kill the player.

    If you are on a map and you kill the whole party, the last law window will tell You that every one is dead and its game over before actually going to the game over.

    We tell you before we punish you, battles.

    In battles when you do an action and the law is broken, if that law would kill You we will tell you before we actually punish you.

    We Punish before we tell you, map.

    If you are on the map and you use a potion and we have stated no you cannot use potions, then we will show you the law window and THEN punish you.

    The following are acceptable punishments: hp, mp, tp, xp, gold.

    No you cannot have multiple punishments.

    cantUse

    Cant use stipulates what a actor can and cannot use. Because laws are not party wide and affect only the actor breaking it the cantUse only applies to that specific actor at the time that they use an action.

    • You can state, for battles: Attack, Item Name, Skill Name, Special Name
    • For maps you can do: Item Name, Skill Name, Special Name
    You can only have three cantUse per law.

    For example: attack, potion, spark

    When a player uses attack in battle or spark in battle they have broken a law. When a player uses potion either in or out of battle that player has broken a law.

    The same goes for out of battle. If a player uses a potion out of battle they will be punished.

    Regarding Breaking Laws in Battle.

    In a battle its the sole act of doing an action thats against the law that breaks the law. For example if the law states you cannot attack and you attack, but it misses, you still broke the law and will be punished according to that law.

    Regarding Yanfly Scripts.

    For Yanfly battle and Yanfly Menu Manager, you don't have to do anything at all.

    This script also works with Yanfly Aftermath, you just have to place laws in the list of reward windows:

    exp custom drops laws

    Reward for not breaking a law

    You can set this up with a tag in the map notes:

    <lawReward i: 5 w:5 a:8 gold:78 xp:90>

    This will reward the player it an item of id 5, weapon of id 5 and armor id of 8. The party will also gain 78 gold and the whole party will gain 90 xp.

    You can also do:

    <lawReward i: "5,6,7" w:"5~89" a:8 gold:"1~78" xp:90>

    This reads as, gain item id of 5,6 and 7. Gain a random weapon between if 5 and 89. Gain armor with id of 8. Gain random gold between 1 and 78 and finally the whole party gains 90 xp.

    Calculate Before or After Battle?

    If you set this plugin option as before then you will see:



    You can scroll through the laws that associated with this map and hit enter to scroll through the list of rewards.

    All of these rewards will be the same for every single battle.

    If you want to have the rewards calculated after every single battle and you are using concepts of: "1 ~ 6" which is how we calculate random rewards.

    Then you'll see:



    Which indicates that there is no reward information to be shown because that information is calculated after every battle.

    Bonus:

    You can do the following:

    i: 1 // item id 1i: "1 ~ 67" // random item between 1 and 67i: "1,2,4" // Give items 1,2 and 4// The above works on weapons and armor, you can use random generator on gold and xp.Public API

    For developers, you get some public api. Non developers might find this useful.

    You have access to the FlareLawsForMap static class which has the following functions on it:

    • getLawsForMap() Gets all the laws for the current map, returns an array of 3 objects.
    Example:

    Code:
    FlareLawsForMap.getLawsForMap() // Returns and array: [Object, Object, Object]
  2. An unexpected but welcome plugin. :)

    I instantly thought of an arena or bonus dungeon type use for this. Rather than restricting the use of the items or abilities, allow the player to use them provided they know there is a price for doing so. It adds a whole new depth to these types of areas.
  3. Slight Bump. Looking for feed back, the same type of updates that came in for currencies tonight is coming to Laws :DDDD along with new features but any others you guys want let me know :D
  4. Thank you for this wonderful plugin. But before I go ahead and use it, I'd like to ask if it's possible to change/add loots during the victory scene if a player hasn't broken the imposed law?
  5. Not as of yet. I can add that as a feature for sure :)
  6. Awesome, I'll be waiting for it then. :) Like as in, wait for it obsessingly. I'm watching you. :| loljk
  7. I'm close to being done :D
  8. Massive Update!

    Version 2.0

    Whats new? Whats new and exciting? OMG Lets all have some amazing fun!!!!

    Law Rewards: You can now use the following tag on a map to give rewards: 

    <lawReward i: 1 a: "1,2,3" w: "5 ~ 23" xp: 89 gold: 879>This reads the following:

    Give item id of 1, armor with ids of 1,2 and 3, a random weapon between id 5 and 23. Finally give the WHOLE PARTY 89 xp and 879 gold.

    This tag is only executed WHEN and ONLY when your WHOLE party does NOT break any laws.

    We have some new plugin options:

    • How many laws per map? If you set up, for example, 76 law tags and choose 6 flaws per map when ever that map loads we will choose 6 random laws of the 76 tags.
    • Calculate law after or before battle? If you set "after" this means that if no one in your party has broken a law, rewards will ONLY be given and rewarded AFTER the battle. this is good if you are using the random syntax: "x ~ y" If you set it to "before" then the rewards will be calculated when the map loads and after every battle if you haven't broken any laws you will ALWAYS get the same reward.
    New Interface for looking at laws.

    Lets look at one where we calculate the law rewards when a map loads:



    On the left we have a list of laws. On the right we have (top to bottom) law description (mandatory) dummy window and a selectable list of rewards.

    Scroll through the laws, hit enter, scroll through the rewards. Hit esc to get back to the list of laws and esc again to get back to the main menu.

    What if you set the plugin option to after?



    Its the same as before accept this time we don't have anything for you to scroll through on the right hand side because these rewards are calculated after each battle and "randomized" assuming you are using "x ~ y" syntax to randomize weapons, armor, items, gold and/or xp.

    This script works with Yanfly Menu Manger (you don't have to do anything) and it works with Yanfly Aftermath :D  

    How do we use with Yanfly Aftermath? Set "laws" in the victory order:

    exp custom drops lawsWhen you win with victory aftermath you'll see:



    This is a selectable list that you can scroll through.

    Regarding XP

    XP is rewarded directly after the battle. So if your enemy gives you 600 xp and you bonus reward 400, every one gets 1000xp, level up's are also shown.

    Always looking for feed back, ideas, suggestions and so on :)

    Bonus: Whats coming in 3.0? Regions. Whats that mean???
  9. Thank you for listening to my suggestion! That was really fast. :o I was going to ask if it was possible to add a number range for weapons, items, armors, gold and xp but it seems like you beat me to it.  :guffaw:  Good work with this. I'm looking forward to 3.0, regions that change laws would be pretty interesting.

    Also, it's really convenient that it's compatible with Yanfly's Aftermath. Now I don't have to remove that plugin. Thank you so much.
  10. interesting script. remind me of FF tactics law :D .

    btw... instead of range of weapon... can we use array instead.

    "[1,3,7,10]"

    will give either weapon 1, 3, 7, or 10.

    or if it's also possible

    "[1,3,7,10], 9, [2,5,4,3]"

    will give 3 weapon. first one either 1,3,7 or 10.

    second one will get weapon 9.

    third one will get either 2,5,4, or 3.

    if it's possible of course.
  11. Apples said:
    Thank you for listening to my suggestion! That was really fast. :o I was going to ask if it was possible to add a number range for weapons, items, armors, gold and xp but it seems like you beat me to it.  :guffaw:  Good work with this. I'm looking forward to 3.0, regions that change laws would be pretty interesting.

    Also, it's really convenient that it's compatible with Yanfly's Aftermath. Now I don't have to remove that plugin. Thank you so much.
    Why thank you good sir :)

    estriole said:
    interesting script. remind me of FF tactics law :D .

    btw... instead of range of weapon... can we use array instead.

    "[1,3,7,10]"

    will give either weapon 1, 3, 7, or 10.

    or if it's also possible

    "[1,3,7,10], 9, [2,5,4,3]"

    will give 3 weapon. first one either 1,3,7 or 10.

    second one will get weapon 9.

    third one will get either 2,5,4, or 3.

    if it's possible of course.
    What you are suggesting doesn't make sense, the reason I do:

    i: 3

    i: "1,2,3"

    Or

    i: "1 ~ x"

    is because it's more human readable. The goal here is to make entering in rewards or amounts or IDs of something as human readable as possible. The concept of "or" though is an interesting on.

    Can you give me an idea of why you want weapons a, b, c OR d?

    ATTN!!!

    There is a slight bug where maps that don't have laws break the game this is a crashing bug I didn't test for fix coming ASAP.
  12. Some example... If i want the reward to be random... if using range 1~x. It means i have to arrange my database sequentially. If i'm at the start of development of the project. I might design my database from the start. Then it's ok. But if i already in the middle of dev... and the item i want to randomize is not at sequential order... (ex: gain either one of dragonic weapon - sword, spear, bow, etc just example)... then it will become problem. If i rearrange my database. Then

    it might break some chest event that give that item.

    If there's another solution instead of hard to read [1,4,5,7] it's okay too.
  13. estriole said:
    Some example... If i want the reward to be random... if using range 1~x. It means i have to arrange my database sequentially. If i'm at the start of development of the project. I might design my database from the start. Then it's ok. But if i already in the middle of dev... and the item i want to randomize is not at sequential order... (ex: gain either one of dragonic weapon - sword, spear, bow, etc just example)... then it will become problem. If i rearrange my database. Then

    it might break some chest event that give that item.

    If there's another solution instead of hard to read [1,4,5,7] it's okay too.

    you can do, since it sounds like you'd want specific weapons: "x,y,z" this allows you to have your database in any order. "1~x" doesn't require your database to be in sequential order, it can be in any order and it randomizes the reward.
  14. Wait... so... w: "1,2,5" will give one random weapon with id 1, 2 , or 5.

    From your post... i thought it give 3 weapon instead.

    map to give rewards: 

    <lawReward i: 1 a: "1,2,3" w: "5 ~ 23" xp: 89 gold: 879>

    This reads the following:

    Give item id of 1, armor with ids of 1,2 and 3, a random weapon between id 5 and 23. Finally give the WHOLE PARTY 89 xp and 879 gold.
  15. No No.

    i: "1,2,3"Gives you items with id of: 1, 2 AND 3.

    i: 1Gives you item with id of 1

    i: "1 ~ 23"Gives you a chance to gain a random item between the id of 1 and 23, it changes every time.

    Update

    Please grab the latest version. If there is no laws for the map then we will not show "laws" in the menu.
  16. DarknessFalls said:
    No No.

    i: "1,2,3"Gives you items with id of: 1, 2 AND 3.

    i: 1Gives you item with id of 1

    i: "1 ~ 23"Gives you a chance to gain a random item between the id of 1 and 23, it changes every time.
    ah ic...  i got misled by your last phrase...

    so basically currently there's no way if i want only one RANDOM item between id 1, 10, 13, 17 only?

    but i don't want item id 2-9, 11-12, 14-16 to included in the randomize.

    so i cannot use i: "1 ~ 17" since it will also include them. and might give me item id 2.

    and like i said earlier... the situation.. i'm already in middle of dev. and i cannot rearrange my database to make it sequential..

    i might use it to give random 'themed' weapon (sword, bow, axe). which i already created but since i organized them by weapon type it's not sequential...

    actually... that's the purpose of my suggestion earlier i: "[1,10,13,17]".

    will give one random item either item with id 1 or 10 or 13 or 17.

    sorry i'm not clear enough? :D .
  17. estriole said:
    ah ic...  i got misled by your last phrase...

    so basically currently there's no way if i want only one RANDOM item between id 1, 10, 13, 17 only?

    but i don't want item id 2-9, 11-12, 14-16 to included in the randomize.

    so i cannot use i: "1 ~ 17" since it will also include them. and might give me item id 2.

    and like i said earlier... the situation.. i'm already in middle of dev. and i cannot rearrange my database to make it sequential..

    i might use it to give random 'themed' weapon (sword, bow, axe). which i already created but since i organized them by weapon type it's not sequential...

    actually... that's the purpose of my suggestion earlier i: "[1,10,13,17]".

    will give one random item either item with id 1 or 10 or 13 or 17.

    sorry i'm not clear enough? :D .

    This makes sense. I will consider a friendly way to do this. :)
  18. Slight bump.

    Fixed a crashing error.
  19. Fixed: 

    - Battle Tests no longer crash

    - When no reward data is given for a map we no longer crash.
  20. I got error:

    • Invalid token C
    • Typerror: length
    after rewarding not commiting any law