summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-11-19 18:19:09 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-11-19 18:19:09 +0000
commit30c8d7704026aa450b64997c2996ee8d9d4f2cec (patch)
treedae267b2e016111da192de4dbf67679878e73409 /src/map/script.c
parent620ea0643c3bcbfed5dd7c84e8d65fc8941997a7 (diff)
downloadhercules-30c8d7704026aa450b64997c2996ee8d9d4f2cec.tar.gz
hercules-30c8d7704026aa450b64997c2996ee8d9d4f2cec.tar.bz2
hercules-30c8d7704026aa450b64997c2996ee8d9d4f2cec.tar.xz
hercules-30c8d7704026aa450b64997c2996ee8d9d4f2cec.zip
- Applied the renewal client support patch from Diablo (eA forum topic 222623)
- Added support for strcharinfo(3) to retrieve the player's map - Added script command "searchitem" for name item searches. - Moved PACKETVER to src/common/mmo.h as it's needed by the char-server now - Changed the status valX from int to long so that it won't break for pointer-storage in other architectures. - Moved the change party leader code to party.c - A few bugfixes or packet field completions based on my past experience messing around with my server. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14155 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c105
1 files changed, 100 insertions, 5 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 8883f3783..57b11f305 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -6086,6 +6086,9 @@ BUILDIN_FUNC(strcharinfo)
else
script_pushconststr(st,"");
break;
+ case 3:
+ script_pushconststr(st,map[sd->bl.m].name);
+ break;
default:
ShowWarning("buildin_strcharinfo: unknown parameter.\n");
script_pushconststr(st,"");
@@ -6231,7 +6234,7 @@ BUILDIN_FUNC(getbrokenid)
num=script_getnum(st,2);
for(i=0; i<MAX_INVENTORY; i++) {
- if(sd->status.inventory[i].attribute==1){
+ if(sd->status.inventory[i].attribute){
brokencounter++;
if(num==brokencounter){
id=sd->status.inventory[i].nameid;
@@ -6260,7 +6263,7 @@ BUILDIN_FUNC(repair)
num=script_getnum(st,2);
for(i=0; i<MAX_INVENTORY; i++) {
- if(sd->status.inventory[i].attribute==1){
+ if(sd->status.inventory[i].attribute){
repaircounter++;
if(num==repaircounter){
sd->status.inventory[i].attribute=0;
@@ -12608,6 +12611,75 @@ BUILDIN_FUNC(checkchatting) // check chatting [Marka]
return 0;
}
+BUILDIN_FUNC(searchitem)
+{
+ struct script_data* data = script_getdata(st, 2);
+ const char *itemname = script_getstr(st,3);
+ struct item_data *items[MAX_SEARCH];
+ int count;
+
+ char* name;
+ int32 start;
+ int32 id;
+ int32 i;
+ TBL_PC* sd = NULL;
+
+ if ((items[0] = itemdb_exists(atoi(itemname))))
+ count = 1;
+ else {
+ count = itemdb_searchname_array(items, ARRAYLENGTH(items), itemname);
+ if (count > MAX_SEARCH) count = MAX_SEARCH;
+ }
+
+ if (!count) {
+ script_pushint(st, 0);
+ return 0;
+ }
+
+ if( !data_isreference(data) )
+ {
+ ShowError("script:searchitem: not a variable\n");
+ script_reportdata(data);
+ st->state = END;
+ return 1;// not a variable
+ }
+
+ id = reference_getid(data);
+ start = reference_getindex(data);
+ name = reference_getname(data);
+ if( not_array_variable(*name) )
+ {
+ ShowError("script:searchitem: illegal scope\n");
+ script_reportdata(data);
+ st->state = END;
+ return 1;// not supported
+ }
+
+ if( not_server_variable(*name) )
+ {
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;// no player attached
+ }
+
+ if( is_string_variable(name) )
+ {// string array
+ ShowError("script:searchitem: not an integer array reference\n");
+ script_reportdata(data);
+ st->state = END;
+ return 1;// not supported
+ }
+
+ for( i = 0; i < count; ++start, ++i )
+ {// Set array
+ void* v = (void*)items[i]->nameid;
+ set_reg(st, sd, reference_uid(id, start), name, v, reference_getref(data));
+ }
+
+ script_pushint(st, count);
+ return 0;
+}
+
int axtoi(const char *hexStg)
{
int n = 0; // position in string
@@ -13057,8 +13129,10 @@ BUILDIN_FUNC(awake)
struct linkdb_node *node = (struct linkdb_node *)sleep_db;
nd = npc_name2id(script_getstr(st, 2));
- if( nd == NULL )
- return 0;
+ if( nd == NULL ) {
+ ShowError("awake: NPC \"%s\" not found\n", script_getstr(st, 2));
+ return 1;
+ }
while( node )
{
@@ -13081,7 +13155,8 @@ BUILDIN_FUNC(awake)
delete_timer(tst->sleep.timer, run_script_timer);
node = script_erase_sleepdb(node);
tst->sleep.timer = INVALID_TIMER;
- //tst->sleep.tick = 0;
+ if(tst->state != RERUNLINE)
+ tst->sleep.tick = 0;
run_script_main(tst);
}
else
@@ -13490,6 +13565,24 @@ BUILDIN_FUNC(checkquest)
return 0;
}
+BUILDIN_FUNC(showevent)
+{
+ TBL_PC *sd = script_rid2sd(st);
+ struct npc_data *nd = map_id2nd(st->oid);
+ int state, color;
+
+ if( sd == NULL || nd == NULL )
+ return 0;
+ state = script_getnum(st, 2);
+ color = script_getnum(st, 3);
+
+ if( color < 0 || color > 4 )
+ color = 0; // set default color
+
+ clif_quest_show_event(sd, &nd->bl, state, color);
+ return 0;
+}
+
/*==========================================
* BattleGround System
*------------------------------------------*/
@@ -14498,6 +14591,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(setcell,"siiiiii"),
BUILDIN_DEF(setwall,"siiiiis"),
BUILDIN_DEF(delwall,"s"),
+ BUILDIN_DEF(searchitem,"rs"),
BUILDIN_DEF(mercenary_create,"ii"),
BUILDIN_DEF(mercenary_heal,"ii"),
BUILDIN_DEF(mercenary_sc_start,"iii"),
@@ -14547,5 +14641,6 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(completequest, "i"),
BUILDIN_DEF(checkquest, "i*"),
BUILDIN_DEF(changequest, "ii"),
+ BUILDIN_DEF(showevent, "ii"),
{NULL,NULL,NULL},
};