mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
180 lines
4.8 KiB
Plaintext
180 lines
4.8 KiB
Plaintext
/*
|
|
systems.collections.collection_camera.script
|
|
When used, a player is able to update his collection when having the correct 'mob' targeted.
|
|
Authors: James Michener
|
|
*/
|
|
|
|
//libraries
|
|
include library.buff;
|
|
include library.collection;
|
|
include library.sui;
|
|
include library.utils;
|
|
|
|
//constants
|
|
const string_id SID_USE_CAMERA = new string_id("collection", "use_camera");
|
|
const string_id SID_PICTURE_TAKEN = new string_id("collection", "picture_taken");
|
|
const string_id SID_INVALID_TARGET = new string_id("collection", "invalid_target");
|
|
const string_id SID_SUCCESS_SNAPSHOT = new string_id("collection", "successful_snapshot");
|
|
const string_id SID_PHOTO_SLOT_COMPLETE = new string_id("collection", "photo_slot_complete");
|
|
const string_id NOT_WHILE_INCAPPED = new string_id ("quest/ground/util/quest_giver_object", "not_while_incapped");
|
|
const string_id SID_NOT_WHILE_IN_COMBAT = new string_id("base_player", "not_while_in_combat");
|
|
const string_id MUST_DISMOUNT = new string_id ("collection", "must_dismount");
|
|
const string_id CREATURE_IS_DEAD = new string_id ("collection", "creature_is_dead");
|
|
const string PHOTO_COLLECTION = "col_photo_durni_01";
|
|
|
|
//triggers
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
//set myCamera to self
|
|
obj_id myCamera = self;
|
|
|
|
//can only consume if you have it picked up
|
|
if(utils.isNestedWithinAPlayer(myCamera))
|
|
{
|
|
mi.addRootMenu(menu_info_types.ITEM_USE, SID_USE_CAMERA);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
sendDirtyObjectMenuNotification(self);
|
|
obj_id myCamera = self;
|
|
|
|
// checks for combat
|
|
if(getState(player, STATE_COMBAT) > 0)
|
|
{
|
|
sendSystemMessage(player, SID_NOT_WHILE_IN_COMBAT);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if(getState(player, STATE_RIDING_MOUNT) == 1)
|
|
{
|
|
sendSystemMessage(player, MUST_DISMOUNT);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if(isDead(player) || isIncapacitated(player))
|
|
{
|
|
sendSystemMessage(player, NOT_WHILE_INCAPPED);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
//get the lookAtTarget
|
|
obj_id intended = getIntendedTarget(player);
|
|
|
|
if(!isIdValid(intended))
|
|
{
|
|
//both targets are null
|
|
sendSystemMessage(player, SID_INVALID_TARGET);
|
|
}
|
|
else
|
|
{
|
|
//check to see if the target qualifies
|
|
checkValidCreature(player, intended);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
boolean checkValidCreature(obj_id player, obj_id target)
|
|
{
|
|
//Picture alread taken
|
|
if(utils.hasScriptVar(target, "picture_taken_debuff"))
|
|
{
|
|
sendSystemMessage(player, SID_PICTURE_TAKEN);
|
|
return false;
|
|
}
|
|
//Alread completed Collection
|
|
if(hasCompletedCollection(player, PHOTO_COLLECTION))
|
|
{
|
|
return false;
|
|
}
|
|
//the creature is dead
|
|
if(isDead(target) || isIncapacitated(target))
|
|
{
|
|
sendSystemMessage(player, CREATURE_IS_DEAD);
|
|
return false;
|
|
}
|
|
string creatureName = getCreatureName(target);
|
|
|
|
if(creatureName.equals("durni"))
|
|
{
|
|
if(!hasCompletedCollectionSlot(player, "photo_durni_01"))
|
|
{
|
|
modifyCollectionSlotValue(player, "photo_durni_01", 1);
|
|
tagTheCreature(player, target);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
photoSlotComplete(player);
|
|
return false;
|
|
}
|
|
}
|
|
else if(creatureName.equals("corellia_durni_fiendish"))
|
|
{
|
|
if(!hasCompletedCollectionSlot(player, "photo_durni_fiendish_01"))
|
|
{
|
|
modifyCollectionSlotValue(player, "photo_durni_fiendish_01", 1);
|
|
tagTheCreature(player, target);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
photoSlotComplete(player);
|
|
return false;
|
|
}
|
|
}
|
|
else if(creatureName.equals("crazed_durni"))
|
|
{
|
|
if(!hasCompletedCollectionSlot(player, "photo_crazed_durni_01"))
|
|
{
|
|
modifyCollectionSlotValue(player, "photo_crazed_durni_01", 1);
|
|
tagTheCreature(player, target);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
photoSlotComplete(player);
|
|
return false;
|
|
}
|
|
}
|
|
else if(creatureName.equals("durni_vehement_warrior"))
|
|
{
|
|
if(!hasCompletedCollectionSlot(player, "photo_durni_vehement_warrior_01"))
|
|
{
|
|
modifyCollectionSlotValue(player, "photo_durni_vehement_warrior_01", 1);
|
|
tagTheCreature(player, target);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
photoSlotComplete(player);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessage(player, SID_INVALID_TARGET);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
void tagTheCreature(obj_id player, obj_id photoTarget)
|
|
{
|
|
string pictureParticle = "appearance/pt_durni_camera.prt";
|
|
//build dictionary for messageTo
|
|
dictionary dict = new dictionary();
|
|
dict.put("target", photoTarget);
|
|
//Inform the player the picture has been taken
|
|
sendSystemMessage(player, SID_SUCCESS_SNAPSHOT);
|
|
//Apply the camera particle and ScriptVar to the creature.
|
|
playClientEffectObj(photoTarget, pictureParticle, photoTarget, "root", null, "root_buff");
|
|
utils.setScriptVar(photoTarget, "picture_taken_debuff", "active");
|
|
//send messageTo to clear the particle and scriptVar after 5 minutes.
|
|
messageTo(photoTarget, "clearCollectionCameraParticle", dict, 300, false);
|
|
}
|
|
|
|
void photoSlotComplete(obj_id player)
|
|
{
|
|
sendSystemMessage(player, SID_PHOTO_SLOT_COMPLETE);
|
|
return;
|
|
}
|