Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

skills now have involved items, lookups can be done with skill-item o…

…r reacted-skill-item scope, stat effects can add and remove items (set on the effect or inferred from the skill), proxy skills can override items; throw skill. Fix FindComponentInThisOrParents. Fix stupid fencepost error in inventory index calculation. Capitalize Move stat in FFT sample. Fix crit formula naming.
  • Loading branch information...
commit a457e6b3e195ca373e6b9f240a10541a9543351e 1 parent 3b09d82
@JoeOsborn authored
Showing with 305 additions and 99 deletions.
  1. +1 −0  Assets/Editor/SRPGKit/ActionSkillDefEditor.cs
  2. +4 −0 Assets/Editor/SRPGKit/EditorGUIExt.cs
  3. +25 −0 Assets/Editor/SRPGKit/FormulaCompiler.cs
  4. +1 −1  Assets/Editor/SRPGKit/ItemEditor.cs
  5. +63 −56 Assets/Editor/SRPGKit/ProxyActionSkillDefEditor.cs
  6. +13 −0 Assets/Plugins/SRPGKit/Character.cs
  7. +4 −2 Assets/Plugins/SRPGKit/Equipment/Equipment.cs
  8. +8 −4 Assets/Plugins/SRPGKit/Game Flow/Inventory.cs
  9. +0 −1  Assets/Plugins/SRPGKit/Game Flow/Item.cs
  10. +1 −1  Assets/Plugins/SRPGKit/Game Flow/Team.cs
  11. +17 −4 Assets/Plugins/SRPGKit/Skills/Action Skills/ProxyActionSkillDef.cs
  12. +2 −1  Assets/Plugins/SRPGKit/Skills/Effects/Formula.cs
  13. +25 −3 Assets/Plugins/SRPGKit/Skills/Effects/Formulae.cs
  14. +111 −25 Assets/Plugins/SRPGKit/Skills/Effects/StatEffect.cs
  15. +14 −1 Assets/Plugins/SRPGKit/Skills/SkillDef.cs
  16. BIN  Assets/Resources/Formulae.asset
  17. +2 −0  Assets/SRPGCK Data/Items/Throwables.meta
  18. BIN  Assets/SRPGCK Data/Items/Throwables/Shuriken.asset
  19. +2 −0  Assets/SRPGCK Data/Items/Throwables/Shuriken.asset.meta
  20. BIN  Assets/SRPGCK Data/Items/Throwables/Super Shuriken.asset
  21. +2 −0  Assets/SRPGCK Data/Items/Throwables/Super Shuriken.asset.meta
  22. BIN  Assets/SRPGCK Data/Skills/Action/Attack/Attack (Magic Gun).asset
  23. BIN  Assets/SRPGCK Data/Skills/Action/Throw/Throw Shuriken.asset
  24. +2 −0  Assets/SRPGCK Data/Skills/Action/Throw/Throw Shuriken.asset.meta
  25. BIN  Assets/SRPGCK Data/Skills/Action/Throw/Throw Super Shuriken.asset
  26. +2 −0  Assets/SRPGCK Data/Skills/Action/Throw/Throw Super Shuriken.asset.meta
  27. BIN  Assets/SRPGCK Data/Skills/Action/Throw/Throw.asset
  28. +2 −0  Assets/SRPGCK Data/Skills/Action/Throw/Throw.asset.meta
  29. BIN  Assets/SRPGCK Data/Skills/Action/Throw/Throw.prefab
  30. +2 −0  Assets/SRPGCK Data/Skills/Action/Throw/Throw.prefab.meta
  31. BIN  Assets/SRPGCK Data/Skills/Move.asset
  32. +2 −0  Assets/SRPGCK Data/Skills/Move.asset.meta
  33. BIN  Assets/Test Resources/FFT/Character.prefab
  34. BIN  Assets/Test Resources/FFT/Team.prefab
  35. BIN  Assets/Test Resources/FFT/fft.unity
  36. BIN  ProjectSettings/QualitySettings.asset
