View unanswered posts | View active topics It is currently Thu Dec 26, 2024 4:51 pm



Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
 Randomized Weapon upon Buying 
Author Message
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Randomized Weapon upon Buying
Alright, I have a plethora of theoretically hypothetical weapons. To have them all be individually buyable would be horrendous for the buy menu. The plan is to have weapon cases be the way to obtain some of these weapons.

Upon purchasing the cases and the unit leaves whatever shuttle they were carried in on, the cases are replaced with a single, random weapon from a small database of possible choices.

The only prerequisite I can think of, aside from being Lua attached to an HDFirearm, would be easy editing of the database.

Thanks in advance


Mon Apr 22, 2013 4:38 pm
Profile
User avatar

Joined: Sun Aug 09, 2009 9:26 am
Posts: 1633
Reply with quote
Post Re: Randomized Weapon upon Buying
There's a mod like that, I think. Here you go.
viewtopic.php?f=61&t=31852


Mon Apr 22, 2013 5:06 pm
Profile
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Re: Randomized Weapon upon Buying
Benpasko wrote:
There's a mod like that, I think. Here you go.
viewtopic.php?f=61&t=31852


Brolands has one weapon, but a bunch of attachments. I'm talking about several seperate weapons. Like buying a pistol case and having a chance you could get an M1911 or a flintlock pistol, among others.


Mon Apr 22, 2013 5:16 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Location: Canadida
Reply with quote
Post Re: Randomized Weapon upon Buying
Sounds like a few tables, and a few random selectors.

Someone brief him on this, I think Weegee uses this extensibly in his scenes for unit generation/archetypes.


Tue Apr 23, 2013 7:02 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Randomized Weapon upon Buying
It's a pretty simple task, really.

Just have all your weapons premade in the ini.

Code:
function Create(self)

   self.randPistol = {"","",""} -- Pistol preset names here
   
   self.pistol = CreateHDfirearm(self.randomPistol[math.random(#self.randomPistol)])
   self.pistol.Pos = self.Pos
   MovableMan:AddParticle(self.pistol)
   self.ToDelete = true

end


Script isn't entirely accurate and theres a few kinks and bugs in it but it gives the idea of the concept.


Tue Apr 23, 2013 8:05 am
Profile
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Re: Randomized Weapon upon Buying
Coops wrote:
Script isn't entirely accurate and theres a few kinks and bugs in it but it gives the idea of the concept.


I appreciate you lending the time, and I can confirm it works after fixing a few errors. I'm not sure if it was intended or not, but after a few tries, it seems the weapon never enters the actor's hands after switching to the case. This, unfortunately, isn't ideal for reasons mostly regarding physics.


Tue Apr 23, 2013 9:29 pm
Profile
Forum Moderator
User avatar

Joined: Fri Feb 02, 2007 3:53 pm
Posts: 1896
Location: in my little gay bunker
Reply with quote
Post Re: Randomized Weapon upon Buying
Yeah, this just creates a weapon at the position of the case. What you need is to check if it is held and if it is then replace the case with a weapon in the actors inventory.


Tue Apr 23, 2013 9:49 pm
Profile
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Re: Randomized Weapon upon Buying
p3lb0x wrote:
Yeah, this just creates a weapon at the position of the case. What you need is to check if it is held and if it is then replace the case with a weapon in the actors inventory.


I really wouldn't know where to start. I know the forum gets this often, but there are people who have a head for code and I'm not one of them.


Tue Apr 23, 2013 9:58 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Location: Canadida
Reply with quote
Post Re: Randomized Weapon upon Buying
Cave Cricket uses something that reads the Actor's inventory, I guess it's the Repair Kit.


Wed Apr 24, 2013 2:26 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Randomized Weapon upon Buying
Foa, if I recall correctly scripts are only actually run on a weapon while it's selected, so you can't run scripts from an actor's inventory. Thus trying to cycle through the actor's inventory wouldn't accomplish anything. That said, the trick to it is to make a dummy object that you start and end at so you can catalogue the actor's entire inventory for, in the case you mentioned, reproduction.

Anyway, asides aside, try this. It's been a while and I'm kind of fuzzy on CC lua things now so it may not work right off the bat. Post error text if you get any.


Last edited by Bad Boy on Wed Apr 24, 2013 3:26 pm, edited 1 time in total.



Wed Apr 24, 2013 2:51 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Wed Sep 05, 2007 4:14 am
Posts: 3966
Location: Canadida
Reply with quote
Post Re: Randomized Weapon upon Buying
That's the one thing I remember, it created an actor that had x weapons up to a count of 30, and it had problems with overlapping names, like the Coalition Shotgun, and the Base.rte Shotgun, there was some point it was resolved, but now it is unresolved now.

Also, double slashes are for ini comments, double hyphens are for lua comments.


Wed Apr 24, 2013 3:16 am
Profile
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Re: Randomized Weapon upon Buying
Bad Boy wrote:
Post error text if you get any.


First, there was a missing 'then' at line 32. I fixed that, along with the comments. Now it says:
Code:
ERROR: no overload of 'MovableManager:AddParticle' matched the arguments (MovableManager, nil)
candidates are:
MovableManager:AddParticle(MovableManager, MovableObject)


Wed Apr 24, 2013 3:35 am
Profile
User avatar

Joined: Wed Feb 17, 2010 12:07 am
Posts: 1545
Location: That small peaceful place called Hell.
Reply with quote
Post Re: Randomized Weapon upon Buying
Code:
   if self.parent ~= nil then //If we have a parent then add the gun to his inventory
      self.parent.AddInventoryItem(self.pistol);
      self.ToDelete = true
   elseif self.parent == nil and self.Age > 1000 //Otherwise, after a second delay to double check if we have a parent, just add the pistol to the map.
      self.pistol.Pos = self.Pos
      MovableMan:AddParticle(self.Pistol) <<------------------------------------------<<
      self.ToDelete = true
   end


Shouldn't be capitalized.


Wed Apr 24, 2013 5:21 am
Profile
User avatar

Joined: Tue Feb 08, 2011 4:14 am
Posts: 59
Reply with quote
Post Re: Randomized Weapon upon Buying
Code:
ERROR: no overload of 'Actor:AddInventoryItem' matched the arguments (HDFirearm)
candidates are:
Actor:AddInventoryItem(MovableObject)


Wed Apr 24, 2013 6:12 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Randomized Weapon upon Buying
Foa wrote:
Also, double slashes are for ini comments, double hyphens are for lua comments.
Oh wow, embarrassing, my mind is all filled with java at the moment.

And sorry about that Xavier (also, sorry for the sloppiness of this, I made way too many errors for something so simple), change the line that says MovableMan:AddInventoryItem(self.pistol) to MovableMan:AddInventoryItem(CreateHDFirearm(self.pistol));


Wed Apr 24, 2013 6:26 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 20 posts ]  Go to page 1, 2  Next

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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.101s | 14 Queries | GZIP : Off ]