Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool firstplay = true;
- //Link active script
- link script links
- {
- int collected_items[256];
- int item_scripts[512];
- int data[2048];
- const int REMOVAL_SCRIPT = 0; //array index of data[]
- void run()
- {
- data[REMOVAL_SCRIPT] = Game->GetItemScript("ItemRemoval");
- while(1)
- {
- CheckInventory();
- Waitdraw();
- Waitframe();
- }
- }
- void CheckInventory()
- {
- for ( int q = 1; q < 512; ++q )
- {
- if ( collected_items[q] )
- {
- if ( !Link->Item[q] )
- {
- itemdata id = Game->LoadItemData(q);
- id->Script = data[REMOVAL_SCRIPT];
- id->RunScript();
- collected_items[q] = 0; //Fuly remove from inventory.
- }
- }
- }
- }
- }
- item script ItemRemoval
- {
- void run()
- {
- bool done = false;
- //effect here
- //can be made to run for more than one frame
- //with a while loop as of 2.55 Alpha 2 or 3 or 4.
- while(!done)
- {
- //when our oop ends
- done = true;
- Waitframe();
- }
- //when done, set back the original item script
- this->Script = links.item_scripts[this->ID];
- }
- }
- //Link Init Script
- link script linkinit
- {
- void run()
- {
- int collectscriptid = Game->GetItemScript("ItemCollect"); //cache here
- itemdata id;
- for ( int q = 1; q < 512; ++q )
- {
- id = Game->LoadItemData(q);
- id->PScript = collectscriptid; //auto-set the collect script for every item in the quest
- }
- if ( firstplay )
- {
- for ( int q = 1; q < 512; ++q )
- {
- id = Game->LoadItemData(q);
- links.item_scripts[q] = id->Script; //cache all original item scripts at the very start of the game
- }
- firstplay = false;
- }
- }
- }
- //Generic collect script to put on a items.
- //Can be forced on all items with Link's init script at the start of every session
- //Marks if Link owns an item, for use when toggling Link->Item[] elsewhere.
- item script ItemCollect
- {
- void run()
- {
- links.collected_items[this->ID] = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement