mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
267 lines
8.7 KiB
Plaintext
267 lines
8.7 KiB
Plaintext
include library.features;
|
|
include library.cybernetic;
|
|
include library.utils;
|
|
include library.hue;
|
|
include library.armor;
|
|
include library.proc;
|
|
|
|
//attach this script to wearables that can only be
|
|
// equipped by REBEL PILOTS
|
|
|
|
const string_id SID_ERROR = new string_id("ep3/cybernetic", "cannot_equip");
|
|
const string_id SID_REQUIRE_EP3 = new string_id("ep3/cybernetic", "ep3_required");
|
|
|
|
trigger OnAttach()
|
|
{
|
|
//since this script is attached in template, this function is only ever called one.
|
|
// This is a good thing.
|
|
cybernetic.setHueColor( self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
//lets reset our armor values in case someone updated the datatable!
|
|
cybernetic.setupArmorValues( self );
|
|
|
|
//cybernetic mods are not persisted, so in OnInit, set them up:
|
|
if (!utils.hasScriptVar( self, "isSetup" ))
|
|
{
|
|
obj_id currentLoc = getContainedBy(self);
|
|
if ( isIdValid(currentLoc) && isPlayer( currentLoc ))
|
|
{
|
|
//do not apply cybernetic skillmods here, because those are persisted!
|
|
cybernetic.applyCyberneticMods( currentLoc, self );
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAboutToBeTransferred(obj_id destContainer, obj_id transferer)
|
|
{
|
|
//if the item is currently equipped, then disallow a player from equipping it:
|
|
obj_id currentLoc = getContainedBy(self);
|
|
if ( isIdValid(currentLoc) )
|
|
{
|
|
//debugSpeakMsg( self, "i am currently in " + getName( currentLoc ));
|
|
if ( isPlayer(currentLoc) )
|
|
{
|
|
if ( isPlayer(transferer) )
|
|
{
|
|
//if ( !isGod(transferer) )
|
|
//{
|
|
//debugSpeakMsg( self, "you cannot unequip me!");
|
|
return SCRIPT_OVERRIDE;
|
|
//}
|
|
//else
|
|
//{
|
|
//debugSpeakMsg( self, "you can unequip me because you are GOD");
|
|
//debugSpeakMsg( self, "removing mods");
|
|
//cybernetic.removeCyberneticMods( currentLoc, self );
|
|
//debugSpeakMsg( currentLoc, "calling revoke cyber skillmods" );
|
|
//cybernetic.revokeCyberneticSkillMods( currentLoc, self );
|
|
//return SCRIPT_CONTINUE;
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
//debugSpeakMsg( self, "being un-equipped via script");
|
|
//debugSpeakMsg( self, "removing mods");
|
|
cybernetic.removeCyberneticMods( currentLoc, self );
|
|
//debugSpeakMsg( currentLoc, "calling revoke cyber skillmods" );
|
|
cybernetic.revokeCyberneticSkillMods( currentLoc, self );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!isPlayer(destContainer) )
|
|
{
|
|
//debugSpeakMsg( destContainer, "this is allowed because destContainer is a non player" );
|
|
return SCRIPT_CONTINUE;//allow the xfer if the destContainer is not a player
|
|
}
|
|
else
|
|
{
|
|
//the s0 set can be worn by anyone, even if they don't have the expansion:
|
|
string templateName = getTemplateName( self );
|
|
if ( templateName.indexOf("s01") == -1)
|
|
{
|
|
//but all other sets require that or godmode:
|
|
if (!features.hasEpisode3Expansion( destContainer ))
|
|
{
|
|
// The s04 right arm does not require the player to have the ep3 expansion.
|
|
if(templateName != "object/tangible/wearables/cybernetic/s04/cybernetic_s04_arm_r.iff")
|
|
{
|
|
|
|
//debugSpeakMsg( destContainer, "this NOT allowed because you don't have the expansion and you aren't GOD" );
|
|
// THIS CHECK SHOULD BE DONE BY WHATEVER IS ATTEMPTING TO EQUIP THE ITEM, IF NOT A PLAYER
|
|
sendSystemMessage( destContainer, SID_REQUIRE_EP3 );
|
|
return SCRIPT_OVERRIDE;//but disallow equipping this item if they don't have ep3 and aren't a god.
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( !isPlayer(transferer) )
|
|
{
|
|
//debugSpeakMsg( destContainer, "this is allowed because the transferer is not a player" );
|
|
cybernetic.applyCyberneticMods( destContainer, self );
|
|
cybernetic.grantCyberneticSkillMods( destContainer, self );
|
|
return SCRIPT_CONTINUE;//allow the xfer if the thing doing the transferring is not a plater
|
|
}
|
|
|
|
//tell the player that he can't, and make it so:
|
|
//if ( !isGod(destContainer) )
|
|
//{
|
|
//debugSpeakMsg( destContainer, "this is not allowed cause you aren't god, yo" );
|
|
sendSystemMessage( destContainer, SID_ERROR );
|
|
return SCRIPT_OVERRIDE;//this makes it so that you cannot equip the item.
|
|
//}
|
|
//else
|
|
//{
|
|
// //debugSpeakMsg( destContainer, "this is allowed cause you are a GOD");
|
|
// sendSystemMessageTestingOnly( destContainer, "Godmode Msg: This transfer is allowed ONLY because you are in GOD MODE");
|
|
// cybernetic.applyCyberneticMods( destContainer, self );
|
|
// cybernetic.grantCyberneticSkillMods( destContainer, self );
|
|
// return SCRIPT_CONTINUE;//ok, we'll allow it o mighty one.
|
|
//}
|
|
}
|
|
|
|
|
|
trigger OnTransferred(obj_id sourceContainer, obj_id destContainer, obj_id transferer)
|
|
{
|
|
//lets check to see if we are a player and the item is being put on or taken off so we can recalc armor
|
|
obj_id player = destContainer;
|
|
|
|
if (isIdValid(destContainer) && isPlayer(destContainer))
|
|
{
|
|
armor.recalculateArmorForPlayer(player);
|
|
proc.buildCurrentProcList(player);
|
|
proc.buildCurrentReacList(player);
|
|
|
|
}
|
|
else if(isIdValid(sourceContainer) && isPlayer(sourceContainer))
|
|
{
|
|
player = sourceContainer;
|
|
armor.recalculateArmorForPlayer(player);
|
|
proc.buildCurrentProcList(player);
|
|
proc.buildCurrentReacList(player);
|
|
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnDestroy()
|
|
{
|
|
obj_id currentLoc = getContainedBy(self);
|
|
if ( isPlayer( currentLoc ) )
|
|
{
|
|
cybernetic.removeCyberneticMods( currentLoc, self );
|
|
cybernetic.revokeCyberneticSkillMods( currentLoc, self );
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//THIS IS WHERE WE DISPLAY INFO BOUT CYBERNETIC ITEMS
|
|
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
|
|
{
|
|
int free = getFirstFreeIndex(names);
|
|
if (free == -1)
|
|
{
|
|
//debugSpeakMsg( player, "no free index" );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
dictionary cyberRow = dataTableGetRow(cybernetic.CYBORG_TABLE, getTemplateName( self ) );
|
|
if ( cyberRow == null )
|
|
return SCRIPT_CONTINUE;//this has nothing.
|
|
|
|
string procEffectString = cyberRow.getString( "procEffectString" );
|
|
if ( procEffectString != null && procEffectString != "" )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "proc" ));
|
|
attribs[free++] = utils.packStringId( new string_id ( "ep3/cybernetic", procEffectString));
|
|
}
|
|
|
|
string moveRateBuff = cyberRow.getString( "moveRateBuff" );
|
|
if ( moveRateBuff != null && moveRateBuff != "" )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "move_rate_buff" ));
|
|
attribs[free++] = utils.packStringId( new string_id ( "ep3/cybernetic", moveRateBuff));
|
|
}
|
|
|
|
if ( cyberRow.getInt( "throwRangeMod" ) != 0 )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "throw_range_mod"));
|
|
if ( cyberRow.getInt( "throwRangeMod" ) > 0 )
|
|
attribs[free++] = "+" + cyberRow.getInt( "throwRangeMod" );
|
|
else
|
|
attribs[free++] = "" + cyberRow.getInt( "throwRangeMod" );
|
|
}
|
|
|
|
if ( cyberRow.getInt( "rangedRangeMod" ) != 0 )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "ranged_range_mod"));
|
|
if ( cyberRow.getInt( "rangedRangeMod" ) > 0 )
|
|
attribs[free++] = "+" + cyberRow.getInt( "rangedRangeMod" );
|
|
else
|
|
attribs[free++] = "" + cyberRow.getInt( "rangedRangeMod" );
|
|
}
|
|
|
|
if ( cyberRow.getInt( "healingMod" ) != 0 )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "healing_mod"));
|
|
if ( cyberRow.getInt( "healingMod" ) > 0 )
|
|
attribs[free++] = "+" + cyberRow.getInt( "healingMod" );
|
|
else
|
|
attribs[free++] = "" + cyberRow.getInt( "healingMod" );
|
|
}
|
|
|
|
if ( cyberRow.getInt( "rangedAccuracyMod" ) != 0 )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "ranged_accuracy_mod"));
|
|
if ( cyberRow.getInt( "rangedAccuracyMod" ) > 0 )
|
|
attribs[free++] = "+" + cyberRow.getInt( "rangedAccuracyMod" );
|
|
else
|
|
attribs[free++] = "" + cyberRow.getInt( "rangedAccuracyMod" );
|
|
|
|
}
|
|
|
|
if ( cyberRow.getInt( "meleeDefMod" ) != 0 )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "melee_def_mod"));
|
|
if ( cyberRow.getInt( "meleeDefMod" ) > 0 )
|
|
attribs[free++] = "+" + cyberRow.getInt( "meleeDefMod" );
|
|
else
|
|
attribs[free++] = "" + cyberRow.getInt( "meleeDefMod" );
|
|
}
|
|
|
|
if ( cyberRow.getInt( "meleeAccuracyMod" ) != 0 )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "melee_accuracy_mod"));
|
|
if ( cyberRow.getInt( "meleeAccuracyMod" ) > 0 )
|
|
attribs[free++] = "+" + cyberRow.getInt( "meleeAccuracyMod" );
|
|
else
|
|
attribs[free++] = "" + cyberRow.getInt( "meleeAccuracyMod" );
|
|
}
|
|
|
|
if ( cyberRow.getInt( "commandoLegs" ) != 0 )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "commando_legs"));
|
|
attribs[free++] = utils.packStringId( new string_id ( "ep3/cybernetic", "commando_legs_desc"));
|
|
}
|
|
|
|
string specialCommand = cyberRow.getString( "specialCommand" );
|
|
if ( specialCommand != null && specialCommand != "" )
|
|
{
|
|
names[free] = utils.packStringId( new string_id ( "ep3/cybernetic", "special_command"));
|
|
attribs[free++] = utils.packStringId( new string_id ( "ep3/cybernetic", specialCommand ));
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|