Page 1 of 1

Freeze Nade

Posted: Wed Jun 17, 2009 5:46 pm
by Fiodis
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?

Re: Freeze Nade

Posted: Wed Jun 17, 2009 5:56 pm
by Frisbeetarian
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).

CreateEntity( config, matrix )

Re: Freeze Nade

Posted: Wed Jun 17, 2009 6:05 pm
by Fiodis
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

Code: Select all

CreateEntity("odf_name", path_point, "something_that_I_assume_is_the_ZE_name")
rather than

Code: Select all

CreateEntity(config, matrix)

(Config, Matrix) would be much more convenient, though....

Re: Freeze Nade

Posted: Wed Jun 17, 2009 7:21 pm
by Frisbeetarian
Whoops, my default search is in the shell Lua files, so how I mentioned it is how they are used there. Sorry for the hasty accusation.

As to the campaign scripts, they are using the same function with a third parameter added.
The second parameter is still a matrix

Code: Select all

        Holocron1Spawn = GetPathPoint("holocronspawn_a", 0) 
        CreateEntity("cor1_item_holocron", Holocron1Spawn, "holocron1")
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.

Re: Freeze Nade

Posted: Wed Jun 17, 2009 7:41 pm
by Fiodis
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):

Code: Select all

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "10" not found
The newest version of code:

Code: Select all

	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?

Re: Freeze Nade

Posted: Fri Jun 26, 2009 2:06 pm
by theITfactor
Fiodis wrote:
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):

Code: Select all

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "10" not found
The newest version of code:

Code: Select all

	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.