ShadowMancer
08-23-2007, 04:18 PM
I am trying to change an items itemclass with script, I am a bit confused as it says in the docs:
itemclass Class
* The class (the type of item) to which this item belongs.
Alright, itemclass is a varible type right? so I think that I would need to set the Family varible under itemclass..
int Family
* The kind of item to which this class belongs (swords, boomerangs,
* potions, etc.) Use the IC_ constants in std.zh to set or compare this
* value.
So, here is what I wrote:
global script main_script {
void run() {
item drop;
item itm_1;
item itm_2;
item itm_3;
item itm_4;
item itm_5;
itemclass old_cls;
itemclass new_cls;
new_cls->Family = 252;
old_cls->Family = 253;
int item_num = 1;
while(true) {
//Mana timer routine
if (MANA_TIMER >= 100) {
if (Link->MP < Link->MaxMP) {Link->MP += 1;}
MANA_TIMER = 0;}
else {MANA_TIMER += 1;}
if(is_spending > 0) {rupie_taker();}
//Custom Item Drop Routine
if (item_num <= Screen->NumItems()) {
drop = Screen->LoadItem(item_num);
if (drop->Class == old_cls) {
drop->Tile = 0;
drop->Class = new_cls;
itm_1 = Screen->CreateItem(150);
itm_1->X = (drop->X-4)+Rand(8);
itm_1->Y = (drop->Y-4)+Rand(8);
}
item_num += 1;
}
else { item_num = 1; }
Waitframe();
}
}
}
I defined the varibles:
itemclass old_cls;
itemclass new_cls;
new_cls->Family = 252;
old_cls->Family = 253;
Now I want to check to see if Drop->Class (Family??) is equal to itemclass id# 253
if (drop->Class == old_cls)
Then change its class to id# 252
drop->Class = new_cls;
Right, seems like it would work but it does not detect the item at all :confused:
Could someone explain how this works please.
Btw All I really want to do is find some unique way to detect a droped item then create a different item and make the droped item disappear. I tried useing item->Tile which can detect the unique tile alright, change the tile to 0. But the script just keeps creating items despite the fact the the detected item drop is now a different tile, very strange.
Here is my old code if someone wants to test it for themselfs:
global script main_script {
void run() {
item drop;
item itm_1;
item itm_2;
item itm_3;
item itm_4;
item itm_5;
int item_num = 1;
while(true) {
if (item_num <= Screen->NumItems()) {
drop = Screen->LoadItem(item_num);
if (drop->Tile == 31165 && drop->CSet != 0) {
drop->Tile = 0;
drop->CSet = 0;
itm_1 = Screen->CreateItem(150);
itm_1->X = (drop->X-4)+Rand(8);
itm_1->Y = (drop->Y-4)+Rand(8);
}
item_num += 1;
}
else { item_num = 1; }
Waitframe();
}
}
}
:googly::googly::googly::googly:
itemclass Class
* The class (the type of item) to which this item belongs.
Alright, itemclass is a varible type right? so I think that I would need to set the Family varible under itemclass..
int Family
* The kind of item to which this class belongs (swords, boomerangs,
* potions, etc.) Use the IC_ constants in std.zh to set or compare this
* value.
So, here is what I wrote:
global script main_script {
void run() {
item drop;
item itm_1;
item itm_2;
item itm_3;
item itm_4;
item itm_5;
itemclass old_cls;
itemclass new_cls;
new_cls->Family = 252;
old_cls->Family = 253;
int item_num = 1;
while(true) {
//Mana timer routine
if (MANA_TIMER >= 100) {
if (Link->MP < Link->MaxMP) {Link->MP += 1;}
MANA_TIMER = 0;}
else {MANA_TIMER += 1;}
if(is_spending > 0) {rupie_taker();}
//Custom Item Drop Routine
if (item_num <= Screen->NumItems()) {
drop = Screen->LoadItem(item_num);
if (drop->Class == old_cls) {
drop->Tile = 0;
drop->Class = new_cls;
itm_1 = Screen->CreateItem(150);
itm_1->X = (drop->X-4)+Rand(8);
itm_1->Y = (drop->Y-4)+Rand(8);
}
item_num += 1;
}
else { item_num = 1; }
Waitframe();
}
}
}
I defined the varibles:
itemclass old_cls;
itemclass new_cls;
new_cls->Family = 252;
old_cls->Family = 253;
Now I want to check to see if Drop->Class (Family??) is equal to itemclass id# 253
if (drop->Class == old_cls)
Then change its class to id# 252
drop->Class = new_cls;
Right, seems like it would work but it does not detect the item at all :confused:
Could someone explain how this works please.
Btw All I really want to do is find some unique way to detect a droped item then create a different item and make the droped item disappear. I tried useing item->Tile which can detect the unique tile alright, change the tile to 0. But the script just keeps creating items despite the fact the the detected item drop is now a different tile, very strange.
Here is my old code if someone wants to test it for themselfs:
global script main_script {
void run() {
item drop;
item itm_1;
item itm_2;
item itm_3;
item itm_4;
item itm_5;
int item_num = 1;
while(true) {
if (item_num <= Screen->NumItems()) {
drop = Screen->LoadItem(item_num);
if (drop->Tile == 31165 && drop->CSet != 0) {
drop->Tile = 0;
drop->CSet = 0;
itm_1 = Screen->CreateItem(150);
itm_1->X = (drop->X-4)+Rand(8);
itm_1->Y = (drop->Y-4)+Rand(8);
}
item_num += 1;
}
else { item_num = 1; }
Waitframe();
}
}
}
:googly::googly::googly::googly: