Data Realms Fan Forums http://45.55.195.193/ |
|
UniTech Teleport to Pod random weapons script http://45.55.195.193/viewtopic.php?f=73&t=18821 |
Page 1 of 1 |
Author: | Natti [ Mon May 24, 2010 8:46 pm ] |
Post subject: | UniTech Teleport to Pod random weapons script |
Hello fellow brains-in-jars, I'd like to have a script on my UniTech Teleport to Pod so, that it would give the teleported actor two random weapons when he is teleported. Somebody? Please? |
Author: | CaveCricket48 [ Mon May 24, 2010 9:22 pm ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
Could you post the script? I don't feel like downloading UniTech. Not that there's anything wrong with it, it's just that it clogs my buy menu. |
Author: | Duh102 [ Mon May 24, 2010 9:32 pm ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
He doesn't have a script if I'm reading it right, he just wants something to attach to the drop pod so that it releases a random actor with random weapons upon cracking. |
Author: | CaveCricket48 [ Mon May 24, 2010 9:49 pm ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
Oh, I get it. You're probably right about the script not already being there, but I don't think he wants a random actor. I think this also belongs in requests, but whatever. Try this out. Don't forget to add/change the current list to UniTech weapons. Code: function Create(self) ---------------------------------------- ----- Settings -- The list of weapons self.weaponslist = { "Assault Rifle" , "Pistol" , "Shotgun" , "SniperRifle" }; -- How many weapons the actor should get self.itemnumber = 2; ---------------------------------------- self.actorcheck = self:Inventory(); if MovableMan:IsActor(self.actorcheck) then for i = 1, self.itemnumber do self:AddInventoryItem(CreateHDFirearm(self.weaponslist[math.random(1,#self.weaponslist)])); end end end |
Author: | Natti [ Tue May 25, 2010 4:29 am ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
I mean, there's the craft that teleports your actor to the UniTec Teleport Module that has been placed in your bunker when building. Code: function Create(self) for actor in MovableMan.Actors do if actor.Team == self.Team and actor.PresetName == "UniTec Teleport Pad Base" then self.Pos = actor.Pos self:GibThis() end end end function Destroy(self) ActivityMan:GetActivity():ReportDeath(self.Team, -1); end That's the existing code. |
Author: | CaveCricket48 [ Tue May 25, 2010 11:34 am ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
Oh. Well, try this: Code: function Create(self) ---------------------------------------- ----- Settings -- The list of weapons self.weaponslist = { "Assault Rifle" , "Pistol" , "Shotgun" , "SniperRifle" }; -- How many weapons the actor should get self.itemnumber = 2; ---------------------------------------- for actor in MovableMan.Actors do if actor.Team == self.Team and actor.PresetName == "UniTec Teleport Pad Base" then self.actorcheck = self:Inventory(); if MovableMan:IsActor(self.actorcheck) then for i = 1, self.itemnumber do self:AddInventoryItem(CreateHDFirearm(self.weaponslist[math.random(1,#self.weaponslist)])); end end self.Pos = actor.Pos self:GibThis() end end end function Destroy(self) ActivityMan:GetActivity():ReportDeath(self.Team, -1); end |
Author: | Natti [ Wed May 26, 2010 1:56 pm ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
Totally forgot this. So, didn't work. No errors. Nothing. Just no weapons. |
Author: | none [ Wed May 26, 2010 7:24 pm ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
self:AddInventoryItem(CreateHDFirearm(self.weaponslist[math.random(1,#self.weaponslist)])); to self.actorcheck:AddInventoryItem(CreateHDFirearm(self.weaponslist[math.random(1,#self.weaponslist)])); |
Author: | Natti [ Wed May 26, 2010 7:54 pm ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
none wrote: self:AddInventoryItem(CreateHDFirearm(self.weaponslist[math.random(1,#self.weaponslist)])); to self.actorcheck:AddInventoryItem(CreateHDFirearm(self.weaponslist[math.random(1,#self.weaponslist)])); Will try that tomorrow, got to sleep now. EDIT: No luck. |
Author: | Abdul Alhazred [ Thu May 27, 2010 6:17 pm ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
I think the problem is here: Code: if MovableMan:IsActor(self.actorcheck) then This code will add two weapons to the first actor: Code: local Weapons = {"SMG", "Pistol", "Shotgun"} local Act = self:Inventory() if Act and Act:IsActor() then Act = ToActor(Act) for i = 1, 2 do Act:AddInventoryItem(CreateHDFirearm(Weapons[SelectRand(1, #Weapons+1)], "Base.rte")) end end I have not tested it with UniTech, but the code would look something like this: Code: function Create(self) -- The list of weapons local Weapons = {"Assault Rifle", "Pistol", "Shotgun", "SniperRifle"} -- How many weapons the actor should get local weps = 2 for Pad in MovableMan.Actors do if Pad.Team == self.Team and Pad.PresetName == "UniTec Teleport Pad Base" then local Act = self:Inventory() if Act and Act:IsActor() then Act = ToActor(Act) for i = 1, weps do Act:AddInventoryItem(CreateHDFirearm(Weapons[SelectRand(1, #Weapons+1)], "UniTec.rte")) end end self.Pos = Pad.Pos self:GibThis() break end end end function Destroy(self) ActivityMan:GetActivity():ReportDeath(self.Team, -1) end If you want to have the payload delivered to the closest pad so you can have several pads and chose which one to use, try this code (again untested): Code: function Create(self) -- The list of weapons local Weapons = {"Assault Rifle", "Pistol", "Shotgun", "SniperRifle"} -- How many weapons the actor should get local weps = 2 -- Teleport to the closest pad local Target local range = 100000 local tmp for Pad in MovableMan.Actors do if Pad.Team == self.Team and Pad.PresetName == "UniTec Teleport Pad Base" then tmp = SceneMan:ShortestDistance(self.Pos, Pad.Pos, false).Magnitude if tmp < range then range = tmp Target = Pad end end end if Target then local Act = self:Inventory() if Act and Act:IsActor() then Act = ToActor(Act) for i = 1, weps do Act:AddInventoryItem(CreateHDFirearm(Weapons[SelectRand(1, #Weapons+1)], "UniTec.rte")) end end self.Pos = Target.Pos self:GibThis() end end function Destroy(self) if self.Pos > 0 then ActivityMan:GetActivity():ReportDeath(self.Team, -1) end end |
Author: | Natti [ Thu May 27, 2010 6:47 pm ] |
Post subject: | Re: UniTech Teleport to Pod random weapons script |
Hell yeah, that worked. Thanks a lot, Abdul! |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |