stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src/clone ccl_spell.c spells.c


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src/clone ccl_spell.c spells.c
Date: 14 Dec 2003 06:10:30 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       03/12/14 06:10:30

Modified files:
        src/clone      : ccl_spell.c spells.c 

Log message:
        Added support for Reclaim spell.

Patches:
Index: stratagus/src/clone/ccl_spell.c
diff -u stratagus/src/clone/ccl_spell.c:1.29 
stratagus/src/clone/ccl_spell.c:1.30
--- stratagus/src/clone/ccl_spell.c:1.29        Sat Nov 22 10:51:28 2003
+++ stratagus/src/clone/ccl_spell.c     Sun Dec 14 06:10:28 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_spell.c,v 1.29 2003/11/21 23:51:28 jsalmon3 Exp $
+//     $Id: ccl_spell.c,v 1.30 2003/12/13 19:10:28 mohydine Exp $
 //@{
 
 /*----------------------------------------------------------------------------
@@ -240,7 +240,23 @@
                errl("Unsupported area-bombardment tag", value);
            }
        }
-    } else if (gh_eq_p(value, gh_symbol2scm("demolish"))) {
+    } else if (gh_eq_p(value, gh_symbol2scm("reclaim"))) {
+       spellaction->CastFunction = CastReclaim;
+       while (!gh_null_p(list)) {
+           value = gh_car(list);
+           list = gh_cdr(list);
+           if (gh_eq_p(value, gh_symbol2scm("range"))) {
+               spellaction->Data.Demolish.Range = gh_scm2int(gh_car(list));
+               list = gh_cdr(list);
+           } else if (gh_eq_p(value, gh_symbol2scm("damage"))) {
+               spellaction->Data.Demolish.Damage = gh_scm2int(gh_car(list));
+               list = gh_cdr(list);
+           } else {
+               errl("Unsupported reclaim tag", value);
+           }
+
+    }
+       } else if (gh_eq_p(value, gh_symbol2scm("demolish"))) {
        spellaction->CastFunction = CastDemolish;
        while (!gh_null_p(list)) {
            value = gh_car(list);
@@ -254,6 +270,7 @@
            } else {
                errl("Unsupported demolish tag", value);
            }
+
        }
     } else if (gh_eq_p(value, gh_symbol2scm("adjust-buffs"))) {
        spellaction->CastFunction = CastAdjustBuffs;
Index: stratagus/src/clone/spells.c
diff -u stratagus/src/clone/spells.c:1.130 stratagus/src/clone/spells.c:1.131
--- stratagus/src/clone/spells.c:1.130  Sun Nov 30 15:21:23 2003
+++ stratagus/src/clone/spells.c        Sun Dec 14 06:10:29 2003
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: spells.c,v 1.130 2003/11/30 04:21:23 jsalmon3 Exp $
+//     $Id: spells.c,v 1.131 2003/12/13 19:10:29 mohydine Exp $
 
 /*
 **     And when we cast our final spell
@@ -86,6 +86,43 @@
 // Cast the Spell
 // ****************************************************************************
 
+
+/**
+**     Cast Reclaim
+**     @param caster   Unit that casts the spell
+**     @param spell    Spell-type pointer
+**     @param target   Target unit that spell is addressed to
+**     @param x        X coord of target spot when/if target does not exist
+**     @param y        Y coord of target spot when/if target does not exist
+**
+**     @return         =!0 if spell should be repeated, 0 if not
+*/
+global int CastReclaim(Unit* caster, const SpellType* spell 
__attribute__((unused)),
+       const SpellActionType* action,Unit* target __attribute__((unused)), int 
x, int y)
+{
+       //UnitType* type;
+
+    DebugCheck(!caster);
+    DebugCheck(!spell);
+    DebugCheck(!spell->Action);
+    DebugCheck(!target);
+
+       PlayerAddCostsFactor(caster->Player, target->Stats->Costs, 50);
+    
+       if (spell->Missile) {
+       MakeMissile(spell->Missile,
+           x * TileSizeX + TileSizeX / 2, y * TileSizeY + TileSizeY / 2,
+           x * TileSizeX + TileSizeX / 2, y * TileSizeY + TileSizeY / 2);
+       //FIXME: need to center the missile correctly
+    }
+    RemoveUnit(target, NULL);
+    UnitLost(target);
+    UnitClearOrders(target);
+    ReleaseUnit(target);
+    
+    return 0;
+}
+
 /**
 **     Cast demolish
 **     @param caster   Unit that casts the spell
@@ -182,7 +219,7 @@
     // FIXME: vladi: cop should be placed only on explored land
     Unit* portal;
     UnitType* ptype;
-
+    
     DebugCheck(!caster);
     DebugCheck(!spell);
     DebugCheck(!spell->Action);
@@ -242,26 +279,26 @@
     mana = action->Data.AreaAdjustVitals.Mana;
     caster->Mana -= spell->ManaCost;
     for (j = 0; j < nunits; ++j) {
-       target = units[j];
+        target = units[j];
 //     if (!PassCondition(caster, spell, target, x, y) {
        if (!CanCastSpell(caster, spell, target, x, y)) {
            continue;
        }
-       if (hp < 0) {
+        if (hp < 0) {
            HitUnit(caster, target, -hp);
-       } else {
+        } else {
            target->HP += hp;
            if (target->HP > target->Stats->HitPoints) {
                target->HP = target->Stats->HitPoints;
            }
-       }
-       target->Mana += mana;
-       if (target->Mana < 0) {
+        }
+        target->Mana += mana;
+        if (target->Mana < 0) {
            target->Mana = 0;
-       }
-       if (target->Mana > target->Type->_MaxMana) {
+        }
+        if (target->Mana > target->Type->_MaxMana) {
            target->Mana = target->Type->_MaxMana;
-       }
+        }
     }
     return 0;
 }
@@ -638,7 +675,7 @@
                    (*corpses)->Y >= y - 1 && (*corpses)->Y <= y + 1) {
                //
                //  Found a corpse. eliminate it and proceed to summoning.
-               //
+               //  
                x = (*corpses)->X;
                y = (*corpses)->Y;
                tempcorpse = *corpses;
@@ -650,7 +687,7 @@
                corpses = &(*corpses)->Next;
            }
        }
-    } else {
+    } else { 
        cansummon = 1;
     }
 
@@ -666,7 +703,7 @@
        target->Y = y;
        //
        //  set life span. ttl=0 results in a permanent unit.
-       //
+       //  
        if (ttl) {
            target->TTL = GameCycle + ttl;
        }
@@ -684,7 +721,7 @@
            DropOutOnSide(target, LookingW, 0, 0);
            CheckUnitToBeDrawn(target);
        }
-
+       
        caster->Mana -= spell->ManaCost;
 
        MakeMissile(spell->Missile,
@@ -767,7 +804,7 @@
        return 0;
     }
     //
-    // Casting an unit spell without a target.
+    // Casting an unit spell without a target. 
     //
     if (spell->Target == TargetUnit && !target) {
        return 0;
@@ -790,15 +827,15 @@
                return 0;
            }
        }
-       for (i = 0; i < NumberBoolFlag; i++) { // User defined flags
-           if (condition->BoolFlag[i] != CONDITION_TRUE) {
-               if ((condition->BoolFlag[i] == CONDITION_ONLY) ^ 
(target->Type->BoolFlag[i])) {
-                   return 0;
-               }
-           }
+        for (i = 0; i < NumberBoolFlag; i++) { // User defined flags
+            if (condition->BoolFlag[i] != CONDITION_TRUE) {
+                if ((condition->BoolFlag[i] == CONDITION_ONLY) ^ 
(target->Type->BoolFlag[i])) {
+                    return 0;
+                }
+            }
        }
        if (condition->Alliance != CONDITION_TRUE) {
-           if ((condition->Alliance == CONDITION_ONLY) ^
+           if ((condition->Alliance == CONDITION_ONLY) ^ 
                    (IsAllied(caster->Player,target) || target->Player == 
caster->Player)) {
                return 0;
            }
@@ -854,7 +891,7 @@
 **
 **     @param caster   Unit who would cast the spell.
 **     @param spell    Spell-type pointer.
-**
+**     
 **     @return Target* choosen target or Null if spell can't be cast.
 **
 */
