Dibelius 0 Report post Posted October 11, 2007 (edited) Original Tutorial adapted from german mod community www.thundermods.net Author: ThunderX86 Special Thanks to: Bibber ================================================================================ As the original buildings of CNC3 do not use sell animations, there are no tags to insert such a sell animation for buildings. But you can do it with some tricks. Requirements for this tutorial: Experience in 3DSMax An almost finished building which already has got models for DAMAGED and REALLYDAMAGED ConditionStates (Code + models) To avoid the play of the pristine building animation only on a certain damaged state, you have to create an animation for all other ConditionStates (DAMAGED, REALLYDAMAGED) besides the animation for the pristine building. Note, that you put all sell animations into one model here! This tutorial doesn't explain how to do that. Once you have exported the model you can adjust the building's code. Search for the following tag in the XML of this building: SlowDeath This Tag could look like this, for instance (adapted of Nod power plant): <SlowDeath id="ModuleTag_Death" SinkDelay="3.0s" SinkRate="4.0" DestructionDelay="8.0s"> <Sound Type="INITIAL" List="HumanFaction_MediumBuilding_DieMS" /> <DieMuxData DeathTypes="ALL" /> </SlowDeath> Change this code as below: <SlowDeath id="ModuleTag_Death" SinkDelay="3.0s" SinkRate="4.0" DestructionDelay="8.0s" DeathFlags="DEATH_1"> <Sound Type="INITIAL" List="HumanFaction_MediumBuilding_DieMS" /> <DieMuxData DeathTypes="ALL" DeathTypesForbidden="SUICIDED" /> </SlowDeath> This modified code of the DieMuxData tag indentifies it for all death types, except for SUICIDED. The type SUICIDED is used for the sell animation later. Furthermore, you specify a flag called DEATH_1 for this death module. So, the whole SlowDeath tag only handles normal destructions caused by generic attacks. Now you need an additional SlowDeath tag which handles only the selling of the building. The code can look like this: <SlowDeath id="ModuleTag_DeathSold" DestructionDelay="2.0s" DeathFlags="DEATH_2"> <DieMuxData DeathTypes="SUICIDED" /> </SlowDeath> Please note the following: DestructionDelay should be set to a time which matches the actual animation time. Unlike for the default death module, another flag called DEATH_2 is set here. These two flags define whether the animation of the default death or the one of the sell animation will be played. Next, you need to define the models and animations in the code. Search for the ScriptedModelDraw tag (often there are more than only 1, so you have to edit all the relevant ones). Here you will find several ModelConditionState and AnimationState tags. Normally, you will find the following ModelConditionStates: STRUCTURE_UNPACKING, DAMAGED, REALLYDAMAGED and DYING. Since we have set the flags DEATH_1 and DEATH_2 for the different death types, we can now get rid of DYING. Change all the ModelConditionState(s) and AnimationState(s) which use DYING in the "ConditionYes" attribute, and replace DYING with DEATH_1. Now we add a new ModelConditionState DEATH_2: <!-- SELLING MODEL --> <ModelConditionState ParseCondStateType="PARSE_NORMAL" ConditionsYes="DEATH_2"> <Model Name="BuildingID_SOLD" /> <!-- BuildingID_SOLD = file name of the selling animation --> </ModelConditionState> Now make sure that the DAMAGED and REALLYDAMAGED animations have got a valid "StateName". Search for the AnimationState tags for the two ConditionStates (DAMAGED and REALLYDAMAGED). Note the DAMAGED animation gets the StateName "STATE_Damaged" and the REALLYDAMAGED animation "STATE_ReallyDamaged" (makes the handling easier). Example: <AnimationState ParseCondStateType="PARSE_NORMAL" ConditionsYes="REALLYDAMAGED" StateName="STATE_ReallyDamaged"> Everything else can be kept as it is. Finally, only the new AnimationState is missing for the selling animation. Note, that the models/animations for the pristine, DAMAGED and REALLYDAMAGED buildings are all in one model. That's why we have to show/hide the fitting "SubObjects" depending on the current state. That works via Script tag of the AnimationState. Here an example code fragment how to use it: <!-- SELL ANIMATION --> <AnimationState ParseCondStateType="PARSE_NORMAL" ConditionsYes="DEATH_2"> <Animation AnimationName="BuildingID_SOLD" AnimationMode="ONCE" /> <script> Prev = CurDrawablePrevAnimationState(); if Prev == "STATE_ReallyDamaged" then CurDrawableHideSubObject("OBJ1_DAMAGED") CurDrawableHideSubObject("OBJ2_DAMAGED") CurDrawableHideSubObject("OBJ1_PRISTINE") CurDrawableHideSubObject("OBJ2_PRISTINE") elseif Prev == "STATE_Damaged" then CurDrawableHideSubObject("OBJ1_REALLYDAMAGED") CurDrawableHideSubObject("OBJ2_REALLYDAMAGED") CurDrawableHideSubObject("OBJ1_PRISTINE") CurDrawableHideSubObject("OBJ2_PRISTINE") else CurDrawableHideSubObject("OBJ1_REALLYDAMAGED") CurDrawableHideSubObject("OBJ2_REALLYDAMAGED") CurDrawableHideSubObject("OBJ1_DAMAGED") CurDrawableHideSubObject("OBJ2_DAMAGED") end </Script> </AnimationState> Short explanation of the used script for the selling animation: Normally, all objects of a model are shown to the player. You can either use 3D Studio Max or directly the W3X file (open it with a standard text editor) to get the object's names. The engine checks the previous state of the building and hides all non-relevant objects then to keep only the right ones visible. Therefore the states STATE_Damaged and STATE_ReallyDamaged are checked which you have defined in the AnimationStates before. ================================================================================ Well, I hope I didn't do total shit with the translation... if you unable to figure out what something means, please ask. Edited October 12, 2007 by Dibelius Share this post Link to post Share on other sites