RPG weapon upgrade
RPG weapon upgrade
RPG weapon upgrade
RPG weapon upgrade
RPG weapon upgrade
RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade
RPG weapon upgrade RPG weapon upgrade
RPG weapon upgrade
Go Back  Xtreme Visual Basic Talk > > > RPG weapon upgrade


Reply
 
Thread Tools Display Modes
  #1  
Old 07-09-2012, 01:07 PM
JackPS9 JackPS9 is offline
Newcomer
 
Join Date: Jun 2012
Posts: 11
Default RPG weapon upgrade


Okay, just trying to figure out how to do this the best way possible.
If the player upgrades strength on the weapon that is costs X amount between
1-50
If you go about 50 the amount you need to pay to upgrade changes
So basicly
If X >= 1 and X <= 50 then
Cost = Str * 5
End if

Problem is that I dont want it to change cause you hit over 50, I want each point after 50 to cost a different amount
So if the player upgrades from 40 to 51 the amount isnt going to be 55 or 110
But each point after the 50 to cost 10 than after 100 to increase it to a different amount and so on.

I hope you guys understand what I mean.
Reply With Quote
  #2  
Old 07-09-2012, 02:54 PM
AtmaWeapon's Avatar
AtmaWeaponRPG weapon upgrade AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

What I would do is make the effect a function of level. For example, past spending 50 points you might want to make the cost higher:
Code:
Function GetUpgradeCost(ByVal level As Integer) As Integer
    If level < 50 Then
        Return 5
    ElseIf level < 100 Then
        Return 10
    Else
        Return 15
    End If
End Function
Then, instead of using a hard-coded cost, call the function:
Code:
Cost = str * GetUpgradeCost(X)
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #3  
Old 07-09-2012, 03:18 PM
JackPS9 JackPS9 is offline
Newcomer
 
Join Date: Jun 2012
Posts: 11
Default

Hows that going to help?
(Sorry haven't really looked into functions....)

Wont that have the same problem as the one I'm having?
Once Str gets above 50 the cost goes from 20 (4 Str) to 40 (4 Str)
Cause the cost per point doubled?


But what I'm looking for is say you pay for 4 points worth
and one point is above only the one point will cost 10 gold while the others are 5 gold each.
Reply With Quote
  #4  
Old 07-10-2012, 08:53 AM
AtmaWeapon's Avatar
AtmaWeaponRPG weapon upgrade AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Ahh, that's a little different, but if you think about it by analogy it's evident how to solve it.

Imagine you're at a store and there's a sale on soda. Cans are $0.50 per can with a limit of 12. If you buy more than 12, the cost is the regular price of $1.25. This means that price is a function of number of cans purchased.
Code:
' (Let's ignore that Doubles are a bad idea for money.)
Function CostOfCan(ByVal numberPurchased As Integer) As Double
    If numberPurchased <= 12 Then
        Return 0.5
    Else
        Return 1.25
    End If
Now, you could do some fancy things with clamping functions and do the whole calculation in one swoop, but there's two other ways to go about it:
  1. For each can, ask CostOfCan() what this one costs and add it to a running total.
  2. Don't have CostOfCan(). Instead, pick up to 6 cans and add that number * 0.5 to the total. Then multiply the rest by 1.25 and add it to the total.
In my opinion, option 1 is nicer, especially as more prices and conditions to meet them are added. It'd look something like this:
Code:
Dim total As Double = 0
For i As Integer = 1 To numberOfCans
    total += CostOfCan(i)
Next
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
RPG weapon upgrade
RPG weapon upgrade
RPG weapon upgrade RPG weapon upgrade
RPG weapon upgrade
RPG weapon upgrade
RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade RPG weapon upgrade
RPG weapon upgrade
RPG weapon upgrade
 
RPG weapon upgrade
RPG weapon upgrade
 
-->