2010-08-08 10:06:34 +02:00
/*
2015-01-30 22:10:29 +01:00
Copyright ( c ) 1998 - 2015 , Enno Rehling < enno @ eressea . de >
2014-07-21 11:34:57 +02:00
Katja Zedel < katze @ felidae . kn - bremen . de
Christian Schlittchen < corwin @ amber . kn - bremen . de >
2010-08-08 10:06:34 +02:00
Permission to use , copy , modify , and / or distribute this software for any
purpose with or without fee is hereby granted , provided that the above
copyright notice and this permission notice appear in all copies .
THE SOFTWARE IS PROVIDED " AS IS " AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS . IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT , INDIRECT , OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE , DATA OR PROFITS , WHETHER IN AN
ACTION OF CONTRACT , NEGLIGENCE OR OTHER TORTIOUS ACTION , ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE .
* */
# include <platform.h>
# include <kernel/config.h>
# include "museum.h"
/* kernel includes */
# include <kernel/building.h>
2014-07-21 11:34:57 +02:00
# include <kernel/connection.h>
2010-08-08 10:06:34 +02:00
# include <kernel/faction.h>
# include <kernel/item.h>
2014-06-09 18:54:48 +02:00
# include <kernel/messages.h>
2010-08-08 10:06:34 +02:00
# include <kernel/order.h>
# include <kernel/plane.h>
# include <kernel/region.h>
# include <kernel/terrain.h>
# include <kernel/unit.h>
# include <kernel/faction.h>
2014-08-27 06:40:18 +02:00
# include <move.h>
2010-08-08 10:06:34 +02:00
/* util includes */
# include <util/attrib.h>
# include <util/base36.h>
# include <util/functions.h>
2016-02-13 13:42:02 +01:00
# include <util/gamedata.h>
2015-05-18 08:59:38 +02:00
# include <util/strings.h>
2014-07-21 11:34:57 +02:00
# include <util/language.h>
2017-12-29 06:13:28 +01:00
# include <util/macros.h>
2013-12-31 10:06:28 +01:00
# include <storage.h>
2010-08-08 10:06:34 +02:00
/* libc includes */
# include <limits.h>
# include <stdlib.h>
# include <assert.h>
# define PFL_MUSEUM PFL_NOMONSTERS | PFL_NORECRUITS | PFL_NOGIVE | PFL_NOATTACK | PFL_NOTERRAIN | PFL_NOMAGIC | PFL_NOSTEALTH | PFL_NOTEACH | PFL_NOBUILD | PFL_NOFEED
attrib_type at_museumexit = {
2014-07-21 11:34:57 +02:00
" museumexit " , NULL , NULL , NULL , a_writeshorts , a_readshorts
2010-08-08 10:06:34 +02:00
} ;
2018-02-09 21:20:43 +01:00
static void a_initmuseumgivebackcookie ( variant * var )
2010-08-08 10:06:34 +02:00
{
2018-02-09 21:20:43 +01:00
var - > v = calloc ( 1 , sizeof ( museumgivebackcookie ) ) ;
2010-08-08 10:06:34 +02:00
}
2018-02-09 21:20:43 +01:00
static void a_writemuseumgivebackcookie ( const variant * var ,
const void * owner , struct storage * store )
2010-08-08 10:06:34 +02:00
{
2018-02-09 21:20:43 +01:00
museumgivebackcookie * gbc = ( museumgivebackcookie * ) var - > v ;
2014-07-21 11:34:57 +02:00
WRITE_INT ( store , gbc - > warden_no ) ;
WRITE_INT ( store , gbc - > cookie ) ;
2010-08-08 10:06:34 +02:00
}
2018-02-09 21:20:43 +01:00
static int a_readmuseumgivebackcookie ( variant * var , void * owner , gamedata * data )
2010-08-08 10:06:34 +02:00
{
2018-02-09 21:20:43 +01:00
museumgivebackcookie * gbc = ( museumgivebackcookie * ) var - > v ;
2016-02-13 13:42:02 +01:00
READ_INT ( data - > store , & gbc - > warden_no ) ;
READ_INT ( data - > store , & gbc - > cookie ) ;
2014-07-21 11:34:57 +02:00
return AT_READ_OK ;
2010-08-08 10:06:34 +02:00
}
attrib_type at_museumgivebackcookie = {
2014-07-21 11:34:57 +02:00
" museumgivebackcookie " ,
a_initmuseumgivebackcookie ,
2018-02-09 21:20:43 +01:00
a_free_voidptr ,
2014-07-21 11:34:57 +02:00
NULL ,
a_writemuseumgivebackcookie ,
a_readmuseumgivebackcookie
2010-08-08 10:06:34 +02:00
} ;
attrib_type at_warden = {
2014-07-21 11:34:57 +02:00
" itemwarden " , NULL , NULL , NULL , a_writeint , a_readint
2010-08-08 10:06:34 +02:00
} ;
2018-02-09 21:20:43 +01:00
static void a_initmuseumgiveback ( variant * var )
2010-08-08 10:06:34 +02:00
{
2018-02-09 21:20:43 +01:00
var - > v = calloc ( 1 , sizeof ( museumgiveback ) ) ;
2010-08-08 10:06:34 +02:00
}
2018-02-09 21:20:43 +01:00
static void a_finalizemuseumgiveback ( variant * var )
2010-08-08 10:06:34 +02:00
{
2018-02-09 21:20:43 +01:00
museumgiveback * gb = ( museumgiveback * ) var - > v ;
2014-07-21 11:34:57 +02:00
i_freeall ( & gb - > items ) ;
2018-02-09 21:20:43 +01:00
free ( gb ) ;
2010-08-08 10:06:34 +02:00
}
static void
2018-02-09 21:20:43 +01:00
a_writemuseumgiveback ( const variant * var , const void * owner ,
2014-07-21 11:34:57 +02:00
struct storage * store )
2010-08-08 10:06:34 +02:00
{
2018-02-09 21:20:43 +01:00
museumgiveback * gb = ( museumgiveback * ) var - > v ;
2014-07-21 11:34:57 +02:00
WRITE_INT ( store , gb - > cookie ) ;
write_items ( store , gb - > items ) ;
2010-08-08 10:06:34 +02:00
}
2018-02-09 21:20:43 +01:00
static int a_readmuseumgiveback ( variant * var , void * owner , struct gamedata * data )
2010-08-08 10:06:34 +02:00
{
2018-02-09 21:20:43 +01:00
museumgiveback * gb = ( museumgiveback * ) var - > v ;
2016-02-13 13:42:02 +01:00
READ_INT ( data - > store , & gb - > cookie ) ;
read_items ( data - > store , & gb - > items ) ;
2014-07-21 11:34:57 +02:00
return AT_READ_OK ;
2010-08-08 10:06:34 +02:00
}
attrib_type at_museumgiveback = {
2014-07-21 11:34:57 +02:00
" museumgiveback " ,
a_initmuseumgiveback ,
a_finalizemuseumgiveback ,
NULL ,
a_writemuseumgiveback ,
a_readmuseumgiveback
2010-08-08 10:06:34 +02:00
} ;
2011-03-07 08:02:35 +01:00
void warden_add_give ( unit * src , unit * u , const item_type * itype , int n )
2010-08-08 10:06:34 +02:00
{
2014-07-21 11:34:57 +02:00
attrib * aw = a_find ( u - > attribs , & at_warden ) ;
museumgiveback * gb = NULL ;
museumgivebackcookie * gbc ;
attrib * a ;
/* has the giver a cookie corresponding to the warden */
for ( a = a_find ( src - > attribs , & at_museumgivebackcookie ) ;
a & & a - > type = = & at_museumgivebackcookie ; a = a - > next ) {
if ( ( ( museumgivebackcookie * ) ( a - > data . v ) ) - > warden_no = = u - > no )
break ;
2011-03-07 08:02:35 +01:00
}
2014-07-21 11:34:57 +02:00
/* if not give it one */
if ( a = = NULL | | a - > type ! = & at_museumgivebackcookie ) {
a = a_add ( & src - > attribs , a_new ( & at_museumgivebackcookie ) ) ;
gbc = ( museumgivebackcookie * ) a - > data . v ;
gbc - > warden_no = u - > no ;
gbc - > cookie = aw - > data . i ;
assert ( aw - > data . i < INT_MAX ) ;
aw - > data . i + + ;
}
else {
gbc = ( museumgivebackcookie * ) ( a - > data . v ) ;
}
/* now we search for the warden's corresponding item list */
for ( a = a_find ( u - > attribs , & at_museumgiveback ) ;
a & & a - > type = = & at_museumgiveback ; a = a - > next ) {
gb = ( museumgiveback * ) a - > data . v ;
if ( gb - > cookie = = gbc - > cookie ) {
break ;
}
}
/* if there's none, give it one */
if ( ! gb ) {
a = a_add ( & u - > attribs , a_new ( & at_museumgiveback ) ) ;
gb = ( museumgiveback * ) a - > data . v ;
gb - > cookie = gbc - > cookie ;
}
2011-03-07 08:02:35 +01:00
2014-07-21 11:34:57 +02:00
/* now register the items */
i_change ( & gb - > items , itype , n ) ;
2011-03-07 08:02:35 +01:00
2014-07-21 11:34:57 +02:00
/* done */
2011-03-07 08:02:35 +01:00
2014-07-21 11:34:57 +02:00
/* this has a caveat: If the src-unit is destroyed while inside
* the museum , the corresponding itemlist of the warden will never
* be removed . to circumvent that in a generic way will be extremly
* difficult . */
2010-08-08 10:06:34 +02:00
}
2011-03-07 08:02:35 +01:00
void create_museum ( void )
2010-08-08 10:06:34 +02:00
{
2016-02-09 21:34:24 +01:00
#if 0 /* TODO: move this to Lua. It should be possible. */
2014-07-21 11:34:57 +02:00
unsigned int museum_id = hashstring ( " museum " ) ;
plane * museum = getplanebyid ( museum_id ) ;
region * r ;
building * b ;
const terrain_type * terrain_hall = get_terrain ( " hall1 " ) ;
const terrain_type * terrain_corridor = get_terrain ( " corridor1 " ) ;
assert ( terrain_corridor & & terrain_hall ) ;
if ( ! museum ) {
museum = create_new_plane ( museum_id , " Museum " , 9500 , 9550 ,
9500 , 9550 , PFL_MUSEUM ) ;
}
if ( findregion ( 9525 , 9525 ) = = NULL ) {
/* Eingangshalle */
r = new_region ( 9525 , 9525 , 0 ) ;
terraform_region ( r , terrain_hall ) ;
r - > planep = museum ;
rsetname ( r , " Eingangshalle " ) ;
rsethorses ( r , 0 ) ;
rsetmoney ( r , 0 ) ;
rsetpeasants ( r , 0 ) ;
set_string ( & r - > display ,
" Die Eingangshalle des Gro<72> en Museum der 1. Welt ist bereits jetzt ein beeindruckender Anblick. Obwohl das Museum noch nicht er<65> ffnet ist, vermittelt sie bereits einen Flair exotischer Welten. In den Boden ist ein gro<72> er Kompass eingelassen, der den Besuchern bei Orientierung helfen soll. " ) ;
}
r = findregion ( 9526 , 9525 ) ;
if ( ! r ) {
/* Lounge */
r = new_region ( 9526 , 9525 , 0 ) ;
terraform_region ( r , terrain_hall ) ;
r - > planep = museum ;
rsetname ( r , " Lounge " ) ;
rsethorses ( r , 0 ) ;
rsetmoney ( r , 0 ) ;
rsetpeasants ( r , 0 ) ;
set_string ( & r - > display ,
" Die Lounge des gro<72> en Museums ist ein Platz, in dem sich die Besucher treffen, um die Eindr<64> cke, die sie gewonnen haben, zu verarbeiten. Gem<65> tliche Sitzgruppen laden zum Verweilen ein. " ) ;
}
r = findregion ( 9526 , 9525 ) ;
if ( ! r - > buildings ) {
const building_type * bt_generic = bt_find ( " generic " ) ;
b = new_building ( bt_generic , r , NULL ) ;
set_string ( & b - > name , " S<EFBFBD> par<EFBFBD> e im d<> monischen Stil " ) ;
set_string ( & b - > display ,
" Diese ganz im d<> monischen Stil gehaltene Sitzgruppe ist ganz in dunklen Schwarzt<7A> nen gehalten. Muster fremdartiger Runen bedecken das merkw<6B> rdig geformte Mobiliar, das unangenehm lebendig wirkt. " ) ;
b = new_building ( bt_generic , r , NULL ) ;
set_string ( & b - > name , " S<EFBFBD> par<EFBFBD> e im elfischen Stil " ) ;
set_string ( & b - > display ,
" Ganz in Gr<47> n- und Braunt<6E> nen gehalten wirkt die Sitzgruppe fast lebendig. Bei n<> herer Betrachtung erschlie<69> t sich dem Betrachter, da<64> sie tats<74> chlich aus lebenden Pflanzen erstellt ist. So ist der Tisch aus einem eizigen Baum gewachsen, und die Polster bestehen aus weichen Grassoden. Ein wundersch<63> n gemusterter Webteppich mit tausenden naturgetreu eingestickter Blumensarten bedeckt den Boden. " ) ;
b = new_building ( bt_generic , r , NULL ) ;
set_string ( & b - > name , " S<EFBFBD> par<EFBFBD> e im halblingschen Stil " ) ;
set_string ( & b - > display ,
" Dieses rustikale Mobiliar ist aus einem einzigen, gewaltigen Baum hergestellt worden. Den Stamm haben flei<65> ige Halblinge der L<> nge nach gevierteilt und aus den vier langen Viertelst<73> mmen die Sitzb<7A> nke geschnitzt, w<> hrend der verbleibende Stumpf als Tisch dient. Schon von weitem steigen dem Besucher die Ger<65> che der K<> stlichkeiten entgegen, die auf dem Tisch stapeln. " ) ;
b = new_building ( bt_generic , r , NULL ) ;
set_string ( & b - > name , " S<EFBFBD> par<EFBFBD> e im orkischen Stil " ) ;
set_string ( & b - > display ,
" Grobgeschreinerte, elfenhautbespannte St<53> hle und ein Tisch aus Knochen, <20> ber deren Herkunft man sich lieber keine Gedanken macht, bilden die Sitzgruppe im orkischen Stil. <20> berall haben Orks ihre Namen, und anderes wenig zitierenswertes in das Holz und Gebein geritzt. " ) ;
b = new_building ( bt_generic , r , NULL ) ;
set_string ( & b - > name , " S<EFBFBD> par<EFBFBD> e im Meermenschenstil " ) ;
set_string ( & b - > display ,
" Ganz in Blau- und Gr<47> nt<6E> nen gehalten, mit Algen und Muscheln verziert wirken die aus altem Meerholz geschnitzten St<53> hle immer ein wenig feucht. Seltsammerweise hat der schwere aus alten Planken gezimmerte Tisch einen Mast mit kompletten Segel in der Mitte. " ) ;
b = new_building ( bt_generic , r , NULL ) ;
set_string ( & b - > name , " S<EFBFBD> par<EFBFBD> e im Katzenstil " ) ;
set_string ( & b - > display ,
" Die W<> nde dieses S<> par<61> e sind aus dunklem Holz. Was aus der Ferne wie ein chaotisch durchbrochenes Flechtwerk wirkt, entpuppt sich bei n<> herer Betrachtung als eine bis in winzige Details gestaltete dschungelartige Landschaft, in die eine Vielzahl von kleinen Bildergeschichten eingewoben sind. Wie es scheint hat sich der K<> nstler M<> he gegeben wirklich jedes Katzenvolk Eresseas zu portr<74> tieren. Das schummrige Innere wird von einem Kamin dominiert, vor dem einige Sessel und weiche Kissen zu einem gem<65> tlichen Nickerchen einladen. Feiner Anduner Sisal bezieht die Lehnen der Sessel und verlockt dazu, seine Krallen hinein zu versenken. Auf einem kleinen Ecktisch steht ein gro<72> er Korb mit roten Wollkn<6B> ulen und grauen und braunen Spielm<6C> usen. " ) ;
} else {
for ( b = r - > buildings ; b ; b = b - > next ) {
b - > size = b - > type - > maxsize ;
}
}
r = findregion ( 9524 , 9526 ) ;
if ( ! r ) {
r = new_region ( 9524 , 9526 , 0 ) ;
terraform_region ( r , terrain_corridor ) ;
r - > planep = museum ;
rsetname ( r , " N<EFBFBD> rdliche Promenade " ) ;
rsethorses ( r , 0 ) ;
rsetmoney ( r , 0 ) ;
rsetpeasants ( r , 0 ) ;
set_string ( & r - > display ,
" Die N<> rdliche Promenade f<> hrt direkt in den naturgeschichtlichen Teil des Museums. " ) ;
}
r = findregion ( 9525 , 9524 ) ;
if ( ! r ) {
r = new_region ( 9525 , 9524 , 0 ) ;
terraform_region ( r , terrain_corridor ) ;
r - > planep = museum ;
rsetname ( r , " S<EFBFBD> dliche Promenade " ) ;
rsethorses ( r , 0 ) ;
rsetmoney ( r , 0 ) ;
rsetpeasants ( r , 0 ) ;
set_string ( & r - > display ,
" Die S<> dliche Promenade f<> hrt den Besucher in den kulturgeschichtlichen Teil des Museums. " ) ;
2011-03-07 08:02:35 +01:00
}
2010-08-08 10:06:34 +02:00
# endif
}
static int
2011-03-07 08:02:35 +01:00
use_museumexitticket ( unit * u , const struct item_type * itype , int amount ,
2014-07-21 11:34:57 +02:00
order * ord )
2010-08-08 10:06:34 +02:00
{
2014-07-21 11:34:57 +02:00
attrib * a ;
region * r ;
unit * warden = findunit ( atoi36 ( " mwar " ) ) ;
int unit_cookie ;
2011-03-07 08:02:35 +01:00
2017-01-10 16:31:05 +01:00
UNUSED_ARG ( amount ) ;
2011-03-07 08:02:35 +01:00
2014-07-21 11:34:57 +02:00
/* Pr<50> fen ob in Eingangshalle */
if ( u - > region - > x ! = 9525 | | u - > region - > y ! = 9525 ) {
cmistake ( u , ord , 266 , MSG_MAGIC ) ;
return 0 ;
2011-03-07 08:02:35 +01:00
}
2014-07-21 11:34:57 +02:00
a = a_find ( u - > attribs , & at_museumexit ) ;
2015-10-30 12:58:27 +01:00
assert ( a ) ;
r = findregion ( a - > data . sa [ 0 ] , a - > data . sa [ 1 ] ) ;
assert ( r ) ;
a_remove ( & u - > attribs , a ) ;
2014-07-21 11:34:57 +02:00
/* <20> bergebene Gegenst<73> nde zur<75> ckgeben */
a = a_find ( u - > attribs , & at_museumgivebackcookie ) ;
if ( a ) {
2015-10-30 12:49:37 +01:00
unit_cookie = a - > data . i ;
a_remove ( & u - > attribs , a ) ;
2014-07-21 11:34:57 +02:00
for ( a = a_find ( warden - > attribs , & at_museumgiveback ) ;
a & & a - > type = = & at_museumgiveback ; a = a - > next ) {
if ( ( ( museumgiveback * ) ( a - > data . v ) ) - > cookie = = unit_cookie )
break ;
}
if ( a & & a - > type = = & at_museumgiveback ) {
museumgiveback * gb = ( museumgiveback * ) ( a - > data . v ) ;
item * it ;
for ( it = gb - > items ; it ; it = it - > next ) {
i_change ( & u - > items , it - > type , it - > number ) ;
}
ADDMSG ( & u - > faction - > msgs , msg_message ( " museumgiveback " ,
" region unit sender items " , r , u , warden , gb - > items ) ) ;
a_remove ( & warden - > attribs , a ) ;
}
2011-03-07 08:02:35 +01:00
}
2014-07-21 11:34:57 +02:00
/* Benutzer zur<75> ck teleportieren */
move_unit ( u , r , NULL ) ;
2011-03-07 08:02:35 +01:00
2014-07-21 11:34:57 +02:00
/* Exitticket abziehen */
i_change ( & u - > items , itype , - 1 ) ;
2011-03-07 08:02:35 +01:00
2014-07-21 11:34:57 +02:00
return 0 ;
2010-08-08 10:06:34 +02:00
}
static int
2011-03-07 08:02:35 +01:00
use_museumticket ( unit * u , const struct item_type * itype , int amount ,
2014-07-21 11:34:57 +02:00
order * ord )
2010-08-08 10:06:34 +02:00
{
2014-07-21 11:34:57 +02:00
attrib * a ;
region * r = u - > region ;
plane * pl = rplane ( r ) ;
2010-08-08 10:06:34 +02:00
2017-01-10 16:31:05 +01:00
UNUSED_ARG ( amount ) ;
2010-08-08 10:06:34 +02:00
2014-07-21 11:34:57 +02:00
/* Pruefen ob in normaler Plane und nur eine Person */
if ( pl ! = get_homeplane ( ) ) {
cmistake ( u , ord , 265 , MSG_MAGIC ) ;
return 0 ;
}
if ( u - > number ! = 1 ) {
cmistake ( u , ord , 267 , MSG_MAGIC ) ;
return 0 ;
}
if ( has_horses ( u ) ) {
cmistake ( u , ord , 272 , MSG_MAGIC ) ;
return 0 ;
}
/* In diesem Attribut merken wir uns, wohin die Einheit zur<75> ckgesetzt
* wird , wenn sie das Museum verl <EFBFBD> <EFBFBD> t . */
a = a_add ( & u - > attribs , a_new ( & at_museumexit ) ) ;
a - > data . sa [ 0 ] = ( short ) r - > x ;
a - > data . sa [ 1 ] = ( short ) r - > y ;
/* Benutzer in die Halle teleportieren */
move_unit ( u , findregion ( 9525 , 9525 ) , NULL ) ;
2010-08-08 10:06:34 +02:00
2014-07-21 11:34:57 +02:00
/* Ticket abziehen */
i_change ( & u - > items , itype , - 1 ) ;
2010-08-08 10:06:34 +02:00
2014-07-21 11:34:57 +02:00
/* Benutzer ein Exitticket geben */
i_change ( & u - > items , itype , 1 ) ;
2010-08-08 10:06:34 +02:00
2014-07-21 11:34:57 +02:00
return 0 ;
}
2010-08-08 10:06:34 +02:00
2014-07-21 11:34:57 +02:00
/***
* special quest door
* * */
2010-08-08 10:06:34 +02:00
2014-07-21 11:34:57 +02:00
bool b_blockquestportal ( const connection * b , const unit * u ,
const region * r )
{
if ( b - > data . i > 0 )
return true ;
return false ;
}
2010-08-08 10:06:34 +02:00
2014-07-21 11:34:57 +02:00
static const char * b_namequestportal ( const connection * b , const region * r ,
const struct faction * f , int gflags )
{
const char * bname ;
int lock = b - > data . i ;
2017-01-10 16:31:05 +01:00
UNUSED_ARG ( b ) ;
UNUSED_ARG ( r ) ;
2014-07-21 11:34:57 +02:00
if ( gflags & GF_ARTICLE ) {
if ( lock > 0 ) {
bname = " a_gate_locked " ;
}
else {
bname = " a_gate_open " ;
}
}
else {
if ( lock > 0 ) {
bname = " gate_locked " ;
}
else {
bname = " gate_open " ;
}
}
if ( gflags & GF_PURE )
return bname ;
return LOC ( f - > locale , mkname ( " border " , bname ) ) ;
2010-08-08 10:06:34 +02:00
}
2014-07-21 11:34:57 +02:00
border_type bt_questportal = {
" questportal " , VAR_INT ,
b_opaque ,
NULL , /* init */
NULL , /* destroy */
b_read , /* read */
b_write , /* write */
b_blockquestportal , /* block */
b_namequestportal , /* name */
b_rvisible , /* rvisible */
b_fvisible , /* fvisible */
b_uvisible , /* uvisible */
} ;
2014-07-22 00:39:30 +02:00
static void use_key1 ( connection * b , void * data ) {
unit * u = ( unit * ) data ;
if ( b - > type = = & bt_questportal ) {
2014-07-22 11:27:43 +02:00
const struct item_type * itype = it_find ( " questkey1 " ) ;
ADDMSG ( & u - > faction - > msgs ,
2018-01-21 18:07:49 +01:00
msg_message ( " use_item " , " unit amount item " , u , 1 , itype - > rtype ) ) ;
2014-07-22 00:39:30 +02:00
b - > data . i & = 0xFE ;
}
}
static void use_key2 ( connection * b , void * data ) {
unit * u = ( unit * ) data ;
if ( b - > type = = & bt_questportal ) {
2014-07-22 11:27:43 +02:00
const struct item_type * itype = it_find ( " questkey2 " ) ;
ADDMSG ( & u - > faction - > msgs ,
2018-01-21 18:07:49 +01:00
msg_message ( " use_item " , " unit amount item " , u , 1 , itype - > rtype ) ) ;
2014-07-22 00:39:30 +02:00
b - > data . i & = 0xFD ;
}
}
static int
use_museumkey ( unit * u , const struct item_type * itype , int amount ,
order * ord )
{
const struct item_type * ikey = it_find ( " questkey1 " ) ;
assert ( u ) ;
assert ( itype & & ikey ) ;
assert ( amount > = 1 ) ;
2015-01-30 20:37:14 +01:00
walk_connections ( u - > region , itype = = ikey ? use_key1 : use_key2 , u ) ;
2014-07-22 00:39:30 +02:00
return 0 ;
}
2011-03-07 08:02:35 +01:00
void register_museum ( void )
2010-08-08 10:06:34 +02:00
{
2014-07-21 11:34:57 +02:00
register_bordertype ( & bt_questportal ) ;
at_register ( & at_warden ) ;
at_register ( & at_museumexit ) ;
at_register ( & at_museumgivebackcookie ) ;
at_register ( & at_museumgiveback ) ;
2010-08-08 10:06:34 +02:00
2014-07-21 11:34:57 +02:00
register_item_use ( use_museumexitticket , " use_museumexitticket " ) ;
2017-02-27 20:41:05 +01:00
register_item_use ( use_museumticket , " use_museumticket " ) ;
register_item_use ( use_museumkey , " use_questkey1 " ) ;
register_item_use ( use_museumkey , " use_questkey2 " ) ;
2010-08-08 10:06:34 +02:00
}