Advertisement
Guest User

Untitled

a guest
Mar 7th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. CONSTRUCTION.as
  2.  
  3. void addSupportShipConstruction(Object& obj, int id, const Design@ dsg, uint amount) {
  4. int index = shipConsIndex(id);
  5. if(index == -1)
  6. return;
  7. ShipConstructible@ cons = cast<ShipConstructible>(queue[index]);
  8. if(cons is null)
  9. return;
  10.  
  11. uint maxAmount = floor(cons.getSupportSupplyFree() / pow(dsg.size,0.6)); //SCALING
  12.  
  13.  
  14. amount = min(amount, maxAmount);
  15. if(amount == 0)
  16. return;
  17.  
  18. int cost = getBuildCost(dsg, amount);
  19. int take = obj.owner.consumeBudget(cost, true);
  20. if(take == -1)
  21. return;
  22.  
  23. if(!cons.addSupports(obj, dsg, amount, cycle=take))
  24. obj.owner.refundBudget(cost, take);
  25.  
  26. int maint = getMaintenanceCost(dsg, amount);
  27. cons.maintainCost += maint;
  28. cons.buildCost += cost;
  29.  
  30. if(cons.started)
  31. obj.owner.modMaintenance(maint, MoT_Construction);
  32.  
  33. deltaConstruction = true;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement