Page 1 of 1

Linked kill object = texture change?

Posted: Sun Feb 20, 2011 12:40 am
by fasty
Is it possible to rig it so on the destruction of an object, another objects texture changes?
I'd assume it would go something like this:
Hidden/Spoiler:
[code]killobjc = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "ObjectIKill" then
<InsertCodeThatChangesTextureHere>
end
end
)[/code]

Re: Linked kill object = texture change?

Posted: Sun Feb 20, 2011 1:10 pm
by Firefang
You have to spawn a new object with the changed texture.

Re: Linked kill object = texture change?

Posted: Wed Feb 23, 2011 10:35 am
by DarthD.U.C.K.
no, you dont have to, you can do it by loading a new texture with the same name into memory
how to switch textures through lua:
1. make a side "textures" and the according folder in _BUILD\Sides\ with the munge.bat and clean.bat in it.
2. make an "msh"-folder in the data_XXX\Sides\Texture folder and put in all textures.
3.1 change the texture(s) once:
make a "textures.req" file with this in it:

Code: Select all

ucft
{
	REQN
	{
	
		"texture"
		"texturename1"
		"texturename2" etc.
	}
}
in your lua, put that in your triggerfunction:

Code: Select all

ReadDataFile("DC:SIDE\\textures.lvl")
3.2 change textures and change them back or change different textures on different events:
make a "textures.req" with this in it

Code: Select all

ucft
{
	REQN
	{
	
		"lvl"
		"texturepack1"
		"texturepack2" etc.
	}
}
make a "req" folder in your sides folder and for each pack listed in the "textures.req"
make a new reqfile called "texturepack1.req" and so on, in each put:

Code: Select all

ucft
{
	REQN
	{
	
		"texture"
		"texturename1"
		"texturename2" etc.
	}
}
in your lua you can now trigger the change by putting this in your function:

Code: Select all

					ReadDataFile("DC:SIDE\\textures.lvl",
								"texturepack1")
and so on.

Re: Linked kill object = texture change?

Posted: Wed Feb 23, 2011 11:43 am
by fasty
Thanks I knew there was SOME way to do it. :wink: That's very clever.

Re: Linked kill object = texture change?

Posted: Wed Feb 23, 2011 11:48 am
by DarthD.U.C.K.
thanks :D
i think you can change mshs and odfs through this too, but im not sure. i tried it with an odf once and it atleast gave some kind of respose (geometry not found :P)

Re: Linked kill object = texture change?

Posted: Wed Feb 23, 2011 7:08 pm
by AceMastermind
fasty wrote:...

Code: Select all

killobjc = OnObjectKill(
   function(object, killer)
      if GetEntityName(object) == "ObjectIKill" then
      <InsertCodeThatChangesTextureHere>
      end
   end
)
What kind of code do you plan to use that actually changes the object's texture? I don't see any properties that can do this for any object. I'm no programmer but I think Firefang may be right. The instructions provided by DarthD.U.C.K. is basically what Syth describes HERE as a "skin side". This thread can't be solved until you have something that works like it should.

Re: Linked kill object = texture change?

Posted: Wed Feb 23, 2011 9:19 pm
by fasty
So far I've gotten my unit to change weapons on object destruction, but I'm still working on a texture change. I don't really know what to put in place of WeaponName1 that will change the texture. Everything I've tried either doesn't work or crashes. :? Changing the geometry causes a crash just like Duck said it would.
Hidden/Spoiler:
[code]killobjc = OnObjectKill(
function(object, killer)
if GetEntityName(object) == "dea1_prop_panel" then
SetClassProperty("rep_inf_ep3_rifleman", "WeaponName1", "rep_weap_inf_emp_launcher")
end
end
)[/code]

Re: Linked kill object = texture change?

Posted: Wed Feb 23, 2011 11:28 pm
by Firefang
You would have to change the unit's msh to change texture. I was working on this a while ago, which proves that a msh can be swapped ingame.

Re: Linked kill object = texture change?

Posted: Thu Feb 24, 2011 12:43 pm
by DarthD.U.C.K.
i tried overriding a msh via sideloading and it complained about model being loaded already.
loading an odf didnt give me an error but i think you have to respawn a prop to get it to use the new odf (if that works)

anyway, like firefang said, you can change the texture by changing the units model with setproperty.
there is however a difference between changing the "odf" of the unit and the texture itself.
if you change the odf with setproperty, it will apply to all units that are spawned after the change was made
if you change it by overriding a texture in the memory, it will apply to all units.
to change the texture in memory, put "ReadDataFile("DC:SIDE\\textures.lvl")" instead of the setpropertyline in the function.