Dear God why did I ever use Tribal IDE!

Fixed tabbing and made the code cleaner and not so hard to read.
This commit is contained in:
Robert MacGregor 2012-07-28 10:56:45 -04:00
parent 9a05e8d86c
commit c4114d5c6d
15 changed files with 766 additions and 809 deletions

View file

@ -4,300 +4,298 @@
function gameConnection::writeSaveFile(%this)
{
//Compile Main Variable List
%mission = $CurrentMission;
%player = %this.player;
%transform = %player.getTransform();
%velocity = %player.getVelocity();
%damage = %player.getDamageLevel();
%race = %this.race;
%armor = %this.armor;
%energy = %player.getEnergyLevel();
%whiteout = %player.getWhiteout();
%damageFlash = %player.getDamageFlash();
%cash = %this.cash;
%hasRadio = %this.hasRadio;
%underStandsHuman = %this.underStandsHuman;
%underStandsBioderm = %this.underStandsBioderm;
%underStandsDraakan = %this.underStandsDraakan;
%underStandsCriollos = %this.underStandsCriollos;
//Compile Main Variable List
%mission = $CurrentMission;
%player = %this.player;
%transform = %player.getTransform();
%velocity = %player.getVelocity();
%damage = %player.getDamageLevel();
%race = %this.race;
%armor = %this.armor;
%energy = %player.getEnergyLevel();
%whiteout = %player.getWhiteout();
%damageFlash = %player.getDamageFlash();
%cash = %this.cash;
%hasRadio = %this.hasRadio;
%underStandsHuman = %this.underStandsHuman;
%underStandsBioderm = %this.underStandsBioderm;
%underStandsDraakan = %this.underStandsDraakan;
%underStandsCriollos = %this.underStandsCriollos;
%time = formatTimeString("hh:nn A");
%date = formatTimeString("mm/dd/yy");
%time = formatTimeString("hh:nn A");
%date = formatTimeString("mm/dd/yy");
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
%fileObj = new fileObject();
%fileObj.openForWrite(%file);
%fileObj.writeLine(";Saved by" SPC %this.nameBase SPC "on" SPC %date SPC "at" SPC %time);
%fileObj.writeLine("");
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
%fileObj = new fileObject();
%fileObj.openForWrite(%file);
%fileObj.writeLine(";Saved by" SPC %this.nameBase SPC "on" SPC %date SPC "at" SPC %time);
%fileObj.writeLine("");
//Todo: Make this writing method more efficient ...
%fileObj.writeLine("[Character]");
%fileObj.writeLine("transform = \x22" @ %transform @ "\x22;");
%fileObj.writeLine("velocity = \x22" @ %velocity @ "\x22;");
%fileObj.writeLine("damage = \x22" @ %damage @ "\x22;");
%fileObj.writeLine("race = \x22" @ %race @ "\x22;");
%fileObj.writeLine("armor = \x22" @ %armor @ "\x22;");
%fileObj.writeLine("energy = \x22" @ %energy @ "\x22;");
%fileObj.writeLine("whiteOut = \x22" @ %whiteout @ "\x22;");
%fileObj.writeLine("damageFlash = \x22" @ %damageFlash @ "\x22;");
%fileObj.writeLine("cash = \x22" @ %cash @ "\x22;");
%fileObj.writeLine("hasRadio = \x22" @ %hasRadio @ "\x22;");
%fileObj.writeLine("underStandsHuman = \x22" @ %underStandsHuman @ "\x22;");
%fileObj.writeLine("underStandsBioderm = \x22" @ %underStandsBioderm @ "\x22;");
%fileObj.writeLine("underStandsDraakan = \x22" @ %underStandsDraakan @ "\x22;");
%fileObj.writeLine("underStandsCriollos = \x22" @ %underStandsCriollos @ "\x22;");
%fileObj.writeLine("");
//Todo: Make this writing method more efficient ...
%fileObj.writeLine("[Character]");
%fileObj.writeLine("transform = \x22" @ %transform @ "\x22;");
%fileObj.writeLine("velocity = \x22" @ %velocity @ "\x22;");
%fileObj.writeLine("damage = \x22" @ %damage @ "\x22;");
%fileObj.writeLine("race = \x22" @ %race @ "\x22;");
%fileObj.writeLine("armor = \x22" @ %armor @ "\x22;");
%fileObj.writeLine("energy = \x22" @ %energy @ "\x22;");
%fileObj.writeLine("whiteOut = \x22" @ %whiteout @ "\x22;");
%fileObj.writeLine("damageFlash = \x22" @ %damageFlash @ "\x22;");
%fileObj.writeLine("cash = \x22" @ %cash @ "\x22;");
%fileObj.writeLine("hasRadio = \x22" @ %hasRadio @ "\x22;");
%fileObj.writeLine("underStandsHuman = \x22" @ %underStandsHuman @ "\x22;");
%fileObj.writeLine("underStandsBioderm = \x22" @ %underStandsBioderm @ "\x22;");
%fileObj.writeLine("underStandsDraakan = \x22" @ %underStandsDraakan @ "\x22;");
%fileObj.writeLine("underStandsCriollos = \x22" @ %underStandsCriollos @ "\x22;");
%fileObj.writeLine("");
//Compile Inventory List
%slotCount = %player.weaponSlotCount;
%healthKits = %player.invRepairKit;
%fileObj.writeLine("[Inventory]");
%fileObj.writeLine("slotCount = \x22" @ %slotCount @ "\x22;");
//Compile Inventory List
%slotCount = %player.weaponSlotCount;
%healthKits = %player.invRepairKit;
%fileObj.writeLine("[Inventory]");
%fileObj.writeLine("slotCount = \x22" @ %slotCount @ "\x22;");
for (%i = 0; %i < %slotCount; %i++)
{
%weaponName = %player.weaponSlot[%i];
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
}
for (%i = 0; %i < %slotCount; %i++)
{
%weaponName = %player.weaponSlot[%i];
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
}
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
%fileObj.detach();
logEcho(" -- Save File Written for Player:" SPC %this.namebase SPC "--");
return true;
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
%fileObj.detach();
logEcho(" -- Save File Written for Player:" SPC %this.namebase SPC "--");
return true;
}
function gameConnection::applySaveFile(%this)
{
//Compile Main Variable List
%mission = $CurrentMission;
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
if (!isFile(%file))
return false;
%transform = getBlockData(%file,"Character",1,"transform");
%velocity = getBlockData(%file,"Character",1,"velocity");
%damage = getBlockData(%file,"Character",1,"damage");
%race = getBlockData(%file,"Character",1,"race");
%armor = getBlockData(%file,"Character",1,"armor");
%energy = getBlockData(%file,"Character",1,"energyLevel");
%whiteout = getBlockData(%file,"Character",1,"whiteOut");
%damageFlash = getBlockData(%file,"Character",1,"damageFlash");
%cash = getBlockData(%file,"Character",1,"cash");
%hasRadio = getBlockData(%file,"Character",1,"hasRadio");
%underStandsHuman = getBlockData(%file,"Character",1,"underStandsHuman");
%underStandsBioderm = getBlockData(%file,"Character",1,"underStandsBioderm");
%underStandsDraakan = getBlockData(%file,"Character",1,"underStandsDraakan");
%underStandsCriollos = getBlockData(%file,"Character",1,"underStandsCriollos");
%player = %this.player;
%player.setTransform(%transform);
%player.setVelocity(%velocity);
%player.applyDamage(%damage);
%player.setArmor(%armor);
%player.setEnergyLevel(%energy);
%player.setWhiteout(%whiteOut);
%player.setDamageFlash(%damageFlash);
%this.cash = %cash;
%this.underStandsHuman = %underStandsHuman;
%this.underStandsBioderm = %underStandsBioderm;
%this.underStandsDraakan = %underStandsDraakan;
%this.underStandsCriollos = %underStandsCriollos;
//Compile Main Variable List
%mission = $CurrentMission;
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
if (!isFile(%file))
return false;
%transform = getBlockData(%file,"Character",1,"transform");
%velocity = getBlockData(%file,"Character",1,"velocity");
%damage = getBlockData(%file,"Character",1,"damage");
%race = getBlockData(%file,"Character",1,"race");
%armor = getBlockData(%file,"Character",1,"armor");
%energy = getBlockData(%file,"Character",1,"energyLevel");
%whiteout = getBlockData(%file,"Character",1,"whiteOut");
%damageFlash = getBlockData(%file,"Character",1,"damageFlash");
%cash = getBlockData(%file,"Character",1,"cash");
%hasRadio = getBlockData(%file,"Character",1,"hasRadio");
%underStandsHuman = getBlockData(%file,"Character",1,"underStandsHuman");
%underStandsBioderm = getBlockData(%file,"Character",1,"underStandsBioderm");
%underStandsDraakan = getBlockData(%file,"Character",1,"underStandsDraakan");
%underStandsCriollos = getBlockData(%file,"Character",1,"underStandsCriollos");
%player = %this.player;
%player.setTransform(%transform);
%player.setVelocity(%velocity);
%player.applyDamage(%damage);
%player.setArmor(%armor);
%player.setEnergyLevel(%energy);
%player.setWhiteout(%whiteOut);
%player.setDamageFlash(%damageFlash);
%this.cash = %cash;
%this.underStandsHuman = %underStandsHuman;
%this.underStandsBioderm = %underStandsBioderm;
%this.underStandsDraakan = %underStandsDraakan;
%this.underStandsCriollos = %underStandsCriollos;
return true;
for (%i = 0; %i < %slotCount; %i++)
{
%weaponName = %player.weaponSlot[%i];
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
}
return true;
for (%i = 0; %i < %slotCount; %i++)
{
%weaponName = %player.weaponSlot[%i];
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
}
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
return;
}
// Generic Import Functions
function importGameData()
{
importGems();
importOres();
importCharacters();
return true;
importGems();
importOres();
importCharacters();
return true;
}
// Gem Import Functions
function importGems()
{
if (!IsObject(GemData))
{
new ScriptObject(GemData);
if (!IsObject(GemData))
{
new ScriptObject(GemData);
if (!IsObject(GameData))
new simGroup(GameData);
if (!IsObject(GameData))
new simGroup(GameData);
GameData.add(GemData);
}
else
return true;
GameData.add(GemData);
}
else
return true;
%file = "data/game/gems.txt";
%count = getBlockCount(%file,"Gem") + 1;
%file = "data/game/gems.txt";
%count = getBlockCount(%file,"Gem") + 1;
for (%i = 1; %i < %count; %i++)
{
%name = getBlockData(%file,"Gem",%i,"Name");
%price = getBlockData(%file,"Gem",%i,"Price");
%sellPrice = getBlockData(%file,"Gem",%i,"SellPrice");
GemData.gem[%i] = %name;
GemData.price[%name] = %price;
GemData.sellPrice[%name] = %sellPrice;
warn("Imported gem:" SPC %name);
}
GemData.gemCount = %count--;
}
for (%i = 1; %i < %count; %i++)
{
%name = getBlockData(%file,"Gem",%i,"Name");
%price = getBlockData(%file,"Gem",%i,"Price");
%sellPrice = getBlockData(%file,"Gem",%i,"SellPrice");
GemData.gem[%i] = %name;
GemData.price[%name] = %price;
GemData.sellPrice[%name] = %sellPrice;
warn("Imported gem:" SPC %name);
GemData.gemCount = %count--;
}
// Ore Import Functions
function importOres()
{
if (!IsObject(OreData))
{
new ScriptObject(OreData);
if (!IsObject(OreData))
{
new ScriptObject(OreData);
if (!IsObject(GameData))
new simGroup(GameData);
if (!IsObject(GameData))
new simGroup(GameData);
GameData.add(OreData);
}
else
return true;
GameData.add(OreData);
}
else
return true;
%file = "data/game/ores.txt";
%count = getBlockCount(%file,"Ore") + 1;
%file = "data/game/ores.txt";
%count = getBlockCount(%file,"Ore") + 1;
for (%i = 1; %i < %count; %i++)
{
%name = getBlockData(%file,"Ore",%i,"Name");
%price = getBlockData(%file,"Ore",%i,"Price");
%sellPrice = getBlockData(%file,"Ore",%i,"SellPrice");
for (%i = 1; %i < %count; %i++)
{
%name = getBlockData(%file,"Ore",%i,"Name");
%price = getBlockData(%file,"Ore",%i,"Price");
%sellPrice = getBlockData(%file,"Ore",%i,"SellPrice");
OreData.ore[%i] = %name;
OreData.price[%name] = %price;
OreData.sellPrice[%name] = %sellPrice;
warn("Imported ore:" SPC %name);
}
OreData.oreCount = %count--;
OreData.ore[%i] = %name;
OreData.price[%name] = %price;
OreData.sellPrice[%name] = %sellPrice;
warn("Imported ore:" SPC %name);
}
OreData.oreCount = %count--;
}
// Character Import Functions
function spawnCharacter(%name,%trans,%aimPos,%team)
{
%object = "Character" @ %name;
if (!IsObject(%object))
return false;
%Bname = %object.name;
%race = %object.race;
%skin = %object.skin;
%voice = %object.voice;
%voicePitch = %object.voicePitch;
%sex = %object.sex;
%bot = aiConnectByName(%Bname,%team);
%bot.race = %race;
%bot.skin = addTaggedString(%skin);
%bot.voice = %voice;
%bot.voiceTag = addTaggedString(%voice);
%bot.voicePitch = %voicePitch;
%bot.sex = %sex;
setVoice(%bot,%voice, %voicePitch);
setSkin(%bot,%skin);
setSkin(%bot,%skin);
setTeam(%bot, %team);
%bot.player.setArmor("light");
%bot.player.setTransform(%trans);
%bot.aimAt(%aimPos);
warn("Spawned Character:" SPC %name);
%object = "Character" @ %name;
if (!IsObject(%object))
return false;
%Bname = %object.name;
%race = %object.race;
%skin = %object.skin;
%voice = %object.voice;
%voicePitch = %object.voicePitch;
%sex = %object.sex;
%bot = aiConnectByName(%Bname,%team);
%bot.race = %race;
%bot.skin = addTaggedString(%skin);
%bot.voice = %voice;
%bot.voiceTag = addTaggedString(%voice);
%bot.voicePitch = %voicePitch;
%bot.sex = %sex;
setVoice(%bot,%voice, %voicePitch);
setSkin(%bot,%skin);
setSkin(%bot,%skin);
setTeam(%bot, %team);
%bot.player.setArmor("light");
%bot.player.setTransform(%trans);
%bot.aimAt(%aimPos);
warn("Spawned Character:" SPC %name);
}
function importCharacters()
{
%path = "data/game/characters/*.txt";
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
{
%name = getFileNameFromString(%file);
%pos = strStr(%name,".");
%character = getSubStr(%name,0,%pos);
importCharacter(%character);
}
%path = "data/game/characters/*.txt";
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
{
%name = getFileNameFromString(%file);
%pos = strStr(%name,".");
%character = getSubStr(%name,0,%pos);
importCharacter(%character);
}
}
function importCharacter(%character)
{
%prefix = "data/game/characters/";
%file = %prefix @ %character @ ".txt";
%charName = %character;
%character = strReplace("Character" @ %character," ","_");
%prefix = "data/game/characters/";
%file = %prefix @ %character @ ".txt";
%charName = %character;
%character = strReplace("Character" @ %character," ","_");
if (!IsFile(%file))
return false;
if (!IsFile(%file))
return false;
if (!IsObject(%character))
{
new scriptObject(%character);
if (!IsObject(%character))
{
new scriptObject(%character);
if (!IsObject(GameData))
new simGroup(GameData);
if (!IsObject(GameData))
new simGroup(GameData);
GameData.add(%character);
}
else
return true;
GameData.add(%character);
}
else
return true;
//Get our variable values ...
%name = getBlockData(%file,"Character",1,"Name");
%race = getBlockData(%file,"Character",1,"Race");
%sex = getBlockData(%file,"Character",1,"Sex");
%skin = getBlockData(%file,"Character",1,"Skin");
%voice = getBlockData(%file,"Character",1,"Voice");
%voicePitch = getBlockData(%file,"Character",1,"VoicePitch");
//Get our variable values ...
%name = getBlockData(%file,"Character",1,"Name");
%race = getBlockData(%file,"Character",1,"Race");
%sex = getBlockData(%file,"Character",1,"Sex");
%skin = getBlockData(%file,"Character",1,"Skin");
%voice = getBlockData(%file,"Character",1,"Voice");
%voicePitch = getBlockData(%file,"Character",1,"VoicePitch");
//Import Message Arrays ... and assign them
%arrayName[0] = "Death";
%arrayName[1] = "Kill";
%arrayName[2] = "Healed";
%arrayCount = 3;
//Import Message Arrays ... and assign them
%arrayName[0] = "Death";
%arrayName[1] = "Kill";
%arrayName[2] = "Healed";
%arrayCount = 3;
for (%i = 0; %i < %arrayCount; %i++)
{
%arrayVariableName[%i] = %arrayName[%i] @ "MessageArray";
for (%j = 0; %j < 100; %j++)
{
%arrayTest = getArrayData(%file,%arrayName[%i],%j);
if (%arrayTest !$= "}")
{
if (%j == 0)
%arrayData[%i] = %arrayData[%i] @ %arrayTest;
else
%arrayData[%i] = %arrayData[%i] @ "\t" @ %arrayTest;
}
else
break;
}
eval(%character @ "." @ %arrayVariableName[%i] SPC "= \x22" @ %arrayData[%i] @ "\x22;");
}
//Assign the variables now ...
%character.name = %name;
%character.race = %race;
%character.sex = %sex;
%character.skin = %skin;
%character.voice = %voice;
%character.voicePitch = %voicePitch;
warn("Imported Character:" SPC %charname);
for (%i = 0; %i < %arrayCount; %i++)
{
%arrayVariableName[%i] = %arrayName[%i] @ "MessageArray";
for (%j = 0; %j < 100; %j++)
{
%arrayTest = getArrayData(%file,%arrayName[%i],%j);
if (%arrayTest !$= "}")
{
if (%j == 0)
%arrayData[%i] = %arrayData[%i] @ %arrayTest;
else
%arrayData[%i] = %arrayData[%i] @ "\t" @ %arrayTest;
}
else
break;
}
eval(%character @ "." @ %arrayVariableName[%i] SPC "= \x22" @ %arrayData[%i] @ "\x22;");
}
//Assign the variables now ...
%character.name = %name;
%character.race = %race;
%character.sex = %sex;
%character.skin = %skin;
%character.voice = %voice;
%character.voicePitch = %voicePitch;
warn("Imported Character:" SPC %charname);
}

