diff --git a/new_actor.py b/new_actor.py index 6942b24f3..1340a72d4 100644 --- a/new_actor.py +++ b/new_actor.py @@ -122,7 +122,7 @@ def addToSpec(actorSpec, actorFileName, objectSpec, actorFileLine): # read tables and get actor located specifically before the most recently added one # use that to determine where in the spec file to write filePathActor = Path(path.curdir, "include/tables/actor_table.h") - filePathSpec = Path(path.curdir, "spec") + filePathSpec = Path(path.curdir, "spec/spec") useNewBuild = False @@ -188,6 +188,8 @@ def completeFiles(actorSpec, actorDefine, actorFileName, objectSpec, objectDefin dataC = dataC.replace("{objectDefine}", objectDefine if createObject else "OBJECT_GAMEPLAY_KEEP") dataC = dataC.replace("{actorVar}", "ActorProfile" if useActorProfile else "ActorInit") dataC = dataC.replace("{actorInitVar}", "Profile" if useActorProfile else "InitVars") + dataC = dataC.replace("{includeObject}", f'\n#include "assets/objects/{objectSpec}/{objectSpec}.h"' if createObject else "") + dataC = dataC.replace("{actorFunc}", "" if useActorProfile else "(ActorFunc)") with open(f"{filePathActor}/{actorFileName}.c", 'w') as file: file.write(dataC) @@ -209,6 +211,7 @@ def completeFiles(actorSpec, actorDefine, actorFileName, objectSpec, objectDefin with open(f"{filePathObject}/{objectSpec}.c", 'r') as file: dataC = file.read() dataC = dataC.replace("{objectSpec}", objectSpec) + dataC = dataC.replace("{actorSpec}", actorSpec) with open(f"{filePathObject}/{objectSpec}.c", 'w') as file: file.write(dataC) @@ -217,6 +220,7 @@ def completeFiles(actorSpec, actorDefine, actorFileName, objectSpec, objectDefin dataH = file.read() dataH = dataH.replace("{objectSpec}", objectSpec) dataH = dataH.replace("{objectSpecCap}", objectSpec.upper()) + dataH = dataH.replace("{actorSpec}", actorSpec) with open(f"{filePathObject}/{objectSpec}.h", 'w') as file: file.write(dataH) @@ -235,8 +239,8 @@ def main(): if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument("-n", "--name", required = True, help = "Name of actor. Use alphanumeric and/or _ as valid characters", default = "") - parser.add_argument("-no", "--noobject", required = False, help = "Optional. Use if you do not want to create an object for this actor", action='store_false') + parser.add_argument("-name", required = True, help = "Name of actor. Use alphanumeric and/or _ as valid characters", default = "") + parser.add_argument("--noobject", required = False, help = "Optional. Use if you do not want to create an object for this actor", action='store_false') args = parser.parse_args() if not os.path.exists(Path(path.curdir, "src") or not os.path.exists(Path(path.curdir, "spec"))): @@ -254,7 +258,9 @@ if __name__ == "__main__": if not os.path.exists(Path(path.curdir, "assets/objects")) and createObject: os.makedirs(Path(path.curdir, "assets/objects")) - if isInFile('ActorProfile', "include/z64actor.h"): + if os.path.exists(Path(path.curdir, "include/actor_profile.h")): + useActorProfile = True + elif isInFile('ActorProfile', "include/z64actor.h"): useActorProfile = True if re.match(r'^[A-Za-z0-9_-]+$', args.name): diff --git a/template_files/object.c b/template_files/object.c index 9ffe54358..6a3167ff0 100644 --- a/template_files/object.c +++ b/template_files/object.c @@ -1,4 +1,5 @@ -#include "ultra64.h" -#include "z64.h" -#include "macros.h" #include "{objectSpec}.h" + +Gfx g{actorSpec}DL[] = { + gsSPEndDisplayList(), +}; diff --git a/template_files/object.h b/template_files/object.h index 3e85336cd..d1aebfa75 100644 --- a/template_files/object.h +++ b/template_files/object.h @@ -1,4 +1,8 @@ #ifndef {objectSpecCap}_H #define {objectSpecCap}_H +#include "gfx.h" + +extern Gfx g{actorSpec}DL[]; + #endif diff --git a/template_files/z_actor.c b/template_files/z_actor.c index 3a85dcb31..21f4429bf 100644 --- a/template_files/z_actor.c +++ b/template_files/z_actor.c @@ -6,6 +6,9 @@ #include "{actorFileName}.h" +#include "play_state.h" +{includeObject} + #define FLAGS (0) void {actorSpec}_Init(Actor* thisx, PlayState* play); diff --git a/template_files/z_actor.h b/template_files/z_actor.h index f738c9a6c..39fd06e4d 100644 --- a/template_files/z_actor.h +++ b/template_files/z_actor.h @@ -2,7 +2,8 @@ #define {actorFileNameCaps}_H #include "ultra64.h" -#include "global.h"{includeObject} +#include "actor.h" +#include "play_state.h" struct {actorSpec};