Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Heretic86

1
Just curious where the ON / OFF value for the Conditions are stored...



module RPG
  class Enemy
    class Action
      def initialize
        @kind = 0
        @basic = 0
        @skill_id = 1
        @condition_turn_a = 0
        @condition_turn_b = 1
        @condition_hp = 100
        @condition_level = 1
        @condition_switch_id = 0
        @rating = 5
      end
      attr_accessor :kind
      attr_accessor :basic
      attr_accessor :skill_id
      attr_accessor :condition_turn_a
      attr_accessor :condition_turn_b
      attr_accessor :condition_hp
      attr_accessor :condition_level
      attr_accessor :condition_switch_id
      attr_accessor :rating
    end
  end
end

None of these appear to contain any data about the Editors conditions, so Im wondering where / how these are stored in the Editor in the window above?  I mean for checking and unchecking the condition sets, not the values themselves...

From the documentation:

Quotecondition_turn_a
condition_turn_b
a and b values specified in the [Turn] condition. To be input in the form a + bx.
When the turn is not specified as a condition, a = 0 and b = 1.

Thing is, although invalid, a = 0 and b = 1 can be entered.  So what controls whether or not that check box is checked?

2
Hopefully a quick question...

Using HTML5 Canvas to generate Experience Inflation and Parameter Curves...

What are the formulas for calculating the Exp Inflation and Parameter Curves?

Pretty much BOTH things that happen in THESE windows...




3
I am still around, focusing on something a bit different.

I have been experimenting to see if I can remake the RPG Maker XP Engine in Javascript, driven on the back end by PHP and MySQL.

There is a lot of work to do on this, but the Tile Editor is complete and some of the back end stuff is done, Event Editor is a Work in Progress, the game engine itself has not been started yet so this is not playable or even close to Alpha stage...

I am deviating from the XP Editor in many places to try to put in IMPROVEMENTS to things I felt that the XP Editor is lacking.  One thing you can immediately notice is there are four graphic layers instead of 3, and an "Auto" mode...  Other things like "Zoom" by just rolling your Mouse Wheel or "Pan" (like Photoshop) where you can hold down the Spacebar and click drag your mouse to pan the map.

These screenshots are of a WEB PAGE so this is all DONE in PURE HTML and Javascript!  Not even the JQueries (too much overhead)!  Map is just a simple map I slapped together...



Layers:



Zoom Out:



Zoom In: (is this zoomed in enough?)



Improvement: Error Detection (This Event has an error where the Condition Switch is out of range, so it is HIGHLIGHTED)



Zooming and Panning:



If I am able to finish this and you want to make games using this, your players wont need to download or install ANYTHING, the plan is to simply send a LINK and play away, so no version comparability issues!






If you have ANY interest, please POST!




Not just scripters but anyone with a general interest...
4
In the XP Editor in Change Fog Color Tone, its obvious to me that it uses an RGBA value.

If I wanted to simulate the effect in CSS / Javascript using a filter, what would I need need to do to use to achieve the same effects on regular images or a Canvas image?

*cough cough* Blizz?
5
General Discussion / CSS Question
August 18, 2021, 11:06:02 pm
I need to make a Text Area behave like a DOS prompt

Basically so it wraps and spaces are placed like they are in a DOS / CMD window...

This might display a little better...

6
Hopefully this is an "easy" one.

I have a page that creates an Instance of a Class.  Then the Class Instance is sent to another page using page.postMessage();  When I receive the data on the other page, and I check the received data to see if the object is an Instance of the Class, it always fails, presumably because I am missing a step.

Properties Page:
class MyClass {
  constructor(name, value){
    this.name = name;
    this.value = value;
  }
}
const foo = new MyClass("bob", 123);
window.postMessage( { myMsg : foo });
function messageListener(msg){
  console.log(msg.data.myMsg instanceof MyClass); // Always returns false
}

I left a lot of code out of the examples but basically using Modules so the same class constructor is available on both pages.

I would like to be able to check the data on the receiving page to see if the object is an instance of the class.

What am I doing wrong?  Most importantly, how can I check on the receiving page to see if the received data is an instance of the class?
7
I put together a simple page that can play back an audio file, and changes pitch by adjusting playbackRate.  Then just to get into the deeper parts of Web Audio API, I saw there was a way to create a visual output of tones in a canvas element.

After I put in the graph canvas tho, I am no longer able to adjust the pitch of an audio file by changing the playback rate, and just in Firefox, but oddly it still works in Chrome.

...
        audio.preservesPitch = false;
        audio.mozPreservesPitch = false;
        audio.webkitPreservesPitch = false;
...

    function graphAnimator(){
      requestAnimationFrame(graphAnimator);
      let fbc_array = new Uint8Array(analyzer.frequencyBinCount);
      analyzer.getByteFrequencyData(fbc_array);
      ctx.clearRect(0, 0, graph.width, graph.height);
      ctx.fillStyle = "#00FFAA";
      for (let i = 0; i < 100; i++){
        let x = i * 3;
        let h = -(fbc_array[i * 8] / 12);
        ctx.fillRect(x, 20, 2, h);
      }
    }
   
    function setupGraph(){
      graph.width = 222;
      graph.height = 20;
      ctx = graph.getContext('2d');
      aCtx = new window.AudioContext();
      analyzer = aCtx.createAnalyser();
      audio_source = aCtx.createMediaElementSource(audio);
      audio_source.connect(analyzer);
      analyzer.connect(aCtx.destination);
      graphAnimator();
    }

Is there a better way to change the pitch of audio?  Honestly, one of the things I did like a bit better about old ass RMXP was its use of MIDI files did not change the playback rate and only changed the tones, but so far, I cant find any reliable ways to play MIDI files, which might be a better solution?  Not sure, and only recently noticed too (or maybe forgotten) that changing Pitch on MP3 / Ogg files does adjust playback rate , lol!

What am I doing wrong that the pitch no longer changes in Firefox but does in Chrome?
8
So playing around with some stuff, and I came across this:

module RPG
  class Troop
    def initialize
      @id = 0
      @name = ""
      @members = []
      @pages = [RPG::BattleEventPage.new]
    end
    attr_accessor :id
    attr_accessor :name
    attr_accessor :members
    attr_accessor :pages
  end
end

Trouble is that there is nothing in the documentation for the structure of the RPG::BattleEventPage.new

Whats up with that?
9
General Discussion / Is This Any Good?
March 29, 2021, 09:01:50 pm
(Removed)

It might look a little familiar... it should!  This is a VERY early version, but what do you guys think so far?

I took the advice a couple very generous folks gave me and worked the Autotiles as best as I could, which as far as I can tell, works PERFECT, even with features that XP didnt have, like the ability to disable affecting Neighbor Autotiles.  Even the "B" tiles work!

- Hold Spacebar and Drag Mouse to Pan the Map
- Mousewheel Up and Down to Zoom In and Out
- Mouse Over a Button for additional information on Modifiers and what else you can do.

Mostly going for User Friendly Interface.  I feel like these were features RPG Maker XP SHOULD have had by default, and last time I used other versions, think they still lack...  The buttons are ALL gonna change positions so its more User Friendly.
10
General Discussion / Hack My Webpage!
March 09, 2021, 05:24:07 am
I am experimenting with a bunch of stuff I am brand new to, so I EXPECT there are gonna be issues...

Other sites I posted on, the messages I got back so far are a bunch of preachers "do not allow users to run their own scripts, ever".  Well, I am not gonna listen to them.  Hasnt been many replies tho, so still waiting for better responses.  Really they just sound very lazy.

Please dont do damage to my server, just the webpage...

What I want to do is to allow Users to UPLOAD THEIR OWN SCRIPTS to an IFRAME to allow them FULL CONTROL of a Canvas Object.  But, it needs to be done so SAFELY.  What I think makes this at least somewhat more secure is not just the code you can see, but a combination of headers and some CORS stuff as well, which you can also see, its just under the response headers.  Sandboxed in.

The GOAL here is for you to BREAK OUT OF THE IFRAME in Javascript and access the rest of the Page.  I set this up to be as easy to hack as possible.  I made it a FORM so you can post ANY JAVASCRIPT YOU WANT in the text field and execute it.  Why?  Because that is what I want ALL USERS to be able to do.  However, the scripts they create need to be completely confined within some sort of sandbox environment that does not put anyone who views their content at risk.  So try things like window.location, window.open, parent.caller, let img = new Image; img.src = 'someurl.jpg',

http://www.webucate.me/iframe/