View file

@ -38,70 +38,69 @@ datablock ItemData(Lootbag)
function LootBagCheckForPickUp(%this) //Not sure why, loot bags won't do a T2 system pickup..
{
cancel(%this.loop);
cancel(%this.loop);
if (!IsObject(%this))
return;
if (!IsObject(%this))
return;
%count = MissionCleanUp.getCount();
%count = MissionCleanUp.getCount();
for(%i = 0; %i < %count; %i++)
{
%test = MissionCleanUp.getObject(%i);
for(%i = 0; %i < %count; %i++)
{
%test = MissionCleanUp.getObject(%i);
if (%test.getClassName() $= "Player" && %test.getState() !$= "dead" && !%test.client.isAIControlled())
{
%dist = vectorDist(%this.getPosition(),%test.getPosition());
if (%test.getClassName() $= "Player" && %test.getState() !$= "dead" && !%test.client.isAIControlled())
{
%dist = vectorDist(%this.getPosition(),%test.getPosition());
if (%dist < %this.getDatablock().pickUpRadius)
{
LootBagPickedUp(%this,%test.client);
return;
}
if (%dist < %this.getDatablock().pickUpRadius)
{
LootBagPickedUp(%this,%test.client);
return;
}
%this.loop = schedule(100,0,"LootBagCheckForPickup",%this);
}
}
%this.loop = schedule(100,0,"LootBagCheckForPickup",%this);
}
}
}
function LootBagPickedUp(%this,%client)
{
%db = %client.player.getDatablock(); //The player's datablock
%money = %this.money; //Monies?
%numItems = %this.numItems; //Giving out items.
%numAmmo = %this.numAmmo; //..Ammo too!
//Does the bag have money?
if (%money $= "")
%hasMoney = false;
else
%hasMoney = true;
%db = %client.player.getDatablock(); //The player's datablock
%money = %this.money; //Monies?
%numItems = %this.numItems; //Giving out items.
%numAmmo = %this.numAmmo; //..Ammo too!
//Does the bag have money?
if (%money $= "")
%hasMoney = false;
else
%hasMoney = true;
if (%money !$= "")
%client.money = %client.money + %money; //Give some monies.
if (%money !$= "")
%client.money = %client.money + %money; //Give some monies.
for (%i = 0; %i < %numItems; %i++)
{
if (%db.max[%this.item[%i]] != 0) //Don't want people in light armor running around with mortars, do we?
{
%client.player.setInventory(%this.item[%i],1);
%client.player.setInventory(%this.ammo[%i],%this.ammoNum[%i]);
}
}
%this.delete(); //Delete the bag.
for (%i = 0; %i < %numItems; %i++)
{
if (%db.max[%this.item[%i]] != 0) //Don't want people in light armor running around with mortars, do we?
{
%client.player.setInventory(%this.item[%i],1);
%client.player.setInventory(%this.ammo[%i],%this.ammoNum[%i]);
}
}
%this.delete(); //Delete the bag.
//Let the player know.
switch (%hasMoney)
{
case 0:
if (%numItems > 1)
messageClient(%client,'MsgClient','You picked up a bag of items that contained %1 items.',%numitems);
else
messageClient(%client,'MsgClient','You picked up a bag of items that contained 1 item.');
case 1:
if (%numItems > 1)
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and %2 items.',%money,%numitems);
else
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and 1 item.',%money);
//Let the player know.
switch (%hasMoney)
{
case 0:
if (%numItems > 1)
messageClient(%client,'MsgClient','You picked up a bag of items that contained %1 items.',%numitems);
else
messageClient(%client,'MsgClient','You picked up a bag of items that contained 1 item.');
case 1:
if (%numItems > 1)
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and %2 items.',%money,%numitems);
else
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and 1 item.',%money);
}
}
}

