Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color crystal with stats
#1
I was just screwing around and came out with this.
This adds a color crystal with stats like a premium crystal, object is spawned by command "/object createloot crystals_mysterious"

this is a git diff since i use git

Code:
diff --git a/MMOCoreORB/bin/scripts/loot/groups.lua b/MMOCoreORB/bin/scripts/loot/groups.lua
index 1287bf3..6de14ad 100644
--- a/MMOCoreORB/bin/scripts/loot/groups.lua
+++ b/MMOCoreORB/bin/scripts/loot/groups.lua
@@ -8,6 +8,7 @@ includeFile("groups/crystals_good.lua")
includeFile("groups/crystals_okay.lua")
includeFile("groups/crystals_poor.lua")
includeFile("groups/crystals_premium.lua")
+includeFile("groups/crystals_mysterious.lua")
includeFile("groups/crystals_quality.lua")
includeFile("groups/crystals_select.lua")
includeFile("groups/data_storage_unit_parts.lua")
diff --git a/MMOCoreORB/bin/scripts/loot/groups/crystals_mysterious.lua b/MMOCoreORB/bin/scripts/loot/groups/crystals_mysterious.lua
new file mode 100644
index 0000000..16d1c4d
--- /dev/null
+++ b/MMOCoreORB/bin/scripts/loot/groups/crystals_mysterious.lua
@@ -0,0 +1,12 @@
+--Automatically generated by SWGEmu Spawn Tool v0.12 loot editor.
+
+crystals_mysterious = {
+    description = "",
+    minimumLevel = 0,
+    maximumLevel = 0,
+    lootItems = {
+        {itemTemplate = "force_crystal_mysterious", weight = 10000000}
+    }
+}
+
+addLootGroupTemplate("crystals_mysterious", crystals_mysterious)
\ No newline at end of file
diff --git a/MMOCoreORB/bin/scripts/loot/items.lua b/MMOCoreORB/bin/scripts/loot/items.lua
index 317f59a..68142b0 100644
--- a/MMOCoreORB/bin/scripts/loot/items.lua
+++ b/MMOCoreORB/bin/scripts/loot/items.lua
@@ -25,6 +25,7 @@ includeFile("items/force_crystal_good.lua")
includeFile("items/force_crystal_okay.lua")
includeFile("items/force_crystal_poor.lua")
includeFile("items/force_crystal_premium.lua")
+includeFile("items/force_crystal_mysterious.lua")
includeFile("items/force_crystal_quality.lua")
includeFile("items/force_crystal_select.lua")
includeFile("items/heavy_duty_clasp.lua")
diff --git a/MMOCoreORB/bin/scripts/loot/items/force_crystal_mysterious.lua b/MMOCoreORB/bin/scripts/loot/items/force_crystal_mysterious.lua
new file mode 100644
index 0000000..6c8709e
--- /dev/null
+++ b/MMOCoreORB/bin/scripts/loot/items/force_crystal_mysterious.lua
@@ -0,0 +1,23 @@
+force_crystal_mysterious = {
+    minimumLevel = 0,
+    maximumLevel = -1,
+    customObjectName = "Mysterious Crystal",
+    directObjectTemplate = "object/tangible/component/weapon/lightsaber/lightsaber_module_force_crystal.iff",
+    craftingValues = {
+        {"mindamage",15,30,0},
+        {"maxdamage",31,50,0},
+        {"attackspeed",1,-1,5},
+        {"woundchance",4,8,5},
+        {"hitpoints",1000,3000,0},
+        {"attackhealthcost",0,9,0},
+        {"attackactioncost",0,9,0},
+        {"attackmindcost",0,9,0},
+        {"forcecost",0,9,0},
+        {"color",32,32,0},
+        {"quality",5,5,0},
+    },
+    customizationStringNames = {},
+    customizationValues = {}
+}
+
+addLootItemTemplate("force_crystal_mysterious", force_crystal_mysterious)
\ No newline at end of file
diff --git a/MMOCoreORB/src/server/zone/objects/tangible/component/lightsaber/LightsaberCrystalComponentImplementation.cpp b/MMOCoreORB/src/server/zone/objects/tangible/component/lightsaber/LightsaberCrystalComponentImplementation.cpp
index 4e7d09d..a174f34 100644
--- a/MMOCoreORB/src/server/zone/objects/tangible/component/lightsaber/LightsaberCrystalComponentImplementation.cpp
+++ b/MMOCoreORB/src/server/zone/objects/tangible/component/lightsaber/LightsaberCrystalComponentImplementation.cpp
@@ -50,20 +50,24 @@ void LightsaberCrystalComponentImplementation::fillAttributeList(AttributeListMe
        }
    }

