|
Page 1 of 1
|
[ 11 posts ] |
|
UniTech Teleport to Pod random weapons script
Author |
Message |
Natti
Data Realms Elite
Joined: Fri Jul 03, 2009 11:05 am Posts: 3878
|
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?
|
Mon May 24, 2010 8:46 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
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.
|
Mon May 24, 2010 9:22 pm |
|
|
Duh102
happy carebear mom
Joined: Tue Mar 04, 2008 1:40 am Posts: 7096 Location: b8bbd5
|
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.
|
Mon May 24, 2010 9:32 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
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
|
Mon May 24, 2010 9:49 pm |
|
|
Natti
Data Realms Elite
Joined: Fri Jul 03, 2009 11:05 am Posts: 3878
|
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.
|
Tue May 25, 2010 4:29 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
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
|
Tue May 25, 2010 11:34 am |
|
|
Natti
Data Realms Elite
Joined: Fri Jul 03, 2009 11:05 am Posts: 3878
|
Re: UniTech Teleport to Pod random weapons script
Totally forgot this. So, didn't work. No errors. Nothing. Just no weapons.
|
Wed May 26, 2010 1:56 pm |
|
|
none
Joined: Fri Dec 18, 2009 11:00 pm Posts: 167
|
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)]));
|
Wed May 26, 2010 7:24 pm |
|
|
Natti
Data Realms Elite
Joined: Fri Jul 03, 2009 11:05 am Posts: 3878
|
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.
|
Wed May 26, 2010 7:54 pm |
|
|
Abdul Alhazred
DRL Developer
Joined: Tue Aug 11, 2009 5:09 am Posts: 395
|
Re: UniTech Teleport to Pod random weapons script
I think the problem is here: Code: if MovableMan:IsActor(self.actorcheck) then You can not use the Movable Manager to verify an actor if it is inside another actor's inventory. 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
|
Thu May 27, 2010 6:17 pm |
|
|
Natti
Data Realms Elite
Joined: Fri Jul 03, 2009 11:05 am Posts: 3878
|
Re: UniTech Teleport to Pod random weapons script
Hell yeah, that worked. Thanks a lot, Abdul!
|
Thu May 27, 2010 6:47 pm |
|
|
|
|
Page 1 of 1
|
[ 11 posts ] |
|
Who is online |
Users browsing this forum: No registered users |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|