- Home /
base character script errors. Plz Help.
Having trouble with this script. Getting two errors.
The code excerpt is from lines 85 - 92 of the BaseCharacter.cs script. The full script is located below for review as well.
private void SetupVitalModifiers() {
//health
GetVital ((int)VitalName.Health).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Constitution), .5f));
//energy
GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((AttributeName.Constitution), 1));
//mana
GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((AttributeName.WillPower), 1));
}
Two errors:
Assets/Scripts/Character Classes/BaseCharacter/.cs(89, 137): error CS1525: Unexpected symbol ';' , expecting ')' or ','
Assets/Scripts/Character Classes/BaseCharacter/.cs(91, 128): error CS1525: Unexpected symbol ';' , expecting ')' or ','
using UnityEngine; using System.Collections; using System; //added to access the enum class
public class BaseCharacter : MonoBehaviour {
private string _name;
private int _level;
private uint _freeExp;
private Attribute[] _primaryAttribute;
private Vital[] _vital;
private Skill[] _skill;
public void Awake() {
_name = string.Empty;
_level = 0;
_freeExp = 0;
_primaryAttribute = new Attribute[Enum.GetValues(typeof(AttributeName)).Length];
_vital = new Vital[Enum.GetValues(typeof(VitalName)).Length];
_skill = new Skill[Enum.GetValues(typeof(SkillName)).Length];
SetupPrimaryAttributes ();
SetupVitals ();
SetupSkills();
}
public string Name {
get{ return _name; }
set{ _name = value; }
}
public int Level {
get{ return _level; }
set{ _level = value;}
}
public uint FreeExp {
get{ return _freeExp; }
set{ _freeExp = value; }
}
public void AddExp(uint exp) {
_freeExp += exp;
CalculateLevel ();
}
//Take the average of all of the players skills and assign that as the player level
public void CalculateLevel() {
}
private void SetupPrimaryAttributes() {
for(int cnt = 0; cnt < _primaryAttribute.Length; cnt++) {
_primaryAttribute[cnt] = new Attribute();
}
}
private void SetupVitals() {
for(int cnt = 0; cnt < _vital.Length; cnt++) {
_vital[cnt] = new vital();
}
}
private void SetupSkills() {
for(int cnt = 0; cnt < _skill.Length; cnt++) {
_skill[cnt] = new skill();
}
}
public Attribute GetPrimaryAttribute(int index) {
return _primaryAttribute[index];
}
public Vital GetVital(int index) {
return _vital[index];
}
public Skill GetSkill(int index) {
return _skill[index];
}
private void SetupVitalModifiers() {
//health
GetVital ((int)VitalName.Health).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Constitution), .5f));
//energy
GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((AttributeName.Constitution), 1));
//mana
GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((AttributeName.WillPower), 1));
}
private void SetupSkillModifiers() {
//melee offense
GetSkill ((int)SkillName.Melee_Offence).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Might), .33f));
GetSkill ((int)SkillName.Melee_Offence).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Nimbleness), .33f));
GetSkill ((int)SkillName.Melee_Defense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Speed), .33f));
GetSkill ((int)SkillName.Melee_Defense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Constitution), .33f));
GetSkill ((int)SkillName.Magic_Offense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Concentration), .33f));
GetSkill ((int)SkillName.Magic_Offense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.WillPower), .33f));
GetSkill ((int)SkillName.Magic_Defense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Concentration), .33f));
GetSkill ((int)SkillName.Magic_Defense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.WillPower), .33f));
GetSkill ((int)SkillName.Ranged_Offense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Concentration), .33f));
GetSkill ((int)SkillName.Ranged_Offense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Speed), .33f));
GetSkill ((int)SkillName.Ranged_Defense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Speed), .33f));
GetSkill ((int)SkillName.Ranged_Defense).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.Nimbleness), .33f));
}
public void StatUpdate() {
for (int cnt = 0; cnt < _vital.Length; cnt++)
_vital [cnt].Update ();
for (int cnt = 0; cnt < _skill.Length; cnt++)
_skill [cnt].Update ();
}
}
Answer by yorgaraz · Jun 01, 2014 at 10:54 PM
I think you forgot to close the parentheses at the end of those two lines.
//energy
GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((AttributeName.Constitution), 1));
//mana
GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((AttributeName.WillPower), 1));
I belive it should be
//energy
GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((AttributeName.Constitution), 1)));
//mana
GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((AttributeName.WillPower), 1)));
Did as you said and it cleared up those errors and gave me 7 more lol. It has to be on my end though either that or its a version issue as Petey from BergZerg Arcade on youtube made the video like 2 or more years ago. It is the hack and slash tutorials. The only reason why I asked on here is he doesn't seem to be active as of around 5 months ago. He made one Reboot video talking about how he was going to redo the whole thing for unity 4.5 but hasn't posted anything since and used to be it was once a week which would have been nice because the older version videos are the best extended tutorials I have found so far, being there is well over 200 something videos. $$anonymous$$inda hard to move on though when there are errors and continuing anyway will probably end in failure. It is the base Character number 3 video if you care to check it out. Your the first person to try to help and resolve my error. So thanks.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Error line 22! Help. i dont know why? 1 Answer
3 errors in scrip. 1 Answer
what is wrong with this online FPS script(not done) ? 1 Answer
Expecting ':' Found '=' Error 1 Answer