Element transmited to skills by weapons
#11
Ok, now there is a bit of confusion here.

The default RMXP code does not make any average when calculating elemental effect. It simply takes the lowest highest value among the element rates a character has against the elements of the attack/skill. That is, if a skill has Fire and Wind, and a character has A against Fire (200) and D against Wind (50) the result will be 50 200, i.e. damage halved doubled.

From what you say I take it in your BS the algorithm is different. You should post the elements_correct method used in your BS. Search for "elements_correct" with ctrl+shift+f, find the last defined method with that name and post it here.
Reply }
#12
Hi Charlie, thank you again for your attention. Sorry for my late reply,
i was taking my time to test all kind of situation before i reply to you,
to avoid any more mistakes/ confusions.

And one more time you got a point. My dmg calculation is not an average as i ve thought.

With my current scripts, the problem comes when i tag weapon or skill with animation tag,
and when i use the element as an attacker against an enemy that is strong to this element.
concrete example :

Fire Sword = 50 % dmg against water enemy.
if i dont tag the sword with sword animation, this is working perfectly.

When i do, the target is setted as :
Element Fire "E" (50% in my case),
Element Sword "C" (100%). but Sword is a dummy Element i use only to get animation related.

And as it is stronger, RMXP uses the 100% dmg from the sword.
i have look on the web for scripts that will define dummy element and cancel them.
I found 2 but none is working... how weird !


here is the 1st script, that is not working as expected :

Code:
#--------------------------------------------------------------------------
# ? ???????
#     element_set : ??
#--------------------------------------------------------------------------
def elements_correct(element_set)
elements = element_set.clone
elements.delete(15)  #            Whenever you get a new element that you don't
elements.delete(16)  # ??????  want to count as an element, just add to
elements.delete(17)  #             to the elements.delete list. (Also, you
elements.delete(18)  #             might want to replace the 18 and 17, eh?)

if element_set == []        
   # 100 ???              
   return 100
end
# ???????????????????
# ????? element_rate ?????????????? Game_Actor
#   ??? Game_Enemy ?????????
weakest = -100
for i in element_set
   weakest = [weakest, self.element_rate(i)].max
end
return weakest
end

regarding the 2nd one, it is too long so i m just gona attach it.
this 2nd script is working in terms of dummy element system as it is deleting the useless element from calculation,
and my dmg from fire to water ( E = 50% in my case) is working, but it has 2 problems :

1) it s got a lot of features and i dont need them, only the element correction thing.

2) I'm having the opposite pblm when using it. The strong ele (A = 150% for me, so Fire attacking Wind) becomes like a B (B = 125%), while B is working at 125 % too... :S

element addons.txt attachment
Reply }
#13
The first one should work. Maybe it's not placed in the right place, which should be after your BS.
Does the BS include some custom elements_correct function? In that case you couldn't use this piece of code as it would conflict with the BS.
Reply }
#14
my BS script includes some codes with elements correction.

for this 1st one, my settings is damage no. 1 (can be set up at the begening of the script in the options). So my case is "when 1"

Code:
def set_attack_damage_value(attacker)
    case DAMAGE_ALGORITHM_TYPE
    when 0
      atk = [attacker.atk - (self.pdef / 2), 0].max
      str = [20 + attacker.str, 0].max
    when 1
      atk = [attacker.atk - ((attacker.atk * self.pdef) / 1000), 0].max
      str = [20 + attacker.str, 0].max
    when 2
      atk = 20
      str = [(attacker.str * 4) - (self.dex * 2) , 0].max
    when 3
      atk = [(10 + attacker.atk) - (self.pdef / 2), 0].max
      str = [(20 + attacker.str) - (self.dex / 2), 0].max
    end
    self.damage = atk * str / 20
    self.damage = 1 if self.damage == 0 and (rand(100) > 40)
    self.damage *= elements_correct(attacker.element_set)
    self.damage /= 100
  end

this 2nd one is yours, and it is working:


Code:
# Element correction
       weapon_elements=[]
      if skill.element_set.include?(26)
        if user.weapon_id > 0
          weapon_elements=[1,4,5,6]&$data_weapons[user.weapon_id].element_set
        end
      end
      self.damage *= elements_correct(skill.element_set | weapon_elements)
    self.damage /= 100
  end

and then element correction about hp and sp regen, i dont show it cz i dont think it can influct.


another script is Actor Advanced status, it says :

Code:
alias acbs_elements_correct_actorstatus elements_correct


Finally, i have found a script that is working to cancel element. But when i use it,
B, C, D, E, are working. and A is working like B, when it is skill...

Code:
$DUMMY_ELEMENTS = [2,3,7,8,9,10,] # add any dummy element IDs other scripts might use
$DUMMY_STATES = [] # add any dummy state IDs other scripts might use



