Programming Questions
Soul_Rider
Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
in Modding
I have been dabbling with programming throughout my life, although never very seriously. I am entirely self-taught, and while I understand the basic terminology, I am not always sure how things would work practically. I have questions that may be quite easy to some of you learned programmers, so I thought I'd start this thread to keep a track of Questions and Answers to help me. I will update each question with links to the most helpful answers.
I hope others will find this resource useful, although I fully expect it to get very code heavy!!
--------------------------------------------------------------------------------
<b><u>Disclaimer:</u> This is a Hypothetical question. I strongly advise against using this information to create an AvP themed mod, as copyright infringment can carry very stiff penalties.</b>
If I were to add a third team to the game, what would be the best way to do it? Assuming that I have amended all the team indices and have created a new team called AlsoAlien, and given them the team number of 3.
Here is where my knowledge of subclassing, or rather lack of it, is highlighted. The first option is to copy all the alien files and relevant code and duplicate it with the team AlsoAlien. this will work, but involves a lot of work, and to my mind, there must be a better solution.
If I created an AlsoAlien.lua and made it look like this:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Alien.lua")
class 'AlsoAlien' (Alien)
AlsoAlien.kMapName = "alsoalien"
function AlsoAlien:OnCreate()
Alien.OnCreate(self)
end
function AlsoAlien:OnDestroy()
Alien.OnDestroy(self)
end
function AlsoAlien:OnInitialized()
Alien.OnInitialized(self)
end
function AlsoAlien:ExecuteSaying(index, menu)
Alien.ExecuteSaying(self, index, menu)
end
Shared.LinkClassToMap("AlsoAlien", AlsoAlien.kMapName, networkVars)<!--c2--></div><!--ec2-->
Would I have a new Alien file that works? I know this would require Alien team to be loaded in the files, even if you wanted a match marine vs alsoalien, but codewise, would the game accept this?
If not, is there a middle ground solution, and could someone explain where I misunderstand the point of subclassing. Of course, if it can be done that way, don't worry about explaining :)
I hope others will find this resource useful, although I fully expect it to get very code heavy!!
--------------------------------------------------------------------------------
<b><u>Disclaimer:</u> This is a Hypothetical question. I strongly advise against using this information to create an AvP themed mod, as copyright infringment can carry very stiff penalties.</b>
If I were to add a third team to the game, what would be the best way to do it? Assuming that I have amended all the team indices and have created a new team called AlsoAlien, and given them the team number of 3.
Here is where my knowledge of subclassing, or rather lack of it, is highlighted. The first option is to copy all the alien files and relevant code and duplicate it with the team AlsoAlien. this will work, but involves a lot of work, and to my mind, there must be a better solution.
If I created an AlsoAlien.lua and made it look like this:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Alien.lua")
class 'AlsoAlien' (Alien)
AlsoAlien.kMapName = "alsoalien"
function AlsoAlien:OnCreate()
Alien.OnCreate(self)
end
function AlsoAlien:OnDestroy()
Alien.OnDestroy(self)
end
function AlsoAlien:OnInitialized()
Alien.OnInitialized(self)
end
function AlsoAlien:ExecuteSaying(index, menu)
Alien.ExecuteSaying(self, index, menu)
end
Shared.LinkClassToMap("AlsoAlien", AlsoAlien.kMapName, networkVars)<!--c2--></div><!--ec2-->
Would I have a new Alien file that works? I know this would require Alien team to be loaded in the files, even if you wanted a match marine vs alsoalien, but codewise, would the game accept this?
If not, is there a middle ground solution, and could someone explain where I misunderstand the point of subclassing. Of course, if it can be done that way, don't worry about explaining :)
Comments
Spectators are kSpectatorIndex. So, if you change kSpectatorIndex to 45125, it is team 45125.
To implement a completely new team, you'd probably have to change lots of things like update relevancy masks, add team type values in editor_setup.xml and whatnot.
I personally would copy&paste the files completely and not create a subclass of Alien. This will only create conflicts between the two teams (e.g. functions doing some particular stuff for all "aliens" would probably affect both teams even if you don't want them to).
So much work it's almost impossible though...
To implement a completely new team, you'd probably have to change lots of things like update relevancy masks, add team type values in editor_setup.xml and whatnot.
I personally would copy&paste the files completely and not create a subclass of Alien. This will only create conflicts between the two teams (e.g. functions doing some particular stuff for all "aliens" would probably affect both teams even if you don't want them to).<!--QuoteEnd--></div><!--QuoteEEnd-->
Hopefully functions are run against teamNumber rather than against team "aliens", if they aren't then I can correct them as I go :)
I understand what you mean though, there are bound to be some funny bugs, but initially this was to find out if the idea is suitable for prototyping, although I didn't explain that above :)
<!--quoteo(post=1961119:date=Aug 11 2012, 04:20 PM:name=Yuuki)--><div class='quotetop'>QUOTE (Yuuki @ Aug 11 2012, 04:20 PM) <a href="index.php?act=findpost&pid=1961119"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Adding a third race would be awesome, 3 completely different matchups instead of 1 (not counting mirrors).
So much work it's almost impossible though...<!--QuoteEnd--></div><!--QuoteEEnd-->
To implement 3 full teams and balance it, yes it would be a hell of a nightmare, just depends on how big the complex each team is as to whether the idea itself is too much work :)