using UnityEngine;
using System.Collections.Generic;
using ORKFramework;
using ORKFramework.Behaviours;
public class testing : MonoBehaviour {
public void TestChanges() {
// cycling through all group members
int groupSize = ORK.Game.Group.size;
for(int i=0;i<=groupSize; i++){
//changing status values
Combatant combatant = ComponentHelper.GetCombatant (ORK.Game.ActiveGroup.GetMember (i));
combatant.Status[0].addValue(1);
//changing object variables
combatant.GetComponent<ObjectVariablesComponent>().GetHandler().GetFloat("variableName1");
combatant.variableName1.AddValue(-1);
//changing equipment durability for equipped equipment on bodyparts
combatant.Equipment[0].durability.AddValue(1) ;
}
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Here's some working code for this function:
public void TestChanges()
{
// get player group members
List<Combatant> combatants = ORK.Game.ActiveGroup.GetGroup();
// or use ORK.Game.ActiveGroup.GetBattle() to only use the battle group members
for(int i=0; i<combatants.Count; i++)
{
//changing status values
combatants[i].Status[0].AddValue(1, false, true, true, false, true, true);
//changing object variables
combatants[i].Variables.ChangeFloat("variableName1", 1, FormulaOperator.Add);
//changing equipment durability for equipped equipment on bodyparts
if(combatants[i].Equipment[0].Equipped &&
combatants[i].Equipment[0].Equipment != null)
{
combatants[i].Equipment[0].Equipment.ChangeDurability(combatants[i], 1, SimpleOperator.Sub);
}
}
}
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
One last thing, I want to use the result of a formula, or a game var, instead of fixed values. After lots of research (and looking at cryptic nodes code), I think I would add this line :
float value = (float)ORK.Formulas.Get(formulaID).Calculate(new FormulaCall(0, player, player)); // to call the formula and put the result in the variable value
Then how do I put the variable value instead of the fixed value for status values, object variables and equipment durability?
Your code is correct, but you don't need the (float) cast in front of the formula, Calculate already returns a float.
To use the result of the formula (your value variable), just replace the '1' or whatever value you've used with value. Changing the status value probably needs an int cast (i.e. (int)value).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I got a question related to this thread.
I need to change the durability and the object vars of the equipment (weapons and armors) in the group inventory of the player. Each equipment has their own object vars and durability, so I think I need to go equipment by equipment and make the changes.
I already have a loop, and I think I got the logic right, but how do I access each item in the inventory? If I put the index number, I think it will mean the index number in the ork editor, not the index slot in the inventory?
Anyways here's my logic:
int numberOfEquipmentsInInventory = ORK.Game.ActiveGroup.Leader.Inventory.GetCount;
for(int j=0; j<numberOfEquipmentsInInventory; j++)
{
if (ORK.Game.ActiveGroup.Leader.Inventory.Items[j] != null)
{
//stuck here, dont know how to do this ORK.Game.ActiveGroup.Leader.Inventory.Items[j].Equipment.ChangeDurability((combatants[1], ORK.Formulas.Get(120).Calculate(new FormulaCall(0, combatants[1], combatants[1])), SimpleOperator.Add);
//and here ORK.Game.ActiveGroup.Leader.Inventory.Items[j].GetHandler().Set("gameVar", 10);
}
Thanks
Try this:
List<EquipShortcut> equipment = new List<EquipShortcut>();
ORK.Game.ActiveGroup.Leader.Inventory.Weapons.Get(id, int.MaxValue, ref equipment);
ORK.Game.ActiveGroup.Leader.Inventory.Armors.Get(id, int.MaxValue, ref equipment);
for(int i=0; i<equipment.Count; i++)
{
equipment[i].ChangeDurability(combatant, value, SimpleOperator.Add);
}
id is the ID/index of the equipment, the rest should be pretty clear, combatant being the combatant, value the durability change, etc.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
List<EquipShortcut> equipment = new List<EquipShortcut>();
ORK.Game.ActiveGroup.Leader.Inventory.Weapons.Get(7, int.MaxValue, ref equipment);
ORK.Game.ActiveGroup.Leader.Inventory.Armors.Get(7, int.MaxValue, ref equipment);
for(int i=0; i<equipment.Count; i++)
{
equipment[7].ChangeDurability(combatants[0], 2, SimpleOperator.Set);
}
}
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
" error CS1502: The best overloaded method match for `ORKFramework.SubInventory.Get(int, int, ref System.Collections.Generic.List)' has some invalid arguments
"
and
"error CS1503: Argument `#3' cannot convert `ref System.Collections.Generic.List' expression to type `ref System.Collections.Generic.List'
Something to do with ref equipment?
List<IShortcut> equipment = new List<IShortcut>();
ORK.Game.ActiveGroup.Leader.Inventory.Weapons.Get(7, int.MaxValue, ref equipment);
ORK.Game.ActiveGroup.Leader.Inventory.Armors.Get(7, int.MaxValue, ref equipment);
for(int i=0; i<equipment.Count; i++)
{
((EquipShortcut)equipment[7]).ChangeDurability(combatants[0], 2, SimpleOperator.Set);
}
}
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
So I've played a lot with the code and managed to make it semi work, still get the error , it doesn't work for all equipment in the inventory, just some, and btw equipment.count returns 0 so I put a fixed number:
List<IShortcut> equipment = new List<IShortcut>();
for(int j=0; j<100; j++)
{
ORK.Game.ActiveGroup.Leader.Inventory.Weapons.Get(j, int.MaxValue, ref equipment);
ORK.Game.ActiveGroup.Leader.Inventory.Armors.Get(j, int.MaxValue, ref equipment);
}
for(int k=0; k<100; k++)
{
if(((EquipShortcut)equipment[k]) != null)
{
((EquipShortcut)equipment[k]).ChangeDurability(combatants[0], 2, SimpleOperator.Set);
Debug.Log ("hello");
}
}
Also, my code was bugged ... used 7 instead of i.
List<IShortcut> equipment = new List<IShortcut>();
ORK.Game.ActiveGroup.Leader.Inventory.Weapons.Get(7, int.MaxValue, ref equipment);
ORK.Game.ActiveGroup.Leader.Inventory.Armors.Get(7, int.MaxValue, ref equipment);
for(int i=0; i<equipment.Count; i++)
{
((EquipShortcut)equipment[i]).ChangeDurability(combatants[0], 2, SimpleOperator.Set);
}
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
List<IShortcut> equipment = new List<IShortcut>();
for(int j=0; j<equipment.Count; j++)
{
ORK.Game.ActiveGroup.Leader.Inventory.Weapons.Get(j, int.MaxValue, ref equipment);
ORK.Game.ActiveGroup.Leader.Inventory.Armors.Get(j, int.MaxValue, ref equipment);
}
for(int i=0; i<equipment.Count; i++)
{
((EquipShortcut)equipment[i]).ChangeDurability(combatants[0], 2, SimpleOperator.Set);
}
But equipment.Count does not work, nothing happens, that's why I tried putting a fixed value of 100.
List<IShortcut> equipment = new List<IShortcut>();
for(int j=0; j<ORK.Weapons.Count; j++)
{
ORK.Game.ActiveGroup.Leader.Inventory.Weapons.Get(j, int.MaxValue, ref equipment);
}
for(int j=0; j<ORK.Armors.Count; j++)
{
ORK.Game.ActiveGroup.Leader.Inventory.Armors.Get(j, int.MaxValue, ref equipment);
}
for(int i=0; i<equipment.Count; i++)
{
((EquipShortcut)equipment[i]).ChangeDurability(combatants[0], 2, SimpleOperator.Set);
}
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!