• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Me and my math issues. Can you help me about the formula?

Status
Not open for further replies.
Level 18
Joined
Jun 2, 2009
Messages
1,233
Hello everyone. I have an ability that provides damage bonus based on Strength. I am increasing item level for each 10 Strength. This is why i have created my system like this.
  • (Strength of (Casting unit) (Include bonuses)) Greater than or equal to 20
  • (Strength of (Casting unit) (Include bonuses)) Less than or equal to 29
But sadly for each 10 Strength points, i was doing like this.

  • (Strength of (Casting unit) (Include bonuses)) Greater than 30
  • (Strength of (Casting unit) (Include bonuses)) Less than or equal to 39
There are 25 conditions check within trigger. How can i make it "proper" way?
I need an integer that checks Strength of the caster and i want to set it's level as TempInt
What is the formula?

Ability is active. It provides bonus for several seconds and checks Strength when it's casted.
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
Set Variable Set TempInt = ((Strength of (Casting unit) (Include bonuses)) / 10) ?
This will floor the result to the next lowest integer, so anything from 30 to 39 strength will result in 3.

I have the feeling you could have solved this one yourself.
No. Math is one of my biggest enemies. Many times i dealt 1000 or 1 damage with spells that says "100" in my maps :)
 
Just out of curiosity, I plugged your question into ChatGPT to see if it would come up with the correct answer, and actually it did. Well, kinda. I don't know why it called it modulo operator, when it's nowhere in the code, and then it started rambling about Case and Switch, which was nonsense, because they don't exist in JASS. And also the code is titled "java."

It definitely needs some more practice with Warcraft 3 coding, but it's a good first guess.
 

Attachments

  • StrengthChatGPT.jpg
    StrengthChatGPT.jpg
    138 KB · Views: 16
Level 14
Joined
Jan 10, 2023
Messages
249
Just out of curiosity, I plugged your question into ChatGPT to see if it would come up with the correct answer, and actually it did. Well, kinda. I don't know why it called it modulo operator, when it's nowhere in the code, and then it started rambling about Case and Switch, which was nonsense, because they don't exist in JASS. And also the code is titled "java."

It definitely needs some more practice with Warcraft 3 coding, but it's a good first guess.
I'm guessing it calls that modulo because integer modulo doesn't really do anything special.

It just divides and integer, the integer rounds down, then it multiplies that by the divisor.

modulo is:
(I'm calling it moduloInt because I forget their name for it)
JASS:
function moduloInt takes integer i, integer d returns integer
    local integer m = n - ( n / d ) * d
    if m < 0 then
        set m = m + n
    endif
    return m
endfunction

I'm not very impressed by their modulo function... it handles negatives poorly imo
 
Last edited:
Status
Not open for further replies.
Top