@@ -898,7 +935,7 @@
        caster->Y + range + caster->Type->TileHeight, table);
     //
     //  Check every unit if it is hostile
-    //
+    // 
     combat = 0;
     for (i = 0; i < nunits; ++i) {
        if (IsEnemy(caster->Player, table[i]) && !table[i]->Type->Coward) {
@@ -934,7 +971,7 @@
            //
            //  The units are already selected.
            //  Check every unit if it is a possible target
-           //
+           // 
            for (i = 0, j = 0; i < nunits; ++i) {
                //  FIXME: autocast conditions should include normal conditions.
                //  FIXME: no, really, they should.
@@ -944,9 +981,9 @@
                }
            }
            nunits = j;
-           //
+           //  
            //  Now select the best unit to target.
-           //  FIXME: Some really smart way to do this.
+           //  FIXME: Some really smart way to do this. 
            //  FIXME: Heal the unit with the lowest hit-points
            //  FIXME: Bloodlust the unit with the highest hit-point
            //  FIMXE: it will survive more
@@ -1035,7 +1072,7 @@
 */
 #if defined(USE_GUILE) || defined(USE_SIOD)
 global unsigned CclGetSpellByIdent(SCM value)
-{
+{  
     int i;
 
     for (i = 0; i < SpellTypeCount; ++i) {
@@ -1046,19 +1083,6 @@
     return -1;
 }
 #elif defined(USE_LUA)
-global unsigned CclGetSpellByIdent(lua_State* l)
-{
-    int i;
-    const char* value;
-
-    value = LuaToString(l, -1);
-    for (i = 0; i < SpellTypeCount; ++i) {
-       if (!strcmp(value, SpellTypeTable[i].IdentName)) {
-           return i;
-       }
-    }
-    return -1;
-}
 #endif
 
 /**
@@ -1081,12 +1105,12 @@
 /**
 **     Check if spell is research for player \p player.
 **     @param  player : player for who we want to know if he knows the spell.
-**     @param  id :
+**     @param  id : 
 */
 global int SpellIsAvailable(const Player* player, int spellid)
 {
     int dependencyId;
-
+    
     DebugCheck(!player);
     DebugCheck(!(0 <= spellid && spellid < SpellTypeCount));
 
@@ -1245,12 +1269,12 @@
     //
     // Can't cast, STOP.
     //
-    return 0;
+    return 0; 
 }
 
 /*
 **     Cleanup the spell subsystem.
-**
+**     
 **     @note: everything regarding spells is gone now.
 **     FIXME: not complete
 */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]