-    if (getColor() != 31){
-        if (owner == ""){
-            StringBuffer str2;
-            str2 << "@jedi_spam:saber_color_" << getColor();
-            alm->insertAttribute("color", str2);
-        } else {
-            StringBuffer str3;
-            str3 << "@jedi_spam:saber_color_" << getColor();
-            alm->insertAttribute("color", str3);
-        }
-    }
-
-    if (player->getJediState() > 1 || player->isPrivileged()){
-        if (getColor() == 31){
+    if(getColor() == 31){
+        if (player->getJediState() > 1 || player->isPrivileged()){
+            if (owner != ""){
+                    alm->insertAttribute("mindamage", minimumDamage);
+                    alm->insertAttribute("maxdamage", maximumDamage);
+                    alm->insertAttribute("wpn_attack_speed", attackSpeed);
+                    alm->insertAttribute("wpn_wound_chance", woundChance);
+                    alm->insertAttribute("wpn_attack_cost_health", sacHealth);
+                    alm->insertAttribute("wpn_attack_cost_action", sacAction);
+                    alm->insertAttribute("wpn_attack_cost_mind", sacMind);
+                    alm->insertAttribute("forcecost", forceCost);
+                } else {
+                    StringBuffer str;
+                    str << "@jedi_spam:crystal_quality_" << getQuality();
+                    alm->insertAttribute("quality", str);
+                }
+            }
+        }else if(getColor() >= 32){
            if (owner != ""){
                alm->insertAttribute("mindamage", minimumDamage);
                alm->insertAttribute("maxdamage", maximumDamage);
@@ -73,13 +77,30 @@ void LightsaberCrystalComponentImplementation::fillAttributeList(AttributeListMe
                alm->insertAttribute("wpn_attack_cost_action", sacAction);
                alm->insertAttribute("wpn_attack_cost_mind", sacMind);
                alm->insertAttribute("forcecost", forceCost);
+                StringBuffer str2;
+                str2 << "@jedi_spam:saber_color_" << (getColor() - 32);
+                alm->insertAttribute("color", str2);
            } else {
-                StringBuffer str;
-                str << "@jedi_spam:crystal_quality_" << getQuality();
-                alm->insertAttribute("quality", str);
+                StringBuffer str3;
+                str3 << "@jedi_spam:saber_color_" << (getColor() - 32);
+                alm->insertAttribute("color", str3);
+                if (player->getJediState() > 1 || player->isPrivileged()){
+                    StringBuffer str;
+                    str << "@jedi_spam:crystal_quality_" << getQuality();
+                    alm->insertAttribute("quality", str);
+                }
            }
-        }
-    }
+        }else{
+            if (owner == ""){
+                StringBuffer str2;
+                str2 << "@jedi_spam:saber_color_" << getColor();
+                alm->insertAttribute("color", str2);
+            } else {
+                StringBuffer str3;
+                str3 << "@jedi_spam:saber_color_" << getColor();
+                alm->insertAttribute("color", str3);
+            }
+        }    
}

