Author Topic: [XP] Exclusion Elements (Excludes Special Elements from Damage Calculations)  (Read 3344 times)

Offline Heretic86

  • Astral Trancist
  • *****
  • Posts: 776
  • LV: 34
    • View Profile
Exclusion Elements
Authors: Heretic
Version: 1.0
Type: Scripting Tool
Key Term: Scripting Tool

Introduction

Scripters Tool

This script will allow Multiple Scripts to have Special Elements that are Excluded from Damage Calculations.

Features

For Scripters, just add your Special Elements to the Exclusion Elements list for Damage Calculations to not be affected by your Special Element.

  • Promotes Script Compatability
  • Error Messages for people using your scripts
  • Start a New Game after Installation

Screenshots

No Screenshots

Demo

No Demo

Script

Place this script ABOVE all depenant scripts.

(click to show/hide)

Instructions

Just install this script above all dependant scripts.

Compatibility

  • Start a New Game after Installation or Game will Crash

Any Scripts that redefine Game_Battler def elements_correct wont be compatible without alterations to code.  It can be made to work however.

KK20 wrote a Script for Target Anyone that does redefine elements_correct.  I made a few changes to it for his script to work either as a Standalone Script and to work with this script when this script is installed above his script.

KK20's Target Anyone
(click to show/hide)

Credits and Thanks

  • KK20

Author's Notes

When you install this script and go to test it, be sure to START A NEW GAME.  If you don't, the data created on a New Game wont be available and will cause a Crash.  So be sure to start a New Game after installation and any other configurations.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Offline LiTTleDRAgo

  • Astral Trancist
  • *****
  • Posts: 851
  • LV: 517
  • Gender: Male
    • View Profile
    • ~
if you do it like this, the game won't crash even if you didn't start up from new game

(click to show/hide)

Offline Heretic86

  • Astral Trancist
  • *****
  • Posts: 776
  • LV: 34
    • View Profile
Riddle me this:

That script doesnt do anything if there are no other scripts that are dependant on it.  How would you suggest the other scripters handle it when their script needs an exclusion element?  Check it every time the array is checked?  Or insert the element id on init?  On init would require starting a new game for that to be called correctly.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Offline LiTTleDRAgo

  • Astral Trancist
  • *****
  • Posts: 851
  • LV: 517
  • Gender: Male
    • View Profile
    • ~
I believe the instruction hasn't changed at all

(click to show/hide)

that code above only create @exclusion_elements to [] if equal nil or false, else will return @exclusion_elements itself

in other words, you don't have to add @exclusion_elements = [] into Game_System#initialize, and when the script is called from old save game, @exclusion_elements will not return nil and the game won't crash

PS : sorry if my engrish is horrible, it's not my primary language



edit : forgot to notice it, of course if some dependant script is inserted in old save game, it needs to restarted from new game to take effect,
to fix that, just alias def exclusion_elements at that dependant script, like this :

(click to show/hide)

with that, script will work even though script is inserted in midway games
« Last Edit: September 09, 2013, 05:45:19 AM by LiTTleDRAgo »

Offline Heretic86

  • Astral Trancist
  • *****
  • Posts: 776
  • LV: 34
    • View Profile
...

edit : forgot to notice it, of course if some dependant script is inserted in old save game, it needs to restarted from new game to take effect,

...

Exactly.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Offline orochii

  • Transcended Spirit
  • ***
  • Posts: 148
  • LV: 15
  • Rhapsody of the Warrior of Ice
    • View Profile
Ummm, forgive me if I'm doing some sacrileges, but is this bad?
Code: [Select]
$exclusion_elements = []

class Game_Battler
  alias asdf_elements_correct elements_correct unless $@ #Edit: Forgot this, to fix the F12 issue.
  def elements_correct(element_set)
    #Forget about all exception elements! Moddaduke.
    element_set = element_set.clone
    for i in $exclusion_elements
      element_set.delete(i)
    end
    asdf_elements_correct(element_set)
  end
end

I'm learnin' so please don't castrate me,
Orochii Zouveleki
« Last Edit: September 09, 2013, 02:29:45 PM by orochii »

Offline Heretic86

  • Astral Trancist
  • *****
  • Posts: 776
  • LV: 34
    • View Profile
Youre learnin so its fine.  I still am too.

I put the variable inside $game_system because declaring it as a Global wont work with Save Games.  Globals all disappear once a game has been closed.  Globals like $game_system are saved when you save a game, but others like $foo wont be saved once the Game exits out, but will survive normal F12 resets.  Aliasing looks just fine by the way.  The original definition I had was modified in such a way that a redefinition was required, but your version on aliasing should work just fine as well, excluding the global.

If you have a script for an exclusion element, use $game_system.add_exclusion_element(element_id) as an Init somewhere for this particular script.  It does the same thing as Push cuz its just an array, but that definition adds some error checking in so that people who use our scripts together can have an easier time of things when there are elements they need to put into their database.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)