• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Solved] Arithmetic with real values not working

Level 9
Joined
Aug 24, 2022
Messages
251
Hello everyone. I have a bounty system, that, depending on difficulty, the reward decreases. Also, I have a code that, when input at the start of the game, increases these rewards by 13%. The following trigger is a part of the "Normal Mode" initialization. The variable used is "Bounty_Handicap", a real variable:

  • Normal Difficulty
    • Events
      • Unit - A unit enters Normal Mode <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Soul (Difficulty Picker)
    • Actions
      • Set VariableSet Secret_Code = |cffffff00-nmphcgm|r
      • Set VariableSet Secret_Code_Description = With this code, every bounty you receive is increased by 13%!
      • Set VariableSet Difficulty_Choosen = |cffffff00Normal Mode|r
      • Set VariableSet Player_Lives = (Player_Lives + 2)
      • Set VariableSet Bounty_Handicap = (Bounty_Handicap + 0.72)
      • -------- - --------
      • Unit - Kill (Triggering unit)
      • Unit - Kill Circle of Power 0112 <gen>
      • Unit - Kill Circle of Power 0109 <gen>
      • Unit - Kill Circle of Power 0040 <gen>
      • Unit - Kill Circle of Power 0030 <gen>
      • Unit - Kill Circle of Power 0019 <gen>
      • -------- - --------
      • Game - Display to (All players) the text: <Empty String>
      • Game - Display to (All players) the text: |cffffff00Normal Mo...
      • -------- - --------
      • Camera - Pan camera for Player 1 (Red) to (Center of Players Souls <gen>) over 0.00 seconds
      • -------- - --------
      • Trigger - Turn off Easy Difficulty <gen>
      • Trigger - Turn off Hard Difficulty <gen>
      • Trigger - Turn off Epic Difficulty <gen>
      • Trigger - Turn off True Difficulty <gen>
      • Trigger - Run Arena Normal Mode Tier 1 <gen> (ignoring conditions)
      • Trigger - Run Arena Normal Mode Tier 2 <gen> (ignoring conditions)
      • Trigger - Run Arena Normal Mode Tier 3 <gen> (ignoring conditions)
      • Trigger - Run Arena Normal Mode Tier Final <gen> (ignoring conditions)
      • Trigger - Turn off (This trigger)
And the following one, is the code trigger, that can be input only before the game starts:

  • Normal Mode Code
    • Events
      • Player - Player 1 (Red) types a chat message containing -nmphcgmm as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: <Empty String>
      • Game - Display to (All players) the text: |cff00ff00Code acce...
      • Set VariableSet Bounty_Handicap = (Bounty_Handicap + 0.13)
