• 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.

[Trigger] Math Problem

Status
Not open for further replies.
Level 17
Joined
Jun 12, 2007
Messages
1,261
I'm working on a save code of myself. But it doesn't work properly due to some math problems.
After a search I found what was the problem. The gold and exp values. They end up being 0. Why, I don't know.

Here is what I use to set up my variable for exp.
  • Set EXPAmount_ForSaves[(Player number of (Triggering player))] = ((Hero experience of Unit_PlayerHero[(Player number of (Triggering player))]) x (Multiplier_ForSaves[(Player number of (Triggering player))] + 10101))
In this case the XP was 0. When you look at normal math, the x has priority above +.
So this should result in: 0 x multiplier (1 to 5 at random) + 10101 = 10101
But it always ends up giving me a 0 why?

Is it because you can't multiply with 0 that I get 0?
Same goes for skills or gold when they are 0.

My formula must be (value x multiplier) + constant number
so even if the x part = 0 it should still add 10101

Help is needed.
 
Level 14
Joined
Nov 23, 2008
Messages
187
You're currently have (HeroExp * (Miltiplier + 10101)). Right variant (watch out for rounded brackets position):

  • Set EXPAmount_ForSaves[(Player number of (Triggering player))] = ((Hero experience of Unit_PlayerHero[(Player number of (Triggering player))] x Multiplier_ForSaves[(Player number of (Triggering player))]) + 10101)
or:

  • Set pnum = (Player number of (Triggering player))
  • Set EXPAmount_ForSaves[pnum] = ((Hero experience of Unit_PlayerHero[pnum] x Multiplier_ForSaves[pnum]) + 10101)
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
So this should fix the issue right?

  • Actions
    • Set TempInteger_ForSaves[(Player number of (Triggering player))] = ((Hero experience of Unit_PlayerHero[(Player number of (Triggering player))]) x Multiplier_ForSaves[(Player number of (Triggering player))])
    • Set EXPAmount_ForSaves[(Player number of (Triggering player))] = (TempInteger_ForSaves[(Player number of (Triggering player))] + 10101)
Edit: I still need somebody to make this for me lol. It will have 55 characters now. And it is not protected so just change value here and there and it still works... urg. But for now it'll do.
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
Thanks, I already got it though.
But to be honest I still failed at making a save and load code. :p

Loading doesn't even work, and the save code is so easy to read that even a 10y old could find out what to edit for better scores. =:(

I'll have to request somebody to do it, but the map is far from even alpha so I don;t think people will help. :p
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
I fail at understanding most of them.
As it should be in GUI, I don't mind custom scripts though. Most of the times they use jass or custom codes I don't get.

The next things is that they store things I don't want them to store.
They usually store spells, level and gold.

But I need to store variables (9 reals (magic power), 4 integers (money, xp, something that depends on story, spawn point) and what items the hero was wearing, with over idk how many items....
It's to complicated for me.
 
Status
Not open for further replies.
Top