Please let me know if this works or does not work as I hope it will...

If you can get out of the iframe in javascript and somehow access "hack target" then I will have to dig deeper in how to do this, please let me know how you did and what I need to do to fix.  Basically in theory everything is blacklisted, then opened up some stuff that hopefully is fully contained within the web page.  I need to set up quite a few other things to make this work as I hope, and could use some assistance from people I know and trust...  Im having some issues getting Reporting to work, so need to focus on that if anyone gets a spot of time...

Thanks a ton guys!
11
So I have had an idea...

The idea involves allowing logged in users to upload Javascripts that they write.  Their scripts will run on other users browsers.  However, I do not trust the other users to not upload malicious content.  Most probably wont, but some will inevitably try.  Thus, the idea of using a Worker comes into play.  I havent played with Workers but basically a Worker simply contains scripts that are running from the DOM, which is what I am thinking will help protect the other users from scripts with malicious intent.  It seems like it will be fairly secure.  Workers are also restricted on ther XMLHttpRequests which only returns null, so that function is pretty much useless for loading even more scripts.

Basically imagine this.  A canvas running in a webpage.  Canvas does something that is handled by the User Scripts from inside the Worker.  The webpage that also has the Canvas element can also allow a user to Login.  Since the scripts inside the Worker are not allowed access to the DOM, theoretically, the User can login without their keystrokes being recorded by User Scripts.  In theory.  The other side of that is that I want whats inside the Worker to influence what is displayed on the Canvas.  I dont really care if the Canvas has to be in the Worker or main DOM as long as the User Script can generate output on the Canvas to other Users.