And the last part of the system, how to define the value of the reward. Note that Arena_Win_Reward and Arena_Lose_Reward are real variables, to define the amount of gold; and Bounty_Win_Reward and Bounty_Lose_Reward are Integer variables, that convert real to integer, to show a round value to players at each wave end:

  • Arena Normal Mode Tier 1
    • Events
    • Conditions
    • Actions
      • -------- [ HUMAN ] --------
      • -------- --------
      • Set VariableSet Arena_Wave_Description = |cff00ffffHuman Army|r: Considered the weakest army of all races, humans are very versatile. When they obtain power through other sources, their combinations can become extremely lethal.
      • Set VariableSet Arena_Wave_Features = |cff00ffffFeatures|r: |cff00ff00Light|r Buff; |cffffff00Medium|r Magic Damage; |cffff0000High|r Physical Resistance; |cffff00ffMini-stun|r
      • Set VariableSet Graveyard_Corpse = Human Soldier (Tier 1)
      • -------- --------
      • -------- Tier 1 Normal --------
      • Set VariableSet Arena_Enemy_Type[1] = Human Slave (Tier 1)
      • Set VariableSet Arena_Enemy_Type[2] = Human Soldier (Tier 1)
      • Set VariableSet Arena_Enemy_Type[3] = Dwarf Shooter (Tier 1)
      • Set VariableSet Arena_Enemy_Type[4] = Mounted Mage (Tier 1)
      • Set VariableSet Arena_Enemy_Type[5] = Human Shepherd (Tier 1)
      • -------- Tier 1 Elites --------
      • Set VariableSet Arena_Enemy_Type[6] = Human Captain - |cffffff00Elite|r (Elite - Tier 1)
      • Set VariableSet Arena_Enemy_Type[7] = Dwarf Mortar - |cffffff00Elite|r (Elite - Tier 1)
      • Set VariableSet Arena_Enemy_Type[8] = Wise Wizard - |cffffff00Elite|r (Elite - Tier 1)
      • Set VariableSet Arena_Enemy_Type[9] = Secret Cultist - |cffffff00Elite|r (Elite - Tier 1)
      • -------- Tier 1 Bosses --------
      • Set VariableSet Arena_Enemy_Type[10] = Royal Guard - |cffff0000Boss|r (Boss - Tier 1)
      • Set VariableSet Arena_Enemy_Type[11] = Pirate Captain - |cffff0000Boss|r (Boss - Tier 1)
      • Set VariableSet Arena_Enemy_Type[12] = Mounted Ghost - |cffff0000Boss|r (Boss - Tier 1)
      • Set VariableSet Arena_Enemy_Type[13] = Petrified Hero - |cffff8080Outerworld|r (Unique - Tier 1)
      • -------- --------
      • -------- WAVE 1: --------
      • Set VariableSet Arena_Current_Wave = 1
      • Set VariableSet Arena_Win_Reward = (300.00 x Bounty_Handicap)
      • Set VariableSet Bounty_Win_Reward = (Integer(Arena_Win_Reward))
      • Set VariableSet Arena_Lose_Reward = (Arena_Win_Reward / 6.00)
      • Set VariableSet Bounty_Lose_Reward = (Integer(Arena_Lose_Reward))
      • -------- Wave Variables: --------
      • Set VariableSet Arena_Enemy_Amount[1] = 100
      • Set VariableSet Music_Waves = HumanArmyTheme <gen>
      • Trigger - Run Arena Add Wave To Hashtable <gen> (ignoring conditions)
My problem is: The reward don't change at all. The first setup, that sets the value of the reward handicap, works fine on every difficult, but the variable don't add any value to it.

Am I misunderstanding something, or forgot to insert any line on it? The variable Set is an arithmetic, because players can input the code before choosing a difficulty, so, doesn't matter whose value was set first. It was supposed to add either 0.13 to the variable value, or the value defined by each difficulty.

Also, I tried to set a definitive value when choosing a difficulty, and then, liberate the code to be inserted. Also, it didn't work.
 
Last edited:
Level 9
Joined
Aug 24, 2022
Messages
251
so, what exactly fires "Arena Normal Mode Tier 1" trigger?
The "Normal Difficulty" trigger, when we step on the circle. I've cutted some of the trigger, because they are very big. Sorry for the incompletion. Everything in the entire system works well. It is an Arena system, like Orc Gladiators map.

I've editted the post, with a more complete version of it, deleting repetitive parts.
 
Level 41
Joined
Feb 27, 2007
Messages
5,222
Just to be clear, adding 0.13 to the bounty doesn’t always increase it by 13%. (For example if the bounty handicap was 0.13 already it would be a 100% increase to the bounty total.) If you want to do that you should multiply the bounty handicap by 1.13 after it is computed.

I suspect somewhere in one of your triggers you have a line that is supposed to say Set Bounty_Handicap = (Bounty_Handicap + x.yz) but actually just says Set Bounty_Handicap = x.yz.
 
Level 27
Joined
Sep 26, 2009
Messages
2,473
It's not apparent from the trigger, so let's assume that the initial value of "Bounty_Handicap" is 0.00.
You run "Normal Difficulty" trigger which sets "Bounty_Handicap = (Bounty_Handicap + 0.72)", so at this point the current value of "Bounty_Handicap" is 0.72.
At the end of the trigger, you have
  • Trigger - Run Arena Normal Mode Tier 1 <gen>
The "Arena Normal Mode Tier 1" trigger uses Bounty_Handicap to modify some values, so for example there is this:
  • Set VariableSet Arena_Win_Reward = (300.00 x Bounty_Handicap)