View
1  Assets/Editor/SRPGKit/ActionSkillDefEditor.cs
@@ -79,6 +79,7 @@ public static ActionSkillDef CreateActionSkillDef()
}
protected virtual void EffectSkillGUI() {
+ atk.involvedItem = EditorGUIExt.PickAssetGUI<Item>("Involved Item", atk.involvedItem);
if(Formula.NotNullFormula(atk.delay) &&
!(atk.delay.formulaType == FormulaType.Constant &&
atk.delay.constantValue == 0)) {
View
4 Assets/Editor/SRPGKit/EditorGUIExt.cs
@@ -395,6 +395,10 @@ public static Enum EnumToolbar(Enum selected)
newFx.dismountMounted
);
break;
+ case StatEffectType.AddItem:
+ case StatEffectType.RemoveItem:
+ newFx.item = PickAssetGUI<Item>("Item", newFx.item);
+ break;
}
if(ctx == StatEffectContext.Action || ctx == StatEffectContext.Any) {
newFx.target = (StatEffectTarget)EditorGUILayout.EnumPopup("Target:", fx.target);
View
25 Assets/Editor/SRPGKit/FormulaCompiler.cs
@@ -229,6 +229,12 @@ public class FormulaCompiler : Grammar<IFormulaElement> {
f.lookupType = LookupType.ReactedSkillParam;
return f;
});
+ LookupOn("item", (parser) => {
+ Formula f = new Formula();
+ f.formulaType = FormulaType.Lookup;
+ f.lookupType = LookupType.ItemParam;
+ return f;
+ });
LookupOn("status", (parser) => {
Formula f = new Formula();
f.formulaType = FormulaType.Lookup;
@@ -284,6 +290,18 @@ public class FormulaCompiler : Grammar<IFormulaElement> {
nextF.lookupType = LookupType.TargetMountEquipmentParam;
} else if(f.lookupType == LookupType.TargetMounterStat) {
nextF.lookupType = LookupType.TargetMounterEquipmentParam;
+ } // else error?
+ f = nextF;
+ }
+ } else if(nextF.lookupType == LookupType.ItemParam) {
+ Debug.Log("er, item param "+nextF.lookupReference+" after "+f.formulaType+"->"+f.lookupType);
+ if(f.formulaType == FormulaType.Lookup) {
+ if(f.lookupType == LookupType.SkillParam) {
+ nextF.lookupType = LookupType.ItemParam;
+ } else if(f.lookupType == LookupType.ReactedSkillParam) {
+ nextF.lookupType = LookupType.ReactedItemParam;
+ } else {
+ throw new SemanticException("Item lookups must be applied to skills or reacted skills or auto lookups");
}
f = nextF;
}
@@ -363,6 +381,13 @@ public class FormulaCompiler : Grammar<IFormulaElement> {
} else if(f.lookupType == LookupType.TargetMounterStat) {
f.lookupType = LookupType.TargetMounterSkillParam;
}
+ } else if(ident != null && ident.Name == "item") {
+ Debug.Log("uh, item blah blah after "+f.formulaType+"->"+f.lookupType);
+ if(f.lookupType == LookupType.SkillParam) {
+ f.lookupType = LookupType.ItemParam;
+ } else if(f.lookupType == LookupType.ReactedSkillParam) {
+ f.lookupType = LookupType.ReactedItemParam;
+ }
} else if(ident != null && ident.Name == "status") {
if(f.lookupType == LookupType.ActorStat) {
f.lookupType = LookupType.ActorStatusEffect;
View
2  Assets/Editor/SRPGKit/ItemEditor.cs
@@ -35,7 +35,7 @@ public static Item CreateItem()
it.parameters = EditorGUIExt.ParameterFoldout(
"Parameter",
it.parameters,
- "item."+it.itemName+".params.",
+ "item."+it.name+".params.",
formulaOptions,
lastFocusedControl,
ref it.editorShowParameters
View
119 Assets/Editor/SRPGKit/ProxyActionSkillDefEditor.cs
@@ -34,6 +34,66 @@ public static ProxyActionSkillDef CreateProxyActionSkillDef()
name = "ProxyActionSkillDef";
patk = target as ProxyActionSkillDef;
}
+
+ protected override void BasicSkillGUI() {
+ CoreSkillGUI();
+ patk.referredSkill = EditorGUIExt.PickAssetGUI<ActionSkillDef>("Referred Skill", patk.referredSkill);
+ if(patk.referredSkill == null) {
+ patk.referredSkillName = EditorGUILayout.TextField("Referred Name", patk.referredSkillName);
+ patk.referredSkillGroup = EditorGUILayout.TextField("Referred Group", patk.referredSkillGroup ?? "");
+ }
+
+ if((patk.mergeIsEnabledF = MergeChoiceGUI("IsEnabled", patk.mergeIsEnabledF)) != MergeMode.UseOriginal) {
+ s.isEnabledF = EditorGUIExt.FormulaField(
+ "Is Enabled",
+ s.isEnabledF,
+ s.skillName+".isEnabledF",
+ formulaOptions,
+ lastFocusedControl
+ );
+ }
+ s.replacesSkill = EditorGUILayout.
+ Toggle("Replaces Skill", s.replacesSkill);
+ if(s.replacesSkill) {
+ s.replacedSkill = EditorGUILayout.
+ TextField("Skill", s.replacedSkill).NormalizeName();
+ s.replacementPriority = EditorGUILayout.
+ IntField("Priority", s.replacementPriority);
+ s.requiresReplacement = EditorGUILayout.
+ Toggle("Requires Replacement", s.requiresReplacement);
+ }
+
+ if(!s.isPassive) {
+ s.deactivatesOnApplication = EditorGUILayout.
+ Toggle("Deactivates After Use", s.deactivatesOnApplication);
+ }
+
+ EditorGUILayout.Space();
+ if((patk.mergeParameters = MergeListChoiceGUI("Parameters", patk.mergeParameters)) != MergeModeList.UseOriginal) {
+ s.parameters = EditorGUIExt.ParameterFoldout(
+ "Parameter",
+ s.parameters,
+ ""+s.GetInstanceID(),
+ formulaOptions,
+ lastFocusedControl,
+ ref showParameters
+ );
+ }
+ EditorGUILayout.Space();
+
+ if((patk.mergePassiveEffects = MergeListChoiceGUI("Passive Effects", patk.mergePassiveEffects)) != MergeModeList.UseOriginal) {
+ s.passiveEffects = EditorGUIExt.StatEffectFoldout(
+ "Passive Effect",
+ s.passiveEffects,
+ StatEffectContext.Normal,
+ ""+s.GetInstanceID(),
+ formulaOptions,
+ lastFocusedControl,
+ ref showPassiveEffects
+ );
+ }
+ }
+
protected override void TargetedSkillGUI() {
if((patk.mergeTurnToFaceTarget = MergeChoiceGUI("Face Target", patk.mergeTurnToFaceTarget)) != MergeMode.UseOriginal) {
atk.turnToFaceTarget = EditorGUILayout.Toggle("Face Target", atk.turnToFaceTarget);
@@ -92,6 +152,9 @@ public static ProxyActionSkillDef CreateProxyActionSkillDef()
}
protected override void EffectSkillGUI() {
+ if((patk.mergeInvolvedItem = MergeChoiceGUI("Involved Item", patk.mergeInvolvedItem)) != MergeMode.UseOriginal) {
+ atk.involvedItem = EditorGUIExt.PickAssetGUI<Item>("Involved Item", atk.involvedItem);
+ }
if((patk.mergeScheduledEffects = MergeChoiceGUI("On-Scheduled Effects", patk.mergeScheduledEffects)) != MergeMode.UseOriginal) {
atk.scheduledEffects = EditorGUIExt.StatEffectGroupGUI("On-Scheduled Effect", atk.scheduledEffects, StatEffectContext.Action, ""+atk.GetInstanceID(), formulaOptions, lastFocusedControl);
}
@@ -103,62 +166,6 @@ public static ProxyActionSkillDef CreateProxyActionSkillDef()
}
}
- protected override void BasicSkillGUI() {
- CoreSkillGUI();
- patk.referredSkillName = EditorGUILayout.TextField("Referred Skill", patk.referredSkillName);
- patk.referredSkillGroup = EditorGUILayout.TextField("Referred Group", patk.referredSkillGroup);
-
- if((patk.mergeIsEnabledF = MergeChoiceGUI("IsEnabled", patk.mergeIsEnabledF)) != MergeMode.UseOriginal) {
- s.isEnabledF = EditorGUIExt.FormulaField(
- "Is Enabled",
- s.isEnabledF,
- s.skillName+".isEnabledF",
- formulaOptions,
- lastFocusedControl
- );
- }
- s.replacesSkill = EditorGUILayout.
- Toggle("Replaces Skill", s.replacesSkill);
- if(s.replacesSkill) {
- s.replacedSkill = EditorGUILayout.
- TextField("Skill", s.replacedSkill).NormalizeName();
- s.replacementPriority = EditorGUILayout.
- IntField("Priority", s.replacementPriority);
- s.requiresReplacement = EditorGUILayout.
- Toggle("Requires Replacement", s.requiresReplacement);
- }
-
- if(!s.isPassive) {
- s.deactivatesOnApplication = EditorGUILayout.
- Toggle("Deactivates After Use", s.deactivatesOnApplication);
- }
-
- EditorGUILayout.Space();
- if((patk.mergeParameters = MergeListChoiceGUI("Parameters", patk.mergeParameters)) != MergeModeList.UseOriginal) {
- s.parameters = EditorGUIExt.ParameterFoldout(
- "Parameter",
- s.parameters,
- ""+s.GetInstanceID(),
- formulaOptions,
- lastFocusedControl,
- ref showParameters
- );
- }
- EditorGUILayout.Space();
-
- if((patk.mergePassiveEffects = MergeListChoiceGUI("Passive Effects", patk.mergePassiveEffects)) != MergeModeList.UseOriginal) {
- s.passiveEffects = EditorGUIExt.StatEffectFoldout(
- "Passive Effect",
- s.passiveEffects,
- StatEffectContext.Normal,
- ""+s.GetInstanceID(),
- formulaOptions,
- lastFocusedControl,
- ref showPassiveEffects
- );
- }
- }
-
public override void OnSRPGCKInspectorGUI () {
BasicSkillGUI();
EditorGUILayout.Space();
View
13 Assets/Plugins/SRPGKit/Character.cs
@@ -179,6 +179,19 @@ public class Character : MonoBehaviour {
public int TeamID { get {
return (int)GetBaseStat("team", teamID);
} }
+ public Team EffectiveTeam { get {
+ return map.arbiter.GetTeam(EffectiveTeamID);
+ } }
+ public Team Team { get {
+ return map.arbiter.GetTeam(TeamID);
+ } }
+
+ public Inventory inventory { get {
+ return GetComponent<Inventory>() ??
+ EffectiveTeam.GetComponent<Inventory>() ??
+ this.Team.GetComponent<Inventory>();
+ } }
+
public Vector3 TilePosition { get {
return map == null ?
View
6 Assets/Plugins/SRPGKit/Equipment/Equipment.cs
@@ -20,7 +20,8 @@ public class Equipment : MonoBehaviour {
public StatusEffect[] statusEffectPrefabs;
Dictionary<string, Formula> runtimeParameters;
- InstantiatedItem baseItem;
+ [System.NonSerialized]
+ public Item baseItem;
public void Start() {
for(int i = 0; i < equipmentSlots.Length; i++) {
@@ -36,7 +37,8 @@ public class Equipment : MonoBehaviour {
wielder = t.GetComponent<Character>();
if(wielder == null) { t = t.parent; }
}
- baseItem = GetComponent<InstantiatedItem>();
+ InstantiatedItem iit = GetComponent<InstantiatedItem>();
+ baseItem = iit != null ? iit.item : null;
if(wielder == null) { Debug.LogError("No wielder"); }
if(equippedSlots == null || equippedSlots.Length == 0) {
wielder.Equip(this);
View
12 Assets/Plugins/SRPGKit/Game Flow/Inventory.cs
@@ -14,17 +14,17 @@ public class Inventory : MonoBehaviour {
Character _character;
Character character { get {
- return _character = SRPGUtil.FindComponentInThisOrParents<Character>(_character);
+ return _character = this.FindComponentInThisOrParents<Character>(_character);
} }
Team _team;
Team team { get {
- return _team = SRPGUtil.FindComponentInThisOrParents<Team>(_team);
+ return _team = this.FindComponentInThisOrParents<Team>(_team);
} }
Arbiter _arbiter;
Arbiter arbiter { get {
- return _arbiter = SRPGUtil.FindComponentInThisOrParents<Arbiter>(_arbiter);
+ return _arbiter = this.FindComponentInThisOrParents<Arbiter>(_arbiter);
} }
public bool limitedStacks=false;
@@ -89,7 +89,11 @@ public class Inventory : MonoBehaviour {
RemoveItem(idx, 1);
return iit;
}
+ public int RemoveItem(Item item, int ct=1) {
+ return RemoveItem(IndexOfItem(item), ct);
+ }
public int RemoveItem(int idx, int ct=1) {
+ if(idx < 0 || idx >= items.Count) { return -1; }
int removed = 0;
while(counts[idx] > 0 && ct > 0) {
totalWeight -= items[idx].weight;
@@ -191,7 +195,7 @@ public class Inventory : MonoBehaviour {
public int IndexOfItem(Item it) {
for(int i = items.Count; i != 0; i--) {
- if(items[i] == it && counts[i-1] > 0) { return i; }
+ if(items[i-1] == it && counts[i-1] > 0) { return i-1; }
}
return -1;
}
View
1  Assets/Plugins/SRPGKit/Game Flow/Item.cs
@@ -9,7 +9,6 @@ public class Item : ScriptableObject {
public bool editorShowParameters=true;
//normal fields:
- public string itemName;
public float weight=0;
public int stackSize=99;
View
2  Assets/Plugins/SRPGKit/Game Flow/Team.cs
@@ -39,7 +39,7 @@ public class Team : MonoBehaviour {
public Arbiter _arbiter;
public Arbiter arbiter { get {
- return _arbiter = SRPGUtil.FindComponentInThisOrParents<Arbiter>(_arbiter);
+ return _arbiter = this.FindComponentInThisOrParents<Arbiter>(_arbiter);
} }
public Formulae fdb { get {
View
21 Assets/Plugins/SRPGKit/Skills/Action Skills/ProxyActionSkillDef.cs
@@ -17,9 +17,11 @@ public enum MergeMode {
public class ProxyActionSkillDef : ActionSkillDef {
public string referredSkillGroup=null;
public string referredSkillName="Attack";
+ public ActionSkillDef referredSkill=null;
ActionSkillDef ReferredSkill { get {
- return character.GetSkill(referredSkillGroup, referredSkillName) as ActionSkillDef;
+ return referredSkill ??
+ (character.GetSkill(referredSkillGroup, referredSkillName) as ActionSkillDef);
} }
public MergeModeList mergePassiveEffects=MergeModeList.Combine;
@@ -69,13 +71,24 @@ public class ProxyActionSkillDef : ActionSkillDef {
}
public MergeMode mergeIsEnabledF=MergeMode.UseOriginal;
- public override bool IsEnabled { get {
+ public override Formula IsEnabledF { get {
switch(mergeIsEnabledF) {
case MergeMode.UseOriginal:
- return ReferredSkill.IsEnabled;
+ return ReferredSkill.IsEnabledF;
case MergeMode.UseProxy:
default:
- return base.IsEnabled;
+ return base.IsEnabledF;
+ }
+ } }
+
+ public MergeMode mergeInvolvedItem=MergeMode.UseOriginal;
+ public override Item InvolvedItem { get {
+ switch(mergeInvolvedItem) {
+ case MergeMode.UseOriginal:
+ return ReferredSkill.InvolvedItem;
+ case MergeMode.UseProxy:
+ default:
+ return base.InvolvedItem;
}
} }
View
3  Assets/Plugins/SRPGKit/Skills/Effects/Formula.cs
@@ -103,7 +103,8 @@ public enum LookupType {
//lookupReference is the status effect type
TargetMountStatusEffect,
TargetMounterStatusEffect,
- ItemParam
+ ItemParam,
+ ReactedItemParam
}
public enum FormulaMergeMode {
View
28 Assets/Plugins/SRPGKit/Skills/Effects/Formulae.cs
@@ -122,8 +122,19 @@ SkillDef scontext
(tcontext != null && tcontext.HasStat(fname));
case LookupType.SkillParam:
return scontext.HasParam(fname);
- case LookupType.ItemParam:
- return icontext.HasParam(fname);
+ case LookupType.ItemParam: {
+ if(icontext == null && scontext != null) {
+ icontext = scontext.InvolvedItem;
+ }
+ if(icontext == null && econtext != null) {
+ icontext = econtext.baseItem;
+ }
+ return icontext != null && icontext.HasParam(fname);
+ }
+ case LookupType.ReactedItemParam: {
+ icontext = scontext.currentReactedSkill.InvolvedItem;
+ return icontext != null && icontext.HasParam(fname);
+ }
case LookupType.ActorStat:
if(scontext != null) { return scontext.character.HasStat(fname); }
if(econtext != null) { return econtext.wielder.HasStat(fname); }
@@ -319,8 +330,19 @@ SkillDef scontext
}
case LookupType.SkillParam:
return scontext.GetParam(fname);
- case LookupType.ItemParam:
+ case LookupType.ItemParam: {
+ if(icontext == null && scontext != null) {
+ icontext = scontext.InvolvedItem;
+ }
+ if(icontext == null && econtext != null) {
+ icontext = econtext.baseItem;
+ }
+ return icontext.GetParam(fname, scontext);
+ }
+ case LookupType.ReactedItemParam: {
+ icontext = scontext.currentReactedSkill.InvolvedItem;
return icontext.GetParam(fname, scontext);
+ }
case LookupType.ActorStat:
if(scontext != null) { return scontext.character.GetStat(fname); }
if(econtext != null) { return econtext.wielder.GetStat(fname); }
View
136 Assets/Plugins/SRPGKit/Skills/Effects/StatEffect.cs
@@ -24,7 +24,11 @@ public enum StatEffectType {
SpecialMove,
ApplyStatusEffect,
RemoveStatusEffect,
- Dismount
+ Dismount,
+ AddItem,
+ RemoveItem
+ //TODO: remove equipment, and make that equipment
+ //the item in question for future stat effects.
};
public enum StatChangeType {
@@ -54,9 +58,11 @@ public class StatEffect {
public bool respectLimits=true;
public bool constrainValueToLimits=true;
- //these three are only relevant for stateffects used in action and reaction skills
+ //these three are only relevant for stateffects used
+ //in action and reaction skills
public string[] reactableTypes;
- //for characters, equipment, and passive skills, "self", "wielder", or "character" is implicit
+ //for characters, equipment, and passive skills, "self",
+ //"wielder", or "character" is implicit
public StatEffectTarget target = StatEffectTarget.Applied;
public Formula triggerF;
@@ -64,7 +70,10 @@ public class StatEffect {
public string specialMoveType="knockback";
public float specialMoveSpeedXY=20, specialMoveSpeedZ=25;
public bool specialMoveAnimateToStart=true;
- public Formula specialMoveGivenStartX, specialMoveGivenStartY, specialMoveGivenStartZ;
+ public Formula
+ specialMoveGivenStartX,
+ specialMoveGivenStartY,
+ specialMoveGivenStartZ;
public Region specialMoveLine;
//only for adding status effect
public StatusEffect statusEffectPrefab;
@@ -73,6 +82,8 @@ public class StatEffect {
public int statusEffectRemovalStrength=0;
//only for dismount status effect
public bool dismountMounter=true, dismountMounted=true;
+
+ public Item item;
public float ModifyStat(
float stat,
@@ -82,7 +93,10 @@ public class StatEffect {
Equipment econtext,
ref float modValue
) {
- Formulae fdb = scontext != null ? scontext.fdb : (ccontext != null ? ccontext.fdb : (econtext != null ? econtext.fdb : Formulae.DefaultFormulae));
+ Formulae fdb = scontext != null ? scontext.fdb :
+ (ccontext != null ? ccontext.fdb :
+ (econtext != null ? econtext.fdb :
+ Formulae.DefaultFormulae));
// Debug.Log("V:"+value);
modValue=value.GetValue(fdb, scontext, ccontext, tcontext, econtext);
float modifiedValue = stat;
@@ -104,7 +118,11 @@ public class StatEffect {
Equipment econtext
) {
float ignore=0;
- return ModifyStat(stat, scontext, ccontext, tcontext, econtext, ref ignore);
+ return ModifyStat(
+ stat,
+ scontext, ccontext, tcontext, econtext,
+ ref ignore
+ );
}
public StatEffectRecord Apply(
@@ -196,7 +214,11 @@ ref modValue
break;
}
case StatEffectType.ApplyStatusEffect: {
- StatusEffect sfx = (GameObject.Instantiate(statusEffectPrefab, Vector3.zero, Quaternion.identity) as StatusEffect);
+ StatusEffect sfx = (GameObject.Instantiate(
+ statusEffectPrefab,
+ Vector3.zero,
+ Quaternion.identity
+ ) as StatusEffect);
sfx.applyingSkill = skill;
Debug.Log("apply status effect "+sfx);
actualTarget.ApplyStatusEffect(sfx);
@@ -205,7 +227,10 @@ ref modValue
}
case StatEffectType.RemoveStatusEffect: {
Debug.Log("remove status effects "+statusEffectRemovalType+" with str "+statusEffectRemovalStrength);
- StatusEffect[] removed = actualTarget.RemoveStatusEffect(statusEffectRemovalType, statusEffectRemovalStrength);
+ StatusEffect[] removed = actualTarget.RemoveStatusEffect(
+ statusEffectRemovalType,
+ statusEffectRemovalStrength
+ );
effect = new StatEffectRecord(this, removed);
break;
}
@@ -219,6 +244,32 @@ ref modValue
effect = new StatEffectRecord(this);
break;
}
+ case StatEffectType.AddItem: {
+ Inventory inv = actualTarget.inventory;
+ if(inv == null) {
+ Debug.LogError("No inventory under effect (add)");
+ }
+ Item involvedItem = item ?? skill.InvolvedItem;
+ if(involvedItem == null) {
+ Debug.LogError("No item in question (add)");
+ }
+ bool success = inv.InsertItem(involvedItem, -1, 1) == 1;
+ effect = new StatEffectRecord(this, inv, involvedItem, success);
+ break;
+ }
+ case StatEffectType.RemoveItem: {
+ Inventory inv = actualTarget.inventory;
+ if(inv == null) {
+ Debug.LogError("No inventory under effect (remove)");
+ }
+ Item involvedItem = item ?? skill.InvolvedItem;
+ if(involvedItem == null) {
+ Debug.LogError("No item in question (remove)");
+ }
+ bool success = inv.RemoveItem(involvedItem, 1) == 1;
+ effect = new StatEffectRecord(this, inv, involvedItem, success);
+ break;
+ }
}
return effect;
}
@@ -233,7 +284,15 @@ public class StatEffectRecord {
public Vector3 specialMoveStart;
public StatusEffect statusEffect;
public StatusEffect[] removedStatusEffects;
- public StatEffectRecord(StatEffect e, float init=0, float endVal=0, float v=0) {
+ public Inventory inventory;
+ public Item involvedItem;
+ public bool success;
+ public StatEffectRecord(
+ StatEffect e,
+ float init=0,
+ float endVal=0,
+ float v=0
+ ) {
effect = e;
initialValue = init;
finalValue = endVal;
@@ -251,26 +310,53 @@ public class StatEffectRecord {
effect = e;
removedStatusEffects = removedSfx;
}
+ public StatEffectRecord(StatEffect e, Inventory inv, Item it, bool succ) {
+ effect = e;
+ inventory = inv;
+ involvedItem = it;
+ success = succ;
+ }
- public bool Matches(string[] statNames, StatChangeType[] changes, string[] reactableTypes) {
- bool statNameOK = statNames == null || statNames.Length == 0 || statNames.Contains(effect.statName);
- bool changeOK = changes == null || changes.Length == 0 || changes.Any(delegate(StatChangeType c) {
- switch(c) {
- case StatChangeType.Any: return true;
- case StatChangeType.NoChange: return value == initialValue;
- case StatChangeType.Change: return value != initialValue;
- case StatChangeType.Increase: return value > initialValue;
- case StatChangeType.Decrease: return value < initialValue;
- }
- return false;
- });
- bool typesOK = reactableTypes == null || reactableTypes.Length == 0 || reactableTypes.All(t => effect.reactableTypes.Contains(t));
+ public bool Matches(
+ string[] statNames,
+ StatChangeType[] changes,
+ string[] reactableTypes
+ ) {
+ bool statNameOK = statNames == null ||
+ statNames.Length == 0 ||
+ statNames.Contains(effect.statName);
+ bool changeOK = changes == null ||
+ changes.Length == 0 ||
+ changes.Any(delegate(StatChangeType c) {
+ switch(c) {
+ case StatChangeType.Any: return true;
+ case StatChangeType.NoChange: return value == initialValue;
+ case StatChangeType.Change: return value != initialValue;
+ case StatChangeType.Increase: return value > initialValue;
+ case StatChangeType.Decrease: return value < initialValue;
+ }
+ return false;
+ });
+ bool typesOK = reactableTypes == null ||
+ reactableTypes.Length == 0 ||
+ reactableTypes.All(t => effect.reactableTypes.Contains(t));
return statNameOK && changeOK && typesOK;
}
- public bool Matches(string statName, StatChangeType change, string[] reactableTypes) {
- return Matches(new string[]{statName}, new StatChangeType[]{change}, reactableTypes);
+ public bool Matches(
+ string statName,
+ StatChangeType change,
+ string[] reactableTypes
+ ) {
+ return Matches(
+ new string[]{statName},
+ new StatChangeType[]{change},
+ reactableTypes
+ );
}
- public bool Matches(StatChange[] changes, string[] reactableTypes) {
+ public bool Matches(
+ StatChange[] changes,
+ string[] reactableTypes
+ ) {
if(changes == null || changes.Length == 0) {
return Matches(null, StatChangeType.Any, reactableTypes);
}
View
15 Assets/Plugins/SRPGKit/Skills/SkillDef.cs
@@ -21,11 +21,19 @@ public class SkillDef : ScriptableObject {
}
public List<Parameter> parameters;
+
+ public Inventory inventory { get {
+ return character.inventory;
+ } }
public Formula isEnabledF;
+ public virtual Formula IsEnabledF { get {
+ return isEnabledF;
+ } }
public virtual bool IsEnabled { get {
return Owner != null &&
- (Formula.NotNullFormula(isEnabledF) ? isEnabledF.GetValue(fdb, this) != 0 : true);
+ (Formula.NotNullFormula(isEnabledF) ? isEnabledF.GetValue(fdb, this) != 0 : true) &&
+ (InvolvedItem == null || inventory.HasItem(InvolvedItem));
} }
//reaction
@@ -65,6 +73,11 @@ public class SkillDef : ScriptableObject {
public Character currentTargetCharacter;
[System.NonSerialized]
public int currentHitType;
+
+ public Item involvedItem;
+ public virtual Item InvolvedItem { get {
+ return involvedItem;
+ } }
public List<StatEffectRecord> lastEffects;
View
BIN  Assets/Resources/Formulae.asset
Binary file not shown
View
2  Assets/SRPGCK Data/Items/Throwables.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 6df7edc1f44e34c94b4f20ebdf5017ba
View
BIN  Assets/SRPGCK Data/Items/Throwables/Shuriken.asset
Binary file not shown
View
2  Assets/SRPGCK Data/Items/Throwables/Shuriken.asset.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ac1d3aa64781042ac8c3530c6a8a934b
View
BIN  Assets/SRPGCK Data/Items/Throwables/Super Shuriken.asset
Binary file not shown
View
2  Assets/SRPGCK Data/Items/Throwables/Super Shuriken.asset.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 14492b81c64de4caabde837bf14c4269
View
BIN  Assets/SRPGCK Data/Skills/Action/Attack/Attack (Magic Gun).asset
Binary file not shown
View
BIN  Assets/SRPGCK Data/Skills/Action/Throw/Throw Shuriken.asset
Binary file not shown
View
2  Assets/SRPGCK Data/Skills/Action/Throw/Throw Shuriken.asset.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 7c0fb2f47e8bd4d3b854fe731a39b2bb
View
BIN  Assets/SRPGCK Data/Skills/Action/Throw/Throw Super Shuriken.asset
Binary file not shown
View
2  Assets/SRPGCK Data/Skills/Action/Throw/Throw Super Shuriken.asset.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3ce30d5d28f07407c81f814adec2772b
View
BIN  Assets/SRPGCK Data/Skills/Action/Throw/Throw.asset
Binary file not shown
View
2  Assets/SRPGCK Data/Skills/Action/Throw/Throw.asset.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: f9e4214bf073c4b3aaf2fd9a9fb239c8
View
BIN  Assets/SRPGCK Data/Skills/Action/Throw/Throw.prefab
Binary file not shown
View
2  Assets/SRPGCK Data/Skills/Action/Throw/Throw.prefab.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 0a1a43f1ace004d2ea105a1344d5a0fe
View
BIN  Assets/SRPGCK Data/Skills/Move.asset
Binary file not shown
View
2  Assets/SRPGCK Data/Skills/Move.asset.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: edd8e31eb7b2c453798075a2b94ca33b
View
BIN  Assets/Test Resources/FFT/Character.prefab
Binary file not shown
View
BIN  Assets/Test Resources/FFT/Team.prefab
Binary file not shown
View
BIN  Assets/Test Resources/FFT/fft.unity
Binary file not shown
View
BIN  ProjectSettings/QualitySettings.asset
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.