Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. var debug = false;
  2.  
  3. enum itemType { thrown, oneHanded, twoHanded, polearm, firearm, bow, xbow, headArmour, bodyArmour, legArmour, handArmour, horse, shield, ammo, misc };
  4. enum dmgType { blunt, cut, pierce, pure, magic };
  5. enum att { str, agi, _int, cha };
  6.  
  7. var itemList = Array(
  8. //Thrown wpn item Id itemName mesh defaultPrice projectileSize weight(kg) itemType atacks dmg dmgType. dmg speed blank blank blank
  9. Array( "stone", "Stone", "stoneMeshItem", 1, 4.5, 0.425, itemType.thrown, Array( Array( dmgType.blunt, 8, 85), 0, 0, 0) ),
  10. Array( "potato", "Potato", "potatoMeshItem", 15, 4.5, 0.225, itemType.thrown, Array( Array( dmgType.blunt, 5, 100), 0, 0, 0) ),
  11. //Melee wpn item Id itemName mesh defaultPrice range(cm) weight(kg) itemType atacks Up dmgType. dmg speed Down dmgType. dmg speed Left dmgType. dmg speed Right dmgType. dmg speed
  12. Array( "swordGoodA", "Knightly Sword", "swordMeshA", 3725, 102, 1.133, itemType.oneHanded, Array( Array( dmgType.cut, 35, 150), Array( dmgType.pierce, 25, 110), Array( dmgType.cut, 30, 130), Array( dmgType.cut, 30, 130)) ),
  13. Array( "pitchforkA", "Pitchfork", "pitchforkMeshA", 350, 190, 2.5, itemType.polearm, Array( Array( dmgType.blunt, 15, 50), Array( dmgType.pierce, 15, 70), 0, 0) ),
  14. Array( "scytheA", "Scythe", "scytheMeshA", 470, 230, 3.225, itemType.polearm, Array( Array( dmgType.cut, 20, 55), Array( dmgType.pierce, 25, 25), Array( dmgType.cut, 30, 50), Array( dmgType.cut, 30, 50)) ),
  15. //Armours item Id itemName mesh defaultPrice range(cm) weight(kg) itemType defense Forearm + Hand phisical magical fall Head phisical magical fall Body phisical magical fall Legs phisical magical fall
  16. Array( "crownA", "Crown", "crownA", 7500, 5, 3.5, itemType.headArmour,Array( Array( 15, 0, 0), Array( 15, 0, 0), Array( 15, 0, 0), Array( 15, 0, 0)) ),
  17. //Misc item Id itemName mesh defaultPrice size(cm) weight(kg) itemType BLANK blank blank blank blank
  18. Array( "coinGold", "Gold Coin", "coinGold", 1000, 5, 0.1, itemType.misc, Array( 0, 0, 0, 0) ),
  19. Array( "coinSilver", "Silver Coin", "coinSilver", 100, 4, 0.75, itemType.misc, Array( 0, 0, 0, 0) ),
  20. Array( "coinCopper", "Copper Coin", "coinCopper", 10, 2.5, 0.05, itemType.misc, Array( 0, 0, 0, 0) ),
  21. Array( "coinSmall", "Small Coin", "coinSmall", 1, 1, 0.01, itemType.misc, Array( 0, 0, 0, 0) )
  22. );
  23.  
  24. var troopList = Array(
  25. // troop Id troopName namePlural stats
  26. // inventory itemID quantity ...
  27. Array( "peasant1", "Peasant", "Peasants", Array(Array(att.str, 13),Array(att.agi, 13),Array(att._int, 13),Array(att.cha, 13)),
  28. Array(Array("potato", 15), Array("pitchforkA", 1), Array("coinSmall", 10)) ),
  29. Array( "peasant2", "Peasant", "Peasants", Array(Array(att.str, 17),Array(att.agi, 17),Array(att._int, 17),Array(att.cha, 17)),
  30. Array(Array("stone", 5), Array("scytheA", 1), Array("coinSmall", 15)) ),
  31. Array( "lord1", "King", "The King", Array(Array(att.str, 30),Array(att.agi, 30),Array(att._int, 30),Array(att.cha, 30)),
  32. Array(Array("crownA", 1), Array("swordGoodA", 1), Array("coinGold", 150)))
  33. );
  34.  
  35. // i.e: Item("potato"); will return the array in itemList which has "potato" as the ID
  36. function Item ( itemID ) {
  37. var theItem = -1;
  38. var i = 0;
  39. while (i < itemList.length);
  40. {
  41. if (theItem == -1 && itemList[i][0] == itemID)
  42. {
  43. theItem = itemList[i];
  44. }
  45. i++;
  46. }
  47. return(theItem);
  48. }
  49.  
  50. // i.e: Troop("peasant1"); will return the array in troopList which has "peasant1" as the ID
  51. function Troop ( troopID ) {
  52. var theTroop = -1;
  53. var i = 0;
  54. while (i < troopList.length)
  55. {
  56. if (theTroop == -1 && troopList[i][0] == troopID)
  57. {
  58. theTroop = troopList[i];
  59. }
  60. i++;
  61. }
  62. return(theTroop);
  63. }
  64.  
  65. function GetInventoryWeight ( troop ) {
  66. var troopInventory = troop[4];
  67. var inventoryWeight = 0;
  68. var item;
  69. var itemWeight;
  70. if ( troopInventory.lenght > 0 )
  71. {
  72. var i = 0;
  73. while ( i < troopInventory.lenght )
  74. {
  75. item = troopInventory[i][0];
  76. itemWeight = item[5];
  77. if ( itemWeight > 0 && troopInventory[i][1] > 0 )
  78. {
  79. itemWeight *= troopInventory[i][1];//quantity of the item
  80. inventoryWeight += itemWeight;
  81. }
  82. i++;
  83. }
  84. }
  85. print ( "Troop " + troop[1] + " inventory weight is " + inventoryWeight);
  86.  
  87. }
  88.  
  89. function Start () {
  90.  
  91. }
  92.  
  93. function Update () {
  94. var troop = 0;
  95. if ( troopList.lenght > 0)
  96. {
  97. while ( troop < troopList.lenght )
  98. {
  99. GetInventoryWeight(troop);
  100. troop++;
  101. }
  102. }
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement