Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const NPC_LAYER =2;//Has to be layer 2 or 1.
- //Used to affect solidity
- // FFC script for talking NPCs with different functions
- // It's pretty much a sign you can approach from any side.
- // D0: String number to be displayed
- // D1: Item for interaction
- // If positive, npc persists until you have the item
- // If Negative, npc doesn't appear until you have the item
- //
- // D2: Screen->D register to store information in.
- // A number between 0-7 unique for each npc on screen
- //
- // D3: Whether screen secrets are triggered after talking to this npc
- ffc script altnpcscript{
- void run(int string, int item_req, int perm,bool secret){
- // So that people don't have to be pixel perfect on placing npcs.
- //Used for determining what combo to change
- int loc= ComboAt(this->X,this->Y);
- //Remember what combo was here before
- int this_combo= Screen->D[loc];
- //Remember the npc's appearance if it is supposed to be invisible until you have an item
- int store_combo= this->Data;
- //NPC appears until you have an item
- if(item_req>0){
- //You don't have the item
- if(!Link->Item[item_req]){
- //Set the combo on layer one at this position
- //To whatever was here before
- SetLayerComboD(NPC_LAYER-1,loc,this_combo);
- //Set the combo here on layer 2 to the npc's data
- SetLayerComboD(NPC_LAYER,loc,this->Data);
- }
- else
- SetLayerComboD(NPC_LAYER,loc,GetLayerComboD(NPC_LAYER-1,loc));
- //Once you have the item, change the combo at this position
- //Uses the stored combo on layer 1 to determine what to put here
- }
- else if(item_req<0){
- //Npc is invisible until you have the item
- this->Data= GH_INVISIBLE_COMBO;
- //Do nothing until you have the item
- while(!Link->Item[item_req])
- Waitframe();
- //Restore npc appearance
- this->Data = store_combo;
- //Change the combo on layer 2 to npc data to affect solidity
- SetLayerComboD(NPC_LAYER,loc,this->Data);
- }
- //When placed here, no errors manifest
- //int LinkX;
- //int LinkY;
- //int centerX;
- //int centerY;
- while(true){
- //When placed here, they do
- // Set up some values to make the if statement smaller.
- int LinkX = Link->X + 8;
- int LinkY = Link->Y + 8;
- int centerX = this->X + this->EffectWidth / 2;
- int centerY = this->Y + this->EffectHeight / 2;
- // If Link is on one of the sides of the NPC and facing it
- if(
- ((Abs(LinkX - centerX) < this->EffectWidth / 2
- && Abs(LinkY - centerY) <= this->EffectHeight / 2 + 12
- && LinkY < centerY && Link->Dir == DIR_DOWN) ||
- (Abs(LinkX - centerX) < this->EffectWidth / 2
- && Abs(LinkY - centerY) <= this->EffectHeight / 2 + 4
- && LinkY > centerY && Link->Dir == DIR_UP) ||
- (Abs(LinkY + 3 - centerY) < this->EffectHeight / 2
- && Abs(LinkX - centerX) <= this->EffectWidth / 2 + 12
- && LinkX < centerX && Link->Dir == DIR_RIGHT) ||
- (Abs(LinkY + 3- centerY) < this->EffectHeight / 2
- && Abs(LinkX - centerX) <= this->EffectWidth / 2 + 12
- && LinkX > centerX && Link->Dir == DIR_LEFT))){
- if(Link->PressEx1){
- Link->InputEx1=false;
- Screen->Message(string);
- if(Screen->D[perm]==0){
- //This is so that any string control codes which read Screen->D aren't
- //immediately triggered
- Waitframes(5);
- //Set screen D register
- Screen->D[perm]=1;
- //Trigger secrets
- if(secret){
- Screen->TriggerSecrets();
- Screen->State[ST_SECRET]= true;
- }
- }
- }
- }
- Waitframe();
- } // End of while(true)
- } // End of void run(int message)
- } // End of ffc script npcscript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement