przem360 / ascii-fantasy-tactics Goto Github PK
View Code? Open in Web Editor NEWText adventure game with tactics battle
Text adventure game with tactics battle
Possible turn playout idea:
move av
> to where? __
f20
attack av
> who? __
g1
Make monster to check neighbouring fields - see #15 if no fighter around then move towards targeted fighter.
player_action_attack();
and player_action_cast();
should check if targetaddr
is in range (is marked as targeted on screen).
Fighters positions are not coming back to defaults after battle, so fighters when starting next battle are placed where they have ended a previous one.
Sometimes monsters are send to position 0,0.
Probably because chase_figters()
can sometimes set finalx
and/or finaly
to 0.
Need to check if these values are 0 and if so, set them to original .x_position
and .y_position
.
#define RANGE_CHAR "+"
const char commands[6][6] = {"move", "attack", "use", "end", "skip", "quit"};
/* First letters of commands should be also legal aliases.
Need to convert input to lower case before checking. */
const char alphabet[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
Test how "random" dice really is.
Consider using time.h
to seed srand();
with current time.
Like in title, entering room 22 breaks exploration loop and goes to intro.
Reason:
while (current_location != 22 && qresult != 0 && game_mode == 2) {
...
}
(textadventure.c, line 177)
After turn passes the dead bodies are gone from board.
For now attack works only on adjacent areas.
Function player_action_attack();
needs to test if PC has a ranged weapon (pcs[i].weapon
, weapons[i].ranged
), if it has draw range based on weapons[i].range
.
After calling draw_monster_range()
loop thru screen array ang get coorinants of every RANGE_CHAR
to array available_moves[20][2]
.
Loop thru available_moves
and calculate coordinates from every point to targeted fighter. If currently calculated distance available_moves[i][j]
is smaller then previous one then save the new one.
Move monster figure to the place where it will be in closest position to targeted fighter.
While playing battle, it happens sometimes that the monster goes off the arena.
For some reason the array the_move[]
gets value 0,0
.
Need to test values of wasmoved
and tookaction
before invoking moving and actions functions.
If currently selected fighter has no spells, command cast
should return an information.
Casting a soell should be posible only if currently selected fighter has this spell.
Consider using draw_range()
inside ai_choose_action()
for checking if fighter is in neighbouring fields.
File helpers.c
should be renamed and broken to battle.c
and battle.h
.
When in battle mode program sometimes crashes while monsters are taking first move.
GDB:
*** stack smashing detected ***: terminated
Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737351489344) at ./nptl/pthread_kill.c:44
44 ./nptl/pthread_kill.c: Nie ma takiego pliku ani katalogu.
(gdb) backtrace
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737351489344)
at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=140737351489344)
at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140737351489344, signo=signo@entry=6)
at ./nptl/pthread_kill.c:89
#3 0x00007ffff7dbe476 in __GI_raise (sig=sig@entry=6)
at ../sysdeps/posix/raise.c:26
#4 0x00007ffff7da47f3 in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff7e05676 in __libc_message (action=action@entry=do_abort,
fmt=fmt@entry=0x7ffff7f57943 "*** %s ***: terminated\n")
at ../sysdeps/posix/libc_fatal.c:155
#6 0x00007ffff7eb278a in __GI___fortify_fail (
msg=msg@entry=0x7ffff7f5792b "stack smashing detected")
at ./debug/fortify_fail.c:26
#7 0x00007ffff7eb2756 in __stack_chk_fail () at ./debug/stack_chk_fail.c:24
#8 0x000055555555aac3 in ai_choose_action (
mid=0x555555561a7f <selected_monster> "b1") at asciibattle.c:1235
#9 0x0000000400000002 in ?? ()
#10 0x000000020000000b in ?? ()
#11 0x0000000c00000005 in ?? ()
#12 0x0000000600000002 in ?? ()
#13 0x000000030000000d in ?? ()
--Type <RET> for more, q to quit, c to continue without paging--c
#14 0x0000000900000003 in ?? ()
#15 0x0000000400000003 in ?? ()
#16 0x000000030000000a in ?? ()
#17 0x0000000b00000005 in ?? ()
#18 0x0000000400000004 in ?? ()
#19 0x00007fff00000009 in ?? ()
#20 0x0000000000000000 in ?? ()
(gdb)
GDB points at variable selected_monster
passed to the ai_choose_action()
.
Valgrind points to: chase_figters()
called from the ai_choose_action()
.
Might be related to issue #19
After targeting first monster gets wild x_position value, sometimes.
May be caused by chase_figters();
Monsters targetting starts in weird coordinants.
Maybe coords[0]
and coords[0]
must be also set to 0 before use?
At least, must note how to pause in Windows/DOS:
#include <dos.h>
...
sleep(5);
Inside of helpers.c
should be function called init();
, to provide initial setup. Function should be invoked in main()
before the game loop.
void init() {
printf("ASCII FANTASY TACTICS");
memcpy(screen, lvl1,sizeof(lvl1));
place_figures();
draw_interface();
}
Need draw_monster_range();
function. Identicalbwith c
mode in the draw_range();
. Monster should perform an attack on first fighter found in range.
Arrow indicating selected fighter or active monster should be added to side_panel
.
###################### Monsters:
#....................# [g] [G1] Fred (Goblin) HP:4
#....................# [r] [R1] Rogue (Human ) HP:5
#..##................# [t] [TW] Tentacle Worm HP:14
#..##................# [f] [BF] Black Flan HP:50
#....................#
#.............##.....#
#.............##.....#
#...+................#
#..+++...............# Fighters:
#.+++++..............# [A] [AV] Avery (Fighter) HP:8
#+++++++.............# > [K] [KK] Koko (B. Mage) HP:6
#+++AKMZ.............# [M] [MA] Marsh (Archer ) HP:6
###################### [Z] [ZK] Zok (W. Mage) HP:8
MARCHE
Fighter MV:4 HP:8 AC:4 MP:2
> move to __
After hitting q
during the battle, the battle quits but player stays in adventure mode. Quitting battle should always end with going back to welcome screen.
In the ai_choose_action();
, at the end, in the else
block should toss a coin dice(2);
and eventually attack fighter in range instead doing chase_figters();
.
Spells and inventory should reside in separate structs.
HP should be set to zero when it drops below zero.
When HP becomes zero board representation (.letter
) should change to ~
and dead one should be out of the turn queue.
Does monster have target? If not, choose.
Walk towards target.
Is target in attack range?
If yes - attack, if no, pass turn.
Every next turn.
Does monster have a target?
How far this monster is from its target?
Is there some Fighter closer (first found is enough)?
If there is 60/40:
60: take closer fighter as a new target.
40: keep following original target.
That's it. Not every fighter has to be targeted.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.