• 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] Interest not Crediting

Status
Not open for further replies.
Level 3
Joined
Jul 12, 2013
Messages
12
Hi everyone.

I was trying to add the interest concept to my TD map. Unfortunately the Interest just does not get credited. Can someone help me with this please. The triggers used are indicated below.

  • Interest Timer Display
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start InterestTimer as a Repeating timer that will expire in 30.00 seconds
      • Countdown Timer - Create a timer window for InterestTimer with title Interest Due in
      • Set InterestTimerWindow = (Last created timer window)
      • Countdown Timer - Start BackupTimer as a One-shot timer that will expire in 30.00 seconds
  • Back Up Timer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • P1Int Equal to 1
    • Actions
      • Countdown Timer - Start BackupTimer as a One-shot timer that will expire in 30.00 seconds
      • Set P1Int = 0
  • Interest Calculations
    • Events
      • Time - BackupTimer expires
    • Conditions
    • Actions
      • Set GP1 = (Player 1 (Red) Current gold)
      • Set IP1 = (GP1 x (RP1 / 100))
      • Player - Add IP1 to Player 1 (Red) Current gold
      • Set P1Int = 1
Thanks is advance.

The default value of P1Int is 0 and RP1 (Interest rate) is 1.

Dread.
 
Last edited by a moderator:
Level 26
Joined
Aug 18, 2009
Messages
4,097
You can only add integer gold, so unless the player has a lot of money, it gets very inaccurate.

Furthermore, RP1 / 100 is integer division. 1 / 100 equals 0 because 100 fits 0 times into 1. You have to convert the values to real and then divide them in order to get a real number. And then convert back to multiply it by GP1 and store it inside an integer variable.
 
Level 3
Joined
Jul 12, 2013
Messages
12
Thanks WaterKnight.

I have changed the trigger as follows. Please let me know if it OK.

  • Interest Calculations
    • Events
      • Time - BackupTimer expires
    • Conditions
    • Actions
      • Set GP1 = (Player 1 (Red) Current gold)
      • Set IP1 = (((GP1 x RP1) / 100) + 1)
      • Player - Add IP1 to Player 1 (Red) Current gold
      • Set P1Int = 1
The +1 is to make the value non 0.

Dread.
 
Status
Not open for further replies.
Top