RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[GW] Magical Weapons

0 Members and 2 Guests are viewing this topic.

**
Rep: +0/-0Level 71
RMRK Junior
GW Magical Weapons
Version: 1.2
Author: Mr G W
Date: (DD/MM/YYYY) - 30/8/2011

Version History


  • <Version 1.2> 2011.8.30 - Tag can now be used to give enemies magical attacks.
  • <Version 1.1> 2011.8.18 - Fixed a crash when a enemy used a normal attack.
  • <Version 1.0> 2011.8.12 - Original Release

Planned Future Versions
  • Nothing. Suggest something...

Description

Allows weapons to deal magical damage on normal attack, so it uses SPI instead of ATK and DEF. Works with YEM RES stat.
This is similar to Magic Weapons in Fire Emblem, such as Runesword or Fire Lance.

Features

  • Allows creation of magical weapons.
  • If using Dual Weapons and one weapon is magical and the other isn't, it will do "hybrid" damage, offensively uses both ATK and SPI and defensively uses DEF and SPI (or RES).

Screenshots

None.

Instructions
Place where it says Materials.
Use the <magical> tag to make a weapon magical.

Script


Code: [Select]
=begin
==================================================================================================
==================================================================================================
Magical Weapons
Version 1.2
By Mr G W - Rmrk.net
Date (DD/MM/YYYY) - 30/8/2011
<Version 1.2> 2011.8.30 - Tag can now be used to give enemies magical attacks.
<Version 1.1> 2011.8.18 - Fixed a crash when a enemy used a normal attack.
<Version 1.0> 2011.8.12 - Original Release

Allows creation of magic weapons, weapons that use your spirit (and resistance
stat, if using YEM stats) instead of attack and defense.

Use the <magical> tag to make a weapon magical.

If using Dual Weapons and one weapon is magical and the other isn't,
it will do "hybrid" damage, offensively uses both ATK and SPI and defensively
uses DEF and SPI (or RES).

The <magical> tag can also be used to give an enemy a magical attack.
Since enemies do not have weapons, the <hybrid> tag can be used to give the
enemy a mixed attack, which is equivalent to the use of two weapons,
1 magical and the other not.

Place below those scripts.
==================================================================================================
==================================================================================================
Compatibility:
This script overrides make_attack_damage_value.
This script will not work if another script is placed below this one that also
overrides the same method. If this script is placed below instead, the other
script will not work. If another script aliases this method, place it below
this script.


Any script that overrides make_attack_damage_value may not work with this or vice versa.

=end

$imported = {} if $imported == nil
$imported["GWMagicWeapons"] = true

class Game_Battler

  def make_attack_damage_value(attacker)
    damage = damage_calc(attacker)
    damage = 0 if damage < 0                        # if negative, make 0
    damage *= elements_max_rate(attacker.element_set)   # elemental adjustment
    damage /= 100
    if damage == 0                                  # if damage is 0,
      damage = rand(2)                              # half of the time, 1 dmg
    elsif damage > 0                                # a positive number?
      @critical = (rand(100) < attacker.cri)        # critical hit?
      @critical = false if prevent_critical         # criticals prevented?
      damage *= 3 if @critical                      # critical adjustment
    end
    damage = apply_variance(damage, 20)             # variance
    damage = apply_guard(damage)                    # guard adjustment
    @hp_damage = damage                             # damage HP
  end
 
  def damage_calc(attacker)
   damage = attacker.atk * 4 - self.def * 2        # base calculation
   if attacker.actor? == false #Enemies
   damage = attacker.spi * 2 - self.spi * 1 if attacker.enemy.magical == true and $imported["RES Stat"] == false
   damage = attacker.spi * 2 - self.res * 1 if attacker.enemy.magical == true and $imported["RES Stat"] == true
   damage = ((attacker.atk * 4 - self.def * 2) + (attacker.spi * 2 - self.spi * 1))/2 if attacker.enemy.hybrid == true and $imported["RES Stat"] == false
   damage = ((attacker.atk * 4 - self.def * 2) + (attacker.spi * 2 - self.res * 1))/2 if attacker.enemy.hybrid == true and $imported["RES Stat"] == true
   end
   return damage unless attacker.actor?
   if attacker.weapons[0] != nil and attacker.weapons[1] == nil #Using only weapon 0
    return damage unless attacker.weapons[0].magical == true
    damage = attacker.spi * 2 - self.spi * 1 if $imported["RES Stat"] == false
    damage = attacker.spi * 2 - self.res * 1 if $imported["RES Stat"] == true   
   elsif attacker.weapons[0] == nil and attacker.weapons[1] != nil #Using only weapon 1
    return damage unless attacker.weapons[1].magical == true
    damage = attacker.spi * 2 - self.spi * 1 if $imported["RES Stat"] == false
    damage = attacker.spi * 2 - self.res * 1 if $imported["RES Stat"] == true
   elsif attacker.weapons[0] != nil and attacker.weapons[1] != nil #Using both weapons
    return damage unless attacker.weapons[0].magical == true or attacker.weapons[1].magical == true
     if attacker.weapons[0].magical == attacker.weapons[1].magical #Both weapons are magical: Deal magic damage only
     damage = attacker.spi * 2 - self.spi * 1 if $imported["RES Stat"] == false
     damage = attacker.spi * 2 - self.res * 1 if $imported["RES Stat"] == true
     elsif attacker.weapons[0].magical != attacker.weapons[1].magical #One weapon is magical, the other isnt. Deals damage based on both stats.
     damage = ((attacker.atk * 4 - self.def * 2) + (attacker.spi * 2 - self.spi * 1))/2 if $imported["RES Stat"] == false
     damage = ((attacker.atk * 4 - self.def * 2) + (attacker.spi * 2 - self.res * 1))/2 if $imported["RES Stat"] == true
     end #If
   end #If
  return damage
  end #Def
 
