Advertisement
Guest User

Untitled

a guest
Nov 17th, 2013
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 19.89 KB | None | 0 0
  1. ////////////////////////////////////////
  2. //  Salvage Mod                Truce  //
  3. ////////////////////////////////////////
  4.  
  5. package Salvage
  6. {
  7.     function hammerImage::onFire(%this,%obj,%slot)
  8.     {
  9.         %time = getSimTime();
  10.        
  11.         if(%obj.lastSwingTime + 190 > %time)
  12.             return;
  13.        
  14.         %obj.lastSwingtime = %time;
  15.        
  16.         %ep   = %obj.getEyePoint();
  17.         %ev   = %obj.getEyeVector();
  18.         %add  = vectorAdd(%ep,vectorScale(%ev,5));
  19.         %type = $TypeMasks::fxBrickObjectType | $TypeMasks::PlayerObjectType;
  20.        
  21.         %ray = containerRaycast(%ep,%add,%type,%obj);
  22.         %col = getWord(%ray,0);
  23.        
  24.         if(!isObject(%col))
  25.             return;
  26.        
  27.         %cl   = %obj.client;
  28.         %type = %col.getClassName();
  29.         %pos  = posFromRaycast(%ray);
  30.        
  31.         %proj = new Projectile()
  32.         {
  33.             datablock       = hammerProjectile;
  34.             initialVelocity = "0 0 0";
  35.             initialPosition = %pos;
  36.             sourceObject    = %obj;
  37.             sourceSlot      = %slot;
  38.             client          = %cl;
  39.         };
  40.        
  41.         MissionCleanup.add(%proj);
  42.        
  43.         switch$(%type)
  44.         {
  45.             case "fxDTSBrick":
  46.                 if(%col.willCauseChainKill() || %col.getName() $= "_static")
  47.                     return;
  48.                
  49.                 %data  = %col.getDatablock();
  50.                 %sizex = %data.brickSizeX;
  51.                 %sizey = %data.brickSizeY;
  52.                 %sizez = %data.brickSizeZ;
  53.                 %vol   = %sizex * %sizey * %sizez;
  54.                
  55.                 if(%vol > 180)
  56.                     return;
  57.                
  58.                 for(%i = 0; %i < 10; %i++)
  59.                 {
  60.                     if(%cl.inventory[%i] $= "")
  61.                         break;
  62.                 }
  63.                
  64.                 if(%i == 10)
  65.                 {
  66.                     %cl.centerPrint("<color:FF0000>Your pack is full!",2);
  67.                     return;
  68.                 }
  69.                
  70.                 %normal = max(1,mFloor(%vol / 3));
  71.                 %health = %col.health--;
  72.                
  73.                 if(%health == -1)
  74.                 {
  75.                     %col.health += %normal;
  76.                     %health     += %normal;
  77.                 }
  78.                
  79.                 %cl.centerPrint("<color:00FF00>Health: " @ %health,1);
  80.                
  81.                 if(%health)
  82.                     return;
  83.                
  84.                 %cl.salvaged[%i]  = Salvage_Input(%col);
  85.                 %cl.inventory[%i] = %data;
  86.                 %cl.color[%i]     = %col.getColorID();
  87.                
  88.                 %col.killBrick();
  89.                 serverCmdBuyBrick(%cl);
  90.            
  91.             case "Player":
  92.                 %db = %col.getDatablock();
  93.                 %db.damage(%col,%obj,%pos,10,$DamageType::HammerDirect);
  94.         }
  95.     }
  96.    
  97.     function hammerImage::onHitObject(%this)
  98.     {
  99.     }
  100.    
  101.     function wrenchImage::onFire(%this,%obj,%slot)
  102.     {
  103.         %time = getSimTime();
  104.        
  105.         if(%obj.lastSwingTime + 540 > %time)
  106.             return;
  107.        
  108.         %obj.lastSwingtime = %time;
  109.        
  110.         %ep   = %obj.getEyePoint();
  111.         %ev   = %obj.getEyeVector();
  112.         %add  = vectorAdd(%ep,vectorScale(%ev,5));
  113.         %type = $TypeMasks::fxBrickObjectType | $TypeMasks::PlayerObjectType;
  114.        
  115.         %ray = containerRaycast(%ep,%add,%type,%obj);
  116.         %col = getWord(%ray,0);
  117.        
  118.         if(!isObject(%col))
  119.             return;
  120.        
  121.         %cl   = %obj.client;
  122.         %type = %col.getClassName();
  123.        
  124.         %proj = new Projectile()
  125.         {
  126.             datablock       = wrenchProjectile;
  127.             initialVelocity = "0 0 0";
  128.             initialPosition = posFromRaycast(%ray);
  129.             sourceObject    = %obj;
  130.             sourceSlot      = %slot;
  131.             client          = %cl;
  132.         };
  133.        
  134.         MissionCleanup.add(%proj);
  135.        
  136.         switch$(%type)
  137.         {
  138.             case "fxDTSBrick":
  139.                 if(%col.getName() $= "_static")
  140.                     return;
  141.                
  142.                 %data  = %col.getDatablock();
  143.                 %sizex = %data.brickSizeX;
  144.                 %sizey = %data.brickSizeY;
  145.                 %sizez = %data.brickSizeZ;
  146.                 %vol   = %sizex * %sizey * %sizez;
  147.                
  148.                 if(%vol > 180)
  149.                     return;
  150.                
  151.                 %normal = max(1,mFloor(%vol / 3));
  152.                 %boost  = mCeil(1.5 * %normal);
  153.                 %health = %col.health++;
  154.                
  155.                 if(%health == 1)
  156.                 {
  157.                     %col.health += %normal;
  158.                     %health     += %normal;
  159.                 }
  160.                
  161.                 if(%health > %boost)
  162.                 {
  163.                     %col.health = %boost;
  164.                     %health     = %boost;
  165.                 }
  166.                
  167.                 %cl.centerPrint("<color:FFFF00>Health: " @ %health,1);
  168.            
  169.             case "Player":
  170.                 %dmg  = %col.getDamageLevel() - 10;
  171.                 %buff = %col.overheal;
  172.                
  173.                 if(%dmg < 0)
  174.                 {
  175.                     %buff += -1 * %dmg;
  176.                     %dmg   = 0;
  177.                    
  178.                     if(%buff > 50)
  179.                         %buff = 50;
  180.                    
  181.                     %col.overheal = %buff;
  182.                 }
  183.                
  184.                 %col.setDamageLevel(%dmg);
  185.                 %cl.centerPrint("<color:FF8000>Health: " @ 100 - mFloor(%col.getDamageLevel()) @ " + " @ mCeil(%buff),1);
  186.         }
  187.     }
  188.    
  189.     function wrenchImage::onHitObject(%this)
  190.     {
  191.     }
  192.    
  193.     function serverCmdBuyBrick(%cl)
  194.     {
  195.         for(%i = 0; %i < 10; %i++)
  196.         {
  197.             %db = %cl.inventory[%i];
  198.            
  199.             if(%db $= "")
  200.                 %db = -1;
  201.            
  202.             Parent::serverCmdBuyBrick(%cl,%i,%db);
  203.             messageClient(%cl,'MsgSetInvData',"",%i,%db);
  204.         }
  205.     }
  206.    
  207.     function servercmdUseInventory(%cl,%i)
  208.     {
  209.         if(%i < 0 || %i > 9)
  210.             return;
  211.        
  212.         %pl = %cl.player;
  213.         %so = %cl.salvaged[%i];
  214.        
  215.         if(!isObject(%pl))
  216.             return;
  217.        
  218.         if(!isObject(%so))
  219.         {
  220.             %cl.inventory[%i] = "";
  221.             serverCmdBuyBrick(%cl);
  222.            
  223.             return;
  224.         }
  225.        
  226.         %temp            = %pl.tempBrick;
  227.         %color           = %cl.color[%i];
  228.         %cl.currentColor = %color;
  229.        
  230.         if(isObject(%temp))
  231.             %temp.setColor(%color);
  232.        
  233.         serverCmdInstantUseBrick(%cl,%cl.inventory[%i],"\x90");
  234.        
  235.         %cl.currInv     = %i;
  236.         %cl.currInvSlot = %i;
  237.     }
  238.    
  239.     function serverCmdInstantUseBrick(%cl,%db,%hash)
  240.     {
  241.         if(%hash !$= "\x90")
  242.             return;
  243.        
  244.         Parent::serverCmdInstantUseBrick(%cl,%db);
  245.     }
  246.    
  247.     function serverCmdPlantBrick(%cl)
  248.     {
  249.         %slot  = %cl.currInv;
  250.         %so    = %cl.salvaged[%slot];
  251.         %brick = Salvage_Output(%so,%cl);
  252.        
  253.         if(!isObject(%brick))
  254.             return;
  255.        
  256.         %cl.salvaged[%slot]  = "";
  257.         %cl.inventory[%slot] = "";
  258.         %cl.instantUseData   = "";
  259.        
  260.         serverCmdCancelBrick(%cl);
  261.         serverCmdBuyBrick(%cl);
  262.        
  263.         %so.delete();
  264.     }
  265.    
  266.     function serverCmdDropTool(%cl,%i)
  267.     {
  268.         if(%i < 0 || %i > 9)
  269.             return;
  270.        
  271.         %pl   = %cl.player;
  272.         %slot = %cl.currInv;
  273.        
  274.         if(!isObject(%pl))
  275.             return;
  276.        
  277.         if(%slot == -1)
  278.         {
  279.             Parent::serverCmdDropTool(%cl,%i);
  280.             return;
  281.         }
  282.        
  283.         %i   = %cl.currInv;
  284.         %so  = %cl.salvaged[%i];
  285.         %inv = %cl.inventory[%i];
  286.        
  287.         if(!isObject(%so))
  288.         {
  289.             %cl.inventory[%i] = "";
  290.             serverCmdBuyBrick(%cl);
  291.            
  292.             return;
  293.         }
  294.        
  295.         %ep   = %pl.getEyePoint();
  296.         %ev   = %pl.getEyeVector();
  297.         %add  = vectorAdd(%ep,vectorScale(%ev,1.1));
  298.         %type = $TypeMasks::fxBrickObjectType     | $TypeMasks::InteriorObjectType |
  299.                 $TypeMasks::StaticShapeObjectType | $TypeMasks::StaticTSObjectType;
  300.        
  301.         %ray = containerRaycast(%ep,%add,%type);
  302.         %col = getWord(%ray,0);
  303.         %dir = 1;
  304.        
  305.         if(isObject(%col))
  306.         {
  307.             %add = vectorAdd(%ep,vectorScale(%ev,-1.1));
  308.             %ray = containerRaycast(%ep,%add,%type);
  309.             %col = getWord(%ray,0);
  310.             %dir = -1;
  311.            
  312.             if(isObject(%col))
  313.                 return;
  314.         }
  315.        
  316.         %obj = new Item()
  317.         {
  318.             datablock = brickItem;
  319.             position  = vectorAdd(%ep,vectorScale(%ev,%dir));
  320.             index     = $Salvage::Index++;
  321.             inventory = %inv;
  322.             color     = %cl.color[%i];
  323.         };
  324.        
  325.         MissionCleanup.add(%obj);
  326.        
  327.         $Salvage::Drop[$Salvage::Index] = %so;
  328.        
  329.         %cl.salvaged[%i]  = "";
  330.         %cl.inventory[%i] = "";
  331.        
  332.         for(%i = 0; %i !$= ""; %i++)
  333.         {
  334.             %line = %so.data[%i];
  335.            
  336.             if(%line $= "")
  337.             {
  338.                 %name = %inv.uiName;
  339.                
  340.                 %obj.schedule(120000,delete);
  341.                 break;
  342.             }
  343.            
  344.             if(getField(%line,0) $= "+-EVENT")
  345.                 continue;
  346.            
  347.             %type = getWord(%line,0);
  348.             %data = getWords(%line,1);
  349.             %pos  = strPos(%data,"\"");
  350.             %name = getSubStr(%data,0,%pos);
  351.            
  352.             switch$(%type)
  353.             {
  354.                 case "+-ITEM":    break;
  355.                 case "+-VEHICLE": break;
  356.             }
  357.         }
  358.        
  359.         %obj.setShapeName(%name);
  360.         %obj.setVelocity(vectorScale(%ev,getRandom(5,15) * %dir));
  361.        
  362.         serverCmdCancelBrick(%cl);
  363.         serverCmdBuyBrick(%cl);
  364.     }
  365.    
  366.     function serverCmdUseTool(%cl,%i)
  367.     {
  368.         Parent::serverCmdUseTool(%cl,%i);
  369.         %cl.currInv = -1;
  370.     }
  371.    
  372.     function GameConnection::onClientEnterGame(%this)
  373.     {
  374.         Parent::onClientEnterGame(%this);
  375.         Salvage_Minigame.addMember(%this);
  376.     }
  377.    
  378.     function GameConnection::getSpawnPoint(%this)
  379.     {
  380.         %brick = %this.checkpointBrick;
  381.        
  382.         if(isObject(%brick))
  383.             return %brick.getSpawnPoint();
  384.        
  385.         return Parent::getSpawnPoint(%this);  
  386.     }
  387.    
  388.     function GameConnection::onDeath(%this,%a,%cl,%b,%c)
  389.     {
  390.         %this.currInv = -1;
  391.        
  392.         for(%i = 0; %i < 5; %i++)
  393.             serverCmdDropTool(%this,%i);
  394.        
  395.         for(%i = 0; %i < 10; %i++)
  396.         {
  397.             %this.currInv = %i;
  398.             serverCmdDropTool(%this);
  399.         }
  400.        
  401.         Parent::onDeath(%this,%a,%cl,%b,%c);
  402.         bottomPrint(%this,"<just:center><color:FF8000>Health: 0 + 0");
  403.     }
  404.    
  405.     function GameConnection::onClientLeaveGame(%this)
  406.     {
  407.         %pl = %this.player;
  408.        
  409.         if(isObject(%pl))
  410.         {
  411.             %this.currInv = -1;
  412.            
  413.             for(%i = 0; %i < 5; %i++)
  414.                 serverCmdDropTool(%this,%i);
  415.            
  416.             for(%i = 0; %i < 10; %i++)
  417.             {
  418.                 %this.currInv = %i;
  419.                 serverCmdDropTool(%this);
  420.             }
  421.         }
  422.        
  423.         Parent::onClientLeaveGame(%this);
  424.     }
  425.    
  426.  
  427.     function Armor::damage(%this,%obj,%proj,%pos,%dmg,%type)
  428.     {
  429.         %crouch = %obj.isCrouched();
  430.         %buff   = %obj.overheal;
  431.        
  432.         if(%crouch)
  433.             %dmg *= 2.1;
  434.        
  435.         if(%buff > 0)
  436.         {
  437.             %buff -= %dmg;
  438.             %dmg   = 0;
  439.            
  440.             if(%buff < 0)
  441.             {
  442.                 %dmg += -1 * %buff;
  443.                 %buff = 0;
  444.             }
  445.            
  446.             %obj.overheal = %buff;
  447.         }
  448.        
  449.         if(%dmg)
  450.         {
  451.             if(%crouch)
  452.                 %dmg /= 2.1;
  453.            
  454.             Parent::damage(%this,%obj,%proj,%pos,%dmg,%type);
  455.         }
  456.     }
  457.  
  458.    
  459.     function getTrustLevel(%a,%b)
  460.     {
  461.         return 2;
  462.     }
  463.    
  464.     function serverCmdUndoBrick(%cl)
  465.     {
  466.     }
  467.    
  468.     function serverCmdClearBricks(%cl)
  469.     {
  470.     }
  471.    
  472.     function serverCmdClearAllBricks(%cl)
  473.     {
  474.     }
  475.    
  476.     function serverCmdClearBrickGroup(%cl)
  477.     {
  478.     }
  479.    
  480.     function serverCmdMagicWand(%cl)
  481.     {
  482.     }
  483.    
  484.     function serverCmdInitUploadHandshake(%cl)
  485.     {
  486.     }
  487.    
  488.     function serverCmdReloadBricks(%cl)
  489.     {
  490.     }
  491.    
  492.     function serverCmdCreateMinigame(%cl)
  493.     {
  494.     }
  495.    
  496.     function serverCmdJoinMinigame(%cl)
  497.     {
  498.     }
  499.    
  500.     function serverCmdLeaveMinigame(%cl)
  501.     {
  502.     }
  503.    
  504.     function serverCmdTeamMessageSent(%cl)
  505.     {
  506.     }
  507.    
  508.     function serverCmdLight(%cl)
  509.     {
  510.     }
  511.    
  512.     function serverCmdUsePrintGun(%cl)
  513.     {
  514.     }
  515.    
  516.     function serverCmdDuplicator(%cl)
  517.     {
  518.     }
  519.    
  520.     function serverCmdFillcan(%cl)
  521.     {
  522.     }
  523.    
  524.     function serverCmdChangemap(%cl)
  525.     {
  526.     }
  527.    
  528.     function serverCmdTimescale(%cl)
  529.     {
  530.     }
  531. };
  532. activatePackage(Salvage);
  533.  
  534. function Salvage_Input(%brick)
  535. {
  536.     %so  = new ScriptObject();
  537.     %cnt = %brick.numEvents;
  538.     %idx = -1;
  539.    
  540.     %name  = %brick.getDatablock().uiName;
  541.     %angle = %brick.getAngleID();
  542.     %plate = %brick.isBasePlate();
  543.     %color = %brick.getColorID();
  544.     %print = %brick.getPrintName();
  545.     %cfx   = %brick.getColorFXID();
  546.     %sfx   = %brick.getShapeFXID();
  547.     %ray   = %brick.isRaycasting();
  548.     %col   = %brick.isColliding();
  549.     %rend  = %brick.isRendering();
  550.    
  551.     %so.brick = %name @ "\" 0 0 0 " @ %angle SPC %plate SPC %color SPC %print SPC %cfx SPC %sfx SPC %ray SPC %col SPC %rend;
  552.    
  553.     %vehicle = %brick.vehicleDatablock;
  554.     %emitter = %brick.emitter;
  555.     %light   = %brick.light;
  556.     %item    = %brick.item;
  557.     %music   = %brick.audioEmitter;
  558.     %name    = %brick.getName();
  559.    
  560.     if(isObject(%vehicle)) %so.data[%idx++] = "+-VEHICLE "      @ %vehicle.uiName         @ "\" " @ %brick.reColorVehicle;
  561.     if(isObject(%emitter)) %so.data[%idx++] = "+-EMITTER "      @ %emitter.emitter.uiName @ "\" " @ %brick.emitterDirection;
  562.     if(isObject(%light))   %so.data[%idx++] = "+-LIGHT "        @ %light.dataBlock.uiName @ "\" ";
  563.     if(isObject(%item))    %so.data[%idx++] = "+-ITEM "         @ %item.dataBlock.uiName  @ "\" " @ %brick.itemPosition SPC %brick.itemDirection SPC %brick.itemRespawnTime;
  564.     if(isObject(%music))   %so.data[%idx++] = "+-AUDIOEMITTER " @ %music.profile.uiName   @ "\" ";
  565.     if(%name !$= "")       %so.data[%idx++] = "+-NTOBJECTNAME " @ %name;
  566.    
  567.     for(%i = 0; %i < %cnt; %i++)
  568.     {
  569.         %enabled = %brick.eventEnabled[%i];
  570.         %input   = %brick.eventInput[%i];
  571.         %delay   = %brick.eventDelay[%i];
  572.         %target  = %brick.eventTarget[%i];
  573.         %eventNT = %brick.eventNT[%i];
  574.         %output  = %brick.eventOutput[%i];
  575.        
  576.         %so.data[%idx++] = "+-EVENT\t" @ %i TAB %enabled TAB %input TAB %delay TAB %target TAB %eventNT TAB %output;
  577.        
  578.         %iidx  = %brick.eventInputIdx[%i];
  579.         %tidx  = %brick.eventTargetIdx[%i];
  580.         %oidx  = %brick.eventOutputIdx[%i];
  581.         %class = (%tidx == -1) ? "fxDTSBrick" : InputEvent_GetTargetClass("fxDTSBrick",%iidx,%tidx);
  582.         %list  = $OutputEvent_ParameterList[%class,%oidx];
  583.        
  584.         for(%j = 1; %j < 5; %j++)
  585.         {
  586.             %param = %brick.eventOutputParameter[%i,%j];
  587.             %word  = getWord(getField(%list,%j - 1),0);
  588.            
  589.             if(%word $= "datablock" && isObject(%param))
  590.                 %param = %param.getName();
  591.            
  592.             %so.data[%idx] = %so.data[%idx] TAB %param;
  593.         }
  594.     }
  595.    
  596.     return %so;
  597. }
  598.  
  599. function Salvage_Output(%so,%cl)
  600. {
  601.     %temp = %cl.player.tempBrick;
  602.    
  603.     if(!isObject(%so) || !isObject(%temp))
  604.         return -1;
  605.    
  606.     %dest = %temp.getPosition();
  607.     %xpos = getWord(%dest,0);
  608.     %ypos = getWord(%dest,1);
  609.     %zpos = getWord(%dest,2);
  610.    
  611.     if(%xpos <= -59 || %xpos >= 191 || %ypos <= -205 || %ypos >= -57 || %zpos <= 286 || %zpos >= 406)
  612.         return -1;
  613.    
  614.     %str    = %so.brick;
  615.     %pos    = strPos(%str,"\"");
  616.     %name   = getSubStr(%str,0,%pos);
  617.     %str    = getSubStr(%str,%pos + 2,strLen(%str));
  618.     %angle  = getWord(%str,3);
  619.     %change = angleID(%temp.angleID - %angle);
  620.     %angle  = angleID(%angle + %change);
  621.    
  622.     switch(%angle)
  623.     {
  624.         case 0: %rot = "1 0  0   0";
  625.         case 1: %rot = "0 0  1  90";
  626.         case 2: %rot = "0 0  1 180";
  627.         case 3: %rot = "0 0 -1  90";
  628.     }
  629.    
  630.     %brick = new fxDTSBrick()
  631.     {
  632.         position  = %dest;
  633.         rotation  = %rot;
  634.         datablock = $uiNameTable[%name];
  635.        
  636.         angleID   = %angle;
  637.         colorID   = getWord(%str,5);
  638.         colorFXID = getWord(%str,7);
  639.         shapeFXID = getWord(%str,8);
  640.        
  641.         isPlanted = 1;
  642.         client    = %cl;
  643.     };
  644.    
  645.     %brick.setTrusted(1);
  646.    
  647.     if(%err = %brick.plant())
  648.     {
  649.         switch(%err)
  650.         {
  651.             case 1: %cmd = 'MsgPlantError_Overlap';
  652.             case 2: %cmd = 'MsgPlantError_Float';
  653.             case 3: %cmd = 'MsgPlantError_Stuck';
  654.             case 4: %cmd = 'MsgPlantError_Unstable';
  655.             case 5: %cmd = 'MsgPlantError_Buried';
  656.             case 6: %cmd = 'MsgPlantError_TooFar';
  657.             case 7: %cmd = 'MsgPlantError_TooLoud';
  658.             case 8: %cmd = 'MsgPlantError_Limit';
  659.         }
  660.        
  661.         messageClient(%cl,%cmd);
  662.         %brick.delete();
  663.        
  664.         return -1;
  665.     }
  666.    
  667.     %bg    = %cl.brickGroup;
  668.     %print = getWord(%str,6);
  669.     %ray   = getWord(%str,9);
  670.     %col   = getWord(%str,10);
  671.     %rend  = getWord(%str,11);
  672.    
  673.     %bg.add(%brick);
  674.    
  675.     %brick.setPrint($printNameTable[%print]);
  676.     %brick.setRayCasting(%ray);
  677.     %brick.setColliding(%col);
  678.     %brick.setRendering(%rend);
  679.    
  680.     for(%i = 0; %i !$= ""; %i++)
  681.     {
  682.         %line = %so.data[%i];
  683.        
  684.         if(%line $= "")
  685.             break;
  686.        
  687.         if(getField(%line,0) $= "+-EVENT")
  688.         {
  689.             %idx    = getField(%line,1);
  690.             %input  = getField(%line,3);
  691.             %target = getField(%line,5);
  692.             %output = getField(%line,7);
  693.             %iidx   = InputEvent_GetInputEventIdx(%input);
  694.             %tidx   = InputEvent_GetTargetIndex("fxDTSBrick",%iidx,%target);
  695.             %class  = (%tidx == -1) ? "fxDTSBrick" : InputEvent_GetTargetClass("fxDTSBrick",%iidx,%tidx);
  696.             %oidx   = OutputEvent_GetOutputEventIdx(%class,%output);
  697.            
  698.             %brick.eventEnabled[%idx]            = getField(%line,2);
  699.             %brick.eventInput[%idx]              = %input;
  700.             %brick.eventInputIdx[%idx]           = %iidx;
  701.             %brick.eventDelay[%idx]              = getField(%line,4);
  702.             %brick.eventTarget[%idx]             = %target;
  703.             %brick.eventTargetIdx[%idx]          = %tidx;
  704.             %brick.eventNT[%idx]                 = getField(%line,6);
  705.             %brick.eventOutput[%idx]             = %output;
  706.             %brick.eventOutputIdx[%idx]          = %oidx;
  707.             %brick.eventOutputAppendClient[%idx] = $OutputEvent_AppendClient[%class,%oidx];
  708.            
  709.             for(%j = 1; %j < 5; %j++)
  710.             {
  711.                 %list = $OutputEvent_ParameterList[%class,%oidx];
  712.                 %type = getField(%list,%j - 1);
  713.                 %val  = getField(%line,%j + 7);
  714.                
  715.                 if(getWord(%type,0) $= "dataBlock" && isObject(%val))
  716.                     %brick.eventOutputParameter[%idx,%j] = %val.getID();
  717.                 else
  718.                     %brick.eventOutputParameter[%idx,%j] = %val;
  719.             }
  720.            
  721.             %brick.numEvents++;
  722.             %brick.implicitCancelEvents = 0;
  723.            
  724.             continue;
  725.         }
  726.        
  727.         %type = getWord(%line,0);
  728.         %data = getWords(%line,1);
  729.        
  730.         if(%type $= "+-NTOBJECTNAME")
  731.         {
  732.             %brick.setNTObjectName(getWord(%data,0));
  733.             continue;
  734.         }
  735.        
  736.         %pos  = strPos(%data,"\"");
  737.         %name = getSubStr(%data,0,%pos);
  738.         %args = getSubStr(%data,%pos + 2,strLen(%data));
  739.        
  740.         switch$(%type)
  741.         {
  742.             case "+-VEHICLE":
  743.                 %brick.setRecolorVehicle(getWord(%args,0));
  744.                 %brick.setVehicle($uiNameTable_Vehicle[%name],%cl);
  745.            
  746.             case "+-EMITTER":
  747.                 %dir = getWord(%args,0);
  748.                
  749.                 if(%dir > 1)
  750.                     %dir = angleID(%dir + %change - 2) + 2;
  751.                
  752.                 %brick.setEmitterDirection(%dir);
  753.                 %brick.setEmitter($uiNameTable_Emitters[%name],%cl);
  754.            
  755.             case "+-ITEM":
  756.                 %pos  = getWord(%args,0);
  757.                 %dir  = getWord(%args,1);
  758.                 %time = getWord(%args,2);
  759.                
  760.                 if(%pos > 1)
  761.                     %pos = angleID(%pos + %change - 2) + 2;
  762.                
  763.                 %dir = angleID(%dir + %change - 2) + 2;
  764.                
  765.                 %brick.setItemPosition(%pos);
  766.                 %brick.setItemDirection(%dir);
  767.                 %brick.setItemRespawnTime(%time);
  768.                 %brick.setItem($uiNameTable_Items[%name]);
  769.            
  770.             case "+-LIGHT":
  771.                 %brick.setLight($uiNameTable_Lights[%name],%cl);
  772.            
  773.             case "+-AUDIOEMITTER":
  774.                 %brick.setSound($uiNameTable_Music[%name],%cl);
  775.         }
  776.     }
  777.    
  778.     if($AddOn__JVS_Content == 1 && %brick.contentTypeID() > -1)
  779.         %brick.noContentEvents = 1;
  780.    
  781.     return %brick;
  782. }
  783.  
  784. function Salvage_HPDisplay()
  785. {
  786.     %count = ClientGroup.getCount();
  787.    
  788.     for(%i = 0; %i < %count; %i++)
  789.     {
  790.         %cl = ClientGroup.getObject(%i);
  791.         %pl = %cl.player;
  792.        
  793.         if(!isObject(%pl))
  794.             continue;
  795.        
  796.         %dmg  = mFloor(%pl.getDamageLevel());
  797.         %buff = mCeil(%pl.overheal);
  798.        
  799.         bottomPrint(%cl,"<just:center><color:FF8000>Health: " @ 100 - %dmg @ " + " @ %buff);
  800.     }
  801.    
  802.     cancel($Salvage::HPDisplay);
  803.     $Salvage::HPDisplay = schedule(100,0,Salvage_HPDisplay);
  804. }
  805.  
  806. function angleID(%id)
  807. {
  808.     while(%id < 0)
  809.         %id += 4;
  810.    
  811.     while(%id > 3)
  812.         %id -= 4;
  813.    
  814.     return %id;
  815. }
  816.  
  817. if(!isObject(Salvage_Minigame))
  818. {
  819.     new ScriptObject(Salvage_Minigame)
  820.     {
  821.         class = "MinigameSO";
  822.        
  823.         playerDatablock     = PlayerNoJet.getID();
  824.         startEquip0         = hammerItem.getID();
  825.         startEquip1         = wrenchItem.getID();
  826.         enableBuilding      = 1;
  827.         useAllPlayersBricks = 1;
  828.        
  829.         fallingDamage = 1;
  830.         weaponDamage  = 1;
  831.         vehicleDamage = 1;
  832.         selfDamage    = 1;
  833.     };
  834.    
  835.     // PlayerDropPoints.getObject(0).setName(SpawnSphere);
  836.    
  837.     // SpawnSphere.position  = "-1 16 0";
  838.     // SpawnSphere.rayHeight = 30;
  839.     // SpawnSphere.radius    = 70;
  840.    
  841.     cancel($Salvage::HPDisplay);
  842.     Salvage_HPDisplay();
  843. }
  844.  
  845. datablock ItemData(brickItem)
  846. {
  847.     category        = "Weapon";
  848.     className       = "Weapon";
  849.     colorShiftColor = "0.65 0.65 0.65 1";
  850.     shapeFile       = "base/data/shapes/brickWeapon.dts";
  851.    
  852.     density      = 0.2;
  853.     doColorShift = 1;
  854.     elasticity   = 0.2;
  855.     emap         = 1;
  856.     friction     = 0.6;
  857.     mass         = 1;
  858.     rotate       = 0;
  859. };
  860.  
  861. function brickItem::onPickup(%this,%item,%obj)
  862. {
  863.     %cl    = %obj.client;
  864.     %index = %item.index;
  865.    
  866.     if(!isObject($Salvage::Drop[%index]))
  867.         return;
  868.    
  869.     for(%i = 0; %i < 10; %i++)
  870.     {
  871.         if(%cl.inventory[%i] $= "")
  872.             break;
  873.     }
  874.    
  875.     if(%i == 10)
  876.     {
  877.         %cl.centerPrint("<color:FF0000>Your pack is full!",2);
  878.         return;
  879.     }
  880.    
  881.     %cl.salvaged[%i]       = $Salvage::Drop[%index];
  882.     %cl.inventory[%i]      = %item.inventory;
  883.     %cl.color[%i]          = %item.color;
  884.     $Salvage::Drop[%index] = "";
  885.    
  886.     serverCmdBuyBrick(%cl);
  887.     %item.delete();
  888. }
  889.  
  890. function brickSpawnpointData::onPlant(%this,%obj)
  891. {
  892.     %obj.enableTouch = true;
  893. }
  894.  
  895. function brickSpawnpointData::onPlayerTouch(%this,%obj,%pl)
  896. {
  897.     %cl = %pl.client;
  898.    
  899.     if(!isObject(%cl))
  900.         return;
  901.  
  902.     if(%cl.brickGroup.isMember(%obj) && %cl.checkPointBrick != %obj)
  903.     {
  904.         %cl.checkPointBrick    = %obj;
  905.         %cl.checkPointBrickPos = %obj.getPosition();
  906.        
  907.         %cl.centerPrint("\c4You have set this as your spawn point.",2);
  908.         %cl.play2D(Beep_Popup_Sound);
  909.        
  910.         Parent::onPlayerTouch(%this,%obj,%pl);
  911.     }
  912. }
  913.  
  914. function fxDtsBrick::getPrintName(%this)
  915. {
  916.     if(%this.getDataBlock().subCategory $= "Prints")
  917.     {
  918.         %texture  = getPrintTexture(%this.getPrintID());
  919.         %path     = filePath(%texture);
  920.         %underPos = strPos(%path,"_");
  921.         %name     = getSubStr(%path,%underPos + 1,strPos(%path,"_",14) - 14) @ "/" @ fileBase(%texture);
  922.        
  923.         if($printNameTable[%name] !$= "")
  924.             return %name;
  925.     }
  926. }
  927.  
  928. announce("Salvage Mod executed successfully.");
  929. echo("Salvage Mod executed successfully.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement