public inbox for xconq7@sourceware.org
 help / color / mirror / Atom feed
* Improved combat code
@ 2004-08-22  2:46 Hans Ronne
  2004-08-22  4:21 ` Eric McDonald
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Ronne @ 2004-08-22  2:46 UTC (permalink / raw)
  To: xconq7

Steps 1 and 2 on my revised agenda for an improved combat code have been
completed. There are now two new tasks, TASK_ATTACK and TASK_FIRE, which
act as subtasks to TASK_HIT_UNIT. If the view of a targeted unit is bad,
these tasks will still schedule an attack or fire into the empty cell
(which the side should do, since it wrongly thinks that something is
sitting there). The attack against the empty cell is mediated by a new
action, ACTION_ATTACK_CELL, which works like ACTION_OVERRUN but without
moving into the cell. For firing into the empty cell, ACTION_FIRE_INTO is
used.

Importantly, the new tasks will clear the bogus view at a rate that can be
set by clear-unit-view-rate. This rate is 50% by default, so each shot at a
bogus view has a 50% chance of clearing it. This fixes the bug that would
cause the AI to cycle indefinitely under certain conditions, and which
prompted this entire overhaul of the combat code.

It should be noted that the AI code deals with attack and fire, but then
sets a hit-unit task at the end, without specifying how to hit. So the task
execution code has to partly redo the job, and figure out what the AI
wanted it to do. It is my intention to eventually get rid of this
duplication, and have the AI set TASK_ATTACK or TASK_FIRE directly.

Other changes and fixes:

1. Several other bugs that would cause buzzing in the AI code have been
fixed. See the ChangeLog for details.

2. The end-of-turn process has been speeded up significantly by reducing
pointless plan executions for units that cannot do anything.

3. Unit images are now updated correctly when a unit is wrecked or changes
type.

4. I have long been frustrated by the stupid behaviour of units within
transports, which act as sitting ducks in the presence of an enemy. I have
therefore added code that makes a unit disembark before a fight if its
fighting ability is significantly reduced as an occupant.

5. Finally, I have added a new table, hp-on-creation, which makes it
possible for a unit to get more than 1 hp on creation. This is useful in
games where units are created outside the creator, and therefore more
vulnerable to attack before they have been completed.

Hans


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Improved combat code
  2004-08-22  2:46 Improved combat code Hans Ronne
@ 2004-08-22  4:21 ` Eric McDonald
  2004-08-22  5:54   ` Hans Ronne
  0 siblings, 1 reply; 3+ messages in thread
From: Eric McDonald @ 2004-08-22  4:21 UTC (permalink / raw)
  To: Hans Ronne; +Cc: xconq7

Hans Ronne wrote:

> 3. Unit images are now updated correctly when a unit is wrecked or changes
> type.

I hope that this was just a mistake on your part:

===================================================================
RCS file: /cvs/xconq/xconq/ChangeLog,v
retrieving revision 1.1473
retrieving revision 1.1474
diff -u -r1.1473 -r1.1474
--- xconq/ChangeLog	2004/08/22 00:12:25	1.1473
+++ xconq/ChangeLog	2004/08/22 00:37:40	1.1474
@@ -1,19 +1,15 @@
-2004-08-22  Eric McDonald
+2004-08-21 Hans Ronne

-	Reduce buzzing when formations are in use. Also, improve previous
-	fix.
-	* run.c (side_move_some_units): Be more selective about what plans
-	get executed by making sure that there is either a pending action
-	or a task list. Only set the 'waitingfortask' flag on plans with
-	formations if their are actually tasks present.
-
-	Fix display bug that appeared in 'change-type' sometime in the past
-	few months, probably as a result of hacking the image loading or
-	unit views.
-	* unit.c (change_unit_type): Upon changing type, set the unit's
-	image name to an empty string (to force loading of a new image),
-	and then call 'set_unit_image'. (A call to 'update_side_display'
-	used to do the right thing, but apparently not anymore.)
+	Add network functions for TASK_ATTACK and TASK_FIRE.
+	* tp.c (net_push_attack_task): New function.
+	(net_set_attack_task): New function.
+	(net_push_fire_task): New function.
+	(net_set_fire_task): New function.
+
+	Fix so that images are updated for units that are
+	wrecked or change type.
+	* unit.c (change_unit_type): Set unit->image_name and
+	unit->imf to NULL and call set_unit_image.

===================================================================
RCS file: /cvs/xconq/xconq/kernel/unit.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- xconq/kernel/unit.c	2004/08/22 00:12:26	1.94
+++ xconq/kernel/unit.c	2004/08/22 00:37:41	1.95
@@ -443,6 +443,10 @@
      all_see_leave(unit, unit->x, unit->y, (transport == NULL));
      /* Do the actual change. */
      unit->type = newtype;
+    /* Reset unit image to new type. */
+    unit->imf = NULL;
+    unit->image_name = NULL;
+    set_unit_image(unit);
      /* Make sure the new unit is complete. */
      unit->cp = u_cp(newtype);
      /* Set the new hp to the same ratio of max as the unit had before.
@@ -520,10 +524,6 @@
  							   newtype, reason))
  	  return;
      }
-    /* Set the unit image by first clearing the old image name.
-       'set_unit_image' will set a new image name and image for us. */
-    unit->image_name = "";
-    set_unit_image(unit);
      /* Increment viewing coverage. */
      cover_area(unit->side, unit, transport, -1, -1, unit->x, unit->y);
      /* If vision range is 0, allow glimpses of adjacent cell terrain.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Improved combat code
  2004-08-22  4:21 ` Eric McDonald
@ 2004-08-22  5:54   ` Hans Ronne
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Ronne @ 2004-08-22  5:54 UTC (permalink / raw)
  To: Eric McDonald; +Cc: xconq7

>Hans Ronne wrote:
>
>> 3. Unit images are now updated correctly when a unit is wrecked or changes
>> type.
>
>I hope that this was just a mistake on your part:

Don't worry. This collision was not intentional. You must have checked in
while I was rebooting from Mac to Linux.

Hans


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-08-22  4:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-22  2:46 Improved combat code Hans Ronne
2004-08-22  4:21 ` Eric McDonald
2004-08-22  5:54   ` Hans Ronne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).