end #Class

class RPG::BaseItem
 
  def magical
    self.note.scan(/<magical>/i){
    return true}
    return false
  end
end

class RPG::Enemy
 
  def magical
    self.note.scan(/<magical>/i){
    return true}
    return false
  end
 
  def hybrid
    self.note.scan(/<hybrid>/i){
    return true}
    return false
  end
 
end

You can also get it from the attachment.

Credit


  • Mr G W
  • Yanfly - For the YEM Battle Stats

Thanks

  • Yanfly - For the YEM Battle Stats
  • Others who made scripts - I've been learning on my own, so other scripts help me understand how RGSS works.

Support

Just post here. If i don't answer, it's because I can't be on.
Any errors or glitches, feel free to post.

Known Compatibility Issues

This script overrides make_attack_damage_value.
This script will not work if another script is placed below this one that also
overrides the same method. If this script is placed below instead, the other
script will not work. If another script aliases this method, place it below
this script.

Any script that overrides make_attack_damage_value may not work with this or vice versa.

Demo


None.

Author's Notes


Older scripts are kept for whatever reason you want.

Restrictions

For commercial use, contact me first. You can use this script how you want as long as you credit.
« Last Edit: August 30, 2011, 06:54:35 PM by Mr G W »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Nice idea. Thanks for sharing!

*
Rep: +0/-0Level 67
RMRK Junior
very nice   :lol:, thanks for sharing  ;)

**
Rep: +0/-0Level 71
RMRK Junior
BUG FIX: When a enemy attacks the game will no longer crash.

I forgot that enemies do not have weapons... >_>

***
Rep:
Level 74
I'm baaack!
Is there a way to make them cost MP to use?

**
Rep: +0/-0Level 71
RMRK Junior
At the moment, no but it could be done. I'll see what i can do.

You could use KGC_RestoredFunctions to add a mana cost to your weapon.
« Last Edit: August 23, 2011, 09:33:43 AM by Mr G W »

***
Rep:
Level 74
I'm baaack!
Tracking down KGC scripts is hard...

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
TWENTY SECONDS on Google found me this:
http://www.rpgmakervx.net/index.php?showtopic=19726
I don't know if Restored Functions is in there, but there are definitely KGC scripts.
it's like a metaphor or something i don't know

**
Rep: +0/-0Level 71
RMRK Junior
Translated KGC Scripts by Mr. Anonymous here.

http://riggstooples.wordpress.com/kgc-scripts/

**
Rep: +0/-0Level 71
RMRK Junior
UPDATE: The <magical> tag can now be used on enemies. Use the <hybrid> tag to give eenmies a hybrid attack since they do not have weapons.

***
Rep:
Level 74
I'm baaack!
TWENTY SECONDS on Google found me this:
http://www.rpgmakervx.net/index.php?showtopic=19726
I don't know if Restored Functions is in there, but there are definitely KGC scripts.

:( I can't use that forum

**
Rep: +0/-0Level 71
RMRK Junior
Translated KGC Scripts by Mr. Anonymous here.

http://riggstooples.wordpress.com/kgc-scripts/

Use this for KGC scripts. The Restored Functions allows you to add MP cost to normal attack.

***
Rep:
Level 74
I'm baaack!
Translated KGC Scripts by Mr. Anonymous here.

http://riggstooples.wordpress.com/kgc-scripts/

Use this for KGC scripts. The Restored Functions allows you to add MP cost to normal attack.

Thanks!