Page 1 of 1
Creating dead bodies help [Solved]
Posted: Wed May 28, 2014 10:14 pm
by Noobasaurus
I'm spawning in animated props with my lua, but when they spawn they're floating and I need them to be on the ground. Gravity doesn't work for them, so I'm wondering if there's a way I can shift the model or animation downwards slightly. The animations don't have any movement.
I've tried using a ton of different ClassLabels from secretsociety but none of them have given me success. I need a "prop" that can use animations and has gravity.
Re: Animated props and gravity
Posted: Wed May 28, 2014 11:24 pm
by MileHighGuy
you could set up a hover vehicle or auto turret with the msh you want
Re: Creating dead bodies help
Posted: Thu May 29, 2014 12:02 am
by Noobasaurus
Hover vehicles and auto turrets can't use animations.
EDIT: I'm trying to use lua to spawn in a dead body whenever a person dies at their location. However, whenever a person dies the error log says this:
Code: Select all
Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "1" not found
And here's the code I'm using to do this.
Code: Select all
deadpeople = OnCharacterDeath(
function(Victim, Killer)
if GetEntityClassName(Victim) == "imp_inf_rifleman" then
local body = GetEntityMatrix(Victim)
CreateEntity("com_item_dead_stormtrooper", body, "dead1")
ReleaseCharacterDeath(deadpeople)
end
end
)
Re: Creating dead bodies help
Posted: Thu May 29, 2014 3:09 am
by razac920
Try:
Code: Select all
deadpeople = OnObjectDeath( // Characters don't have locations, and once dead GetCharacterUnit doesn't return the object
function(Victim, Killer)
//if GetEntityClassName(Victim) == "imp_inf_rifleman" then <-- do you want this to ONLY work for Stormtroopers? Maybe there is a LUA function for objects, but I've never used it, I prefer to make 2 lists, one of characters, and one of objects, and to link them on spawn, that way I can find the object and hence the position from the character
local body = GetEntityMatrix(Victim)
CreateEntity("com_item_dead_stormtrooper", body, "dead1") <-- I've never tried this, is this what was working before? All I can say is I would lower the bodies that you did create to the ground using local lower = CreateEntityMatrix(0,0,0,0,0,-1,0,body) and using this location instead
// ReleaseCharacterDeath(deadpeople) <-- this line would have killed the event call back and let it run only once
end
//end
)
Re: Creating dead bodies help
Posted: Fri May 30, 2014 12:37 am
by Noobasaurus
Thank you for your help.
I've decided that doing this mostly in lua isn't quite my cup of tea, so I'm back to spawning them in as powerups. I basically just set the power up class and probability to the class and to 100% every time someone spawns. It works pretty well for the most part, but sometimes a powerup is dropped instead of a body. Here is what makes this happen:
Code: Select all
peoplespawn = OnCharacterSpawn(
function(character)
SetClassProperty("imp_inf_rifleman", "DropItemClass", "com_item_dead_stormtrooper")
SetClassProperty("imp_inf_rifleman", "DropItemProbability", "1")
end
)
I've tried setting it without an
OnCharacterSpawn, but it only works for the first person who spawns. Does anyone know how to make this power up drop the only drop that can happen and make it drop 100% of the time via lua? Thanks.
EDIT: Well, it seems that the texture for the model isn't working in general. I think this might be okay for the mod. Now I just need a 100% drop rate.
Re: Creating dead bodies help
Posted: Fri May 30, 2014 12:49 am
by MileHighGuy
I think you need to set the other dropped items' probability to 0 as well. I don't know about the other problem.
Re: Creating dead bodies help
Posted: Fri May 30, 2014 2:22 am
by razac920
Yeah you need to set the other item drop probabilities to zero. I don't know why you are changing the entire class property repeatedly each time a character spawns, you should only change it once, so add ReleaseCharacterSpawn(peoplespawn) just before end.
But you really shouldn't be changing class properties when the game is going on -- just change it once at the beginning and keep your mod multiplayer compatible.
However, I don't think SetClassProperty works well on lists, such as DropItemClass or WeaponSection (fortunately the numbered variants exist for 1-4).
I'd recommend just making a new class imp_inf_rifleman2 which is identical to the stormtrooper in every way except that it inherits from imp_inf_default_rifleman2, which inherits from imp_inf_default2, which inherits from com_inf_default2, and com_inf_default2 has all the DropItemClass sections changed to what you want. Then you don't have to mess with LUA, other than loading this stormtrooper variant.
Re: Creating dead bodies help
Posted: Sat May 31, 2014 2:00 pm
by Noobasaurus
Alright, so I've got it mainly working. I set all the powerups to the dead body, and then using lua I set all of the units' probability to dispense one to 100%. It seems to work only for first spawn but that's all I need. Either that or there were too many powerups on the battlefield.
I got the texture working, it was some simple error by me. Now I've tried to edit the texture and it won't change to the new one. I should be able to get this solved soon, but the dead body problem is solved so that's great! Thank you guys for your help.