Working on my mod, I ran into a problem: the alien side was cloned from Halo. Plasma rifles, nades, left and right....
So I started de-Haloizing. When I came to the Plasma Grenade, I decided to go for something mildly unconventional. A few ideas went down the bin until I thought of a CryoCharge.
Upon explosion, it releases waves of supercooled gas that freeze any nearby units to an icicle. Part ODF, part LUA.
Now, in order to do this, I'll use LUA to grab the matrices of the dead bodies in the gas cloud and teleport an animated, reskinned prop to their location, which will die after a certain amount of time. Here's some code:
Hidden/Spoiler:
[code] OnCharacterDeath(
function(Victim, Killer)
if GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "all_inf_engineer" then
frozen_spawn = GetPathPoint("frozen_spawn", 0) --gets the path point
CreateEntity("frozen_flamer", frozen_spawn, "flamerfreeze") --spawns the frozen playermodel
local body = GetEntityMatrix(Victim) --get's the body's location
SetEntityMatrix(flamerfreeze, body)
end, else
if GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "all_inf_rifleman_urban" then
frozen_spawn = GetPathPoint("frozen_spawn", 0) --gets the path point
CreateEntity("frozen_rifleman", frozen_spawn, "riflemanfreeze") --spawns the frozen playermodel
local body = GetEntityMatrix(Victim) --get's the body's location
SetEntityMatrix(riflemanfreeze, body)
end, else
if GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "imp_inf_officer_gray" then
frozen_spawn = GetPathPoint("frozen_spawn", 0) --gets the path point
CreateEntity("frozen_sniper", frozen_spawn, "sniperfreeze") --spawns the frozen playermodel
local body = GetEntityMatrix(Victim) --get's the body's location
SetEntityMatrix(sniperfreeze, body)
end
end
)[/code][/size]
Now, as you can see, I use "CreateEntity" to create the animated prop, all ready in my world folders. Then I set it's matrix as that of the dead body...or something or other. Now, this code is all based on the assumption here:
CreateEntity("frozen_rifleman", frozen_spawn, "riflemanfreeze")
Ther first is the ODF, the second the path point, the third, I assume, is the thing's name in ZE, or variable, or whatever. Is it?
Nice try, but had you searched the shipped Lua files, you would have found your answer (though you would have had to extrapolate the inputs from it's use).
Actually, since I've never used this particular bit of code, I ripped it from Geo's campaign mission via Example Finder. I do my homework, I just don't understand it on occasion. Hence I extrapolated, as in my post, and wanted confirmation. Now I see I'm off.
You have two little parameters there; why did the Geonosis one have three?
EDIT - All of the scripts that showed up via Example Finder had
Notice the variable used is defined right above the CreateEntity call (GetPathPoint() returns a matrix).
The third parameter is not a ZE name (since the object is never in ZE), but instead is a name equivalent to the ZE name of an object that is placed in ZE.
Frisbeetarian wrote:The third parameter is not a ZE name (since the object is never in ZE), but instead is a name equivalent to the ZE name of an object that is placed in ZE.
Oh, thanks. This simplifies things; no need for me to use GetPathPoint. What if there's more than one of them? That may screw up my script. EDIT - hang on, maybe not. Still what if there's more than one victim with the same ODF and hence same animated prop?
EDIT 2 - Tested it, no CTD, but it doesn't work. The error (repeated several times):
OnCharacterDeath(
function(Victim, Killer)
if GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "all_inf_engineer" then
local body = GetEntityMatrix(Victim) --get's the body's location
CreateEntity("frozen_flamer", body, "flamerfreeze") --spawns the frozen playermodel
elseif GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "all_inf_rifleman_urban" then
local bodyz = GetEntityMatrix(Victim) --get's the body's location
CreateEntity("frozen_rifleman", bodyz, "riflemanfreeze") --spawns the frozen playermodel
elseif GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "imp_inf_officer_gray" then
local bodyx = GetEntityMatrix(Victim) --get's the body's location
CreateEntity("frozen_sniper", bodyx, "sniperfreeze") --spawns the frozen playermodel
end
end
)
Why isn't it finding the entity when I have the proper ODFs in the world's odf folder and the msh's in the msh folder? What's the problem with the CreateEntity line?
Frisbeetarian wrote:The third parameter is not a ZE name (since the object is never in ZE), but instead is a name equivalent to the ZE name of an object that is placed in ZE.
Oh, thanks. This simplifies things; no need for me to use GetPathPoint. What if there's more than one of them? That may screw up my script. EDIT - hang on, maybe not. Still what if there's more than one victim with the same ODF and hence same animated prop?
EDIT 2 - Tested it, no CTD, but it doesn't work. The error (repeated several times):
OnCharacterDeath(
function(Victim, Killer)
if GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "all_inf_engineer" then
local body = GetEntityMatrix(Victim) --get's the body's location
CreateEntity("frozen_flamer", body, "flamerfreeze") --spawns the frozen playermodel
elseif GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "all_inf_rifleman_urban" then
local bodyz = GetEntityMatrix(Victim) --get's the body's location
CreateEntity("frozen_rifleman", bodyz, "riflemanfreeze") --spawns the frozen playermodel
elseif GetObjectLastHitWeaponClass(Victim) == "cha_weap_inf_cryocharge" and GetEntityClassName(GetCharacterUnit(Victim)) == "imp_inf_officer_gray" then
local bodyx = GetEntityMatrix(Victim) --get's the body's location
CreateEntity("frozen_sniper", bodyx, "sniperfreeze") --spawns the frozen playermodel
end
end
)
Why isn't it finding the entity when I have the proper ODFs in the world's odf folder and the msh's in the msh folder? What's the problem with the CreateEntity line?
In order for them to work you have to load them somewhere else, ie actually place them somewhere else in the world, or have them load as a side (not playable though, just loaded) - then it should work. I do this with my Mario Party Minigame to get the indicator spheres to spawn.