Data Realms Fan Forums
http://forums.datarealms.com/

CreateHDFirearm and AddInventoryItem resutls in ID=255 ?
http://forums.datarealms.com/viewtopic.php?f=73&t=46191
Page 1 of 1

Author:  The5 [ Thu Aug 03, 2017 5:40 pm ]
Post subject:  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 ;)

Author:  4zK [ Thu Aug 03, 2017 5:47 pm ]
Post subject:  Re: CreateHDFirearm and AddInventoryItem resutls in ID=255 ?

Is the HDFirearm GetsHitsByMOs = 1? It has to be in order to be read.

Author:  The5 [ Thu Aug 03, 2017 6:05 pm ]
Post subject:  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.

Author:  4zK [ Thu Aug 03, 2017 6:10 pm ]
Post subject:  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.

Author:  The5 [ Thu Aug 03, 2017 8:20 pm ]
Post subject:  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.

Author:  4zK [ Fri Aug 04, 2017 10:55 am ]
Post subject:  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.

Author:  The5 [ Fri Aug 04, 2017 11:59 am ]
Post subject:  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.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/