prepare events for achievements

This commit is contained in:
Ondřej Novák 2025-04-17 11:54:03 +02:00
parent 0550d584e6
commit f5450c0f92
9 changed files with 101 additions and 20 deletions

View file

@ -45,6 +45,7 @@ gen_stringtable.c
advconfig.c
temp_storage.cpp
lang.c
ach_events.c
${CMAKE_BINARY_DIR}/resources.cpp
)

29
game/ach_events.c Normal file
View file

@ -0,0 +1,29 @@
#include "ach_events.h"
#include <stdint.h>
#include <stdlib.h>
#include <libs/event.h>
#include "globals.h"
void enable_achievements(char enable) {
}
void ach_event_kill_monster(int id) {
wzprintf("(event) kill monster %d\n", id);
}
void ach_event_pick_item(int id) {
wzprintf("(event) pick item %d\n", id);
}
void ach_event_end_game() {
wzprintf("(event) end_game\n");
}
void ach_event_inv_add(int id) {
wzprintf("(event) inventory add %d\n", id);
}
void ach_event_dialog_paragraph(int pgf) {
wzprintf("(event) dialog paragraph %d\n", pgf);
}
void ach_event_full_party() {
wzprintf("(event) full party\n");
}

17
game/ach_events.h Normal file
View file

@ -0,0 +1,17 @@
#ifndef SKELDAL_ACH_EVENTS_
#define SKELDAL_ACH_EVENTS_
typedef struct thuman THUMAN;
void ach_event_kill_monster(int id);
void ach_event_pick_item(int id);
void ach_event_end_game();
void ach_event_inv_add(int id);
void ach_event_dialog_paragraph(int pgf);
void ach_event_full_party();
void enable_achievements(char enable);
#endif

View file

@ -20,6 +20,7 @@
#include "globals.h"
#include <stdarg.h>
#include "lang.h"
#include "ach_events.h"
typedef struct t_paragraph
{
@ -275,8 +276,10 @@ static int find_pgnum(char *pc)
static void goto_paragraph(int prgf)
{
T_PARAGRAPH *z;
ach_event_dialog_paragraph(prgf+local_pgf);
do
{
@ -1008,6 +1011,7 @@ char join_character(int i)
h->direction=viewdir;
h->groupnum=cur_group;
h->inmaphash=current_map_hash;
if (j == POCET_POSTAV-1) ach_event_full_party();
reg_grafiku_postav();
bott_draw(1);
return 0;

View file

@ -14,6 +14,9 @@
#include "specproc.h"
#include <string.h>
#include "ach_events.h"
#define MOB_ZNAKY "FLBLCH"
#define MOB_START 1
@ -380,6 +383,7 @@ void load_enemies(short *data,int size,int *grptr,const TMOB *template,int32_t t
mobs[i].dir=(data[1]>>14)&0x3;
mobs[i].home_pos=data[0];
mobs[i].vlajky|=MOB_LIVE;
mobs[i].id = (uint8_t)j;
if (mobs[i].speed<1)
{
char buff[256];
@ -1347,6 +1351,7 @@ void mob_check_death(int num,TMOB *p)
bott_draw(0);
if (p->lives>0) return;
SEND_LOG("(GAME) Monster killed ... '%s'",p->name);
ach_event_kill_monster(p->id);
sect=p->sector;
p->vlajky&=~MOB_IN_BATTLE & ~MOB_LIVE;
free_path(num);

View file

@ -1521,6 +1521,7 @@ typedef struct tmob
char anim_counts[6]; //pocet animacnich policek pro kazdy pohyb
char mobs_name[7]; //zaklad jmena souboru pro moba
char vlajky2; //vlajky pro summon z konzoli (BIT0 - neukladat)
uint8_t id; //mobile id (template index);
int32_t experience; //zkusenost
char vlajky; //BIT0 - 1 v boji
char anim_phase; //cinnost kterou mob dela

View file

@ -24,6 +24,8 @@
#include <stddef.h>
#include <string.h>
#include "ach_events.h"
#define neprezbrojit() (battle && (battle_mode!=MD_PREZBROJIT || select_player!=human_selected-postavy))
#define _SHOP_ST "_SHOPS.TMP"
@ -556,10 +558,11 @@ void pop_item(int sect,int pos,int mask,short **picked_item)
void pick_set_cursor(void)
{
if (picked_item==NULL)
if (picked_item==NULL) {
item_in_cursor=H_MS_DEFAULT;
else
} else {
item_in_cursor=-(glob_items[*picked_item-1].ikona);
}
mouse_set_default(item_in_cursor);
}
@ -574,6 +577,12 @@ void do_items_specs(void)
GlobEvent(MAGLOB_ONPICKITEM,viewsector,viewdir);
if (picked_item==0) return;
const short *s = picked_item;
while (*s) {
ach_event_pick_item(abs(*s)-1);
++s;
}
p=&glob_items[*picked_item-1];
switch(p->druh)
{
@ -781,6 +790,7 @@ char put_item_to_inv(THUMAN *p,short *picked_items)
i--;
it=abs(picked_items[i]);
p->inv[pos]=it;
ach_event_inv_add(it-1);
picked_items[i]=0;
}
return (i==0);
@ -1924,9 +1934,15 @@ static char bag_action(int xr, int yr) {
while (*pk)
{
p=human_selected->inv[id];
human_selected->inv[id]=abs(*pk);
int itm = abs(*pk);
human_selected->inv[id]=itm;
ach_event_inv_add(itm-1);
*pk=p;pk++;
if (*pk) while (human_selected->inv[id]) if ((++id)>=human_selected->inv_size) id=0;
if (*pk) {
while (human_selected->inv[id]) {
if ((++id)>=human_selected->inv_size) id=0;
}
}
}
}
else
@ -2042,7 +2058,11 @@ void vymen_batohy()
c=picked_item;
it=human_selected->wearing[PO_BATOH]=*c++;
i=6;
while (*c && i<MAX_INV) human_selected->inv[i++]=-*c++;
while (*c && i<MAX_INV) {
int itm = -*c++;
human_selected->inv[i++]=itm;
ach_event_inv_add(itm-1);
}
human_selected->inv_size=glob_items[it-1].nosnost+6;
}
else
@ -2219,6 +2239,7 @@ char human_click(int id,int xa,int ya,int xr,int yr)
break;
}
human_selected->wearing[place]=*picked_item;
ach_event_inv_add(*picked_item-1);
if (itsave) *picked_item=itsave;
else
{

View file

@ -897,6 +897,7 @@ void call_macro_ex(int side, int flags, int runatside) {
}
rand_value = save_rand;
save_load_trigger(saved_trigger);
(void)count_actions;
SEND_LOG("(MULTIACTIONS) End: Sector %d, Side %d, Call %X, Actions: %d",runatside/4,runatside & 3,flags,count_actions);
}

View file

@ -18,6 +18,7 @@
#include <libs/pcx.h>
#include "globals.h"
#include "ach_events.h"
#include "lang.h"
#define MUSIC "TRACK06.MUS"
@ -616,6 +617,7 @@ void konec_hry()
int task_id;
int timer;
ach_event_end_game();
schovej_mysku();
curcolor=0;