Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by FrostHDD · Nov 15, 2012 at 12:43 PM · meleemmoskillsmagic

How do skills affect damage you can do

i have made a skill script and im going to make a melee magic and ranged script but i want my skills to affect how much damage my attacks can do here is my skill script and i will probably add more skills like smithing along the way but here it is:

 var MeleeXP = 0;
 var MeleeLevel = 0;
 var MeleeLevelMultiplier = 1.5;
 var NeededMeleeXP = 100;
 var maxMeleeLevel = 99;
 
 var RangedXP = 0;
 var RangedLevel = 0;
 var RangedLevelMultiplier = 1.5;
 var NeededRangedXP = 100;
 var maxRangedLevel = 99;
 
 var MagicXP = 0;
 var MagicLevel = 0;
 var MagicLevelMultiplier = 1.5;
 var NeededMagicXP = 100;
 var maxMagicLevel = 99;
 
 function Update() {
  MeleeLevelStuff();
  RangedLevelStuff();
  MagicLevelStuff();
 }
 function MeleeLevelStuff() {
   if(MeleeXP > NeededMeleeXP) {
        print ("You've Past Level" + MeleeLevel);
        MeleeLevel += (1);       
        XP = 0;
        NeededMeleeXP = (NeededMeleeXP * MeleeLevelMultiplier);
        if(MeleeLevel > maxMeleeLevel)
       MeleeLevel = 99; 
       if(MeleeLevel == 99);
            print ("You've Reached The Max Melee Level");
        }
 }
 function RangedLevelStuff() {
   if(RangedXP > NeededRangedXP) {
        print ("You've Past Level" + RangedLevel);
        RangedLevel += (1);       
        XP = 0;
        NeededRangedXP = (NeededRangedXP * RangedLevelMultiplier);
        if(RangedLevel > maxRangedLevel)
       RangedLevel = 99; 
       if(RangedLevel == 99);
            print ("You've Reached The Max Ranged Level");          
        }
 }
 function MagicLevelStuff() {
   if(MagicXP > NeededMagicXP) {
        print ("You've Past Level" + MagicLevel);
        RangedLevel += (1);       
        XP = 0;
        NeededMagicXP = (NeededMagicXP * MagicLevelMultiplier);
        if(MagicLevel > maxMagicLevel)
       MagicLevel = 99; 
       if(MagicLevel == 99);
            print ("You've Reached The Max Magic Level");          
        }
 } 
 function OnGUI()
 {
 GUI.Label (Rect (20, 45, 100, 20), "Range" );
  GUI.Label (Rect (20, 60, 100, 20), RangedLevel + "/" + maxRangedLevel);
  GUI.Label (Rect (10, 5, 100, 20), "Strength" );
    GUI.Label (Rect (20, 20, 100, 20), MeleeLevel + "/" + maxMeleeLevel);
    GUI.Label (Rect (20, 80, 100, 20), "Magic" );
  GUI.Label (Rect (20, 95, 100, 20), MagicLevel + "/" + maxMagicLevel);   
    }

i dont know how to go along making it so the skills affect how much damage can be done please just help i would make my own melee script just show me how i would go along doing so thank you to anyone that helps

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by RonHiler · Nov 15, 2012 at 01:53 PM

You need to come up with some kind of relationship between the Melee level and the damage you want the player to be doing. That is entirely game dependent. But for example, say you want the player to do 10 points of damage plus 1 point of extra damage per every 2 melee levels. You would have a function something like this:

 function int GetDamage() {
     return (10 + MeleeLevel/2);
     }

(I'm a C# programmer, not a UScript programmer, so forgive me if there are syntax errors in there, hopefully you get the idea). I hope that helps.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FakeBerenger · Nov 15, 2012 at 01:55 PM 0
Share

I'd say, but that's not my cup of $$anonymous$$ either :

 function GetDamage() : int
avatar image RonHiler · Nov 15, 2012 at 02:48 PM 0
Share

Ah, thanks for the correction JB. I suppose one of these days I ought to learn UnityScript :)

avatar image
0

Answer by FakeBerenger · Nov 15, 2012 at 01:54 PM

That's not your code dealing with damages. That's the code for leveling up. We need the function called when the weapon strikes / the spell hits.

Anyway, it's probably going to be along those lines :

 function OnHit( Player player )
 {
     // A real formula is up to you, I keep it simple here
     life -= player.weapon.damage + player.strength;

     // Other stuffs
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

rpg, skills and characters the structure, confused 0 Answers

how should i go along making a melee system 1 Answer

Melee system not working 0 Answers

level up script please help 1 Answer

The type 'ModifyingAttribute' does not contain a constructor that takes '2' arguments. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges