Another maths question :(

Grags_1977

Ultra Cool Member
Reaction score
32
I want to take away 20% gold of my hero when he dies.

Set player1 gold to player1 gold - 20%

How do I do this please?

:eek::eek::eek::eek::eek::eek::eek::eek::eek:
 

merlinds

Member
Reaction score
15
Set gold of the player = Gold of the player - (Gold of the player * 0.2)
or
Set Gold of the player = (Gold of the player * 0.8)
:D
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
would you want to do a straight 20%?
or you open to maybe a more dynamic ammount, a set ammount, increasing with every level, with a random integer tacked on the end to make it appear to be a random number, along with a game text that says that you lost X gold
 

Grags_1977

Ultra Cool Member
Reaction score
32
Well this is the whole trigger. (Including the new 20% gold loss) i'm open to suggestions.

Trigger:
  • Revive Hero
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
    • Conditions
      • (Triggering unit) Equal to Unit_Hero
    • Actions
      • Sound - Stop Sound_Music After fading
      • Sound - Play Sound_Death <gen>
      • Set Real_TimeOfDay = (In-game time of day)
      • Game - Set the time of day to 0.00
      • Set TempPoint[14] = (Position of Unit_Hero)
      • Set TempUnitGroup[10] = (Units within 2000.00 of TempPoint[14])
      • Custom script: call RemoveLocation( udg_TempPoint[14] )
      • Unit Group - Pick every unit in TempUnitGroup[10] and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to 100.00%
      • Custom script: call DestroyGroup ( udg_TempUnitGroup[10] )
      • Wait 2.00 seconds
      • Game - Display to (All players) the text: |cffff0000You have ...
      • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - ((Player 1 (Red) Current gold) x (Integer(0.20))))
      • Wait 8.00 seconds
      • Sound - Stop Sound_Death <gen> After fading
      • Trigger - Run Force Push <gen> (ignoring conditions)
      • Camera - Pan camera for Player 1 (Red) to TempPoint[14] over 0.00 seconds
      • Hero - Instantly revive (Triggering unit) at TempPoint[14], Show revival graphics
      • Custom script: call RemoveLocation( udg_TempPoint[14] )
      • Selection - Select Unit_Hero for Player 1 (Red)
      • Special Effect - Create a special effect attached to the overhead of Unit_Hero using UI\Feedback\GoldCredit\GoldCredit.mdl
      • Special Effect - Destroy (Last created special effect)
      • Sound - Play Sound_Music
      • Game - Set the time of day to Real_TimeOfDay


|cffff0000You have died and lost 20% of your gold!

You will be revived in 8 more seconds.

^ thats the death message (Red)

I was contimplating making death permanent forcing the user to save & load. But decided against it. But I don't want death to be just a tiny inconvenience either. I would LOVE to make the user lose all thier experience towards thier next level. But wouldn't have the slightest idea where to begin. As setting the hero's xp to zero really does set it to zero (Includes ALL levels they have)
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
this is my suggestion, its gonna be jass since im practicing, but thats nice cuz all you do is copy and past then:
JASS:
function GoldLoss takes integer a, integer b, integer c returns integer
  return ( ( a + b ) / 2 ) + c - 20
endfunction


Trigger:
  • Actions
    • Set Int[1] = gold of the player x 0.8
    • Set Int[2] = (SqrRoot of level of the hero) x (whatever you want, this would be x10 at lvl 100 etc)
    • Set Int[3] = Random number between 1 and 40
    • Custom Script: set udg_Gold_Loss = GoldLoss( udg_Int[1], udg_Int[2], udg_Int[3])


this would set the gold loss equal to the average between the square root of the heroes level x an integer and 20% of the total gold + (random number between -20 and 20)
 

merlinds

Member
Reaction score
15
Trigger:
  • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - ((Player 1 (Red) Current gold) x (Integer(0.20))))

mmm, if you convert 0.2 to integer does it becomes 0??
i think you must convert the current gold to real first, then multply and the turn it into integer.
 

Grags_1977

Ultra Cool Member
Reaction score
32
:confused:

I think i'll stick with the way Merlins done it :thup:



EDIT: Thanks Merlin, I'm glad you caught that before I ran another full test.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
it would be like this:
gold integer -> gold real -> x0.8 -> new gold integer

or

gold - (gold/5)

ya that would probably be best, i more just wanted to practice my jass :p
 

Ayanami

칼리
Reaction score
288
Trigger:
  • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - ((Player 1 (Red) Current gold) x (Integer(0.20))))

mmm, if you convert 0.2 to integer does it becomes 0??
i think you must convert the current gold to real first, then multply and the turn it into integer.

That will not work. When you convert 0.20 to an integer, it becomes 0. So essentially, you're not subtracting any gold. You'd have to convert the current gold to real, then work from there. Example:

Trigger:
  • Actions
    • Set TempInt = (Integer(((Real((Player 1 (Red) Current gold))) x 0.20)))
    • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - TempInt)


Or, to do it in 1 line:

Trigger:
  • Actions
    • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - (Integer(((Real((Player 1 (Red) Current gold))) x 0.20))))


Lots of conversion :)
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
thats gui for u :p, you should only convert the gold to real then back after the math is done, so 2 conversions for the minimal ammount
 

Grags_1977

Ultra Cool Member
Reaction score
32
Urgh, I can't rep anyone... I have to spread it about.

But thanks a lot for the replys.
 

Iwan_Krissov

New Member
Reaction score
18
I was contimplating making death permanent forcing the user to save & load. But decided against it. But I don't want death to be just a tiny inconvenience either. I would LOVE to make the user lose all thier experience towards thier next level. But wouldn't have the slightest idea where to begin. As setting the hero's xp to zero really does set it to zero (Includes ALL levels they have)
This can be done also. At first you need to know which amount of experience is needed for which level. This can be found in the gameplay constants. Afterwards you can make an integer-array that stores the minimum-experience for every level and finally you can than write your trigger, which sets the experience of the hero to an minimumvalue according to the level the hero currently has.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
In the unlikely event that he still needs it, why not use:
Trigger:
  • Player - Set Player 1 (Red) Current gold to (((Player 1 (Red) Current gold) / 5) x 4)

since 4x/5 gives the same as x - 20%.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top