View file

@ -33,6 +33,6 @@ datablock StaticShapeData(MiningBox) : StaticShapeDamageProfile {
// -----------------------------------------------------
function MiningBox::onAdd(%this, %obj)
{
%obj.startFade(1,0,1);
%obj.applyDamage(%obj.getDataBlock().maxDamage); //Start the rock off
%obj.startFade(1,0,1);
%obj.applyDamage(%obj.getDataBlock().maxDamage); //Start the rock off
}

View file

@ -72,5 +72,5 @@ datablock StaticShapeData(DeployedSpine) : StaticShapeDamageProfile {
//----------------------------------------------------------------------------
function DetructableSecurityCamera::onDestroyed(%this, %obj)
{
schedule(1000,0,"delete",%obj);
schedule(1000,0,"delete",%obj);
}

View file

@ -9,159 +9,149 @@
function InteriorInstance::buyObject(%this,%objectID,%client,%team)
{
if (%this.generatorCount $= "")
%this.generatorCount = 0;
if (%this.inventoryCount $= "")
%this.inventoryCount = 0;
if (%this.sensorCount $= "")
%this.sensorCount = 0;
if (%this.sentryCount $= "")
%this.sentryCount = 0;
if (%this.bannerCount $= "")
%this.bannerCount = 0;
if (%this.turretBaseCount $= "")
%this.turretBaseCount = 0;
if (%this.generatorCount $= "")
%this.generatorCount = 0;
if (%this.inventoryCount $= "")
%this.inventoryCount = 0;
if (%this.sensorCount $= "")
%this.sensorCount = 0;
if (%this.sentryCount $= "")
%this.sentryCount = 0;
if (%this.bannerCount $= "")
%this.bannerCount = 0;
if (%this.turretBaseCount $= "")
%this.turretBaseCount = 0;
switch(%objectID)
{
case 0: //Generator
if (%this.generatorCount == $Property::Max[%this.interiorFile,0])
return false;
switch(%objectID)
{
case 0: //Generator
if (%this.generatorCount == $Property::Max[%this.interiorFile,0])
return false;
%shape = new StaticShape()
{
DataBlock = GeneratorLarge;
Position = vectorAdd($Property::Offset[%this.interiorFile,0,%this.generatorCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,0,%this.generatorCount];
Team = %team;
};
%shape = new StaticShape()
{
DataBlock = GeneratorLarge;
Position = vectorAdd($Property::Offset[%this.interiorFile,0,%this.generatorCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,0,%this.generatorCount];
Team = %team;
};
GeneratorLarge.gainPower(%shape);
%this.generatorCount++;
GeneratorLarge.gainPower(%shape);
case 1: //Inventory
if (%this.generatorCount == 0 || %this.inventoryCount == $Property::Max[%this.interiorFile,1]) //Don't create if there's no generators
return false;
%this.generatorCount++;
%shape = new StaticShape()
{
DataBlock = StationInventory;
Position = vectorAdd($Property::Offset[%this.interiorFile,1,%this.inventoryCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,1,%this.inventoryCount];
Team = %team;
};
case 1: //Inventory
if (%this.generatorCount == 0 || %this.inventoryCount == $Property::Max[%this.interiorFile,1]) //Don't create if there's no generators
return false;
StationInventory.gainPower(%shape);
%this.inventoryCount++;
%shape = new StaticShape()
{
DataBlock = StationInventory;
Position = vectorAdd($Property::Offset[%this.interiorFile,1,%this.inventoryCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,1,%this.inventoryCount];
Team = %team;
};
case 2: //Sensor (Medium)
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
return false;
%shape = new StaticShape()
{
DataBlock = SensorMediumPulse;
Position = vectorAdd($Property::Offset[%this.interiorFile,2,%this.sensorCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,2,%this.sensorCount];
Team = %team;
};
SensorMediumPulse.gainPower(%shape);
%this.sensorCount++;
StationInventory.gainPower(%shape);
case 3: //Sensor (Large)
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
return false;
%this.inventoryCount++;
%shape = new StaticShape()
{
DataBlock = SensorLargePulse;
Position = vectorAdd($Property::Offset[%this.interiorFile,3,%this.sensorCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,3,%this.sensorCount];
Team = %team;
};
SensorLargePulse.gainPower(%shape);
%this.sensorCount++;
case 2: //Sensor (Medium)
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
return false;
case 4: //Sentry Turrets
if (%this.generatorCount == 0 || %this.sentryCount == $Property::Max[%this.interiorFile,4])
return false;
%shape = new StaticShape()
{
DataBlock = SensorMediumPulse;
Position = vectorAdd($Property::Offset[%this.interiorFile,2,%this.sensorCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,2,%this.sensorCount];
Team = %team;
};
SensorMediumPulse.gainPower(%shape);
%this.sensorCount++;
%shape = new StaticShape()
{
DataBlock = SentryTurret;
Position = vectorAdd($Property::Offset[%this.interiorFile,4,%this.sentryCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,4,%this.sentryCount];
Team = %team;
};
SentryTurret.gainPower(%shape);
%this.sentryCount++;
case 5: //Banner (Strength)
if (%this.bannerCount == $Property::Max[%this.interiorFile,5])
return false;
%shape = new StaticShape()
{
DataBlock = Banner_Strength;
Position = vectorAdd($Property::Offset[%this.interiorFile,5,%this.bannerCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,5,%this.bannerCount];
Team = %team;
};
%this.bannerCount++;
case 3: //Sensor (Large)
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
return false;
case 6: //Large Turret Base
if (%this.generatorCount == 0 || %this.turretBaseCount == $Property::Max[%this.interiorFile,6])
return false;
%shape = new StaticShape()
{
DataBlock = SensorLargePulse;
Position = vectorAdd($Property::Offset[%this.interiorFile,3,%this.sensorCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,3,%this.sensorCount];
Team = %team;
};
%shape = new StaticShape()
{
DataBlock = TurretBaseLarge;
Position = vectorAdd($Property::Offset[%this.interiorFile,6,%this.turretBaseCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,6,%this.turretBaseCount];
Team = %team;
};
SensorLargePulse.gainPower(%shape);
%this.turretBaseCount++;
}
%this.sensorCount++;
case 4: //Sentry Turrets
if (%this.generatorCount == 0 || %this.sentryCount == $Property::Max[%this.interiorFile,4])
return false;
%shape = new StaticShape()
{
DataBlock = SentryTurret;
Position = vectorAdd($Property::Offset[%this.interiorFile,4,%this.sentryCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,4,%this.sentryCount];
Team = %team;
};
SentryTurret.gainPower(%shape);
%this.sentryCount++;
case 5: //Banner (Strength)
if (%this.bannerCount == $Property::Max[%this.interiorFile,5])
return false;
%shape = new StaticShape()
{
DataBlock = Banner_Strength;
Position = vectorAdd($Property::Offset[%this.interiorFile,5,%this.bannerCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,5,%this.bannerCount];
Team = %team;
};
%this.bannerCount++;
case 6: //Large Turret Base
if (%this.generatorCount == 0 || %this.turretBaseCount == $Property::Max[%this.interiorFile,6])
return false;
%shape = new StaticShape()
{
DataBlock = TurretBaseLarge;
Position = vectorAdd($Property::Offset[%this.interiorFile,6,%this.turretBaseCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,6,%this.turretBaseCount];
Team = %team;
};
%this.turretBaseCount++;
}
%this.getGroup().add(%shape);
setTargetName(%shape.target,addTaggedString(%client.namebase @ "'s"));
setTargetSensorGroup(%shape.getTarget(), %team);
%shape.setSelfPowered();
return %shape;
%this.getGroup().add(%shape);
setTargetName(%shape.target,addTaggedString(%client.namebase @ "'s"));
setTargetSensorGroup(%shape.getTarget(), %team);
%shape.setSelfPowered();
return %shape;
}
function staticShape::setPosition(%this,%pos)
{
%this.setTransform(%pos);
return %this;
%this.setTransform(%pos);
return %this;
}
function staticShape::getRotation(%this)
{
%trans = %this.getTransform();
return getWord(%trans, 3) SPC getWord(%trans, 4) SPC getWord(%trans,5);
%trans = %this.getTransform();
return getWord(%trans, 3) SPC getWord(%trans, 4) SPC getWord(%trans,5);
}
function objectIDToDatablock(%objectID)
{
switch(%objectID)
{
case 0: return "GeneratorLarge";
case 1: return 0;
default: return -1;
}
return -1;
switch(%objectID)
{
case 0: return "GeneratorLarge";
case 1: return 0;
default: return -1;
}
return -1;
}

View file

@ -9,45 +9,45 @@
//This should be used if I make some sort of online System
function setVoice(%client, %voice, %voicepitch)
{
freeClientTarget(%client);
%client.voice = %voice;
%client.voicetag = addtaggedstring(%voice);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
freeClientTarget(%client);
%client.voice = %voice;
%client.voicetag = addtaggedstring(%voice);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
if (IsObject(%client.player))
%client.player.setTarget(%client.target);
if (IsObject(%client.player))
%client.player.setTarget(%client.target);
}
function setSkin(%client, %skin)
{
freeClientTarget(%client);
%client.skin = addtaggedstring(%skin);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
freeClientTarget(%client);
%client.skin = addtaggedstring(%skin);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
if (IsObject(%client.player))
%client.player.setTarget(%client.target);
if (IsObject(%client.player))
%client.player.setTarget(%client.target);
}
function setName(%client, %name)
{
freeClientTarget(%client);
%client.namebase = %name;
%client.name = addtaggedstring(%name);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
freeClientTarget(%client);
%client.namebase = %name;
%client.name = addtaggedstring(%name);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
if (IsObject(%client.player))
%client.player.setTarget(%client.target);
if (IsObject(%client.player))
%client.player.setTarget(%client.target);
//Update the client in the lobby.
HideClient(%client);
ShowClient(%client);
//Update the client in the lobby.
HideClient(%client);
ShowClient(%client);
}
function setTeam(%client,%team)
{
%client.team = %team;
%client.setSensorGroup(%team);
setTargetSensorGroup(%client.target,%team);
%client.team = %team;
%client.setSensorGroup(%team);
setTargetSensorGroup(%client.target,%team);
}

View file

@ -11,13 +11,13 @@ function ServerNetwork::onConnect(%this)
function ServerNetwork::onConnectFailed(%this)
{
if (%this.testingServer)
{
error("Error: Unable to verify connection to server "@%this.testIP@" at port "@%this.testPort@"!");
%this.testIP = "";
%this.testPort = "";
%this.testingServer = false;
}
if (%this.testingServer)
{
error("Error: Unable to verify connection to server "@%this.testIP@" at port "@%this.testPort@"!");
%this.testIP = "";
%this.testPort = "";
%this.testingServer = false;
}
}
function ServerNetwork::onDisconnect(%this)
@ -42,8 +42,8 @@ function ServerNetwork::onLine(%this, %line)
function ServerNetwork::testServerIP(%this, %IP, %port)
{
%this.testingServer = true;
%this.testIP = %ip;
%this.testPort = %port;
%this.connect(%ip @ ":" @ %port);
%this.testingServer = true;
%this.testIP = %ip;
%this.testPort = %port;
%this.connect(%ip @ ":" @ %port);
}