[Tutorial] Simulate cell item construction stages

Post your mods and custom content here

[Tutorial] Simulate cell item construction stages

Postby smithforge » Sun Sep 30, 2012 6:39 pm

Simulating Building Stages

The following is a spinoff from my chicken experiments. As I have not seen anything similar around (I assume the sticky Mod List also maintains all the existing tutorials?), I would like to share it with fellow modders.

This is a trick that utilizes the fact that action queues for placing item assumes that the first <createItem> tag to be the one for the item to be placed. I don't know if this is intended behavior or a bug, but as long as it is around, we can use the following trick to simulate gradual building up of an item.


The actual sequence is shown in the following image slides (with the sample action script further below)

Image

Extended transcript: (just in case image doesn't load)
1. Started by placing the item (via right menu)
2. The action queue can go through the acting of gathering raw materials and visiting the workbenches
3. But instead of creating the intended item as the last step, create a dummy item (with different gfx) instead.
4. Due to current action processing, the first createItem is assumed to be the item required and the citizen will bring the dummy item and place it at the final spot. The action queue continues with more steps however.
5. (optional) after the createItem statement, we can create other items in the citizen hand as props (in this example, I created a stone hammer). Just remember to destroy it later before the action queue ends.
6,7,8. use <replaceCellItem> to replace the placed dummy item with other items that is intended to show the stages of construction (obviously with different graphics). Remember a little to wait between. (My method is simply to divide the original intended total construction time between the stages, so that the total time is the same)
9. As a final step, use <replaceCellItem> with the ACTUAL item originally intended to be built. Remember to get rid of any props created.


This is my definition of the action for constructing the chicken coop
Code: Select all
   <!-- Chicken Coop -->
   <action>
      <id>qConstructChickenCoopOpen</id>      
      <priorityID>itemconstruction</priorityID>
      <name>Construct Chicken Coop(Open)</name>
      <generatedItem>iChickenCoopOpen</generatedItem>
      <queue>
         <pick>rmwood</pick>
         <move>carpentrybench</move>
         <wait>20</wait>
         <destroyItem />
         <pick>rmwood</pick>
         <move>carpentrybench</move>
         <wait>20</wait>
         <destroyItem />
         <unlock />
         <pick>rmwood</pick>
         <move>wooddetailer</move>
         <wait>20</wait>
         <destroyItem />
         <createItem>iChickenCoopBuildingStage00</createItem>
         <wait>5</wait>
         <createItem>stonehammer</createItem> <!-- pretend to build -->
         <wait>5</wait>
         <replaceCellItem>iChickenCoopBuildingStage01</replaceCellItem>
         <wait>10</wait>
         <replaceCellItem>iChickenCoopBuildingStage02</replaceCellItem>
         <wait>10</wait>
         <replaceCellItem>iChickenCoopBuildingStage03</replaceCellItem>
         <wait>10</wait>
         <replaceCellItem>iChickenCoopOpen</replaceCellItem>
         <destroyItem />
      </queue>
   </action>



We can also do the same for "deconstruction" by just reversing the sequence of cell item replacements finished by a <destroyCellItem/>
Code: Select all
   <action>
      <id>qDeconstructChickenCoop</id>      
      <priorityID>itemconstruction</priorityID>
      <name>Deconstruct</name>
      <queue>
         
         <move useSource="true">iChickenCoopOpen,iChickenCoopClosed</move>
         <wait>5</wait>
         <createItem>stonehammer</createItem> <!-- pretend to build -->
         <wait>10</wait>
         <replaceCellItem>iChickenCoopBuildingStage03</replaceCellItem>
         <wait>10</wait>
         <replaceCellItem>iChickenCoopBuildingStage02</replaceCellItem>
         <wait>10</wait>
         <replaceCellItem>iChickenCoopBuildingStage01</replaceCellItem>
         <wait>10</wait>
         <destroyCellItem/>
         <destroyItem/>
      </queue>
   </action>


Hope this can be useful to somebody.
smithforge
 
Posts: 222
Joined: Mon Sep 24, 2012 3:23 pm

Re: [Tutorial] Simulate cell item construction stages

Postby supermalparit » Sun Sep 30, 2012 6:41 pm

I LOVE vodoo scripting!
Xavi Canal
Image
User avatar
supermalparit
Towns team
 
Posts: 2444
Joined: Thu Oct 27, 2011 11:57 pm


Return to Modding

Who is online

Users browsing this forum: No registered users and 3 guests

cron