[REQUEST]Not a script request but a little code (i think :P)

Started by X-Law, April 12, 2009, 11:19:38 am

Previous topic - Next topic

X-Law

Hi there!
Well, this is hard to explain, at least for me.
I'm making a little script. It works like when you equip an specific armor, then a global variable get a value.
Then my problem comes, when i just want to persist the highest value. I mean, the variable is like a percentage, but i just want the highest percentage to persist. Don't know how to explain it better. A little example
Armor - New parameter = 25
Armor2 - New parameter = 50

Player1 - Equip Armor
Global.Variable = 25
Player2 - Equip Armor2
so now
Global.Variable = 50
but if now
Player1 - re-equip Armor
then
Global.Variable = 25 again
So what i want is that how to analyze the armors equipped before changing the "variable" value, to see what of the armors equipped has the highest "new parameter"
I hope it's a little more easy to understand now :/

Thanks in advance
(i'm a nub scripter as you can see :( )

AlbatrosStorm is on sale now!

Aqua

Okay just add this little part somewhere... :)
Remember to change the syntax


tempvar = $globalvar
$globalvar = ARMORVALUE
if tempvar >= $globalvar
$globalvar = tempvar
end

Fantasist

You beat me to it Aqua >8U

QuoteArmor - New parameter = 25
Armor2 - New parameter = 50

Player1 - Equip Armor
Global.Variable = 25
Player2 - Equip Armor2
so now
Global.Variable = 50
but if now
Player1 - re-equip Armor
then
Global.Variable = 25 again


deriving from that, here's the logic. Before you do Global.variable = something, check if it is larger than Global.variable: if value > Global.variable then Global.variable = value

btw, :welcome:
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




X-Law

Hey thank you Aquaman and Fantasist (Mirage xD)
But now i realized i'm just a VERY noob at scripting.
Well, i'll try to explain in the better way.
I'm trying to make a script that could be called "Reduce Encounter Percentage Using Armors"
I took the idea from FF series and from one script i see the other day for VX. But from this i'm just using the make_encounter algorithm.
I created a new method in Game System
def reduce_encounter_armor(id)
  case id
  when 1 then return 50
  when 2 then return 100
  else
    return 0
  end
end
Then in Game Actor in the "equip" method i added in the part of shield, head, body and accesory (when 1 #Shield, when 2 # Head, etc)
if $game_system.reduce_encounter_armor(id) !=0
   $Remember_Percentage = $game_system.reduce_encounter_armor(id)
else
   $Remember_Percentage = 0
end
I think that "else" it's not correct :/. Now i can implement that piece of code Aquaman posted. But then i have another problem
If you equip an armor with 50% then $Remember_Percentage would be 50. And now if then i equip with another character, another armor with 25%. Using that Aquaman's piece of code $Remember_Percentage will stay the highest value, i mean 50. But the prob is, what if now the other character unequip his armor with 50%? If using the "else" part, then $Remember_Percentage would be 0 now, but if i don't use the "else" then it still remain as 50...
How can i make this? if u unequip, then it must analyze if another character has equiped an armor with Reduce encounter %, and then change the value of $Remember_Percentage to that armor's value :/
I think this is hard to understand, too much with my bad english :(

Quotebtw, :welcome:

Yeah, thanks ^^. I forgot to introduce myself

I need help :( I'm a  :n00b:. Thanks in advance.

AlbatrosStorm is on sale now!

Aqua

Wait... you added

if $game_system.reduce_encounter_armor(id) !=0
   $Remember_Percentage = $game_system.reduce_encounter_armor(id)
else
   $Remember_Percentage = 0
end

In the equip part?

What you did should be all fine if you add it to either...
1) the unequip part too.
2) just some place that updates more often.  Like... alias the update method of Scene_Map or something XD

Fantasist

QuoteI'm trying to make a script that could be called "Reduce Encounter Percentage Using Armors"

I see what you want, but I don't understand how you're planning to implement the feature. Those numbers, 50, 25, 100... they are chance of encounter for certain steps, right?

hold on...

I looked it up and as I understand, the encounter chance depends totally on this little method in Game_Player:

#--------------------------------------------------------------------------
  # * Make Encounter Count
  #--------------------------------------------------------------------------
  def make_encounter_count
    # Image of two dice rolling
    if $game_map.map_id != 0
      n = $game_map.encounter_step
      @encounter_count = rand(n) + rand(n) + 1
    end
  end


@encounter_count = rand(n) + rand(n) + 1 where n is the "Steps Average" setting you set in the map's properties. rand(n) returns a random number between 0 and 29 (both included), so it's rand(n) + rand(n) + 1. After that many steps, the encounter occurs.

Figure out how you will implement the percentage into the encounter count.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




X-Law

April 12, 2009, 08:27:07 pm #6 Last Edit: April 12, 2009, 09:03:13 pm by Starholekirby86
QuoteWhat you did should be all fine if you add it to either...
1) the unequip part too.
2) just some place that updates more often.  Like... alias the update method of Scene_Map or something XD