void LightsaberCrystalComponentImplementation::fillObjectMenuResponse(ObjectMenuResponse* menuResponse, CreatureObject* player) {
@@ -151,13 +172,21 @@ void LightsaberCrystalComponentImplementation::tuneCrystal(CreatureObject* playe

        // Color code is lime green.
        String tuneName;
+        if(getColor() < 32){
        if (getCustomObjectName().toString().contains("(Exceptional)"))
            tuneName = "\\#00FF00" + postTuneName + " (Exceptional) (tuned)";
        else if (getCustomObjectName().toString().contains("(Legendary)"))
            tuneName = "\\#00FF00" + postTuneName + " (Legendary) (tuned)";
        else
            tuneName = "\\#00FF00" + postTuneName + " (tuned)";
-
+        }else{
+        if (getCustomObjectName().toString().contains("(Exceptional)"))
+            tuneName = "\\#00FF00" + name + "'s Crystal (Exceptional) (tuned)";
+        else if (getCustomObjectName().toString().contains("(Legendary)"))
+            tuneName = "\\#00FF00" + name + "'s Crystal (Legendary) (tuned)";
+        else
+            tuneName = "\\#00FF00" + name + "'s Crystal (tuned)";
+        }
        setCustomObjectName(tuneName, true);
        player->sendSystemMessage("@jedi_spam:crystal_tune_success");
    } else {
@@ -176,20 +205,24 @@ void LightsaberCrystalComponentImplementation::updateCraftingValues(CraftingValu

    int colorMax = values->getMaxValue("color");
    int color = values->getCurrentValue("color");
-
    setMaxCondition(values->getCurrentValue("hitpoints"));

-    if (colorMax != 31) {
+    if (colorMax < 31) {
        int finalColor = MIN(color, 11);
        setColor(finalColor);
        updateCrystal(finalColor);
-    }
-    else {
+    }
+    else if(colorMax >= 32){
+        int rndnum = System::random(11);
+        setColor(rndnum+32);
+        updateCrystal(rndnum);
+        
+    } else {
        setColor(31);
        updateCrystal(31);
    }

-    if (color == 31){
+    if (color >= 31){
        setQuality(values->getCurrentValue("quality"));
        setAttackSpeed(Math::getPrecision(values->getCurrentValue("attackspeed"), 2));
        setMinimumDamage(MIN(values->getCurrentValue("mindamage"), 50));
@@ -218,27 +251,44 @@ int LightsaberCrystalComponentImplementation::inflictDamage(TangibleObject* atta
        ManagedReference<WeaponObject*> weapon = cast<WeaponObject*>(_this.getReferenceUnsafeStaticCast()->getParent().get()->getParent().get().get());

        if (weapon != NULL) {
-            if (getColor() == 31) {
-                weapon->setAttackSpeed(weapon->getAttackSpeed() - getAttackSpeed());
-                weapon->setMinDamage(weapon->getMinDamage() - getMinimumDamage());
-                weapon->setMaxDamage(weapon->getMaxDamage() - getMaximumDamage());
-                weapon->setHealthAttackCost(weapon->getHealthAttackCost() - getSacHealth());
-                weapon->setActionAttackCost(weapon->getActionAttackCost() - getSacAction());
-                weapon->setMindAttackCost(weapon->getMindAttackCost() - getSacMind());
-                weapon->setWoundsRatio(weapon->getWoundsRatio() - getWoundChance());
-                weapon->setForceCost(weapon->getForceCost() - getForceCost());
-            }
-
-            if (getColor() != 31) {
-                weapon->setBladeColor(31);
-                weapon->setCustomizationVariable("/private/index_color_blade", 31, true);
-
-                if (weapon->isEquipped()) {
-                    ManagedReference<CreatureObject*> parent = cast<CreatureObject*>(weapon->getParent().get().get());
-                    ManagedReference<SceneObject*> inventory = parent->getSlottedObject("inventory");
-                    inventory->transferObject(weapon, -1, true, true);
-                    parent->sendSystemMessage("@jedi_spam:lightsaber_no_color"); //That lightsaber can not be used until it has a color-modifying Force crystal installed.
-                }
+            
+            if(getColor() == 31){
+                    weapon->setAttackSpeed(weapon->getAttackSpeed() - getAttackSpeed());
+                    weapon->setMinDamage(weapon->getMinDamage() - getMinimumDamage());
+                    weapon->setMaxDamage(weapon->getMaxDamage() - getMaximumDamage());
+                    weapon->setHealthAttackCost(weapon->getHealthAttackCost() - getSacHealth());
+                    weapon->setActionAttackCost(weapon->getActionAttackCost() - getSacAction());
+                    weapon->setMindAttackCost(weapon->getMindAttackCost() - getSacMind());
+                    weapon->setWoundsRatio(weapon->getWoundsRatio() - getWoundChance());
+                    weapon->setForceCost(weapon->getForceCost() - getForceCost());
+            }else if(getColor() >= 32){
+                    weapon->setAttackSpeed(weapon->getAttackSpeed() - getAttackSpeed());
+                    weapon->setMinDamage(weapon->getMinDamage() - getMinimumDamage());
+                    weapon->setMaxDamage(weapon->getMaxDamage() - getMaximumDamage());
+                    weapon->setHealthAttackCost(weapon->getHealthAttackCost() - getSacHealth());
+                    weapon->setActionAttackCost(weapon->getActionAttackCost() - getSacAction());
+                    weapon->setMindAttackCost(weapon->getMindAttackCost() - getSacMind());
+                    weapon->setWoundsRatio(weapon->getWoundsRatio() - getWoundChance());
+                    weapon->setForceCost(weapon->getForceCost() - getForceCost());
+                    weapon->setBladeColor(31);
+                    weapon->setCustomizationVariable("/private/index_color_blade", 31, true);
+
+                    if (weapon->isEquipped()) {
+                        ManagedReference<CreatureObject*> parent = cast<CreatureObject*>(weapon->getParent().get().get());
+                        ManagedReference<SceneObject*> inventory = parent->getSlottedObject("inventory");
+                        inventory->transferObject(weapon, -1, true, true);
+                        parent->sendSystemMessage("@jedi_spam:lightsaber_no_color"); //That lightsaber can not be used until it has a color-modifying Force crystal installed.
+                    }
+            }else{
+                    weapon->setBladeColor(31);
+                    weapon->setCustomizationVariable("/private/index_color_blade", 31, true);
+
+                    if (weapon->isEquipped()) {
+                        ManagedReference<CreatureObject*> parent = cast<CreatureObject*>(weapon->getParent().get().get());
+                        ManagedReference<SceneObject*> inventory = parent->getSlottedObject("inventory");
+                        inventory->transferObject(weapon, -1, true, true);
+                        parent->sendSystemMessage("@jedi_spam:lightsaber_no_color"); //That lightsaber can not be used until it has a color-modifying Force crystal installed.
+                    }
            }
        }
    }
diff --git a/MMOCoreORB/src/server/zone/objects/tangible/components/SaberInventoryContainerComponent.cpp b/MMOCoreORB/src/server/zone/objects/tangible/components/SaberInventoryContainerComponent.cpp
index d741c60..66eb180 100644
--- a/MMOCoreORB/src/server/zone/objects/tangible/components/SaberInventoryContainerComponent.cpp
+++ b/MMOCoreORB/src/server/zone/objects/tangible/components/SaberInventoryContainerComponent.cpp
@@ -75,7 +75,6 @@ int SaberInventoryContainerComponent::notifyObjectInserted(SceneObject* sceneObj
    ManagedReference<WeaponObject*> weao = cast<WeaponObject*>( sceneObject->getParent().get().get());

    Locker locker(weao);
-
    if (weao->isJediWeapon()) {
        ManagedReference<LightsaberCrystalComponent*> crystal = cast<LightsaberCrystalComponent*>( object);
        if (crystal->getColor() == 31){
@@ -87,9 +86,19 @@ int SaberInventoryContainerComponent::notifyObjectInserted(SceneObject* sceneObj
            weao->setMindAttackCost(weao->getMindAttackCost() + crystal->getSacMind());
            weao->setWoundsRatio(weao->getWoundsRatio() + crystal->getWoundChance());
            weao->setForceCost(weao->getForceCost() + crystal->getForceCost());
-        }
-
-        if (crystal->getColor() != 31) {
+        }else if(crystal->getColor() >= 32){
+            weao->setAttackSpeed(weao->getAttackSpeed() + crystal->getAttackSpeed());
+            weao->setMinDamage(weao->getMinDamage() + crystal->getMinimumDamage());
+            weao->setMaxDamage(weao->getMaxDamage() + crystal->getMaximumDamage());
+            weao->setHealthAttackCost(weao->getHealthAttackCost() + crystal->getSacHealth());
+            weao->setActionAttackCost(weao->getActionAttackCost() + crystal->getSacAction());
+            weao->setMindAttackCost(weao->getMindAttackCost() + crystal->getSacMind());
+            weao->setWoundsRatio(weao->getWoundsRatio() + crystal->getWoundChance());
+            weao->setForceCost(weao->getForceCost() + crystal->getForceCost());
+            int color = (crystal->getColor() - 32);
+            weao->setBladeColor(color);
+            weao->setCustomizationVariable("/private/index_color_blade", color, true);
+        }else{
            int color = crystal->getColor();
            weao->setBladeColor(color);
            weao->setCustomizationVariable("/private/index_color_blade", color, true);
@@ -124,9 +133,18 @@ int SaberInventoryContainerComponent::notifyObjectRemoved(SceneObject* sceneObje
                weao->setMindAttackCost(weao->getMindAttackCost() - crystal->getSacMind());
                weao->setWoundsRatio(weao->getWoundsRatio() - crystal->getWoundChance());
                weao->setForceCost(weao->getForceCost() - crystal->getForceCost());
-            }
-
-            if (crystal->getColor() != 31) {
+            }else if(crystal->getColor() >= 32){
+                weao->setAttackSpeed(weao->getAttackSpeed() - crystal->getAttackSpeed());
+                weao->setMinDamage(weao->getMinDamage() - crystal->getMinimumDamage());
+                weao->setMaxDamage(weao->getMaxDamage() - crystal->getMaximumDamage());
+                weao->setHealthAttackCost(weao->getHealthAttackCost() - crystal->getSacHealth());
+                weao->setActionAttackCost(weao->getActionAttackCost() - crystal->getSacAction());
+                weao->setMindAttackCost(weao->getMindAttackCost() - crystal->getSacMind());
+                weao->setWoundsRatio(weao->getWoundsRatio() - crystal->getWoundChance());
+                weao->setForceCost(weao->getForceCost() - crystal->getForceCost());
+                weao->setBladeColor(31);
+                weao->setCustomizationVariable("/private/index_color_blade", 31, true);
+            }else{
                weao->setBladeColor(31);
                weao->setCustomizationVariable("/private/index_color_blade", 31, true);
            }

I hope this is in the right place.
 
Reply
  



Forum Jump:


Browsing: 1 Guest(s)