Ive been doing some reading on Workers in JS, but dont quite understand it well enough to see how to achieve BOTH access to the DOM element (which may be insecure if the Worker Script is given the Canvas element as calling Parent may allow unintended access to the DOM, where the script can record another users Username and Password.  Scripts can be uploaded by unknown User, and the concept of allowing a User to upload their own scripts and execute them in the browser is the foundation of the idea so I can NOT simply say "dont let users upload scripts".  I would like to have BOTH but in a way that is as secure as I can make it and STILL allow users to create accounts and upload their scripts.  As I understand it, for the DOM to communicate with the Worker, it uses postMessage, and visa versa.  Objects passed to the Worker are COPIES, thus presenting more difficulty.

How do I make an HTML Canvas (maybe from DOM) take data processed in a custom user script in a secure manner where by the rest of the DOM (such as a Login or Session Cookie) is inaccessible to the Worker?

Oh, and to add Insult to Injury, lets throw in some CSP too! CPS is Content Security Policy.
https://content-security-policy.com/

Looks like I am gonna need that, and Im thinking I dont think it will compromise security stuff too much if I load all the JS files from a single page, like js.php?id=1 and set up the CSP to allow my files, and use the js.php for User files?

 Even a VERY basic example would be EXTREMELY helpful.  Does anyone have an idea on how to do this?
12
General Discussion / Autotiles in Canvas
February 16, 2021, 05:36:06 am
I came across this thread:
https://forum.chaos-project.com/index.php/topic,12618.msg172028.html#msg172028

Quote from: Blizzard on December 02, 2012, 11:15:38 amHere's our C++ code for that.

I have defined the ID arrays somewhere on top first.

static int _autotiles[6][8][4] = {
{{27, 28, 33, 34}, { 5, 28, 33, 34}, {27,  6, 33, 34}, { 5,  6, 33, 34},
{27, 28, 33, 12}, { 5, 28, 33, 12}, {27,  6, 33, 12}, { 5,  6, 33, 12}},
{{27, 28, 11, 34}, { 5, 28, 11, 34}, {27,  6, 11, 34}, { 5,  6, 11, 34},
{27, 28, 11, 12}, { 5, 28, 11, 12}, {27,  6, 11, 12}, { 5,  6, 11, 12}},
{{25, 26, 31, 32}, {25,  6, 31, 32}, {25, 26, 31, 12}, {25,  6, 31, 12},
{15, 16, 21, 22}, {15, 16, 21, 12}, {15, 16, 11, 22}, {15, 16, 11, 12}},
{{29, 30, 35, 36}, {29, 30, 11, 36}, { 5, 30, 35, 36}, { 5, 30, 11, 36},
{39, 40, 45, 46}, { 5, 40, 45, 46}, {39,  6, 45, 46}, { 5,  6, 45, 46}},
{{25, 30, 31, 36}, {15, 16, 45, 46}, {13, 14, 19, 20}, {13, 14, 19, 12},
{17, 18, 23, 24}, {17, 18, 11, 24}, {41, 42, 47, 48}, { 5, 42, 47, 48}},
{{37, 38, 43, 44}, {37,  6, 43, 44}, {13, 18, 19, 24}, {13, 14, 43, 44},
{37, 42, 43, 48}, {17, 18, 47, 48}, {13, 18, 43, 48}, { 1,  2,  7,  8}}
};

And this is how they are used:

// y, x and j are simply ints, iterated from 0 to 6, 8 and 4 respectively
int position = _autotiles[y][x][j] - 1;
int tx = x * 32 + j % 2 * 16;
int ty = y * 32 + j / 2 * 16;
int sx = position % 6 * 16;
int sy = position / 6 * 16;
generated->bltOver(tx, ty, autotile, sx, sy, 16, 16);
if (animated)
{
generated->bltOver(tx, ty + 192, autotile, sx + 96, sy, 16, 16);
generated->bltOver(tx, ty + 384, autotile, sx + 192, sy, 16, 16);
generated->bltOver(tx, ty + 576, autotile, sx + 288, sy, 16, 16);
}

Bitmap::bltOver simply overwrites the already existing pixels, nothing special. "autotile" is a the actual bitmap loaded from the file (the one that is 96x128 pixels) and "generated" is the bitmap that is put together for rendering. It looks the same like the generated bitmap that you can view in the RMXP editor when you open an autotile in a tileset setting.

So, I am not sure if this helps me at all.  What I am wondering is what the correlation between the surrounding 8 tiles, and how they are factored in for position determination?  Basically, is there a formulaic way to calculate which autotile should be selected from the generated tilemap?

https://www.webucate.me/canvas/editor.html

Click the "Toggle Tiles" button, then same as RMXP, if you Double Click on the Autotile Row, another window will open showing the generated map.  And yes my code looks absolutely awful right now.  Focused on functionality first...
13
It drives me crazy when I keep having to put things down for months at a time and try to pick it back up again later and forget everything I had in my head while working on it...

Active page that is a Work In Progress where I am having my issue:
http://www.webucate.me/canvas/canvas.html

Now that I have a bit of time to play around with this again.  I am sure if you look you can pretty easily figure out what I am doing here.

Issues are related to the Scale.  When I set the Scale to 2:1 (or 200%) I am ending up with VERTICAL SEAMS between my Tiles.

What do I need to do to get rid of that SEAM when zoomed in?

All Javascript so you can simply Right Click and View Source.  I did split off the Scrollbars class in a separate file, but that seems to work ten shades of great (*proud*).

Im sure the bug is in function drawLayersToCanvas(), just confused because I am not using Floats and my coordinates are whole numbers...

Suggestions?
14
General Discussion / HTML Canvas - Tilemap Creator
November 22, 2020, 05:06:57 am
Color me stumped.

Im playing around with Canvas in HTML.  Basically a knockoff of RMXP Tile Editor.

(Removed)

The trouble I am having is with the BOX Draw Mode.  When I draw the box, I cant quite finger out how to get the drawn map to repeat tiles correctly, although it DOES repeat tiles.

- Click teh "Toggle Tiles" button.  New window should appear.  Once the Tilemap loads, the "Loading" msg should go away.
- Select SEVERAL TILES to map as a Pattern in the "Tile Paints" window
- Click the "BOX" button.
- Click and DRAG the mouse on the map to draw.
- When drawing with either a -X or -Y vale from where you first clicked, the tiles do not repeat like they do in RMXP.

In my source code (just right click and view source) look at line 297 please.

I will only leave this alone for so long so dont be too surprised if this page gets changed soon.

Any help would be appreciated.

Yes, I am still around but only barely...

---

Edit: Nevermind.  I think I got it.

Next question, how to do a Circle / Oval?  Also a bit stumped there...  I had to put this ALL down for a couple years so I am supremely rusty...
15
https://www.bluesnews.com/s/211939/rpg-maker-mz-this-summer

RPG Maker MZ is a new installment in the RPG Maker series to be released on Steam for Windows and macOS this summer. This will allow you to get in touch with your inner Lord British to create an old-school role-playing game. Word is: "Including all new features, and some fan favorite returning features, RPG Maker MZ will make RPG Making faster and easier than ever before. But making it easier wasn't our only aim, this RPG Maker aims to be the most powerful for experienced developers as well." Here's more from the description, including a bit that humorously describes how their collection of premade assets can be used "to create a game that's absolutely full of originality":

A Tool Designed to Make Games

RPG Maker is known in Japan as "RPG Tsukūru." "Tsukūru" is a coined term that, in a literal sense, combines the Japanese words for "make" and "tool." This signifies that RPG Maker is a tool that is designed to make games. Within RPG Maker, we have already programmed the basic operations that support RPGs. You can make games easily by just combining settings for game components that are comprised of the main character's parameters and enemies' movements.

Create an Original Game with Ease!

As samples, we have prepared a wealth of resources comprised of drawings and music that are needed to make games. All you need to focus on is giving shape to your own ideas. On top of that, for anyone looking for something beyond the samples already provided, we have set aside a vast collection of additional downloadable content intended for the RPG Maker series.
By using these assets in combination, you can create a game that's absolutely full of originality.
16
General Discussion / Pixel Game Maker MV
March 12, 2019, 05:39:02 pm
https://store.steampowered.com/app/837510/Pixel_Game_Maker_MV__MV/

The link, at the time of this post, is Early Access, but, the upside it is FREE THIS WEEK!
17
Video Games / Chrono Trigger for the PC Released!
February 27, 2018, 09:04:36 pm
https://www.bluesnews.com/s/188279/pc-chrono-trigger-released

QuoteSteam News announces SQUARE ENIX has decided it was time to pull the trigger on the unexpected release of CHRONO TRIGGER for Windows on Steam. They explain the surprise in this post, which also includes a launch trailer and details on a limited edition:

Here's a quick introduction to the story for you:

A chance encounter amid the festivities of Guardia's Millennial Fair in Leene Square introduces our young hero, Crono, to a girl by the name of Marle. Deciding to explore the fair together, the two soon find themselves at an exhibition of the Telepod, the latest invention by Crono's longtime friend Lucca. Marle, fearless and brimming with curiosity, volunteers to assist in a demonstration. An unanticipated malfunction, however, sends her hurtling through a rift in the dimensions. Taking hold of the girl's pendant, Crono bravely follows in pursuit. But the world into which he emerges is the one of four centuries before. Journey to the forgotten past, the distant future, and even to the very End of Time. The epic quest to save a planet's future makes history once again...

If you've had the pleasure of playing CHRONO TRIGGER before, then you'll be pleased to find out that this version includes animated cutscenes, as well as the Dimensional Vortex and Lost Sanctum dungeons from previous versions of the game. We've also updated the controls, graphics and sound to make this the definitive version of CHRONO TRIGGER!

Finally, there's also a Limited Edition available, you have until the 2nd of April 2018 to pick it up, and it includes the following bonus content:


  • An enchanting and specially edited CHRONO TRIGGER medley consisting of 5 songs: Far Off Promise, Wind Scene, Battle with Magus, Corridors of Time and CHRONO TRIGGER.

  • Composer Yasunori Mitsuda's digital liner notes.

  • A collection of 6 stunning wallpapers for your PC (Sizes: 1024 x 768, 1280 x 1024, 1920 x 1080, 2560 x 1600).



Video Trailer here.

---

For those who dont know, Chrono Trigger is one of the best, if not THE best RPG of ALL TIME.  If you havent played it, and are at least a fan of JRPGs in general, I'd strongly encourage everyone who hasnt played this classic to pick this game up!
18
General Discussion / See With Your Ears - Video
January 20, 2018, 06:01:39 pm

https://www.youtube.com/watch?v=kavxsXhzD48

The video above is aimed mostly at Film Production, but both games and movies rely on audio to really sell the story.

When youre in the audience, you really dont pay that much attention to sounds in movies or games.  When you are making a game, or movie (which Ive done work on several), sound is the first thing that is overlooked.  Its not just about the sound being there or birds making noise, its about where the audience feels like they are at.  You can use sound to completely control the emotion of everything the audience feels.  Take out those frog sounds or water drips and you can create a state of unease where the audience can experience a sense of being disconnected from the character they are intended to project themselves on to.  Just as much as you can use audio to create a sense of unease, you can also use sound to help the audience project on to a character by letting them hear what the main character hears.  You can use Sounds to tell the audience what to focus on.  A door opens or closes, footsteps, a busy town, the ticking of a bomb, roar of a train, everything.

This is one of my frustrations in building anything with RPG Maker.  The sound library is OK at best, it has music and combat effects, but thats really about it.  A lot of other times, other engines dont really come with any audio assets.  However, I think my #1 issue with audio has to be with RPG Makers limitations in the audio department.  A lot of things should have been in the default engine that simply are not there.  Namely having only one BGS channel, no sound emitters, and just a general lack of tools to implement the underlying ambience of any environment.  Way back in the day when Doom 3 first came out over a decade ago, people payed heavy attention to the realtime shadows, and they critiqued the graphics, but sound is nearly always forgotten by those except the pros.  Thats why they are the pros.  The place that Doom 3 really shined was in its Audio department.  Yes, the game play is exceptionally dated by todays standards, its very "monster in a closet" and "it moves, shoot it" isnt fun any more.  What Doom 3 does have is great sound design, using all those ambient sounds and ticks and footsteps and audio effects that can really draw a player in, even today.  If you have a copy, fire it up, turn out the lights, ignore the graphics and turn up the volume.  LISTEN as you start exploring the world.  Pay close attention to the sounds.  That is what is missing in so many games AND movies.

Ryex and ForeverZer0 are really the only two scripters I know of that have done anything to address the limitations of RPG Maker in the audio department.  But it isnt just about RPG Maker, but gaming in general.  What do you think could be done to make the Sound Design of games better from a Developers Perspective?  If you've focused on sounds in your game, more so than just "put it there to make it seem normal", what are your tricks?  How do you implement sound design?  What advice can you offer to everyone else out there?
19
Anyone know the method or even how to control the Cursor object in the Windows Selectable class?  Im just playing around with windows and menus, and there isnt much for a scrolling horizontal menu window...
20
Since Enemies dont really have any place except a Config to add parameters, Im just curious if any scripts you know of rely on checking the Name for special properties?

For example:
Ghost - Ghost\property[val]

Trouble is with this method:

  #--------------------------------------------------------------------------
  # * Get Name
  #--------------------------------------------------------------------------
  def name
    return $data_enemies[@enemy_id].name
  end


I already have a work around, assigning @name during init, but fear it may cause some conflicts with other scripts, so just curious...

(got bored, wanted floating enemies to have a floating animation... :p )
21
Heretic's Unlimited Event Page Conditions
Authors: Heretic
Version: 1.0
Type: Event Add-on
Key Term: Misc Add-on



Introduction

Event Page Conditions in RPG Maker XP are quite limited.  They only allow you to pick from 2 Game Swithces, check if a Variable is equal to or greater than a specified value, or a single Self Switch.  This script throws that ALL out the front door and allows you to create Unlimited Page Conditions by using Scripts to be a Condition!  Thus, literally anything that can be evaluated in a Script can be a Page Condition!

Most things can be achieved by using a Parallel Event, then checking a Conditional Branch -> Script, then enabling a Game Switch or some other way to make an Event Page active.  Thats great and all, but this makes things a lot simpler and does not eat up Game Switches or require additional work to make Pages become Active.



Features


  • Fully unlocks Event Page Conditions, that is a pretty big feature

  • Evaluations can be Skipped if needed




Screenshots

No Screenshots

Demo

No demo, yet.


Script

Place above Main and below Scene_Debug / SDK (if used)
Spoiler: ShowHide

#==============================================================================
#
#           HERETIC'S UNLIMITED EVENT PAGE CONDITIONS [XP]
#           Version - 1.0
#           Monday, August 8th, 2016
#
#==============================================================================
#
#  ---  Overview  ---
#
#  This script will allow you to use Scripts as a Page Condition! 
#
#  This completely unlocks the functionality of Page Conditions, which now have
#  absolutely NO LIMITS!  For example, the Default Page Conditions allow
#  you to check a Game Variable, and the Page is only active if that
#  Game Variable is equal to or greater than what ever number you put there.
#  But, you could not check if the Game Variable was equal to or less than!
#  Now you can easily make Game Variable Less Than a Page Condition!
#
#  ---  Installation  ---
#
#  Place above Main and below Scene Debug.  Place below the SDK if used.
#
#  ---  Instructions  ---
#
#  Add a Comment to an Event says "Condition:" followed by a Script Condition.
#
#  Example 1:
#  @>Comment: Condition: $foo == $bar
#
#  Example 2:
#  @>Comment: Condition: $game_player.direction == 2 and $game_switches[12]
#
#  Example 3:
#  @>Comment: Condition: $game_player.moving? and $game_switches[12] and
#           : (not $game_system.map_interpreter.running? or $foo == $bar)
#
#  Example 4: (Not every line needs to be dedicated to evaluation.)
#  @>Comment: Condition: p = $game_player
#           : p.direction != 2
#
#  Example 5: (Comments within Comments work too, note the # Character)
#  @>Comment: Condition: p = $game_player
#           : # If Player is facing Down
#           : p.direction == 2
#
#  ---  Common Events  ----
#
#  This script does NOT affect Common Events, ONLY Map Events.
#
#  ---  Battle Event Pages  ---
#
#  This script does NOT affect Battle Event Page Conditions.  I wrote another
#  script for Battle Event Pages already. 
#
#  That script is called "Unlimited Battle Page Conditions" and is available
#  as one of my many scripts in Heretic's Collection.
#
#  ---  Multi Line Support  ---
#
#  You can extend your scripts to Multiple Lines of Comment Boxes!  The
#  Comment Box should be plenty big enough to hold your text!  Besides
#  that, you're using Script Calls, so if you can't fit your text into
#  one Box, you can write a Method that returns true or false and plug
#  that into your own script!
#
#  You can have Multiple Conditions also, each in their own Comment Box.
#
#
#  ---  Self Switches  ---
#
#  This script doesn't interfere with the use of Self Switches (ABCD).  Feel
#  free to combine both Self Switches and Script Conditions.
#
#
#  ---  Skipping Evaluation  ---
#
#  There may be certain conditions when you do NOT want a certain Page to
#  evaulate its Script Conditions.  For example, running an Event and you
#  don't want the Page to change until it is done doing its thing.  You
#  can turn Script Evaluation ON or OFF by either a Script Call or with
#  a Comment.  It is intended to use BOTH in conjunction with each other.
#  Basically, it gives you more control over when Scripts are evaluated.
#
#  To temporarily prevent a Page from executing its Script Conditions, simply
#  add a Comment to the Event's Page that reads:
#
#  @>Comment: \skip_eval
#
#  This is intended to be turned OFF with a Script Call or Move Route.
#
#  @>Script: $game_map.events[id].skip_eval = true / false
#  @>Set Move Route: This Event
#                  : $>Script: self.skip_eval = false
#                  : $>Script: skip_eval=(false)
#
#  NOTE: The Page MUST BE ACTIVE to change Skip Eval or else you will set
#        the Skip Eval on the WRONG PAGE.
#
#  NOTE: Once Skip Eval has been changed, it will retain the state you set
#        until the Map has been left entirely and transferred back to.  This
#        includes going into Battle Scenes.  The value of Skip Eval will be
#        remembered even after Battles are exited, but RESET if you leave
#        the Map and come back to this Map.
#
#
#  ---  Performance  ---
#
#  Each Script Condition is evaluated once per frame so don't go crazy using
#  too many Script Conditions, or at least make sure they evaluate quickly.
#  Script Conditions all evaluated on each Map.  Thus, if you have many maps
#  but only a few maps that use Script Conditions, don't worry too much.  You
#  may see performance issues if you use lots and lots of Script Conditions
#  on the same map.  This does end up being tons faster than using multiple
#  Parallel Events for very specific purposes however.
#
#
#  ---  Compatability  ---
#
#  This script may have some compatability issues with other scripts that
#  modify the RPG::Event::Page::Conditions class.  It has been tested with
#  More Self-Switches by Gameus / Game Guy and although only briefly tested
#  appears to work just fine.  This script works by replacing attr_accessor
#  methods with my custom definitions.  Instead of returning a property of
#  an object, it now uses self_switch_valid and self_switch_ch as getter
#  methods which consider if Script Conditions are being used.
#
#  It should also work just fine with Optimization Scripts as evaluation of
#  the Script Conditions is handled outside of Event and Game Map update
#  methods entirely.
#
#
#  ---  Legal  ---
#
#  You may distribute this script on websites in the scripts unaltered form.
#
#  You may use this script in Commercial or Non Commercial projects without
#  compensation as long as you give me credit for the use of my scripts.
#
#
#  ---  Config  ---
#
#  This script has no configurable Options.
#
#
#  ---  Version History  ---
#
#  Version 1.0 - Monday, August 8th, 2016
#  - Initial Release
#
#==============================================================================

#==============================================================================
# ** RPG - Main RPG Module
#==============================================================================
module RPG
  #----------------------------------------------------------------------------
  # ** Event - RPG::Event
  #----------------------------------------------------------------------------
  class Event
    #--------------------------------------------------------------------------
    # ** Page - RPG::Event::Page
    #--------------------------------------------------------------------------
    class Page
      #------------------------------------------------------------------------
      # ** Condition - RPG::Event::Page::Condition
      #------------------------------------------------------------------------
      class Condition
        #----------------------------------------------------------------------
        # * Public Instance Variables - RPG::Event::Page::Condition
        #----------------------------------------------------------------------
        attr_accessor :script_condition
        attr_accessor :map_id
        attr_accessor :event_id
        attr_accessor :skip_eval
        #----------------------------------------------------------------------
        # * Initialize - RPG::Event::Page::Condition
        #  - Adds Default Values for new Properties
        #----------------------------------------------------------------------
        alias script_condition_initialize initialize unless $@
        def initialize
          # Call Original or other Aliases
          script_condition_initialize
          # Container for Script Conditions
          @script_condition = nil
          # New Properties used for generating a Self Switches Hash Key
          @map_id = nil
          @event_id = nil
        end
        #----------------------------------------------------------------------
        # * Self Switch Valid - RPG::Event::Page::Condition
        #  - Replaces attr_reader with reader method
        #----------------------------------------------------------------------
        def self_switch_valid
          # Overrides @self_switch_valid value if a Script Condition exists
          return true if not @script_condition.nil?
          # Return Original Value (Self Switch is Checked in Edit Event)
          @self_switch_valid
        end
        #----------------------------------------------------------------------
        # * Self Switch Ch - RPG::Event::Page::Condition
        #  - Replaces attr_reader with reader method
        #  - Self Switch Channel is usually 'A' unless 'BCD' are specified
        #  - Checks both Self Switch and Script Condition to return Channel
        #----------------------------------------------------------------------
        def self_switch_ch
          # Use Self Switch Ch (ABCD) if Valid and Switch is OFF
          if @self_switch_valid
            # Hash Key for Self Switches
            key = [@map_id, @event_id, @self_switch_ch]
            # Use Self Switch Ch (ABCD) if Valid and Switch is OFF
            return @self_switch_ch if not $game_self_switches[key]
          end
          # If Script Condition Array has any Scripts
          if not @script_condition.nil? and @script_condition.size > 0
            # Iterate each Self Switch Script Condition
            for script in @script_condition
              # Create a Hash Key for Self Switches Hash with Script
              ss_key = [@map_id, @event_id, script]
              # Return the Script if Self Switch Script is OFF
              return script if not $game_self_switches[ss_key]
            end
            # Return Last Script in Array as Self Switch Channel
            return @script_condition.last
          end
          # Default Self Switch Channel (ABCD)
          @self_switch_ch
        end
      end
    end
  end
end

#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
  #----------------------------------------------------------------------------
  # * Initialize - Game_Event
  #  - Checks each Page of Event for Script Conditions in Comments
  #        map_id : Map ID
  #         event : Game_Event stored in $data
  #----------------------------------------------------------------------------
  alias script_condition_initialize initialize unless $@
  def initialize(map_id, event)
    # Default value and Shorthand
    script, sc = nil, $game_map.script_conditions
    # Iterate each of the Event's Pages
    event.pages.each {|page|
      # Store values in Condition Object for Self Switch Keys
      page.condition.map_id, page.condition.event_id = map_id, event.id
      # Iterate Each Command
      page.list.each {|command|
        # If Event Command is the first line of a Comment
        if command.code == 108
          # If Script is not nil (two Script Conditions in sequence)
          if not script.nil?
            # Modify Condition Object and Add to Hash for Evaluation
            add_script_condition(page.condition, script, map_id, event.id, sc)
            # Clear the String since it is now stored in the Condition Object
            script = nil
          end
          # Scan the Comment and look for \skip_eval Comments for this Page
          command.parameters[0].gsub(/^\\skip_eval/i) {
            page.condition.skip_eval = true
          }
          # Use Regular Expression to look for "Condition:" and Capture String
          command.parameters[0].gsub(/^Condition:(.*)/){ script = $1.strip }
        # Else if Script and Event Command is a Comment, but not the first line
        elsif not script.nil? and command.code == 408
          # Append Script String with any text from this line of the Comment
          script += "\n" + command.parameters[0]
        # If Script String has contents
        elsif not script.nil?
          # Modify Condition Object and Add to Hash for Evaluation
          add_script_condition(page.condition, script, map_id, event.id, sc)
          # Clear the String since it is now stored in the Condition Object
          script = nil
          # Next Command (One Condition per Comment Box)
          next
        end
      }
    }
    # Call Original or other Aliases
    script_condition_initialize(map_id, event)
  end
  #----------------------------------------------------------------------------
  # * Add Script Condition - Game_Event
  #  - Modifies the Condition Object with New Parameters for Script Evaluation
  #               c : RPG::Event::Page::Condition
  #          map_id : Map ID of Event
  #        event_id : Event ID
  #              sc : Shorthand for $game_map.script_conditions
  #----------------------------------------------------------------------------
  def add_script_condition(c, script, map_id, event_id, sc)
    # Loop to check for Syntax Errors
    begin
      # Evaluate the Script String and remember result
      result = eval(script)
    # Script Evaluated has a Syntax Error
    rescue
      # Display Warning to User
      script_condition_error(script, event_id, map_id)
      # Prevent Storing of Script Condition
      return
    end
    # Create a Boolean Value based on result for proper storage
    value = (result) ? true : false
    # Remember value of Script Evaluation in the Self Switch Hash
    $game_self_switches[[map_id, event_id, script]] = value   
    # Create Array if Nil
    c.script_condition = [] if c.script_condition.nil?
    # Push Script on to Script Condition Array
    c.script_condition << script
    # Add Script to Script Conditions Hash in Game Map with Event ID as Key
    sc[event_id] ? sc[event_id] << script : sc[event_id] = [script]
  end
  #----------------------------------------------------------------------------
  # * Eval Script Condition - Game_Event
  #  - Evaluates Script Conditions
  #       scripts : Array of Scripts for this Event's Conditions
  #----------------------------------------------------------------------------
  def eval_script_condition(scripts)
    # Default
    refresh_event = false
    # Iterate each Script in the Array
    for script in scripts
      # Run the Script and remember the result (Syntax already checked)
      result = eval(script)
      # Create a Boolean Value based on result for proper storage
      value = (result) ? true : false
      # If Stored Self Switch Value is not the same as the result
      if $game_self_switches[[$game_map.map_id, id, script]] != value
        # Store the Result in the Self Switches Hash
        $game_self_switches[[$game_map.map_id, id, script]] = value
        # Flag to Refresh this Event after running all Scripts if more than 1
        refresh_event = true
      end
    end
    # Refresh this Event if the Refresh Flag is set
    refresh if refresh_event
  end
  #----------------------------------------------------------------------------
  # * Script Condition Error - Game_Event
  #  - Prints a Warning and shows Script with a Syntax Error
  #        script : String of Script with Syntax Error
  #            id : Event ID with the Problem
  #        map_id : ID of Map with Event with Syntax Error in Condition
  #----------------------------------------------------------------------------
  def script_condition_error(script, id, map_id)
    # If running game from Editor
    if $DEBUG
      # Explain the Problem
      print "Warning: A Script Condition has a Syntax Error\n",
            "Event ID: ", id, "\nMap ID: ", map_id, "\n\n",
            "Condition: ", script, "\n\n",
            "Conditions should evaluate to true or false\n",
            "Example 1: Condition: $foo == $bar\n",
            "Example 2: Condition: $foo == $bar or $baz"
    end
  end
  #----------------------------------------------------------------------------
  # * Erased? - Game_Event
  #  - Returns true if Event is Erased
  #----------------------------------------------------------------------------
  def erased?
    return @erased
  end
  #----------------------------------------------------------------------------
  # * Skip Eval? - Game_Event
  #  - Getter method, returns Flag set in RPG::Event::Page::Condition
  #----------------------------------------------------------------------------
  def skip_eval?
    @page.condition.skip_eval if @page
  end
  #----------------------------------------------------------------------------
  # * Skip Eval= - Game_Event
  #  - Setter method, sets Flag set in RPG::Event::Page::Condition
  #----------------------------------------------------------------------------
  def skip_eval=(arg)
    @page.condition.skip_eval = (arg) ? true : false
  end
end

#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
  #----------------------------------------------------------------------------
  # * Public Instance Variables - Game_Map
  #----------------------------------------------------------------------------
  attr_accessor     :script_conditions    # Holds Event Script Page Conditions
  #----------------------------------------------------------------------------
  # * Setup - Game_Event
  #  - Creates a Hash to hold Script Conditions for constant Evaluation
  #      map_id : Map ID from $data
  #----------------------------------------------------------------------------
  alias script_condition_setup setup unless $@
  def setup(map_id)
    # If Map ID is Valid and does not match current Map ID
    if map_id > 0 and map_id != @map_id
      # Create or Clear Hash
      @script_conditions = {}
    end
    # Call Original or other Aliases
    script_condition_setup(map_id)
  end
  #----------------------------------------------------------------------------
  # * Eval Script Conditions - Game_Map
  #  - Evaluates all Script Conditions in Hash and Refreshes Event if needed
  #----------------------------------------------------------------------------
  def eval_script_conditions
    # Check that Script Conditions exists
    return unless @script_conditions
    # Iterate any Script Condition
    @script_conditions.each {|id, scripts|
      # Get the Event
      event = @events[id]
      # If Event does not exist (typically event removed during game editing)
      if not event
        # Remove the Script Conditions from the Hash
        @script_conditions.delete(id)
        # Next Script
        next
      end
      # Skip this Event if Event has a Skip Eval flag
      next if event.skip_eval?
      # Evaluate Script Conditions (Array of Scripts) from within the Event
      event.eval_script_condition(scripts) unless event.erased?
    }
  end
end

#==============================================================================
# ** Game_Screen
#==============================================================================
class Game_Screen
  #----------------------------------------------------------------------------
  # * Update - Game_Screen
  #  - Calls to eval_script_conditions in the Map, so it will still evaluate
  #    even during Battle Scenes
  #  - Game_Screen is updated after important objects are updated for proper
  #    timing of changing Pages.  Thus, the Map, Events, Interpreter, Player
  #    and System are all updated before evaulating Script Conditions.  If
  #    the evaluations were run, for example, prior to updating either the
  #    Player or Map Interpreter, Page Changes would occur at improper times
  #    and most likely cause you a headache trying to figure out why thinggs
  #    did not work as you expect at the times you expect.
  #----------------------------------------------------------------------------
  alias script_condition_update update unless $@
  def update
    # Call Original or other Aliases
    script_condition_update
    # Update any Event Script Conditions
    $game_map.eval_script_conditions
  end
end



Instructions

To add a Page Condition for an Event, simply put in a Comment followed by your Script Condition:

@>Comment: Condition: $game_player.direction == 2

To override Script Evaluation temporarily, add a \skip_eval Comment to that Event Page, which can be turned off later with a Script Call.  This is useful for Events whose Pages you don't want to change until the Event has finished doing what ever its doing.

**See Documentation for full explanation**



Compatibility

Seems to be pretty compatible with most scripts.  I tested it briefly with More Self-Switches and it seems to work just fine.  I did replace two Properties in RPG::Event::Page::Condition Objects with reader methods, which may cause some compatibility issues with other scripts.  Since this script appears to be almost unique, I doubt it will cause too many issues.



Credits and Thanks


  • I'd like to thank my lawn for not being emo and not cutting itself.




Author's Notes

This is more of an Event Add-on, as it enhances the functionality of Events, but might also qualify as an Environment Add-on.

Anything that can be scripted can be evaluated.  That being said, the evaluations may not fit in the Comment Box.  This can be easily resolved with custom Methods.  If you need help with creating a Custom Condition, feel free to ask any Scripter.

NOTE: All Evaluations should evaluate to true / false.  Don't forget to leave off the word "if" in your evaluations.  Use "$foo == $bar" instead of "if $foo == $bar".
22
Heretic's Unlimited Battle Page Conditions
Authors: Heretic
Version: 1.1
Type: Battle Add-on
Key Term: Battle Add-on



Introduction

Normally, Battle Page Conditions are limited to Turn, Enemy HP, Actor HP, and Switch is ON.  This Script will allow you to use Script Conditions to determine if a Battle Event Page should run or not!

Anything that can be Scripted can be a Page Condition!  This means you can check if a specific Party Member has a specific Weapon or Armor equipped, or maybe Gold is at a certain value.  Because this allows Scripts, you can literally write your Conditions to check ANYTHING that can be evaluated with a Script!



Features


  • Fully unlocks Page Conditions in the Database -> Troops Tab




Screenshots

No Screenshots.


Demo

No Demo


Script

Spoiler: ShowHide

#=============================================================================
#
#           Heretic's Unlimited Battle Page Conditions [XP]
#           Authors: Heretic
#           Version 1.1
#           Friday, March 11th, 2016
#
#-----------------------------------------------------------------------------
#
#  ---   UPDATES  ----
#
#  Core functionality is unchanged.  I added two new commands as an easy way
#  to check things during battle.
#
#  * troop_defeated?
#   - Returns TRUE only when everyone has been beaten or has run away
#
#  - level_up?
#   - Returns TRUE if ANY of the current Party is going to level up if
#     this battle is won and they are alive at the end of the battle
#    ** NOTE: Use this as a Secondary Condition
#
#  Examples of New Commands:
#
#  @>Comment: Condition: troop_defeated? and not level_up?
#
#  ---   OVERVIEW   ---
#
#  This script will allow you to add an Unlimited Number of Page Conditions
#  for Battle Events by using Comments as a Condition on each Battle Page
#
#  ---   IMPORTANT!   ---
#  ---   IMPORTANT!   ---
#  ---   IMPORTANT!   ---
#
#  The Conditions that you put in to the Comment MUST be able to evaluate
#  to true / false!
#
#  What this means is that a Condition of var = 1 will run, but not evaluate
#  to true, so it wont ever be recognized as a valid condition.  By placing
#  a Condition of "if var == 1" will return true, which makes it valid when
#  the proper conditions are met.
#
#  ---   USAGE   ---
#
#  Create a Condition by making a Comment ANYWHERE on a Battle Event Page
#  with "condition:" followed by your Scripted Condition in the Comment.
#
#  Example #1: 
#
#  @>Comment:  condition:  $foo == $bar
#
#  NOTE:  Pay attention!  I left off the word "if" from the Condition.  It
#  works exactly the same way as Conditional Branch -> Script
#
#
#  Comment Conditions will run Eval for ALL of the contents for each Comment
#  all at once.  This allows you to have a Multi Line Condition.
#
#  Example #2: 
#
#  @>Comment:  condition:  ($foo == $bar AND
#                           $lorem == $ipsum)
#
#  NOTE:  Parenthesis () are not required!  You could also use && in place of
#  the word AND.  If you Nest Conditions, you may need to use Parenthesis
#  ($foo == $bar AND $lorem == $ipsum) OR $game_party.actors[0].hp == 0
#
#
#  Comments run as Scripts just like a Script Event, so you can put anything
#  into the Script.  Loops, Iterations, Create Variables, Self Switches, etc.
#
#  Example #3   
#
#  @>Comment:  condition:  result = false
#                          for actor in $game_party.actors
#                            result = true if actor.weapon_id == 12
#                          end
#                          result == true
#
#
#  Each Comment Condition you add will add another Condition to check before
#  the Battle Event Page can be run.  This allows you to add as many Conditions
#  as you want.  THERE IS NO LIMIT.  Each Comment Condition is considered as
#  its own Condition.
#
#  Example #4: 
#
#  @>Comment:  condition:  $game_party.actors[0].hp == $game_party.actors[0].maxhp
#  @>Comment:  condition:  $game_party.actors[0].id == 2
#
#  In the above example, BOTH Conditions MUST BE MET for the Battle Event Page
#  to be considered Valid and thus run.
#
#
#  You can use OR Statements inside of a single Comment Condition allowing for
#  greater flexibility of Battle Page Conditions.
#
#  Examle #5:
#
#  @>Comment: condition: $foo == $bar OR $lorem == $ipsum
#
#
#  ANY Sript Logic can be used provided it fits in the comment.  Its all
#  evaluated the same way.
#
#  ---   BATTLE EVENTING   ---
#
#  Battle Eventing has a Menu for a few things already.  Such as checking to
#  make sure a certain Switch is on before running the Battle Event Page.  You
#  can now use a Comment Condition to check if a certain Switch is OFF before
#  running a Battle Event Page.
#
#  Battle Event also uses what is called SPAN.
#
#  SPAN controls when and how many times to run a Battle Event Page.
#
#  Span:   Battle - Page runs ONCE per the entire Battle
#  Turn:   Page runs ONCE per Turn, even if conditions are still met.
#  Moment: Runs when Conditions are met, and continues to run as long as
#          those conditions are met.
#
#  Comment Conditions are EXTREMELY USEFUL for allowing a Span Moment Page
#  to STOP RUNNING.  It allows you to run the Page once.  Like a specific
#  enemy has a State of "Immune to Fire", run some dialogue once, then
#  use some variable to set that the page has run already.  You could use
#  a Switch, or even any other variable like @this_page_ran = true, and set
#  that as a Condition.
#
#  Example #6
#
#  @>Comment:  condition:  if $game_troop.enemies[0].states.include?(12)
#                            @this_new_var_for_page_ran = true
#                          else
#                            unless @this_new_var_for_page_ran
#                              @this_new_var_for_page_ran = false
#                            end
#                          end
#  @>Comment:  condition:  if @this_new_var_for_page_ran != true
#  @>Text:  "Don't cast Fire on him!  He is now Immune to Fire!"
#
#  ---   COMMAND LIST   ---
#
#  I'd like to make this as easy as possible for people to use.  So to do that
#  these list of Commands should make adding Comment Conditions easier.
#
#  Example of Command:
#
#  - item_in_inventory?(item_id)

#  @>Comment  condition: # If Party has a Potion in their Inventory
#                        if item_in_inventory(1)
#
#
#  Command List
#  - item_in_inventory?(item_id)
#
#
#  ---   CHANGE LOG   ---
#
#  Version 1.0: Monday, January 20th, 2014
#  - Initial Release
#
#  Version 1.1: Wednesday, Jauary 22nd, 2014
#  - Altered Logic: Evaulations MUST return TRUE to be considered valid
#    * Necessary because For Loops returned Arrays which caused incorrect Evals
#      If TRUE is not returned now, then it will be considered Invalid
#
#-----------------------------------------------------------------------------



class Scene_Battle
  #--------------------------------------------------------------------------
  # * Battle Event Setup
  #
  #   - Replacement for default XP Battle System setup_battle_event
  #   - Any Script Conflicts would most likely come from this method
  #--------------------------------------------------------------------------
  def setup_battle_event
    # If battle event is running
    if $game_system.battle_interpreter.running?
      return
    end
    # Search for all battle event pages
    for index in 0...$data_troops[@troop_id].pages.size
      # Get event pages
      page = $data_troops[@troop_id].pages[index]
      # Make event conditions possible for reference with c
      c = page.condition
     
      # New Code for checking extra Conditions in Comments of Battle Page
      page_condition_valid = has_battle_page_condition?(page)
     
      # This code is mostly default with the addition of "page_condition_valid"
     
      # Go to next page if no conditions are appointed
      unless c.turn_valid or c.enemy_valid or
             c.actor_valid or c.switch_valid or
             page_condition_valid
        next
      end
     
      # Default code
     
      # Go to next page if action has been completed
      if $game_temp.battle_event_flags[index]
        next
      end
      # Confirm turn conditions
      if c.turn_valid
        n = $game_temp.battle_turn
        a = c.turn_a
        b = c.turn_b
        if (b == 0 and n != a) or
           (b > 0 and (n < 1 or n < a or n % b != a % b))
          next
        end
      end
      # Confirm enemy conditions
      if c.enemy_valid
        enemy = $game_troop.enemies[c.enemy_index]
        if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
          next
        end
      end
      # Confirm actor conditions
      if c.actor_valid
        actor = $game_actors[c.actor_id]
        if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp
          next
        end
      end
      # Confirm switch conditions
      if c.switch_valid
        if $game_switches[c.switch_id] == false
          next
        end
      end
     
      # This small block is also all that was added to the Default code
     
      # Confirm Page Condition (if Additional Page Condition exists)
      if page_condition_valid
        # If running the extra Page Condition returns false (which is default)
        if eval_page_conditions(page) == false
          # Go to next Battle Event Page if one exists and skip processing this
          next
        end
      end
     
      # The rest of the code in this method is Default
     
      # Set up event
      $game_system.battle_interpreter.setup(page.list, 0)
      # If this page span is [battle] or [turn]
      if page.span <= 1
        # Set action completed flag
        $game_temp.battle_event_flags[index] = true
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Has Page Condition (Comment Conditions  I.E. "condition: (var1 == var2)
  #   page : Battle Event Page
  #
  #   This checks for the existence of any Page Conditions.  It returns
  #   true if it finds at least one condition, then stops.  If any conditions
  #   are in Comments, then it uses another method to check for ALL of the
  #   conditions on the page passed in via the argument.
  #
  #   This is NEW CODE and should not cause any Script Conflicts.
  #
  #   Version 1.1 - Changed name for higher degree of compatability.
  #--------------------------------------------------------------------------
  def has_battle_page_condition?(page)
    # For each Battle Event Command on this Battle Page
    for command in page.list
      # If Command is First Line of a Comment
      if command.code == 108
        # Check each Commment if it has "condition:" as String
        command.parameters[0].gsub(/^condition:(.*)/i){$1}
        # found a Battle Condition in a Comment
        return true if $1 != nil
      end
    end
    # Default - No Valid Battle Page Conditions in Comment Commands found
    return false
  end
  #--------------------------------------------------------------------------
  # * Eval Page Conditions
  #   - Finds ALL Page Conditions in Comments, then Evaluates them
  #
  #   NOTE: Conditions MUST be able to return a Value
  #         $foo = "Bar" will not return anything, thus evals to nil (false)
  #         $foo == "Bar" will return either True or False
  #
  #   This code will check to enusre ALL of the Comment Conditions on a
  #   Battle Event Page are met.  If you have Two Conditions, both must
  #   eval to True for an Event Page to be considered "valid".  Each Comment
  #   Condition is considered as a Separate Condition.  Everything in the
  #   Comment Box is evaluated all at once, so you can create temporary
  #   variables, Loops, OR statements, etc as long as it is all contained
  #   in ONE Comment.  IE "if $foo == $bar OR actor_id == 2".  Complex
  #   scripts may adversely affect performance.
  #
  #   This is NEW CODE and should not cause any Script Conflicts.
  #
  #--------------------------------------------------------------------------
  def eval_page_conditions(page)
    # For each Battle Event Command on this Battle Page
    for i in 0...page.list.size
      # Get Command
      command = page.list[i]
      # If Command is First Line of a Comment
      if command.code == 108
        # Check each Commment if it has "condition:" as String
        command.parameters[0].gsub(/^condition:(.*)/i){$1}
        # If Battle Condition in a Comment
        if $1 != nil
          # Remember the Condition
          condition = $1
          # Check for more lines in the Comment to Eval all at once
          while (page.list[i + 1] and page.list[i + 1].code == 408)
            # Advance Counter
            i += 1
            # Add Next Line of Comment (code 408) to Condition to eval
            condition += "\n" + page.list[i].parameters[0]
          end
          # Run the Script (Improper Script Calls may Crash here)
          result = eval(condition)
          # Evaluate Page Conditions for EACH Comment
          if result == true
            # Remains True as long as ALL Comment Conditions are met
            passed = true
          else
            # If Any Conditions in Comments Eval to False then Page is False
            return false
          end
        end
      end
    end
    # If All Comment Conditions on this Page are met, this variable will exist
    return true if passed
    # Default
    return false
  end

 
  #--------------------------------------------------------------------------#
  # **  Custom Commands for Easy Checks for Conditional Switches             #
  #                                                                          #
  #             ALL METHODS MUST RETURN TRUE OR FALSE                        #
  #--------------------------------------------------------------------------#

  #--------------------------------------------------------------------------
  # * Item In Inventory
  #     item_id : Item Id from Database
  #
  #   Example: 1 is a Potion
  #            # If Party has a Potion in the Inventory
  #            item_in_inventory?(1)
  #
  #            2 is a High Potion
  #            # If Party has a High Potion in the Inventory
  #            item_in_inventory?(2)
  #
  #  This is an Example Script.  It could be accomplished by copying and
  #  pasting the one "return true if ..." line of code.  I provided this
  #  because it makes it easy for us to script easier condition checks
  #  for others that may use this script.
  #--------------------------------------------------------------------------
  def item_in_inventory?(item_id)
    # If Item is in Inventry, return True
    return true if $game_party.item_number(item_id) > 0
    # Default
    return false
  end
  #--------------------------------------------------------------------------
  # * Troop Defeated?
  #  - Returns TRUE if the Troops have all been defeated or run away
  #  - Returns FALSE if any of the Troops are still alive
  #--------------------------------------------------------------------------
  def troop_defeated?
    # Return false if even 1 enemy exists
    for enemy in $game_troop.enemies
      # If this Enemy hasn't run away
      if enemy.exist?
        # They are still being battled in the battle scene so not defeated yet
        return false
      end
    end
    # Default Some of the Troops are still alive
    return true
  end
  #--------------------------------------------------------------------------
  # * Level Up? - Scene_Battle
  #  - Returns TRUE if anyone in the Party will Level Up
  #   NOTE: This will evaluate to TRUE during the entire battle so be sure
  #         to use this as a SECOND CONDITION
  #--------------------------------------------------------------------------
  def level_up?
    # Placeholder for Total Exp to be won in this battle
    battle_exp = 0
    # Check each Enemy in the current Troop that is fought
    for enemy in $game_troop.enemies
      # If enemy is not hidden and didnt run away / escape
      unless enemy.hidden
        # Add the Enemy's experience to the Total Experience to be gained
        battle_exp += enemy.exp
      end
    end
    # If using Heretic's Window Level Up and Bonus Exp
    if @bonus_exp.is_a?(Integer)
      # Add the Bonus Experience to Total Exp each Actor will receive on a Win
      battle_exp += @bonus_exp
    end
    # Check each of the Party Members
    for actor in $game_party.actors
      # If Actor isnt Dead or other Conditions that prevent getting Exp
      if actor.cant_get_exp? == false
        # If this Actor will Level Up
        if battle_exp >= actor.next_rest_exp_s.to_i
          # Return an Evaluator for Comparison
          return true
        end
      end
    end
    # No Actors will Level Up this Battle
    return false
  end
end



Instructions

To create a Custom Battle Page Condition, simply add a Comment to the Battle Page followed by your Script.

@>Comment: Condition: $game_party.actors[0].weapon_id == 12



Compatibility

This should work with any Battle System that uses Event Pages.



Credits and Thanks


  • I'd like to thank Captain Jack Sparrow for coining the phrase "utterly deceptive twaddlespeak" because its funny!

  • I'd also like to thank Blizzard for hosting my Collection and other Demos




Author's Notes

I made this script a while ago, and it was included in my "Collection" but I apparently forgot to post it.

This script is NOT intended for use with Map Event Conditions.  There is another script that will work for Map Events.
23
Anyone care to take a look?  Im testing right now, see if there are any real nasty bugs or compatability stuff that needs to get fixed.

Basically, instead of having to change Switches around to make certain Event Pages active, this allows you to do the same thing by using a Script as a Page Condition.  I found it is actually a hell of a lot easier than creating a Parallel Event, then using Conditional Branches, changing a Switch, Variable or Self Switch.

Example:
@>Comment: Condition: $game_player.direction != 2

Example 2:
@>Comment: Condition: i = $game_system.map_interpreter
                      i.running?

I know it isnt exactly "efficient", but it will make things easier, especially during script development processes.  I just want to test this before releasing and get some feedback on it.

Suggestions?  Compatibility issues?  Better-er code?



Edit: Okay, I changed a few things...
24
Under the Tools -> Options Menu, there is an option for Transparent Color.  I need to be able to read the Custom Data from inside a script.  How and Where is that information located?

Also, under Materialbase -> Graphics/Characters -> Import, you are given two for "Transparent Color (L-Click)" and "Semi-Transparent Color (R-Click)".  How and where do I get that information?
25
Since I'm currently stuck on my Light Script, I thought I would expand my skillset and do it in a way that helps everyone interested.  Im going with C++ for this.  Getting a compiler was a pain, but I finally got one.  Visual C++ 2015.

So what Ive done so far is this.  New Win32 project, dll, and empty project.

Header.h
#define DLLEXPORT __declspec(dllexport)

extern "C" DLLEXPORT int hello(int);


Source.cpp
#include "header.h"

int hello(int arg)
{
arg++;
return arg;
}


RPG Maker Script (Ruby):
class Game_Character
  Hello =  Win32API.new("rotate.dll", "hello", "I", "I")
 
  def hello(arg)
    print Hello.call(arg)
  end
end


Event Move Route -> Script:
$>script: hello(5)

---

This is as basic as it gets.

Im completely unfamiliar with C++ headers.  So if my next step is to interact with a Bitmap, where do I go from there?  Also assuming that since Im working with Transparency that is had from .png files, the term "Bitmap" is a bit misleading.

I tried looking at a few examples online, but it doesnt make sense yet.  Im stuck at exporting the function in DLLEXPORT, but basically I'll make a function that does image rotation using some of the prebuilt methods, (GDI?) and return the Image.  Or, do I need to use pointers and make changes to the memory addresses on the fly?  Wouldnt that affect the bitmap stored in RPG::Cache?

extern "C" DLLEXPORT HBITMAP rotateBitmap(HBITMAP, float)

I know I need another header in there so I can declare what a HBITMAP is...

What is my next step?

*feels very stupid*
26
So I was digging thru Pandora's Box and found this cool little thing!  The games are totally incomplete but I thought they were quite interesting.  Im sure there are a number of people that would be interested in this...

http://downloads.chaos-project.com/heretic86/3DEngineV5.rar
27




New script for XP that Im working on now...

All the Light Sources are FULLY DYNAMIC!

I've played with a couple of Dynamic Light Scripts, and they all seemed to have either a lot of trouble or serious shortcomings.  The one I am working on now, so far, is running at a very high framerate as opposed to a couple that I have played with, and should be very easy to use!  There is still quite a bit to do with it before I reach a Release Candidate status tho.

- I dont have any intent of building in a feature like "Fog of War" however, just so you know.

- I dont have any intent of putting in "Dynamic Shadows" where the corners of buildings cast shadows.  Not doing anything that fancy...

- I do have the intent of putting in some different graphics so the Player can have a "Flashlight" if you will

Are there any "features" that anyone would like to have built in to the script as I continue working on this?

-----

Edit - Full Version Released for download and Demo here:
http://forum.chaos-project.com/index.php/topic,13682.0.html

I should have edited this post a while ago for anyone who is interested in the full functionality of this script.  Sorry for the delay...
28
Heretic's Moving Platforms XP
Authors: Heretic
Version: 1.0
Type: Movement Add-on
Key Term: Movement Add-on



Introduction
This script allows you to easily create Platforms that your Player and even other NPCs can hop on and be transported around with!


Features


  • Allow the Player to get on a Platform and ride it across impassable areas**

  • Allow NPC Characters to ride on Platforms**

  • Intended for large Multi Event Platforms

  • Platform Master allows one Event to control many

  • Platforms should "feel" just like walking around on normal Map Tiles

  • My fingers hurt from all this typing so I am not sure if that is a feature, does show commitment...



** Additional Scripts required for use of these features


Screenshots

Spoiler: ShowHide

(Animated Gif, give it a moment to load...)



Demo

Download Version 1.0 Here


Script

Spoiler: ShowHide

Script is in the Demo



Instructions

REQUIRES:
Heretic's Modular Passable
Heretic's Collision Optimizer
Heretic's Restrict Tile Passages (to move on Impassable Tiles)

Platforms are easy!
To create a Platform, just put in a Comment in the first 10 lines or so that says "\platform[n]" where "n" is a Number!

Next, give it a Comment of "\tile_allow_move[n, n]" where "n" is a Simple Tile ID!  (See Restrict Tile Passages for more info)

Next, give it a Comment of "\allow_npc" if you want NPC Events to move on your Platform.  (Feature requires NPCs on Event Tiles)

Next, give your Platform a Map Tile as a Graphic, set the Move Frequency to Highest, then give it a Move Route that has a WAIT command at locations you expect characters to get on and off.

Thats it!

If you wish to control a bunch of Platforms, use a Platform Master!  Just change one Event from "\platform[n]" to "\platform_master[n]" and that Platform Master will control ALL other Platforms where "n" is the same Number!  You don't even have to give the other Platforms Move Routes, Speed, Move Frequency, just set the Graphics!  This is a Platform Group!

NOTE:  You can only use one Platform Master per Platform Group

You can sync two or more Platform Groups by giving your Platforms or Platform Masters a "\platform_sync[n, n]" Comment where "n" is the Platform Group ID of the other Platform Groups you wish to sync with!  This means when a Platform waits for characters to get on and off, other Sync Groups will also wait for characters.  This is better displayed in the Demo.


Compatibility
Fully compatible with all other scripts that require Modular Passable, including Looping Maps.

This DOES work with Jumping and 8D Movement Systems.

This DOES work with Heretic's Caterpillar 2.0+

This most likely will not work with Pixel Movement scripts.

This does work with both ForeverZer0's and Blizzards Pathfinder scripts, however, you will not be able to pathfind on a Platform.

Not compatible with thin crust pizza when toppings include baloney and peanut butter.  What a disgusting combination.  Squid and Kiwi Fruit Pizzas are untested.


Credits and Thanks


  • Thanks to everyone that Beta Tested this script for me

  • Thanks to Blizzard for hosting the files I uploaded for the Demo

  • Thank you to Enterbrain for not putting this feature into RPG Maker XP and thereby giving me something to do.




Author's Notes

LEGAL

Pre release versions of this script included very strong legal restrictions preventing distribution of games with those versions due to known game crashing bugs.  Those bugs have since been corrected and the Legal has been altered to allow distribution of games, both free and commercial.  Trust me, if you are using an older version, your players will find those game crashing bugs and you'll only end up making yourself look bad.  I worked very hard to make sure this version does not have any game crashing bugs, but you may still experience some while building your game.

WAITING

If your Platform is not given a Wait command, then characters will not be able to get on or off of Platforms or Platform Groups by stepping or jumping on or off.  Platforms must have a Wait command for boarding and unboarding to commence.

DEBUG:

Additional stuff was written into the code to allow you to hold down the CTRL Key and get on or off of ANY valid Platforms.  This was done because once you are on a Platform, youre pretty well stuck there until the Platform uses a Wait command as part of its Move Route.  While in DEBUG mode, creators need to be able to hop on and off Platforms at any time.
29
My current name no longer suits the functions of this script.

HERETIC'S LOCK SCREEN SCROLLING

It started off just locking the screen.  Quick, dirty, and easy.  But Captain Overkill here decided to go overboard as usual.  Basically, you can now Lock Screen Scrolling, let the Player wander around without having the screen always centered on them (very useful for cutscenes), but you can run Scroll Commands from the List of Event Commands and it will ignore Player movement.  I also thought a way would be needed to check if the Player went off the screeen, so I did that, then I put in more stuff so you can only move characters (Player and Events) while on the screen!  Think Side Scroller Shooter!  Sort of like that.  Also, imagine a Chase Scene, where if you go off the screen, you Fail!  The advanced collision stuff needed Modular Passable, so this is a bit of an oddity for me.  The script works without Modular Passable, but the more advanced features, like collisions wont work without it.  It does work PERFECTLY with Looping Maps!  I have to finish the documentation on it, which shouldnt take too long.  It will be up in a day or so.

Due to all the new features, I think it needs a new name.  What should I name this script?
30
NOTE: This is NOT a script release because of its very buggy quality.  This post is intended for discussion of effective ways to achieve this goal.

I thought this was worth while to share.

MOVING PLATFORMS



Its VERY buggy since I've only spent about 2 days working on it so far.  None the less, functional concept!  Im sure there are people interested in seeing what is happening, so here is my Prototype!

DOWNLOAD: Prototype Demo (Obsoleted)

NOTE: This version is now OUT OF DATE.  Full version has been released here.  The download version on this page is a prototype and lacks the functionality and stability of the release version.

This is eventually planned as another add-on for Modular Passable.  I just wanted some feedback from other Scripters what you guys would do in order to resolve the numerous bugs that currently exist.  Yeah, mirrored post in my "Collection" thread. 

But just curious what you guys all think?

Edit:  I'll probably put up new versions as they become available...  I already put up one new version.  Stoopid tyops!