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



Reply to topic  [ 2 posts ] 
 A script that forces you to buy two guns in a set? 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Mon Jul 12, 2010 5:39 am
Posts: 4558
Reply with quote
Post A script that forces you to buy two guns in a set?
OK: What I'm trying to do is make a script that forces you to buy 2 guns at once, and when bought, you dual wield them.
Is there any way to do this?


Wed Mar 14, 2012 1:23 am
Profile WWW
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post Re: A script that forces you to buy two guns in a set?
I don't think you can force the player to buy both guns as separate entries in the Midas ordering GUI, but you can offer one gun for sale which can have a script on it to add the second gun to the inventory of the first actor to hold it. The name and description could of course indicate to the player that buying the first gun will also get them the second.

Code:
function Update(self)
   if self.RootID ~= 255 and self.Sharpness == 1 then
      if self.RootID == self.ID then
         self.b = CreateHDFirearm("guna","Mod.rte")
         self.b.PresetName = self.PresetName
         self.b.Vel = self.Vel
         self.b.Pos = self.Pos
         MovableMan:AddParticle(self.b)
         self.c = CreateHDFirearm("gunb","Mod.rte")
         self.c.PresetName = self.PresetName
         self.c.Vel = self.Vel
         self.c.Pos = self.Pos
         MovableMan:AddParticle(self.c)
         self.Sharpness = 0
         self.ToDelete = true
         self.Lifetime = 0
      else
         self.y = MovableMan:GetMOFromID(self.RootID)
         if self.y then
            if self.y:IsActor() then
               self.z = ToAHuman(MovableMan:GetMOFromID(self.RootID))
               if self.z then
                  self.b = CreateHDFirearm("guna","Mod.rte")
                  self.b.PresetName = self.PresetName
                  self.z:AddInventoryItem(self.b)
                  self.c = CreateHDFirearm("gunb","Mod.rte")
                  self.c.PresetName = self.PresetName
                  self.z:AddInventoryItem(self.c)
                  self.z:GetController():SetState(Controller.WEAPON_CHANGE_PREV,true)
                  self.Sharpness = 0
                  self.ToDelete = true
                  self.Lifetime = 0
               end
            end
         end
      end
   end
end

I wound up making a similar script to this so I figured why not. Just apply this to a weapon with a sprite of the two guns next to each other, give it this script, and replace guna, gunb, and Mod.rte respectively.


Wed Mar 14, 2012 7:37 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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

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