PDA

View Full Version : Script Help Request (again)



Lelouche Vi Britannia
03-06-2016, 01:04 PM
Ok, so far I found scripts for what I want to do with a few things, but there is one thing I don't have a script for. I've already tried a few times to get this to work but was frustrated by failure and scrapped it to keep things simple. But since I started Dichotomy (which might be getting back burner-ed sadly) I wanted to do this and couldn't figure out how to do it.

What I'm trying to do is create an item that unlocks specific chests, basically a treasure chest key. At the same time it was meant to work only on specific chests. The original idea was Overworld and Overworld cavern chests would be opened by the keys, leaving treasure chests in dungeons to be opened by level keys. If the idea works I could have the same kind of Overworld chests show up randomly in dungeons as well only open-able by chest keys, with other dungeon chests open-able by the finite number of level keys available in that level.

Also there would be a lot of these treasure chests, and the keys would be rare drops from certain enemies or sold by merchants.

So, scripting guru's... how is this done? I wouldn't mind someone doing the scripting for me, but I would still want to know how it works so I could utilize that knowledge in future projects or just to flesh out older ones and finally release them.

Tamamo
03-06-2016, 01:49 PM
And this is why we need a Treasure Chest (Level Key Only) combo.
Can't you just disable the key item in the dungeons?

Lelouche Vi Britannia
03-06-2016, 02:12 PM
I tried that, for some reason it doesn't work. The key counter shows 0 for level keys and I don't show the counter for normal keys. But with a counter of 0 Level keys, it still consumed one of my normal keys to open a door anyway, which of course means that it makes the difference in keys kind of moot if you include both types.

Lelouche Vi Britannia
05-08-2016, 07:27 PM
Bumping thread in the hopes that a dev can shed some light on this....

ywkls
05-08-2016, 10:46 PM
The only place you'd need a script would be inside a dungeon. On the overworld, you can have a level too! Even if you set the level as zero, a level-specific key for that wouldn't work in dungeons. That's how I had locked chests in one of my quests.

As for chests in dungeons that require specific keys, that's something that would need a script. Let me cogitate on it and get back to you.

Lelouche Vi Britannia
05-08-2016, 11:19 PM
Why didn't I think of that. Lol

ywkls
05-08-2016, 11:21 PM
Alright, try this. No guarantees it will work, because it is untested. Place the ffc (that looks like a chest) on top of a solid combo that looks like the open chest and set the flag to Run Script at Screen Init.


ffc script Locked_Treasure_Chest{
void run(int item_ID,int Key_Counter){
if(Screen->State[ST_CHEST]){
this->Data = 0;
Quit();
}
while(!Activated(this,Key_Counter))
Waitframe();

this->Data = GH_INVISIBLE_COMBO;
CreateItemAt(item_ID,Link->X,Link->Y);
Game->Counter[Key_Counter]--;
Link->Action = LA_HOLD2LAND;
Link->HeldItem = item_ID;
Screen->State[ST_CHEST]=true;
` KeepAUnpressed();
this->Data = 0;
}
}

bool Activated(ffc this, int Key_Counter){
if(Game->Counter[Key_Counter]==0)return false;
if(Link->Dir!=DIR_UP)return false;
if(Link->X<this->-8)return false;
if(Link->X>this->X+8)return false;
if(Link->Y<this->Y+8)return false;
if(Link->Y>this->Y+16)return false;
if(!Link->PressA)return false;
return true;
}

void KeepAUnpressed(){
while(Link->InputA){
Link->InputA = false;
Link->PressA = false;
Waitframe();
}
}


The basics for this script were created by Saffith, I just modified it. The key item would have to increase the custom counter and that would be what you'd have to display onscreen, probably separate from the normal key counter. To initialize the counter, just add a section like this to either a global init script or the global active script above the while loop.


int MaxKeys =100;//This needs to be outside of all loops.

Game->MCounter[CR_SCRIPT1] = MaxKeys;//This part would be inside the init script or in the active script before the while loop.



Let me know if that works!

Lelouche Vi Britannia
05-08-2016, 11:34 PM
If I ever get around to testing it, I will.

ywkls
05-08-2016, 11:38 PM
Edited the script slightly. This idea could also be used for a block that vanished if you examine it with a certain item in your inventory. Could also work for Npcs that move aside whenever you speak to them and have an item. Really, there are tons of things this could do.