浏览代码

Introduced new spell configuration options (not used yet)

AlexVinS 11 年之前
父节点
当前提交
ce8fa33efc

+ 13 - 2
config/schemas/spell.json

@@ -53,7 +53,17 @@
 						"smart":{
 							"type": "boolean",
 							"description": "true: friendly/hostile based on positiveness; false: all targets"
-						}
+						},
+						"clearTarget":
+						{
+							"type": "boolean",
+							"description": "LOCATION target only. Target hex/tile must be clear"
+						},
+						"clearAffected":
+						{
+							"type": "boolean",
+							"description": "LOCATION target only. All affected hexes/tile must be clear"
+						}						
 					}
 				}
 			}
@@ -120,7 +130,8 @@
 		},
 		"targetType":{
 				  "type": "string",
-				  "enum": ["NO_TARGET","CREATURE","OBSTACLE"]
+				  "description": "NO_TARGET - instant cast no aiming, default; CREATURE - target is unit; OBSTACLE - target is OBSTACLE; LOCATION - target is location",
+				  "enum": ["NO_TARGET","CREATURE","OBSTACLE","LOCATION"]
 		},
 		"anim":{
 				"type": "number",

+ 12 - 0
config/spells/ability.json

@@ -1,6 +1,7 @@
 {
 	"stoneGaze" : {
 		"index" : 70,
+		"targetType": "NO_TARGET",
 		"anim" : 70,
 		"sounds": {
 			"cast": "PARALYZE"
@@ -33,6 +34,7 @@
 	},
 	"poison" : {
 		"index" : 71,
+		"targetType": "NO_TARGET",
 		"anim" : 67,
 		"sounds": {
 			"cast": "POISON"
@@ -67,6 +69,7 @@
 	},
 	"bind" : {
 		"index" : 72,
+		"targetType": "NO_TARGET",
 		"anim" : 68,
 		"sounds": {
 			"cast": "BIND"
@@ -90,6 +93,7 @@
 	},
 	"disease" : {
 		"index" : 73,
+		"targetType": "NO_TARGET",
 		"anim" : 69,
 		"sounds": {
 			"cast": "DISEASE"
@@ -124,6 +128,7 @@
 	},
 	"paralyze" : {
 		"index" : 74,
+		"targetType": "NO_TARGET",
 		"anim" : 70,
 		"sounds": {
 			"cast": "PARALYZE"
@@ -156,6 +161,7 @@
 	},
 	"age" : {
 		"index" : 75,
+		"targetType": "NO_TARGET",
 		"anim" : 71,
 		"sounds": {
 			"cast": "AGE"
@@ -184,6 +190,7 @@
 	},
 	"deathCloud" : {
 		"index" : 76,
+		"targetType": "NO_TARGET",
 		"anim" : 72,
 		"sounds": {
 			"cast": "DEATHCLD"
@@ -203,6 +210,7 @@
 	},
 	"thunderbolt" : {
 		"index" : 77,
+		"targetType": "NO_TARGET",
 		"anim" : 38,
 		"sounds": {
 			"cast": "LIGHTBLT"
@@ -220,6 +228,7 @@
 	},
 	"dispelHelpful" : {
 		"index" : 78,
+		"targetType": "NO_TARGET",
 		"anim" : 41,
 		"sounds": {
 			"cast": "DISPELL"
@@ -236,6 +245,7 @@
 	},
 	"deathStare" : {
 		"index" : 79,
+		"targetType": "NO_TARGET",
 		"anim" : 80,
 		"sounds": {
 			"cast": "DEATHSTR"
@@ -255,6 +265,7 @@
 	},
 	"acidBreath" : {
 		"index" : 80,
+		"targetType": "NO_TARGET",
 		"anim" : 81,
 		"sounds": {
 			"cast": "ACID"
@@ -280,6 +291,7 @@
 	},
 	"acidBreathDamage" : {
 		"index" : 81,
+		"targetType": "NO_TARGET",
 		"anim" : 81,
 		"sounds": {
 			"cast": "ACID"

+ 10 - 0
config/spells/adventure.json

@@ -2,6 +2,7 @@
 	"summonBoat" : {
 		"index" : 0,
 		"anim" : -1,
+		"targetType": "NO_TARGET",
 		"sounds": {
 			"cast": "SUMMBOAT"
 		},
@@ -16,6 +17,7 @@
 	},
 	"scuttleBoat" : {
 		"index" : 1,
+		"targetType": "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "SCUTBOAT"
@@ -31,6 +33,7 @@
 	},
 	"visions" : {
 		"index" : 2,
+		"targetType": "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "VISIONS"
@@ -46,6 +49,7 @@
 	},
 	"viewEarth" : {
 		"index" : 3,
+		"targetType": "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "VIEW"
@@ -61,6 +65,7 @@
 	},
 	"disguise" : {
 		"index" : 4,
+		"targetType": "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "DISGUISE"
@@ -76,6 +81,7 @@
 	},
 	"viewAir" : {
 		"index" : 5,
+		"targetType": "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "VIEW"
@@ -91,6 +97,7 @@
 	},
 	"fly" : {
 		"index" : 6,
+		"targetType": "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "FLYSPELL"
@@ -106,6 +113,7 @@
 	},
 	"waterWalk" : {
 		"index" : 7,
+		"targetType": "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "WATRWALK"
@@ -121,6 +129,7 @@
 	},
 	"dimensionDoor" : {
 		"index" : 8,
+		"targetType": "LOCATION",
 		"anim" : -1,
 		"sounds": {
 			"cast": "TELPTOUT"
@@ -136,6 +145,7 @@
 	},
 	"townPortal" : {
 		"index" : 9,
+		"targetType": "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "TELPTOUT"

+ 11 - 1
config/spells/offensive.json

@@ -1,6 +1,7 @@
 {
 	"magicArrow" : {
 		"index" : 15,
+		"targetType": "CREATURE",
 		"anim" : 64,
 		"sounds": {
 			"cast": "MAGICBLT"
@@ -22,6 +23,7 @@
 	},
 	"iceBolt" : {
 		"index" : 16,
+		"targetType": "CREATURE",
 		"anim" : 46,
 		"sounds": {
 			"cast": "ICERAY"
@@ -43,6 +45,7 @@
 	},
 	"lightningBolt" : {
 		"index" : 17,
+		"targetType": "CREATURE",
 		"anim" : 38,
 		"sounds": {
 			"cast": "LIGHTBLT"
@@ -64,6 +67,7 @@
 	},
 	"implosion" : {
 		"index" : 18,
+		"targetType": "CREATURE",
 		"anim" : 10,
 		"sounds": {
 			"cast": "DECAY"
@@ -86,6 +90,7 @@
 	},
 	"chainLightning" : {
 		"index" : 19,
+		"targetType": "CREATURE",
 		"anim" : 38,
 		"sounds": {
 			"cast": "CHAINLTE"
@@ -104,6 +109,7 @@
 	},
 	"frostRing" : {
 		"index" : 20,
+		"targetType": "LOCATION",
 		"anim" : 45,
 		"sounds": {
 			"cast": "FROSTING"
@@ -125,6 +131,7 @@
 	},
 	"fireball" : {
 		"index" : 21,
+		"targetType": "LOCATION",
 		"anim" : 53,
 		"sounds": {
 			"cast": "FIREBALL"
@@ -146,6 +153,7 @@
 	},
 	"inferno" : {
 		"index" : 22,
+		"targetType": "LOCATION",
 		"anim" : 9,
 		"sounds": {
 			"cast": "FIREBLST"
@@ -167,6 +175,7 @@
 	},
 	"meteorShower" : {
 		"index" : 23,
+		"targetType": "LOCATION",
 		"anim" : 16,
 		"sounds": {
 			"cast": "METEOR"
@@ -261,6 +270,7 @@
 	},
 	"titanBolt" : {
 		"index" : 57,
+		"targetType" : "CREATURE",
 		"anim" : 38,
 		"sounds": {
 			"cast": "LIGHTBLT"
@@ -277,5 +287,5 @@
 			"negative": true,
 			"special": true
 		}
-	},
+	}
 }

+ 25 - 2
config/spells/other.json

@@ -1,6 +1,7 @@
 {
 	"quicksand" : {
 		"index" : 10,
+		"targetType" : "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": "QUIKSAND"
@@ -16,6 +17,7 @@
 	},
 	"landMine" : {
 		"index" : 11,
+		"targetType" : "NO_TARGET",
 		"anim" : -1,
 		"sounds": {
 			"cast": ""
@@ -35,13 +37,17 @@
 	},
 	"forceField" : {
 		"index" : 12,
+		"targetType" : "LOCATION",
 		"anim" : -1,
 		"sounds": {
 			"cast": "FORCEFLD"
 		},
 		"levels" : {
 			"base":{
-				"range" : "0"
+				"range" : "0",
+				"targetModifier":{
+					"clearAffected": true
+				}
 			}
 		},
 		"flags" : {
@@ -50,13 +56,17 @@
 	},
 	"fireWall" : {
 		"index" : 13,
+		"targetType" : "LOCATION",		
 		"anim" : -1,
 		"sounds": {
 			"cast": "FIREWALL"
 		},
 		"levels" : {
 			"base":{
-				"range" : "0"
+				"range" : "0",
+				"targetModifier":{
+					"clearAffected": true
+				}				
 			}
 		},
 		"flags" : {
@@ -69,6 +79,7 @@
 	},
 	"earthquake" : {
 		"index" : 14,
+		"targetType" : "NO_TARGET",		
 		"anim" : -1,
 		"sounds": {
 			"cast": "ERTHQUAK"
@@ -85,6 +96,7 @@
 	
 	"dispel" : {
 		"index" : 35,
+		"targetType" : "CREATURE",			
 		"anim" : 41,
 		"sounds": {
 			"cast": "DISPELL"
@@ -103,6 +115,7 @@
 	},
 	"cure" : {
 		"index" : 37,
+		"targetType" : "CREATURE",		
 		"anim" : 39,
 		"sounds": {
 			"cast": "CURE"
@@ -122,6 +135,7 @@
 	},
 	"resurrection" : {
 		"index" : 38,
+		"targetType" : "CREATURE",			
 		"anim" : 79,
 		"sounds": {
 			"cast": "RESURECT"
@@ -143,6 +157,7 @@
 	},
 	"animateDead" : {
 		"index" : 39,
+		"targetType" : "CREATURE",			
 		"anim" : 79,
 		"sounds": {
 			"cast": "ANIMDEAD"
@@ -163,6 +178,7 @@
 	},
 	"sacrifice" : {
 		"index" : 40,
+		"targetType" : "CREATURE",			
 		"anim" : 79,
 		"sounds": {
 			"cast": "SACRIF1"
@@ -184,6 +200,7 @@
 	},
 	"teleport" : {
 		"index" : 63,
+		"targetType" : "CREATURE",			
 		"anim" : -1,
 		"sounds": {
 			"cast": "TELPTOUT"
@@ -203,6 +220,7 @@
 	},
 	"removeObstacle" : {
 		"index" : 64,
+		"targetType" : "OBSTACLE",		
 		"anim" : -1,
 		"sounds": {
 			"cast": "REMOVEOB"
@@ -218,6 +236,7 @@
 	},
 	"clone" : {
 		"index" : 65,
+		"targetType" : "CREATURE",		
 		"anim" : -1,
 		"sounds": {
 			"cast": "CLONE"
@@ -237,6 +256,7 @@
 	},
 	"fireElemental" : {
 		"index" : 66,
+		"targetType" : "NO_TARGET",		
 		"anim" : -1,
 		"sounds": {
 			"cast": "SUMNELM"
@@ -252,6 +272,7 @@
 	},
 	"earthElemental" : {
 		"index" : 67,
+		"targetType" : "NO_TARGET",	
 		"anim" : -1,
 		"sounds": {
 			"cast": "SUMNELM"
@@ -267,6 +288,7 @@
 	},
 	"waterElemental" : {
 		"index" : 68,
+		"targetType" : "NO_TARGET",	
 		"anim" : -1,
 		"sounds": {
 			"cast": "SUMNELM"
@@ -282,6 +304,7 @@
 	},
 	"airElemental" : {
 		"index" : 69,
+		"targetType" : "NO_TARGET",	
 		"anim" : -1,
 		"sounds": {
 			"cast": "SUMNELM"

+ 29 - 1
config/spells/timed.json

@@ -1,6 +1,7 @@
 {
 	"shield" : {
 		"index" : 27,
+		"targetType" : "CREATURE",			
 		"anim" : 27,
 		"sounds": {
 			"cast": "SHIELD"
@@ -27,6 +28,7 @@
 	},
 	"airShield" : {
 		"index" : 28,
+		"targetType" : "CREATURE",
 		"anim" : 2,
 		"sounds": {
 			"cast": "AIRSHELD"
@@ -53,6 +55,7 @@
 	},
 	"fireShield" : {
 		"index" : 29,
+		"targetType" : "CREATURE",
 		"anim" : 11,
 		"sounds": {
 			"cast": "FIRESHIE"
@@ -81,6 +84,7 @@
 	},
 	"protectAir" : {
 		"index" : 30,
+		"targetType" : "CREATURE",
 		"anim" : 22,
 		"sounds": {
 			"cast": "PROTECTA"
@@ -107,6 +111,7 @@
 	},
 	"protectFire" : {
 		"index" : 31,
+		"targetType" : "CREATURE",
 		"anim" : 24,
 		"sounds": {
 			"cast": "PROTECTF"
@@ -133,6 +138,7 @@
 	},
 	"protectWater" : {
 		"index" : 32,
+		"targetType" : "CREATURE",
 		"anim" : 23,
 		"sounds": {
 			"cast": "PROTECTW"
@@ -159,6 +165,7 @@
 	},
 	"protectEarth" : {
 		"index" : 33,
+		"targetType" : "CREATURE",
 		"anim" : 26,
 		"sounds": {
 			"cast": "PROTECTE"
@@ -185,6 +192,7 @@
 	},
 	"antiMagic" : {
 		"index" : 34,
+		"targetType" : "CREATURE",
 		"anim" : 5,
 		"sounds": {
 			"cast": "ANTIMAGK"
@@ -224,6 +232,7 @@
 
 	"magicMirror" : {
 		"index" : 36,
+		"targetType" : "CREATURE",
 		"anim" : 3,
 		"sounds": {
 			"cast": "BACKLASH"
@@ -248,6 +257,7 @@
 
 	"bless" : {
 		"index" : 41,
+		"targetType" : "CREATURE",
 		"anim" : 36,
 		"sounds": {
 			"cast": "BLESS"
@@ -282,6 +292,7 @@
 	},
 	"curse" : {
 		"index" : 42,
+		"targetType" : "CREATURE",
 		"anim" : 40,
 		"sounds": {
 			"cast": "CURSE"
@@ -317,6 +328,7 @@
 	},
 	"bloodlust" : {
 		"index" : 43,
+		"targetType" : "CREATURE",
 		"anim" : 4,
 		"sounds": {
 			"cast": "BLOODLUS"
@@ -360,6 +372,7 @@
 	},
 	"precision" : {
 		"index" : 44,
+		"targetType" : "CREATURE",
 		"anim" : 25,
 		"sounds": {
 			"cast": "PRECISON"
@@ -403,6 +416,7 @@
 	},
 	"weakness" : {
 		"index" : 45,
+		"targetType" : "CREATURE",
 		"anim" : 56,
 		"sounds": {
 			"cast": "WEAKNESS"
@@ -446,6 +460,7 @@
 	},
 	"stoneSkin" : {
 		"index" : 46,
+		"targetType" : "CREATURE",
 		"anim" : 54,
 		"sounds": {
 			"cast": "TUFFSKIN"
@@ -485,7 +500,7 @@
 	},
 	"disruptingRay" : {
 		"index" : 47,
-		"targetType" : "CREATURE", //fix, dont remove
+		"targetType" : "CREATURE",
 		"anim" : 14,
 		"sounds": {
 			"cast": "DISRUPTR"
@@ -525,6 +540,7 @@
 	},
 	"prayer" : {
 		"index" : 48,
+		"targetType" : "CREATURE",
 		"anim" : 0,
 		"sounds": {
 			"cast": "PRAYER"
@@ -588,6 +604,7 @@
 	},
 	"mirth" : {
 		"index" : 49,
+		"targetType" : "CREATURE",
 		"anim" : 20,
 		"sounds": {
 			"cast": "MIRTH"
@@ -636,6 +653,7 @@
 	},
 	"sorrow" : {
 		"index" : 50,
+		"targetType" : "CREATURE",
 		"anim" : 30,
 		"sounds": {
 			"cast": "SORROW"
@@ -684,6 +702,7 @@
 	},
 	"fortune" : {
 		"index" : 51,
+		"targetType" : "CREATURE",
 		"anim" : 18,
 		"sounds": {
 			"cast": "FORTUNE"
@@ -725,6 +744,7 @@
 	},
 	"misfortune" : {
 		"index" : 52,
+		"targetType" : "CREATURE",
 		"anim" : 48,
 		"sounds": {
 			"cast": "MISFORT"
@@ -766,6 +786,7 @@
 	},
 	"haste" : {
 		"index" : 53,
+		"targetType" : "CREATURE",
 		"anim" : 31,
 		"sounds": {
 			"cast": "HASTE"
@@ -811,6 +832,7 @@
 	},
 	"slow" : {
 		"index" : 54,
+		"targetType" : "CREATURE",
 		"anim" : 19,
 		"sounds": {
 			"cast": "MUCKMIRE"
@@ -858,6 +880,7 @@
 	},
 	"slayer" : {
 		"index" : 55,
+		"targetType" : "CREATURE",
 		"anim" : 28,
 		"sounds": {
 			"cast": "SLAYER"
@@ -908,6 +931,7 @@
 	},
 	"frenzy" : {
 		"index" : 56,
+		"targetType" : "CREATURE",
 		"anim" : 17,
 		"sounds": {
 			"cast": "FRENZY"
@@ -946,6 +970,7 @@
 
 	"counterstrike" : {
 		"index" : 58,
+		"targetType" : "CREATURE",
 		"anim" : 7,
 		"sounds": {
 			"cast": "CNTRSTRK"
@@ -984,6 +1009,7 @@
 	},
 	"berserk" : {
 		"index" : 59,
+		"targetType" : "CREATURE",
 		"anim" : 35,
 		"sounds": {
 			"cast": "BERSERK"
@@ -1042,6 +1068,7 @@
 	},
 	"hypnotize" : {
 		"index" : 60,
+		"targetType" : "CREATURE",
 		"anim" : 21,
 		"sounds": {
 			"cast": "HYPNOTIZ"
@@ -1158,6 +1185,7 @@
 	},
 	"blind" : {
 		"index" : 62,
+		"targetType" : "CREATURE",
 		"anim" : 6,
 		"sounds": {
 			"cast": "BLIND"

+ 13 - 30
lib/CSpellHandler.cpp

@@ -35,7 +35,7 @@ namespace SpellConfig
 
 ///CSpell::LevelInfo
 CSpell::LevelInfo::LevelInfo()
-	:description(""),cost(0),power(0),AIValue(0),smartTarget(true),range("0")
+	:description(""),cost(0),power(0),AIValue(0),smartTarget(true), clearTarget(false), clearAffected(false), range("0")
 {
 
 }
@@ -587,17 +587,7 @@ std::vector<JsonNode> CSpellHandler::loadLegacyData(size_t dataSize)
 			for(size_t i = 0; i < GameConstants::SPELL_SCHOOL_LEVELS ; i++)
 				descriptions.push_back(parser.readString());
 
-			std::string attributes = parser.readString();
-
-			std::string targetType = "NO_TARGET";
-
-			if(attributes.find("CREATURE_TARGET_1") != std::string::npos
-				|| attributes.find("CREATURE_TARGET_2") != std::string::npos)
-				targetType = "CREATURE_EXPERT_MASSIVE";
-			else if(attributes.find("CREATURE_TARGET") != std::string::npos)
-				targetType = "CREATURE";
-			else if(attributes.find("OBSTACLE_TARGET") != std::string::npos)
-				targetType = "OBSTACLE";
+			parser.readString(); //ignore attributes. All data present in JSON
 
 			//save parsed level specific data
 			for(size_t i = 0; i < GameConstants::SPELL_SCHOOL_LEVELS; i++)
@@ -609,16 +599,6 @@ std::vector<JsonNode> CSpellHandler::loadLegacyData(size_t dataSize)
 				level["aiValue"].Float() = AIVals[i];
 			}
 
-			if(targetType == "CREATURE_EXPERT_MASSIVE")
-			{
-				lineNode["targetType"].String() = "CREATURE";
-				getLevel(3)["range"].String() = "X";
-			}
-			else
-			{
-				lineNode["targetType"].String() = targetType;
-			}
-
 			legacyData.push_back(lineNode);
 
 
@@ -708,6 +688,8 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
 		spell->targetType = CSpell::CREATURE;
 	else if(targetType == "OBSTACLE")
 		spell->targetType = CSpell::OBSTACLE;
+	else if(targetType == "LOCATION")
+		spell->targetType = CSpell::LOCATION;
 	else 
 		logGlobal->warnStream() << "Spell " << spell->name << ". Target type " << (targetType.empty() ? "empty" : "unknown ("+targetType+")") << ". Assumed NO_TARGET.";
 
@@ -812,14 +794,15 @@ CSpell * CSpellHandler::loadFromJson(const JsonNode& json)
 		
 		CSpell::LevelInfo & levelObject = spell->levels[levelIndex];
 
-		const si32 levelPower   = levelNode["power"].Float();		
-		
-		levelObject.description = levelNode["description"].String();
-		levelObject.cost        = levelNode["cost"].Float();
-		levelObject.power       = levelPower;
-		levelObject.AIValue     = levelNode["aiValue"].Float();
-		levelObject.smartTarget = levelNode["targetModifier"]["smart"].Bool();
-		levelObject.range       = levelNode["range"].String();
+		const si32 levelPower     = levelObject.power = levelNode["power"].Float();		
+
+		levelObject.description   = levelNode["description"].String();
+		levelObject.cost          = levelNode["cost"].Float();
+		levelObject.AIValue       = levelNode["aiValue"].Float();
+		levelObject.smartTarget   = levelNode["targetModifier"]["smart"].Bool();
+		levelObject.clearTarget   = levelNode["targetModifier"]["clearTarget"].Bool();
+		levelObject.clearAffected = levelNode["targetModifier"]["clearAffected"].Bool();			
+		levelObject.range         = levelNode["range"].String();
 		
 		for(const auto & elem : levelNode["effects"].Struct())
 		{

+ 4 - 1
lib/CSpellHandler.h

@@ -103,6 +103,8 @@ public:
 		si32 AIValue; //AI values: per skill level: 0 - none, 1 - basic, etc
 
 		bool smartTarget;
+		bool clearTarget;
+		bool clearAffected;
 		std::string range;
 
 		std::vector<Bonus> effects;
@@ -113,6 +115,7 @@ public:
 		template <typename Handler> void serialize(Handler &h, const int version)
 		{
 			h & description & cost & power & AIValue & smartTarget & range & effects;
+			h & clearTarget & clearAffected;
 		}
 	};
 
@@ -124,7 +127,7 @@ public:
 	 */
 	const CSpell::LevelInfo& getLevelInfo(const int level) const;
 public:
-	enum ETargetType {NO_TARGET, CREATURE, OBSTACLE};
+	enum ETargetType {NO_TARGET, CREATURE, OBSTACLE, LOCATION};
 	enum ESpellPositiveness {NEGATIVE = -1, NEUTRAL = 0, POSITIVE = 1};
 
 	struct TargetInfo

+ 1 - 1
lib/Connection.h

@@ -27,7 +27,7 @@
 #include "mapping/CCampaignHandler.h" //for CCampaignState
 #include "rmg/CMapGenerator.h" // for CMapGenOptions
 
-const ui32 version = 750;
+const ui32 version = 751;
 const ui32 minSupportedVersion = version;
 
 class CConnection;