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



Reply to topic  [ 7 posts ] 
 CreateHDFirearm and AddInventoryItem resutls in ID=255 ? 
Author Message
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post CreateHDFirearm and AddInventoryItem resutls in ID=255 ?
EDIT: For future visitors stumbling upon this:
The issue with ID = 255 is the "GetsHitByMOs = 0" property on the Weapon!

--------
I first add a fist item to my actor upon spawning them
Code:
   self.actor = ToActor(self)
   if not (self.actor:HasObject("Fist")) then
      local newFist = CreateHDFirearm("Fist", "The5");
      self.actor:AddInventoryItem(newFist);
   end


And then later I try to access the weapons ID:
Code:
function The5Lib.GetWeaponHeldByID(obj)
   local MO = ToMovableObject(obj) --even tried casting to MO to make sure I get the ID
   if (MO.RootID == MO.ID or MO.RootID == 255) then return -1
   else return MO.RootID
   end
end


Both ID and RootID return 255.

Been 6 years since I last modded CC, so bare with me here ;)


Last edited by The5 on Thu Aug 03, 2017 8:55 pm, edited 1 time in total.



Thu Aug 03, 2017 5:40 pm
Profile WWW
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post Re: CreateHDFirearm and AddInventoryItem resutls in ID=255 ?
Is the HDFirearm GetsHitsByMOs = 1? It has to be in order to be read.


Thu Aug 03, 2017 5:47 pm
Profile
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post Re: CreateHDFirearm and AddInventoryItem resutls in ID=255 ?
Ah! Nope, GetsHitByMOs = 0.
I don't want the actors "fist" weapon to be hit-able.

Thanks for clearing that up so swiftly!

Is there any documentation meanwhile that would explain these tricky bits?
I am aware of the generated lua doc on the wiki.


Thu Aug 03, 2017 6:05 pm
Profile WWW
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post Re: CreateHDFirearm and AddInventoryItem resutls in ID=255 ?
The wiki pages + the miscellaneous forum posts are the only documentation I'm afraid.

An easy & practical workaround would be to have the HDFirearm fist itself be set to Scale = 0, that way the hitbox would be non-existent.

If you still want to include a visual element, you can use an Attachable that's GetsHitByMOs = 0 since it will rotate, however not shrink along with the parent.


Thu Aug 03, 2017 6:10 pm
Profile
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post Re: CreateHDFirearm and AddInventoryItem resutls in ID=255 ?
Thanks for he heads up!

I wonder if the Attachable/Device itself will not have an ID created due to GetsHitByMOs=0
or if the ID just can't be accessed via the exposed property, for some reason.


BTW:
Can I set a scale in the .ini on the HDFirearm?
Or how would I generally go about prevent any interaction in there, without messing with GetsHitByMOs.

Also, can I dynamically scale objects in luascript? I wanted to do a weapon back the day, but I think it crashed CC.


Thu Aug 03, 2017 8:20 pm
Profile WWW
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post Re: CreateHDFirearm and AddInventoryItem resutls in ID=255 ?
The Scale value can only be applied in .lua, I'm afraid.

Yeah, the only thing it's good for is Scale = 0, as it doesn't seem to ♥♥♥♥ with the engine too much. Generally the game doesn't like the value being altered.


Fri Aug 04, 2017 10:55 am
Profile
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post Re: CreateHDFirearm and AddInventoryItem resutls in ID=255 ?
I'm gonna try and realize my weapon that bloats enemy bodies till they pop :p
See if I can make it without crashing CC by now.


Fri Aug 04, 2017 11:59 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 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.045s | 14 Queries | GZIP : Off ]