summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-17 07:29:01 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-17 07:29:01 +0000
commitcf21db7985cfaf093cca2a1d4bc3e43e7f145ff3 (patch)
tree047dfb2d283c62b7dffde8f5fb3efb82d89104b2
parentdf571ba029476eff320e48d3c52a616bbc9d2fad (diff)
downloadhercules-cf21db7985cfaf093cca2a1d4bc3e43e7f145ff3.tar.gz
hercules-cf21db7985cfaf093cca2a1d4bc3e43e7f145ff3.tar.bz2
hercules-cf21db7985cfaf093cca2a1d4bc3e43e7f145ff3.tar.xz
hercules-cf21db7985cfaf093cca2a1d4bc3e43e7f145ff3.zip
* Added 2 new script commands to support 2/15's cards patch
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1123 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-SVN.txt11
-rw-r--r--src/map/script.c120
2 files changed, 131 insertions, 0 deletions
diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt
index 9f194fc23..a881182d6 100644
--- a/Changelog-SVN.txt
+++ b/Changelog-SVN.txt
@@ -1,5 +1,16 @@
Date Added
+02/17
+ * Added 2 new script commands to support 2/15's cards patch... most of the
+ effects in kRO should be available now ^^ [celest]
+
+ - isequipped(...): Accepts a list of item ID's and checks whether all of
+ the items/cards have been equipped.
+ - isequippedcnt(...): Same as above, except it returns how many of the items
+ are being equipped
+
+ Example: if(isequipped(4002,4004,4006)) bonus bStr,1;
+
02/16
* Char SQL: Fixed the Whisper chat on splittet mapservers (i think now all features work!) [Sirius]
diff --git a/src/map/script.c b/src/map/script.c
index ce70b29c3..482a136cf 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -46,6 +46,11 @@
#endif
#define SCRIPT_BLOCK_SIZE 256
+
+#define FETCH(n, t) \
+ if(st->end>st->start+(n)) \
+ (t)=conv_num(st,&(st->stack->stack_data[st->start+(n)]));
+
enum { LABEL_NEXTLINE=1,LABEL_START };
static unsigned char * script_buf;
static int script_pos,script_size;
@@ -301,6 +306,8 @@ int buildin_logmes(struct script_state *st); // [Lupus]
int buildin_summon(struct script_state *st); // [celest]
int buildin_isnight(struct script_state *st); // [celest]
int buildin_isday(struct script_state *st); // [celest]
+int buildin_isequipped(struct script_state *st); // [celest]
+int buildin_isequippedcnt(struct script_state *st); // [celest]
void push_val(struct script_stack *stack,int type,int val);
int run_func(struct script_state *st);
@@ -528,6 +535,8 @@ struct {
{buildin_summon,"summon","si*"}, // summons a slave monster [Celest]
{buildin_isnight,"isnight",""}, // check whether it is night time [Celest]
{buildin_isday,"isday",""}, // check whether it is day time [Celest]
+ {buildin_isequipped,"isequipped","i*"}, // check whether another item/card has been equipped [Celest]
+ {buildin_isequippedcnt,"isequippedcnt","i*"}, // check how many items/cards are being equipped [Celest]
{NULL,NULL,NULL},
};
int buildin_message(struct script_state *st); // [MouseJstr]
@@ -6549,6 +6558,117 @@ int buildin_isday(struct script_state *st)
return 0;
}
+/*================================================
+ * Check whether another item/card has been
+ * equipped - used for 2/15's cards patch [celest]
+ *------------------------------------------------
+ */
+int buildin_isequipped(struct script_state *st)
+{
+ struct map_session_data *sd;
+ int i, j, k, id = 1;
+ int ret = -1;
+
+ sd = script_rid2sd(st);
+
+ for (i=0; id!=0; i++) {
+ int flag = 0;
+
+ FETCH (i+2, id) else id = 0;
+ if (id <= 0)
+ continue;
+
+ for (j=0; j<10; j++) {
+ int index, type;
+ index = sd->equip_index[j];
+ if(index < 0) continue;
+ if(j == 9 && sd->equip_index[8] == index) continue;
+ if(j == 5 && sd->equip_index[4] == index) continue;
+ if(j == 6 && (sd->equip_index[5] == index || sd->equip_index[4] == index)) continue;
+ type = itemdb_type(id);
+
+ if(sd->inventory_data[index]) {
+ if (type == 4 || type == 5) {
+ if (sd->inventory_data[index]->nameid == id)
+ flag = 1;
+ } else if (type == 6) {
+ for(k=0; k<sd->inventory_data[index]->slot; k++) {
+ if (sd->status.inventory[index].card[0]!=0x00ff &&
+ sd->status.inventory[index].card[0]!=0x00fe &&
+ sd->status.inventory[index].card[0]!=(short)0xff00 &&
+ sd->status.inventory[index].card[k] == id) {
+ flag = 1;
+ break;
+ }
+ }
+ }
+ if (flag) break;
+ }
+ }
+ if (ret == -1)
+ ret = flag;
+ else
+ ret &= flag;
+ if (!ret) break;
+ }
+
+ push_val(st->stack,C_INT,ret);
+ return 0;
+}
+
+/*================================================
+ * Check how many items/cards in the list are
+ * equipped - used for 2/15's cards patch [celest]
+ *------------------------------------------------
+ */
+int buildin_isequippedcnt(struct script_state *st)
+{
+ struct map_session_data *sd;
+ int i, j, k, id = 1;
+ int ret = 0;
+
+ sd = script_rid2sd(st);
+
+ for (i=0; id!=0; i++) {
+ FETCH (i+2, id) else id = 0;
+ if (id <= 0)
+ continue;
+
+ for (j=0; j<10; j++) {
+ int index, type, flag = 0;
+ index = sd->equip_index[j];
+ if(index < 0) continue;
+ if(j == 9 && sd->equip_index[8] == index) continue;
+ if(j == 5 && sd->equip_index[4] == index) continue;
+ if(j == 6 && (sd->equip_index[5] == index || sd->equip_index[4] == index)) continue;
+ type = itemdb_type(id);
+
+ if(sd->inventory_data[index]) {
+ if (type == 4 || type == 5) {
+ if (sd->inventory_data[index]->nameid == id)
+ flag = 1;
+ } else if (type == 6) {
+ for(k=0; k<sd->inventory_data[index]->slot; k++) {
+ if (sd->status.inventory[index].card[0]!=0x00ff &&
+ sd->status.inventory[index].card[0]!=0x00fe &&
+ sd->status.inventory[index].card[0]!=(short)0xff00 &&
+ sd->status.inventory[index].card[k] == id) {
+ flag = 1;
+ break;
+ }
+ }
+ }
+ if (flag) {
+ ret++;
+ break;
+ }
+ }
+ }
+ }
+
+ push_val(st->stack,C_INT,ret);
+ return 0;
+}
//
// ŽÀs•”main
//