I did it the equip part, because in there i know the actually armor equiped id. Example:
when 1  # Shield
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor1_id], $data_armors[id])
        $game_party.gain_armor(@armor1_id, 1)
        @armor1_id = id
        $game_party.lose_armor(id, 1)
        #Here i put that coded said before
        if $game_system.reduce_encounter_armor(id) !=0
          $Remember_Percentage = $game_system.reduce_encounter_armor(id)
        else
          $Remember_Percentage = 0
        end
      end

In there "id" is the actual equiped armor.
But... there is no "unequip" part in Game Actor, at least i didn't see it  :O.o:
And in Scene_Map... mmm i don't know how to obtain that ID in scene_map :(

QuoteI see what you want, but I don't understand how you're planning to implement the feature. Those numbers, 50, 25, 100... they are chance of encounter for certain steps, right?

Exactly right ^^ it's a percentage.
I use it in Game_Player in that method you said. I make this:

#--------------------------------------------------------------------------
  # * Make Encounter Count
  #--------------------------------------------------------------------------
  def make_encounter_count
    # Image of two dice rolling
    if $game_map.map_id != 0
     #add this line
      if $Remember_Percentage == 0
         n = $game_map.encounter_step
        @encounter_count = rand(n) + rand(n) + 1
      else
         n =  $game_map.encounter_step
         random_number = n + ((n * $Remember_Percentage) / 100)
         @encounter_count_b = rand(random_number) + rand(random_number) + 1
         @encounter_count = @encounter_count_b + ((@encounter_count_b * $Remember_Percentage) / 100)
      end
    end
  end

But then i have the problem i explained. This part in make_encounter_count is ok, i think.
:(

AlbatrosStorm is on sale now!

fugibo


Fantasist

when 1  # Shield
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor1_id], $data_armors[id])
        $game_party.gain_armor(@armor1_id, 1)
        @armor1_id = id
        $game_party.lose_armor(id, 1)
        #Here i put that coded said before
        if $game_system.reduce_encounter_armor(id) !=0
          $Remember_Percentage = $game_system.reduce_encounter_armor(id)
        else
          $Remember_Percentage = 0
        end
      end


QuoteI did it the equip part, because in there i know the actually armor equiped id.


You actually know both. Before the line @armor1_id = id, @armor1_id contains the ID of the previously equipped shield. After that line, @armor1_id contains the newly equipped shield ID. When you unequip, you're simply equipping "nothing" instead of an other shield.

So that solves that problem. With this, you don't need to mod Scene_Map if I'm not wrong.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




X-Law

but still, i0ve the same problem, i don't know if some other character has equiped some armor that give a value to $Remember_Percentage
:wacko:
Thanks once again. But still i didn't get it to work right  :(

Edit:
Quote
TAGS, DANGIT

Sorry for that ^^. I forgot to use it :P

AlbatrosStorm is on sale now!