#==============================================================================
# Game_Battler
#==============================================================================

class Game_Battler
  
  def elements_correct(elements)
    multiplier = size = 0
    elements.each {|i|
        unless $DUMMY_ELEMENTS.include?(i)
          multiplier += self.element_rate(i)
          size += 1
        end}
    return (size == 0 ? 100 : multiplier/size)
  end
  
end
Reply }
#15
Okay, try this.
Get rid of the last script and use this modified version of mine:
Code:
# Element correction
      weapon_elements=[]
      dummy_elements = [2,3,7,8,9,10,] # add any dummy element IDs other scripts might use
      if skill.element_set.include?(26)
        if user.weapon_id > 0
          weapon_elements=[1,4,5,6]&$data_weapons[user.weapon_id].element_set
        end
      end
      self.damage *= elements_correct((skill.element_set | weapon_elements) - dummy_elements)
    self.damage /= 100
  end
All this code does is:
1) add the weapon elements to skills with the non-elemental tag
2) cancel any dummy elements from the set sent to the elements_correct function
Reply }
#16
*Respect*
Charlie you're really an Ace... it works now, thank you again and again dude !

this makes it work for the skill. where do i copy the code to make it work with normal attacks as well ?
Reply }
#17
For the normal attacks you just need to leave the dummy elements from the computations made in elements_correct, right?
Use this modified version of the set_attack_damage_value code.

Code:
def set_attack_damage_value(attacker)
    case DAMAGE_ALGORITHM_TYPE
    when 0
      atk = [attacker.atk - (self.pdef / 2), 0].max
      str = [20 + attacker.str, 0].max
    when 1
      atk = [attacker.atk - ((attacker.atk * self.pdef) / 1000), 0].max
      str = [20 + attacker.str, 0].max
    when 2
      atk = 20
      str = [(attacker.str * 4) - (self.dex * 2) , 0].max
    when 3
      atk = [(10 + attacker.atk) - (self.pdef / 2), 0].max
      str = [(20 + attacker.str) - (self.dex / 2), 0].max
    end
    self.damage = atk * str / 20
    self.damage = 1 if self.damage == 0 and (rand(100) > 40)
    dummy_elements = [2,3,7,8,9,10,] # add any dummy element IDs other scripts might use
    self.damage *= elements_correct(attacker.element_set - dummy_elements)
    self.damage /= 100
  end

There would an alternative and cleaner way of doing this, but if this one works... :)
Reply }
#18
dam.. doesn t work this time :(

could it be because of this code just above in the same BS ? :

Code:
#--------------------------------------------------------------------------
  def attack_effect(attacker)
    self.critical = @evaded = @missed = false
    hit_result = (rand(100) < attacker.hit)
    set_attack_result(attacker) if hit_result
    weapon = attacker.actor? ? $data_weapons[attacker.weapon_id] : nil
    if hit_result
      set_attack_state_change(attacker)
    else
      self.critical = false
      @missed = true
    end
    self.damage = POP_EVA if @evaded
    self.damage = POP_MISS if @missed
    return true
  end
  #--------------------------------------------------------------------------
  def perfect_attack_effect(attacker)
    self.critical = @evaded = @missed = false
    set_attack_result(attacker)
    weapon = attacker.actor? ? $data_weapons[attacker.weapon_id] : nil
    set_attack_state_change(attacker)
    return true
  end
def set_attack_result(attacker)
    set_attack_damage_value(attacker)
    if self.damage > 0
      self.damage /= 2 if self.guarding?
      set_attack_critical(attacker)
      set_critical_damage(attacker) if self.critical
    end
    apply_variance(5) if self.damage.abs > 0
    set_attack_hit_value(attacker)
  end
Reply }
#19
No, I don't think so. What exactly does not work?
Reply }
#20
everything works, except the normal attack when the weapon is taged with element "E" + dummy element.
dummy element is considered as a "C" element and i deal normal damage, whereas when it s on a skill... dummy element is working as expected :S
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Refreshing original skills names Whisper 2 5,116 05-31-2020, 04:35 PM
Last Post: Whisper
   Showing only specific skills in a window Mel 2 5,956 01-12-2016, 01:34 PM
Last Post: Mel
   Syvakal's Conditional Skills And Equipment Crashes Samven 0 3,979 08-02-2011, 01:58 PM
Last Post: Samven
   Help with using KGC's delayed skills prioran 0 3,664 05-07-2010, 11:46 PM
Last Post: prioran
   Skills that restore SP and reactive skills. Admetrynne 5 8,188 03-29-2010, 05:49 PM
Last Post: Admetrynne
   Simple Request about Element Defense status mageone 0 3,302 11-21-2009, 06:40 PM
Last Post: mageone



Users browsing this thread: 1 Guest(s)