[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus data/ccl/missiles.ccl data/ccl/spells...
From: |
Crestez Leonard |
Subject: |
[Stratagus-CVS] stratagus data/ccl/missiles.ccl data/ccl/spells... |
Date: |
Fri, 03 Oct 2003 06:37:08 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Crestez Leonard <address@hidden> 03/10/03 06:37:08
Modified files:
data/ccl : missiles.ccl spells.ccl
src/action : actions.c
src/ai : ai_magic.c
src/clone : ccl_spell.c spells.c
src/game : loadgame.c
src/include : spells.h
Log message:
Ai uses it's own autocast. Added spell cleanup code.
Patches:
Index: stratagus/data/ccl/missiles.ccl
diff -u stratagus/data/ccl/missiles.ccl:1.32
stratagus/data/ccl/missiles.ccl:1.33
--- stratagus/data/ccl/missiles.ccl:1.32 Fri Sep 26 16:32:00 2003
+++ stratagus/data/ccl/missiles.ccl Fri Oct 3 06:37:04 2003
@@ -26,7 +26,7 @@
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
;;
-;; $Id: missiles.ccl,v 1.32 2003/09/26 20:32:00 jsalmon3 Exp $
+;; $Id: missiles.ccl,v 1.33 2003/10/03 10:37:04 n0body Exp $
;; NOTE: the missiles could be sorted for races, but did this make sense?
@@ -42,135 +42,169 @@
'file "missiles/lightning.png" 'size '(32 32) 'frames 30
'class 'missile-class-point-to-point-with-hit 'sleep 1 'speed 16 'range 1
'draw-level 50)
+
(define-missile-type 'missile-griffon-hammer
'file "missiles/gryphon_hammer.png" 'size '(32 32) 'frames 15
'impact-sound "fireball hit"
'class 'missile-class-point-to-point-3bounces 'sleep 1 'speed 16 'range 2
'draw-level 50 'impact-missile 'missile-explosion)
+
(define-missile-type 'missile-dragon-breath
'file "missiles/dragon_breath.png" 'size '(32 32) 'frames 5
'impact-sound "fireball hit"
'class 'missile-class-point-to-point-3bounces 'sleep 1 'speed 16 'range 2
'draw-level 70 'impact-missile 'missile-explosion)
+
(define-missile-type 'missile-fireball
'file "missiles/fireball.png" 'size '(32 32) 'frames 5
'impact-sound "fireball hit"
'draw-level 50 'class 'missile-class-point-to-point 'sleep 1 'speed 16
'range 1)
+
(define-missile-type 'missile-flame-shield
'file "missiles/flame_shield.png" 'size '(32 48) 'frames 6
'draw-level 50 'class 'missile-class-flame-shield 'sleep 2 'speed 4 'range 1)
+
(define-missile-type 'missile-blizzard
'file "missiles/blizzard.png" 'size '(32 32) 'frames 4
'class 'missile-class-blizzard 'sleep 2 'speed 8 'range 1
'draw-level 100 'impact-missile 'missile-blizzard-hit)
+
(define-missile-type 'missile-death-and-decay
'file "missiles/death_and_decay.png" 'size '(32 32) 'frames 8
'draw-level 100 'class 'missile-class-death-decay 'sleep 1 'speed 0 'range 1)
+
(define-missile-type 'missile-big-cannon
'file "missiles/big_cannon.png" 'size '(16 16) 'frames 20
'draw-level 50 'impact-sound "explosion"
'class 'missile-class-point-to-point 'sleep 1 'speed 16 'range 2
'impact-missile 'missile-cannon-tower-explosion)
+
(define-missile-type 'missile-exorcism
'file "missiles/exorcism.png" 'size '(48 48) 'frames 10
'draw-level 50 'class 'missile-class-point-to-point 'sleep 1 'speed 16
'range 1)
+
(define-missile-type 'missile-heal-effect
'file "missiles/heal_effect.png" 'size '(48 48) 'frames 10
'draw-level 50 'class 'missile-class-stay-with-delay 'sleep 1 'speed 16
'range 1)
+
(define-missile-type 'missile-touch-of-death
'file "missiles/touch_of_death.png" 'size '(32 32) 'frames 30
'draw-level 50 'class 'missile-class-point-to-point-with-hit 'sleep 1 'speed
16 'range 1)
+
(define-missile-type 'missile-rune
'file "missiles/rune.png" 'size '(16 16) 'frames 4
'draw-level 20 'class 'missile-class-stay-with-delay 'sleep 5 'speed 16
'range 1)
+
(define-missile-type 'missile-whirlwind
'file "missiles/tornado.png" 'size '(56 56) 'frames 4
'draw-level 50 'class 'missile-class-whirlwind 'sleep 2 'speed 2 'range 1)
+
(define-missile-type 'missile-catapult-rock
'file "missiles/catapult_rock.png" 'size '(32 32) 'frames 15
'impact-sound "explosion"
'draw-level 50 'class 'missile-class-point-to-point-with-delay 'sleep 1
'speed 16 'range 2
'impact-missile 'missile-impact)
+
(define-missile-type 'missile-ballista-bolt
'file "missiles/ballista_bolt.png" 'size '(64 64) 'frames 5
'draw-level 50 'impact-sound "explosion"
'class 'missile-class-point-to-point 'sleep 1 'speed 16 'range 2
'impact-missile 'missile-impact)
+
(define-missile-type 'missile-arrow
'file "missiles/arrow.png" 'size '(40 40) 'frames 5
'draw-level 50 'impact-sound "bow hit"
'class 'missile-class-point-to-point 'sleep 1 'speed 32 'range 0)
+
(define-missile-type 'missile-axe
'file "missiles/axe.png" 'size '(32 32) 'frames 15
'impact-sound "bow hit"
'draw-level 50 'class 'missile-class-point-to-point 'sleep 1 'speed 32
'range 0)
+
(define-missile-type 'missile-submarine-missile
'file "missiles/submarine_missile.png" 'size '(40 40) 'frames 5
'impact-sound "explosion"
'draw-level 50 'class 'missile-class-point-to-point 'sleep 1 'speed 16
'range 1
'impact-missile 'missile-impact)
+
(define-missile-type 'missile-turtle-missile
'file "missiles/turtle_missile.png" 'size '(40 40) 'frames 5
'draw-level 50 'impact-sound "explosion"
'class 'missile-class-point-to-point 'sleep 1 'speed 16 'range 1
'impact-missile 'missile-impact)
+
(define-missile-type 'missile-small-fire
'file "missiles/small_fire.png" 'size '(32 48) 'frames 6
'draw-level 45 'class 'missile-class-fire 'sleep 8 'speed 16 'range 1)
+
(define-missile-type 'missile-big-fire
'file "missiles/big_fire.png" 'size '(48 48) 'frames 10
'draw-level 45 'class 'missile-class-fire 'sleep 8 'speed 16 'range 1)
+
(define-missile-type 'missile-impact
'file "missiles/ballista-catapult_impact.png" 'size '(48 48) 'frames 10
'draw-level 50 'class 'missile-class-stay-with-delay 'sleep 1 'speed 16
'range 1)
+
(define-missile-type 'missile-normal-spell
'file "missiles/normal_spell.png" 'size '(32 32) 'frames 6
'draw-level 50 'class 'missile-class-stay-with-delay 'sleep 5 'speed 0
'range 1)
+
(define-missile-type 'missile-explosion
'file "missiles/explosion.png" 'size '(64 64) 'frames 20
'draw-level 50 'class 'missile-class-stay-with-delay 'sleep 1 'speed 16
'range 1)
+
(define-missile-type 'missile-small-cannon
'file "missiles/cannon.png" 'size '(32 32) 'frames 15
'draw-level 50 'impact-sound "explosion"
'class 'missile-class-point-to-point-with-delay 'sleep 1 'speed 16 'range 1
'impact-missile 'missile-cannon-explosion)
+
(define-missile-type 'missile-cannon-explosion
'file "missiles/cannon_explosion.png" 'size '(32 32) 'frames 4
'draw-level 50 'class 'missile-class-stay-with-delay 'sleep 1 'speed 16
'range 1)
+
(define-missile-type 'missile-cannon-tower-explosion
'file "missiles/cannon-tower_explosion.png" 'size '(32 32) 'frames 4
'draw-level 50 'class 'missile-class-stay-with-delay 'sleep 1 'speed 16
'range 1)
+
(define-missile-type 'missile-daemon-fire
'file "missiles/daemon_fire.png" 'size '(32 32) 'frames 15
'draw-level 70 'impact-sound "fireball hit"
'class 'missile-class-point-to-point 'sleep 1 'speed 16 'range 1)
+
(define-missile-type 'missile-green-cross
'file "missiles/green_cross.png" 'size '(32 32) 'frames 4
'draw-level 150 'class 'missile-class-cycle-once 'sleep 1 'speed 16 'range 1)
+
(define-missile-type 'missile-red-cross
'file "missiles/red_cross.png" 'size '(32 32) 'frames 4
'draw-level 5 'class 'missile-class-cycle-once 'sleep 1 'speed 16 'range 1)
+
(define-missile-type 'missile-none
'size '(32 32) 'draw-level 50
'class 'missile-class-none 'sleep 1 'speed 16 'range 1)
+
(define-missile-type 'missile-blizzard-hit
'file "missiles/blizzard.png" 'size '(32 32) 'frames 4
'draw-level 60 'class 'missile-class-stay-with-delay 'sleep 2 'speed 8
'range 1)
+
(define-missile-type 'missile-death-coil
'file "missiles/touch_of_death.png" 'size '(32 32) 'frames 30
'draw-level 50 'class 'missile-class-point-to-point 'sleep 1 'speed 16
'range 1)
+
(define-missile-type 'missile-hit
'size '(15 15) 'draw-level 150
'class 'missile-class-hit 'sleep 1 'speed 1 'range 16)
+
(define-missile-type 'missile-custom
'size '(32 32) 'draw-level 50
'class 'missile-class-custom 'sleep 1 'speed 16 'range 1)
+
(define-missile-type 'missile-critter-explosion
'file "missiles/catapult_rock.png" 'size '(32 32) 'frames 15
'impact-sound "explosion" 'draw-level 50
'class 'missile-class-hit 'sleep 1 'speed 16 'range 2
'impact-missile 'missile-impact 'can-hit-owner #t)
-
(define-burning-building
'(percent 0 missile missile-big-fire)
Index: stratagus/data/ccl/spells.ccl
diff -u stratagus/data/ccl/spells.ccl:1.6 stratagus/data/ccl/spells.ccl:1.7
--- stratagus/data/ccl/spells.ccl:1.6 Thu Oct 2 17:21:06 2003
+++ stratagus/data/ccl/spells.ccl Fri Oct 3 06:37:05 2003
@@ -26,7 +26,7 @@
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
;;
-;; $Id: spells.ccl,v 1.6 2003/10/02 21:21:06 n0body Exp $
+;; $Id: spells.ccl,v 1.7 2003/10/03 10:37:05 n0body Exp $
;; For documentation see stratagus/doc/ccl/ccl.html ;; FIXME write and move
doc.
@@ -162,6 +162,7 @@
'sound-when-cast "haste"
'missile-when-cast "missile-normal-spell"
'autocast '(range 6 combat only condition (coward false alliance only))
+ 'ai-cast '(range 6 condition (coward false alliance only))
)
(define-spell "spell-slow"
@@ -176,6 +177,7 @@
'sound-when-cast "slow"
'missile-when-cast "missile-normal-spell"
'autocast '(range 10 combat only condition (coward false alliance
false))
+ 'ai-cast '(range 10 condition (coward false alliance false))
)
(define-spell "spell-bloodlust"
@@ -189,7 +191,8 @@
max-bloodlust-ticks 10)
'sound-when-cast "bloodlust"
'missile-when-cast "missile-normal-spell"
- 'autocast '(range 6 combat only condition (coward false alliance only))
+ 'autocast '(range 6 condition (coward false alliance only))
+ 'ai-cast '(range 6 combat only condition (coward false alliance only))
)
(define-spell "spell-invisibility"
Index: stratagus/src/action/actions.c
diff -u stratagus/src/action/actions.c:1.95 stratagus/src/action/actions.c:1.96
--- stratagus/src/action/actions.c:1.95 Mon Sep 29 13:04:13 2003
+++ stratagus/src/action/actions.c Fri Oct 3 06:37:05 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: actions.c,v 1.95 2003/09/29 17:04:13 n0body Exp $
+// $Id: actions.c,v 1.96 2003/10/03 10:37:05 n0body Exp $
//@{
@@ -614,6 +614,7 @@
HandleUnitAction(unit);
DebugCheck( *tpos!=unit ); // Removed is evil.
+#define DEBUG_ACTIONS
#ifdef DEBUG_ACTIONS
//
// Dump the unit to find the network unsyncron bug.
Index: stratagus/src/ai/ai_magic.c
diff -u stratagus/src/ai/ai_magic.c:1.18 stratagus/src/ai/ai_magic.c:1.19
--- stratagus/src/ai/ai_magic.c:1.18 Mon Sep 29 20:27:52 2003
+++ stratagus/src/ai/ai_magic.c Fri Oct 3 06:37:05 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ai_magic.c,v 1.18 2003/09/30 00:27:52 n0body Exp $
+// $Id: ai_magic.c,v 1.19 2003/10/03 10:37:05 n0body Exp $
//@{
@@ -75,7 +75,7 @@
for (j = 0; j < SpellTypeCount; j++) {
// Check if we can cast this spell. SpellIsAvailable checks
for upgrades.
if (unit->Type->CanCastSpell[j] && SpellIsAvailable(player, j)
&&
- SpellTypeById(j)->AutoCast) {
+ (SpellTypeById(j)->AutoCast ||
SpellTypeById(j)->AICast)) {
#ifdef DEBUG
success = // Follow on next line (AutoCastSpell).
#endif
Index: stratagus/src/clone/ccl_spell.c
diff -u stratagus/src/clone/ccl_spell.c:1.11
stratagus/src/clone/ccl_spell.c:1.12
--- stratagus/src/clone/ccl_spell.c:1.11 Thu Oct 2 17:21:07 2003
+++ stratagus/src/clone/ccl_spell.c Fri Oct 3 06:37:06 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_spell.c,v 1.11 2003/10/02 21:21:07 n0body Exp $
+// $Id: ccl_spell.c,v 1.12 2003/10/03 10:37:06 n0body Exp $
//@{
/*----------------------------------------------------------------------------
@@ -493,18 +493,25 @@
CclSpellAction(gh_car(list),spell->Action);
list=gh_cdr(list);
} else if (gh_eq_p(value,gh_symbol2scm("condition"))) {
- if (!spell->Conditions) {
- spell->Conditions=(ConditionInfo*)malloc(sizeof(ConditionInfo));
+ if (!spell->Condition) {
+ spell->Condition=(ConditionInfo*)malloc(sizeof(ConditionInfo));
}
- CclSpellCondition(gh_car(list),spell->Conditions);
+ CclSpellCondition(gh_car(list),spell->Condition);
list=gh_cdr(list);
} else if (gh_eq_p(value,gh_symbol2scm("autocast"))) {
if (!spell->AutoCast) {
spell->AutoCast=(AutoCastInfo*)malloc(sizeof(AutoCastInfo));
- memset(spell->AutoCast,0,sizeof(AutoCastInfo*));
+ memset(spell->AutoCast,0,sizeof(AutoCastInfo));
}
CclSpellAutocast(gh_car(list),spell->AutoCast);
list=gh_cdr(list);
+ } else if (gh_eq_p(value,gh_symbol2scm("ai-cast"))) {
+ if (!spell->AICast) {
+ spell->AICast=(AutoCastInfo*)malloc(sizeof(AutoCastInfo));
+ memset(spell->AICast,0,sizeof(AutoCastInfo));
+ }
+ CclSpellAutocast(gh_car(list),spell->AICast);
+ list=gh_cdr(list);
} else if (gh_eq_p(value,gh_symbol2scm("sound-when-cast"))) {
// Free the old name, get the new one
free(spell->SoundWhenCast.Name);
@@ -554,70 +561,6 @@
** @param file File pointer to save to
** @param action Pointer to action to save.
*/
-local void SaveSpellCondition(CLFile *file,ConditionInfo* condition)
-{
- char condstrings [3][10] = {
- "true", /// CONDITION_TRUE
- "false", /// CONDITION_FALSE
- "only" /// CONDITION_ONLY
- };
-
- DebugCheck(!file);
- DebugCheck(!condition);
-
- CLprintf(file,"( ");
- //
- // First save data related to flags.
- // NOTE: (int) is there to keep compilers happy.
- //
- if (condition->Undead!=CONDITION_TRUE) {
- CLprintf(file,"undead %s ",condstrings[(int)condition->Undead]);
- }
- if (condition->Organic!=CONDITION_TRUE) {
- CLprintf(file,"organic %s ",condstrings[(int)condition->Organic]);
- }
- if (condition->Hero!=CONDITION_TRUE) {
- CLprintf(file,"hero %s ",condstrings[(int)condition->Hero]);
- }
- if (condition->Coward!=CONDITION_TRUE) {
- CLprintf(file,"coward %s ",condstrings[(int)condition->Coward]);
- }
- if (condition->Alliance!=CONDITION_TRUE) {
- CLprintf(file,"alliance %s ",condstrings[(int)condition->Alliance]);
- }
- if (condition->Building!=CONDITION_TRUE) {
- CLprintf(file,"building %s ",condstrings[(int)condition->Building]);
- }
- if (condition->TargetSelf!=CONDITION_TRUE) {
- CLprintf(file,"self %s ",condstrings[(int)condition->TargetSelf]);
- }
- //
- // Min/Max vital percents
- //
- CLprintf(file,"min-hp-percent %d ",condition->MinHpPercent);
- CLprintf(file,"max-hp-percent %d ",condition->MaxHpPercent);
- CLprintf(file,"min-mana-percent %d ",condition->MinManaPercent);
- CLprintf(file,"max-mana-percent %d ",condition->MaxManaPercent);
- //
- // Max buff ticks stuff
- //
- CLprintf(file,"max-slow-ticks %d ",condition->MaxSlowTicks);
- CLprintf(file,"max-haste-ticks %d ",condition->MaxHasteTicks);
- CLprintf(file,"max-bloodlust-ticks %d ",condition->MaxBloodlustTicks);
- CLprintf(file,"max-invisibility-ticks %d
",condition->MaxInvisibilityTicks);
- CLprintf(file,"max-invincibility-ticks %d
",condition->MaxInvincibilityTicks);
- //
- // The end.
- //
- CLprintf(file,")\n");
-}
-
-/*
-** Save a spell action to a file.
-**
-** @param file File pointer to save to
-** @param action Pointer to action to save.
-*/
local void SaveSpellAction(CLFile *file,SpellActionType* action)
{
if (action->CastFunction==CastAreaBombardment) {
@@ -692,7 +635,96 @@
}
}
-/**
+/*
+** Save a spell action to a file.
+**
+** @param file File pointer to save to
+** @param action Pointer to action to save.
+*/
+local void SaveSpellCondition(CLFile *file,ConditionInfo* condition)
+{
+ char condstrings [3][10] = {
+ "true", /// CONDITION_TRUE
+ "false", /// CONDITION_FALSE
+ "only" /// CONDITION_ONLY
+ };
+
+ DebugCheck(!file);
+ DebugCheck(!condition);
+
+ CLprintf(file,"( ");
+ //
+ // First save data related to flags.
+ // NOTE: (int) is there to keep compilers happy.
+ //
+ if (condition->Undead!=CONDITION_TRUE) {
+ CLprintf(file,"undead %s ",condstrings[(int)condition->Undead]);
+ }
+ if (condition->Organic!=CONDITION_TRUE) {
+ CLprintf(file,"organic %s ",condstrings[(int)condition->Organic]);
+ }
+ if (condition->Hero!=CONDITION_TRUE) {
+ CLprintf(file,"hero %s ",condstrings[(int)condition->Hero]);
+ }
+ if (condition->Coward!=CONDITION_TRUE) {
+ CLprintf(file,"coward %s ",condstrings[(int)condition->Coward]);
+ }
+ if (condition->Alliance!=CONDITION_TRUE) {
+ CLprintf(file,"alliance %s ",condstrings[(int)condition->Alliance]);
+ }
+ if (condition->Building!=CONDITION_TRUE) {
+ CLprintf(file,"building %s ",condstrings[(int)condition->Building]);
+ }
+ if (condition->TargetSelf!=CONDITION_TRUE) {
+ CLprintf(file,"self %s ",condstrings[(int)condition->TargetSelf]);
+ }
+ //
+ // Min/Max vital percents
+ //
+ CLprintf(file,"min-hp-percent %d ",condition->MinHpPercent);
+ CLprintf(file,"max-hp-percent %d ",condition->MaxHpPercent);
+ CLprintf(file,"min-mana-percent %d ",condition->MinManaPercent);
+ CLprintf(file,"max-mana-percent %d ",condition->MaxManaPercent);
+ //
+ // Max buff ticks stuff
+ //
+ CLprintf(file,"max-slow-ticks %d ",condition->MaxSlowTicks);
+ CLprintf(file,"max-haste-ticks %d ",condition->MaxHasteTicks);
+ CLprintf(file,"max-bloodlust-ticks %d ",condition->MaxBloodlustTicks);
+ CLprintf(file,"max-invisibility-ticks %d
",condition->MaxInvisibilityTicks);
+ CLprintf(file,"max-invincibility-ticks %d
",condition->MaxInvincibilityTicks);
+ //
+ // The end.
+ //
+ CLprintf(file,")\n");
+}
+
+/*
+** Save autocast info to a CCL file
+**
+** @param file The file to save to.
+** @param autocast Auocastinfo to save.
+*/
+void SaveSpellAutoCast(CLFile *file,AutoCastInfo* autocast)
+{
+ char condstrings [3][10] = {
+ "true", /// CONDITION_TRUE
+ "false", /// CONDITION_FALSE
+ "only" /// CONDITION_ONLY
+ };
+
+ CLprintf(file,"( range %d",autocast->Range);
+ if (autocast->Combat!=CONDITION_TRUE) {
+ CLprintf(file,"undead %s ",condstrings[(int)autocast->Combat]);
+ }
+ if (autocast->Condition) {
+ CLprintf(file," condition ");
+ SaveSpellCondition(file,autocast->Condition);
+ }
+ CLprintf(file," )\n");
+}
+
+/*
** Save spells to a CCL file.
**
** @param file The file to save to.
@@ -746,20 +778,28 @@
SaveSpellAction(file,spell->Action);
CLprintf(file,"\n");
//
- // FIXME: Save conditions
+ // Save conditions
//
- if (spell->Conditions) {
+ if (spell->Condition) {
CLprintf(file," 'condition '");
- SaveSpellCondition(file,spell->Conditions);
+ SaveSpellCondition(file,spell->Condition);
CLprintf(file,"\n");
}
//
- // FIXME: Save autocast and AI info
+ // Save own unit autocast
//
if (spell->AutoCast) {
- CLprintf(file," 'autocast '(range %d condition
",spell->AutoCast->Range);
- SaveSpellCondition(file,spell->Conditions);
- CLprintf(file,")\n");
+ CLprintf(file," 'autocast '");
+ SaveSpellAutoCast(file,spell->AutoCast);
+ CLprintf(file,"\n");
+ }
+ //
+ // Save AI autocast.
+ //
+ if (spell->AICast) {
+ CLprintf(file," 'ai-cast '");
+ SaveSpellAutoCast(file,spell->AICast);
+ CLprintf(file,"\n");
}
CLprintf(file,")\n");
}
Index: stratagus/src/clone/spells.c
diff -u stratagus/src/clone/spells.c:1.105 stratagus/src/clone/spells.c:1.106
--- stratagus/src/clone/spells.c:1.105 Thu Oct 2 17:21:07 2003
+++ stratagus/src/clone/spells.c Fri Oct 3 06:37:07 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: spells.c,v 1.105 2003/10/02 21:21:07 n0body Exp $
+// $Id: spells.c,v 1.106 2003/10/03 10:37:07 n0body Exp $
/*
** And when we cast our final spell
@@ -1255,11 +1255,23 @@
int i;
int j;
int combat;
+ AutoCastInfo* autocast;
DebugCheck(!spell);
DebugCheck(!spell->AutoCast);
DebugCheck(!caster);
+ //
+ // Ai cast should be a lot better. Use autocast if not found.
+ //
+ if (caster->Player->Ai&&spell->AICast) {
+ DebugLevel3Fn("The borg uses AI autocast XP.\n");
+ autocast=spell->AICast;
+ } else {
+ DebugLevel3Fn("You puny mortal, join the colective!\n");
+ autocast=spell->AutoCast;
+ }
+
x=caster->X;
y=caster->Y;
range=spell->AutoCast->Range;
@@ -1282,8 +1294,8 @@
//
// Check generic conditions. FIXME: a better way to do this?
//
- if (spell->AutoCast->Combat!=CONDITION_TRUE) {
- if ((spell->AutoCast->Combat==CONDITION_ONLY)^(combat)) {
+ if (autocast->Combat!=CONDITION_TRUE) {
+ if ((autocast->Combat==CONDITION_ONLY)^(combat)) {
return 0;
}
}
@@ -1293,8 +1305,8 @@
// TargetNone?
return NewTargetNone();
case TargetSelf :
- if (PassCondition(caster, spell, caster, x, y, spell->Conditions) &&
- PassCondition(caster, spell, caster, x, y,
spell->AutoCast->Condition)) {
+ if (PassCondition(caster, spell, caster, x, y, spell->Condition) &&
+ PassCondition(caster, spell, caster, x, y,
autocast->Condition)) {
return NewTargetUnit(caster);
}
return 0;
@@ -1314,8 +1326,8 @@
for (i = 0, j = 0; i < nunits; i++) {
// FIXME: autocast conditions should include normal conditions.
// FIXME: no, really, they should.
- if (PassCondition(caster, spell, table[i], x, y,
spell->Conditions) &&
- PassCondition(caster, spell, table[i], x, y,
spell->AutoCast->Condition)) {
+ if (PassCondition(caster, spell, table[i], x, y,
spell->Condition) &&
+ PassCondition(caster, spell, table[i], x, y,
autocast->Condition)) {
table[j++] = table[i];
}
}
@@ -1364,17 +1376,6 @@
{
}
-/**
-** Spells destructor (currently does nothing)
-*/
-global void DoneSpells()
-{
-// FIXME
- free(SpellTypeTable);
- // nothing yet
-}
-
-
// ****************************************************************************
// Get Spell.
// ****************************************************************************
@@ -1509,7 +1510,7 @@
return 0;
}
- return PassCondition(caster,spell,target,x,y,spell->Conditions);
+ return PassCondition(caster,spell,target,x,y,spell->Condition);
}
/**
@@ -1580,6 +1581,45 @@
return CanCastSpell(caster, spell, target, x, y) &&
spell->Action->CastFunction(caster, spell, target, x, y);
}
+/*
+** Cleanup the spell subsystem.
+**
+** @note: everything regarding spells is gone now.
+** FIXME: not complete
+*/
+void CleanSpells(void)
+{
+ SpellType* spell;
+
+ DebugLevel0("Cleaning spells.\n");
+ for (spell = SpellTypeTable; spell < SpellTypeTable + SpellTypeCount;
++spell) {
+ free(spell->IdentName);
+ free(spell->Name);
+ free(spell->Action);
+ if (spell->Condition) {
+ free(spell->Condition);
+ }
+ //
+ // Free Autocast.
+ //
+ if (spell->AutoCast) {
+ if (spell->AutoCast->Condition) {
+ free(spell->AutoCast->Condition);
+ }
+ free(spell->AutoCast);
+ }
+ if (spell->AICast) {
+ if (spell->AICast->Condition) {
+ free(spell->AICast->Condition);
+ }
+ free(spell->AICast);
+ }
+ // FIXME: missile free somewhere else, right?
+ }
+ free(SpellTypeTable);
+ SpellTypeTable=0;
+ SpellTypeCount=0;
+}
#if 0
@@ -1606,11 +1646,6 @@
different range, cost and time to live (possibly and other
parameters as extensions)
- FIXME: this should be configurable by CCL.
-
- FIXME: 0x7F as unlimited range is too less for big maps.
-
-
*/
#endif
Index: stratagus/src/game/loadgame.c
diff -u stratagus/src/game/loadgame.c:1.64 stratagus/src/game/loadgame.c:1.65
--- stratagus/src/game/loadgame.c:1.64 Thu Oct 2 11:39:32 2003
+++ stratagus/src/game/loadgame.c Fri Oct 3 06:37:08 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: loadgame.c,v 1.64 2003/10/02 15:39:32 jsalmon3 Exp $
+// $Id: loadgame.c,v 1.65 2003/10/03 10:37:08 n0body Exp $
//@{
@@ -104,6 +104,7 @@
CleanMap();
CleanReplayLog();
CleanCclCredits();
+ CleanSpells();
FreeVisionTable();
#ifdef HIERARCHIC_PATHFINDER
PfHierClean ();
Index: stratagus/src/include/spells.h
diff -u stratagus/src/include/spells.h:1.28 stratagus/src/include/spells.h:1.29
--- stratagus/src/include/spells.h:1.28 Thu Oct 2 17:21:07 2003
+++ stratagus/src/include/spells.h Fri Oct 3 06:37:08 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: spells.h,v 1.28 2003/10/02 21:21:07 n0body Exp $
+// $Id: spells.h,v 1.29 2003/10/03 10:37:08 n0body Exp $
#ifndef __SPELLS_H__
#define __SPELLS_H__
@@ -233,10 +233,15 @@
**
*/
typedef struct {
- ConditionInfo *Condition; /// Conditions to cast the spell.
+ /// FIXME: this below is SQUARE!!!
int Range; /// Max range of the target.
+
+ ConditionInfo *Condition; /// Conditions to cast the spell.
+
+ /// Detalied generic conditions (not per-target, where Condition is
evaluated.)
/// Combat mode is when there are hostile non-coward units around
int Combat; /// If it should be casted in
combat
+
/// FIXME: Add stuff here for target preference.
/// FIXME: Heal units with the lowest hit points first.
} AutoCastInfo;
@@ -255,19 +260,21 @@
// Spell Specifications
TargetType Target; /// Targetting information. See
TargetType.
SpellActionType *Action; /// More arguments for spell (damage,
delay, additional sounds...).
-#define INFINITE_RANGE 0xFFFFFFF
+
int Range; /// Max range of the target.
+#define INFINITE_RANGE 0xFFFFFFF
int ManaCost; /// required mana for each cast
int DependencyId; /// Id of upgrade, -1 if no upgrade
needed for cast the spell.
- ConditionInfo *Conditions; /// Conditions to cast the spell.
(generic (no test for each target))
-
-// Autocast // FIXME : can use different for AI ? Use it in this
structure ?
- AutoCastInfo *AutoCast; /// AutoCast information
+ ConditionInfo *Condition; /// Conditions to cast the spell.
(generic (no test for each target))
-// Uses for graphics and sounds
- SoundConfig SoundWhenCast; /// sound played if cast
- MissileType *Missile; /// missile fired on cast
+ // Autocast informations. No AICast means the AI use AutoCast.
+ AutoCastInfo *AutoCast; /// AutoCast information for your own
units
+ AutoCastInfo *AICast; /// AutoCast information for ai. More
detalied.
+
+ // Graphics and sounds. Add something else here?
+ SoundConfig SoundWhenCast; /// Sound played if cast
+ MissileType *Missile; /// Missile fired on cast
} SpellType;
/*----------------------------------------------------------------------------
@@ -297,7 +304,7 @@
extern void SaveSpells(CLFile * file);
/// done spell tables
-extern void DoneSpells(void);
+extern void CleanSpells(void);
/// return 1 if spell is availible, 0 if not (must upgrade)
extern int SpellIsAvailable(const Player* player, int SpellId);
- [Stratagus-CVS] stratagus data/ccl/missiles.ccl data/ccl/spells...,
Crestez Leonard <=