View unanswered posts | View active topics It is currently Fri Jan 10, 2025 12:02 am



Reply to topic  [ 15 posts ] 
 Undroppable weapons 
Author Message
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1972
Location: The Netherlands
Reply with quote
Post Undroppable weapons
Hi people,

I am in the process of making an actor that comes equipped with its own weapons and it is very important that this actor doesn't lose these since it won't be able to pick up any others.

Is there a way to disable the ability to drop its weapons without resorting to using a turret? (The reason I don't want to use a turret is that it'll carry more than one weapon.)


Wed Jun 24, 2009 8:01 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Undroppable weapons
If the weapon is dropped automagically return it?


Wed Jun 24, 2009 8:06 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Undroppable weapons
Well, you can set the JointStrength of the weapon to something like over9000, that will ensure the weapon won't get blown/shot out of the actors hands.


Wed Jun 24, 2009 8:09 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Undroppable weapons
Try rapidly disabling the controller state:
WEAPON_DROP
If that fails, constantly check for the weapon, and add to inventory if it odes not have it.

The weapon on update self lifetimes to 0.


Wed Jun 24, 2009 8:22 am
Profile
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1972
Location: The Netherlands
Reply with quote
Post Re: Undroppable weapons
@Grif: That'd be amazing. How would I accomplish that?
@MaximDude: That's not an issue thankfully. They can't be hit by anything. :)
@mail2345: I think you're talking lua here? :???:


Wed Jun 24, 2009 8:27 am
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: Undroppable weapons
Give the weapon low gil so it breaks when hitting the ground then check for WEAPON_DROP and if the actor is missing that weapon in his inventory, add a new one. (Yes this does require Lua)


Wed Jun 24, 2009 8:46 am
Profile WWW
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Undroppable weapons
no, just have the weapon's lua (currently only run on weapons that noone is holding) add the weapon to the nearest actor's inventory, and delete itself.


Wed Jun 24, 2009 8:59 am
Profile WWW
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Undroppable weapons
Code:
function Update(self)
  self.LifeTime = 0
end
This script goes to the gun, making it disappear when it's not in anyones inventory

Code:
function Update(self)
  i = 1
  self.gunfound = 0
  while i < MovableMan:GetMOIDCount() - 1 do --iterate through everything
    self.thingie = MovableMan:GetMOFromID(i) --get a pointer to the object
    if self.ID == self.thingie.RootID and self.thingie.presetName == "gun presetname here" then --if self has the gun in inventory
      self.gunfound = 1
    end
    i = i + 1
  end
  if self.gunfound == 0 then --if the gun wasn't found, add the gun into the actor's inventory
    local gun = CreateHDFirearm("gun preset name here")
    self:AddInventoryItem(gun)
  end
end
This goes to the actor, adding a gun to it's inventory whenever it hasn't got it. Hopefully these are typo-free.


Wed Jun 24, 2009 8:59 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Undroppable weapons
self.ToDelete = true is marginally faster than lifetime tweaks, but that is probably a better way of doing it if you only want the weapon to be undroppable for one actor.


Wed Jun 24, 2009 9:06 am
Profile WWW
User avatar

Joined: Tue Apr 01, 2008 4:49 pm
Posts: 1972
Location: The Netherlands
Reply with quote
Post Re: Undroppable weapons
Thanks! You are lifesavers. :grin:


Wed Jun 24, 2009 9:08 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Undroppable weapons
Also, lifetime = 0 means infinite lifetime, not no lifetime.


Wed Jun 24, 2009 6:53 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Undroppable weapons
@piipu

He has multiple weapons, so self:HasObject("gun name") works better.


Wed Jun 24, 2009 7:08 pm
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post Re: Undroppable weapons
Eh, if the actor will recreate a gun each time it drops, you will be able to spam that. And not only that, but you wont be able to destroy the gun ever since it keeps respawning.

Just make sure JointStrength is very high so knocking it off the actor will be tough enough (50000 = rocket to the face). Then if you want the weapons to be able to pickup again, but not let any other units pick them up, check out Darlos' code on the heavy soldier weapons. It has a good example of making weapons be able to pickup only by certain units.


Wed Jun 24, 2009 7:52 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Undroppable weapons
Hurfadurf numgun, if you DELETE the previous copy and then add a new one to the actor it's not going to be "spammable".


Wed Jun 24, 2009 8:01 pm
Profile
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Undroppable weapons
@Mail: Yeah, I just thought about it myself. Besides, the gun doesn't have a MOID when it's not held.
Code:
function Update(self)
  if not self:HasObject("gun name") then
    gun = CreateHDFireArm("gun name")
    self:AddInventoryItem(gun)
  end
end
That's a piece of code that should work.


Wed Jun 24, 2009 8:51 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 15 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.048s | 15 Queries | GZIP : Off ]