Data Realms Fan Forums
http://forums.datarealms.com/

A quick question..
http://forums.datarealms.com/viewtopic.php?f=1&t=37856
Page 1 of 1

Author:  333severs [ Sun Dec 16, 2012 8:35 pm ]
Post subject:  A quick question..

Hello, is there a way to make it so that your mod is only available to a certain team? I swore I had seen some variable related but I can't find it now. Thanks for any replies!

Author:  Arcalane [ Mon Dec 17, 2012 12:02 am ]
Post subject:  Re: A quick question..

Define 'team'. Do you mean as in the red/green/blue/yellow teams, or as in a mod 'faction'?

Author:  333severs [ Mon Dec 17, 2012 2:49 am ]
Post subject:  Re: A quick question..

I mean team as in the different colors. Say I am playing with my brother. He makes his own modded weapons, and I make mine. What line of code can I add so that my weapons are only available in the Drop menu to my team (Red) and not his team (Blue) and vise-versa.

Author:  Asklar [ Mon Dec 17, 2012 3:01 am ]
Post subject:  Re: A quick question..

I don't think that's possible to do.

Well, at least not in an easy way. You could add a script to all of the things belonging to that faction and make them gib if they are part of another team.

Author:  333severs [ Mon Dec 17, 2012 3:41 am ]
Post subject:  Re: A quick question..

It is like four different objects.. Would it be a lot of code to make them gib if it isn't held by the right team? That sounds very interesting

Author:  Bad Boy [ Mon Dec 17, 2012 4:21 am ]
Post subject:  Re: A quick question..

Try this, it should delete the actor if it's not on the desired team and refund its cost. Note that it won't work for items like guns or bombs, as that'd probably be a bit more difficult (I guess you'd need to find the team of the delivery craft).

You'll need to manually set the team, either directly in the script or by replacing the number with some ini writable, lua readable value (e.g. sharpness). Also, if it works but is only refunding the cost of the actor, not any items he's holding, try changing self:GetGoldValue(0 , 1); to self:GetTotalValue(0 , 1);. I'm not entirely sure if goldvalue also includes inventory items.

Note that it's untested so I can't guarantee it'll work. Enjoy.
Code:
function Create(self)
   self.DesiredTeam = 0;
   self.Refund = self:GetGoldValue(0 , 1);
end
function Update(self)
   if not self.Team == self.DesiredTeam then
      ActivityMan:GetActivity():SetTeamFunds(ActivityMan:GetActivity():GetTeamFunds(self.Team) + self.Refund , self.Team);
      self.ToDelete = true;
   end
end

Author:  333severs [ Mon Dec 17, 2012 10:21 am ]
Post subject:  Re: A quick question..

Well, I've never used lua before haha. If it is going to be a struggle to do it I'll just not bother really. Thanks for the tips. Also, what I was referring to seeing once is "Team = 0" That I found in the Silver Man actor code. I thought maybe it would be what I was asking about.

Author:  Asklar [ Mon Dec 17, 2012 11:22 pm ]
Post subject:  Re: A quick question..

Ah, that, if I recall correctly, it makes an actor to always be part of a team.

I remember the old AAL marine that jumped out from the escape pods contained in the crafts had that line in it's code, but I can't tell if it will work on bought actors.

You can give it a try, set Team = 0 for team 1 (red team), Team = 1 for team 2(green team) and so on.

Author:  Bad Boy [ Tue Dec 18, 2012 4:07 am ]
Post subject:  Re: A quick question..

It won't be trouble at all. Attach it to the actor using ScriptPath = whateveryoucallthefile.lua and change desired team to whatever team you want it for. As asklar said, 0 is red, 1 is green, etc in order.
I just took a look at the ai initialization and updating stuff and it's easy to include so here's a version that'll do everything for you. Just copy it into a text file and rename that file's extension as .lua, then attach it to your actor as mentioned above.
Code:
require("Actors/AI/NativeHumanAI")
function Create(self)
   self.AI = NativeHumanAI:Create(self)
   self.DesiredTeam = 0;
   self.Refund = self:GetGoldValue(0 , 1);
end
function Update(self)
   if not self.Team == self.DesiredTeam then
      ActivityMan:GetActivity():SetTeamFunds(ActivityMan:GetActivity():GetTeamFunds(self.Team) + self.Refund , self.Team);
      self.ToDelete = true;
   end
end
function UpdateAI(self)
   self.AI:Update(self)
end


Edit: Oh yeah, you'll need to change the two lines that say HumanAI to CrabAI and TurretAI if you're also using this for turrets or crabs. Probably the same deal with rockets or dropships.

Author:  painbringer1998 [ Fri Dec 21, 2012 6:20 am ]
Post subject:  Re: A quick question..

why not just make something buyable = 0 and use AddHDFirearm to add it directly to the unit, so only the unit has it use it, it may not be as magical as LUA but it sure is a hell of a lot easier.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/