which will evaluate as "Arena_Win_Reward = 300 * 0.72"

At some point later player may input a code which will run "Normal Mode Code" - this increases Bounty_Handicap by 0.13, to a total of 0.85.
But that's it. You don't run "Arena Normal Mode Tier 1" again, so there is nothing refreshing your data using the updated Bounty_Handicap.
 
Level 27
Joined
Sep 26, 2009
Messages
2,473
Maybe OP should clarify. My understanding was that "Normal Mode Code" trigger may run only after "Normal Difficulty".
The first two actions in "Normal Difficulty" trigger are:
  • set VariableSet Secret_Code = |cffffff00-nmphcgm|r
  • Set VariableSet Secret_Code_Description = With this code, every bounty you receive is increased by 13%!
and I believe before the edited post, this text was printed using "Game - Display text" action (although I may remember wrong).
Anyway, I find it strange that the "Normal Difficulty" trigger would run AFTER "Normal Mode Code" trigger even though it sets the secret code & description that the second trigger should use.
 
Level 9
Joined
Aug 24, 2022
Messages
251
I haven't time to test what you guys said, yet, but, let me explain how the system works.

The very first trigger is the "Normal Difficulty". It sets, at the start of the game, these variables:
  • Secret_Code: It's a string var, that show to players, when the game ends, a code that can be put on the next play;
  • Secret_Code_Description: It's a string var, that explains to players what the code above do. They are concatenated;
  • Difficulty_Choosen: Another string var, but now, to set up other small systems inside the project;
  • Player_Lives: An integer var, that sets how much tries, players have.
  • Bounty_Handicap: The actual problem. It's a real var, that multiplies the base bounty by a value below 1 (so, the arithmetic turns into a % calculation).
The second trigger, is the "Normal Mode Code". It is the trigger that activates when player 1 input the code, at the start of the game. Basically, it changes the value of Bounty_Handicap (Supposed to add 0.13 to the base value of bounty, set before by the "Normal Difficulty" trigger), and gives to all players a visual feedback, saying that the code have been accepted, and what it does.

The third trigger is the "Normal Mode Tier 1". It's a trigger that set up things like Wave_Description, types of enemies, quantity of enemies, bounty, music, that sort of thing. This trigger has 7 waves, so I've cut the other 6 because their are repetitive. The variables related to the bounty, in this trigger, are:
  • Arena_Win_Reward: A real var, that sets the total bounty by the arithmetic (Base value x Bounty_Handicap var);
  • Bounty_Win_Reward: An integer var, that converts the var above into an integer, and shows to all players at each wave end;
  • Arena_Lose_Reward: Same as Arena_Win_Reward, but its value is the Arena_Win_Reward divided by 6;
  • Bounty_Lose_Reward: Same function as Bounty_Win_Reward;

So, It doesn't matter if I input the code for bonus bounty or not, the system works with the bounty set by the "Normal Difficulty" trigger. If I choose either Easy Difficulty (With 0.85 Bounty_Handicap) or Hard Difficulty (With 0.59 Bounty_Handicap), system works fines, and make the calculations correctly. It's just the code, the line that add 0.13 to Bounty_Handicap, that doesn't work.
 
Level 9
Joined
Aug 24, 2022
Messages
251
Guys, I've found a solution. I've tested the code with a fixed value, set BEFORE the difficulty. I've checked values, and it went from 0.00 to 0.13 (With the code), and then, the difficulty trigger added to the base value of 0.13. I've tested on all modes, and all of them did the math correctly.

Somehow, using arithmetic in the code trigger, was not adding correctly values to the variable, and were returning different %'s than expected (Somehow, system calculated a 71% handicap on normal mode {0.72 + 0.13}).

So, to conclude, I just need to separate a time for player 1 to insert any code before choosing a difficulty, and problem solved. Thanks for everyone's attention and care. This conversation helped me solve my problem. Feel free to join our discord and visit our homepage here at hive.

Outerworld Arena Project Homepage

Outerworld Arena Project Discord
 
Last edited:
Top