]> git.localhorst.tv Git - l2e.git/blobdiff - src/common/Spell.cpp
first scripting implementation
[l2e.git] / src / common / Spell.cpp
index 907034645b76373b3961340614b988cc6007bbbe..bcf7f2948aaf1b0579502d052f2c2d3dd8ab63fd 100644 (file)
@@ -15,25 +15,33 @@ using loader::TypeDescription;
 namespace common {
 
 Spell::Spell()
-: name(""), value(0), cost(0), usability(0) {
+: name(""), value(0), cost(0), status(false), battle(false) {
 
 }
 
 
 void Spell::CreateTypeDescription() {
        Spell s;
-       TypeDescription &td(TypeDescription::CreateOrGet("Spell"));
-
-       td.SetSize(sizeof(Spell));
 
-       // TODO: flags
+       int boolId(TypeDescription::GetTypeId("Boolean"));
        int numberId(TypeDescription::GetTypeId("Number"));
        int stringId(TypeDescription::GetTypeId("String"));
        int targetsId(TypeDescription::GetTypeId("TargetingMode"));
 
-       td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), stringId, true));
-       td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), numberId, false));
-       td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), targetsId, false));
+       TypeDescription &td(TypeDescription::CreateOrGet("Spell"));
+       td.SetDescription("All data about a spell (soon).");
+       td.SetConstructor(&Construct);
+       td.SetSize(sizeof(Spell));
+
+       td.AddField("name", FieldDescription(((char *)&s.name) - ((char *)&s), stringId).SetReferenced().SetDescription("the spell's name"));
+       td.AddField("cost", FieldDescription(((char *)&s.cost) - ((char *)&s), numberId).SetDescription("Amount of magic points needed and deducted for invocation"));
+       td.AddField("targets", FieldDescription(((char *)&s.targetingMode) - ((char *)&s), targetsId).SetDescription("how target selection is to be performed"));
+       td.AddField("status", FieldDescription(((char *)&s.status) - ((char *)&s), boolId).SetDescription("if the spell can be used at the status screen"));
+       td.AddField("battle", FieldDescription(((char *)&s.battle) - ((char *)&s), boolId).SetDescription("if the spell can be used in battle"));
+}
+
+void Spell::Construct(void *data) {
+       new (data) Spell;
 }
 
 }