diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 372751344..1c76af5d4 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ -June 25, 2009 +June 26, 2009 (Changes by Graf Zahl) +- Added Gez's actor replacement per skill submission. + +June 25, 2009 - Joystick axes can be configured in the menu again. TODO: Config saving and loading, XInput, allow axes to be used as buttons (for the Xbox controller's trigger buttons), allow the joystick to move through the diff --git a/src/g_level.h b/src/g_level.h index 2b82f8495..c286caa9e 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -533,6 +533,8 @@ int G_SkillProperty(ESkillProperty prop); typedef TMap SkillMenuNames; +typedef TMap SkillActorReplacement; + struct FSkillInfo { FName Name; @@ -554,6 +556,8 @@ struct FSkillInfo FString MustConfirmText; char Shortcut; FString TextColor; + SkillActorReplacement Replace; + SkillActorReplacement Replaced; FSkillInfo() {} FSkillInfo(const FSkillInfo &other) @@ -562,6 +566,11 @@ struct FSkillInfo } FSkillInfo &operator=(const FSkillInfo &other); int GetTextColor() const; + + void SetReplacement(FName a, FName b); + FName GetReplacement(FName a); + void SetReplacedBy(FName b, FName a); + FName GetReplacedBy(FName b); }; extern TArray AllSkills; diff --git a/src/g_skill.cpp b/src/g_skill.cpp index bbb703de5..8125208e9 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -70,6 +70,8 @@ void FMapInfoParser::ParseSkill () skill.MustConfirm = false; skill.Shortcut = 0; skill.TextColor = ""; + skill.Replace.Clear(); + skill.Replaced.Clear(); sc.MustGetString(); skill.Name = sc.String; @@ -159,6 +161,17 @@ void FMapInfoParser::ParseSkill () sc.MustGetNumber (); skill.ACSReturn = sc.Number; } + else if (sc.Compare("ReplaceActor")) + { + ParseAssign(); + sc.MustGetString(); + FName replaced = sc.String; + ParseComma(); + sc.MustGetString(); + FName replacer = sc.String; + skill.SetReplacement(replaced, replacer); + skill.SetReplacedBy(replacer, replaced); + } else if (sc.Compare("Name")) { ParseAssign(); @@ -338,6 +351,8 @@ FSkillInfo &FSkillInfo::operator=(const FSkillInfo &other) MustConfirmText = other.MustConfirmText; Shortcut = other.Shortcut; TextColor = other.TextColor; + Replace = other.Replace; + Replaced = other.Replaced; return *this; } @@ -363,3 +378,48 @@ int FSkillInfo::GetTextColor() const return color; } +//========================================================================== +// +// FSkillInfo::SetReplacement +// +//========================================================================== + +void FSkillInfo::SetReplacement(FName a, FName b) +{ + Replace[a] = b; +} + +//========================================================================== +// +// FSkillInfo::GetReplacement +// +//========================================================================== + +FName FSkillInfo::GetReplacement(FName a) +{ + if (Replace.CheckKey(a)) return Replace[a]; + else return NAME_None; +} + +//========================================================================== +// +// FSkillInfo::SetReplaced +// +//========================================================================== + +void FSkillInfo::SetReplacedBy(FName b, FName a) +{ + Replaced[b] = a; +} + +//========================================================================== +// +// FSkillInfo::GetReplaced +// +//========================================================================== + +FName FSkillInfo::GetReplacedBy(FName b) +{ + if (Replaced.CheckKey(b)) return Replaced[b]; + else return NAME_None; +} diff --git a/src/info.cpp b/src/info.cpp index 4cac243bf..a5e9434b7 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -48,9 +48,13 @@ #include "p_local.h" #include "templates.h" #include "cmdlib.h" +#include "g_level.h" extern void LoadActors (); +extern TArray AllSkills; + + //========================================================================== // // @@ -164,9 +168,10 @@ void FActorInfo::RegisterIDs () // //========================================================================== -FActorInfo *FActorInfo::GetReplacement () +FActorInfo *FActorInfo::GetReplacement (bool lookskill) { - if (Replacement == NULL) + FName skillrepname = AllSkills[gameskill].GetReplacement(this->Class->TypeName); + if (Replacement == NULL && (!lookskill || skillrepname == NAME_None)) { return this; } @@ -174,7 +179,18 @@ FActorInfo *FActorInfo::GetReplacement () // potential infinite recursion. FActorInfo *savedrep = Replacement; Replacement = NULL; - FActorInfo *rep = savedrep->GetReplacement (); + FActorInfo *rep = savedrep; + // Handle skill-based replacement here. It has precedence on DECORATE replacement + // in that the skill replacement is applied first, followed by DECORATE replacement + // on the actor indicated by the skill replacement. + if (lookskill && skillrepname != NAME_None && PClass::FindClass(skillrepname) != NULL) + { + rep = PClass::FindClass(skillrepname)->ActorInfo; + } + // Now handle DECORATE replacement chain + // Skill replacements are not recursive, contrarily to DECORATE replacements + rep = rep->GetReplacement(false); + // Reset the temporarily NULLed field Replacement = savedrep; return rep; } @@ -184,9 +200,10 @@ FActorInfo *FActorInfo::GetReplacement () // //========================================================================== -FActorInfo *FActorInfo::GetReplacee () +FActorInfo *FActorInfo::GetReplacee (bool lookskill) { - if (Replacee == NULL) + FName skillrepname = AllSkills[gameskill].GetReplacedBy(this->Class->TypeName); + if (Replacee == NULL && (!lookskill || skillrepname == NAME_None)) { return this; } @@ -194,7 +211,12 @@ FActorInfo *FActorInfo::GetReplacee () // potential infinite recursion. FActorInfo *savedrep = Replacee; Replacee = NULL; - FActorInfo *rep = savedrep->GetReplacee (); + FActorInfo *rep = savedrep; + if (lookskill && skillrepname != NAME_None && PClass::FindClass(skillrepname) != NULL) + { + rep = PClass::FindClass(skillrepname)->ActorInfo; + } + rep = rep->GetReplacee (false); Replacee = savedrep; return rep; } diff --git a/src/info.h b/src/info.h index 9bc97b89b..03176ed21 100644 --- a/src/info.h +++ b/src/info.h @@ -165,8 +165,8 @@ struct FActorInfo return FindState(1, &name); } - FActorInfo *GetReplacement (); - FActorInfo *GetReplacee (); + FActorInfo *GetReplacement (bool lookskill=true); + FActorInfo *GetReplacee (bool lookskill=true); PClass *Class; FState *OwnedStates;