Jump to content

Photo

Push Rod


  • Please log in to reply
16 replies to this topic

#1 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 28 May 2010 - 06:38 AM

i hope this script is possible. i really need it in my temple of time. i dont know how to use ffc so dont make it to an ffc.

okay lets start. this item shoots an projektile wich is invisible an cannot trigger any secrets. if the projektil touches a push block then the block will be pushed. it should not fly through solid combos. but it should fly through water. and it need to have the same sfx as the wand. of course the push blocks can aktivates push block triggers

thanks to everyone who helps me icon_smile.gif

#2 Zepinho

Zepinho

    Experienced Forumer

  • Members
  • Location:Trieste, Italy

Posted 28 May 2010 - 09:44 AM

Hi!
Good idea.
Try this.
It still needs a bit more work to avoid Link disappear...
I will include a DrawTile of Link itself to avoid the problem.

CODE

// pushing wand script
import "std.zh"

const int RANGE = 176; // range in pixel

int push_combo;
int push_x;
int push_y;
int stored_x;
int stored_y;

item script PushingWand{
void run(){
  Game->PlaySound(SFX_WAND);
  Link->Action = LA_ATTACKING;
  int dx = 0;
  int dy = 0;
  int x;
  int y;
  int loc;
  if(Link->Dir == DIR_UP) dy = -1;
  else if(Link->Dir == DIR_DOWN) dy = 1;
  else if(Link->Dir == DIR_LEFT) dx = -1;
  else if(Link->Dir == DIR_RIGHT) dx = 1;
  for(int i=0;i<RANGE;i++){
   x = Link->X + i*dx;
   y = Link->Y + i*dy;
   loc = ComboAt(x+8,y+8);
   if(!CanWalk(x,y,Link->Dir,1,false)){
   //if(IsPushable(loc)){
    push_combo = 20;
    push_x = x - dx;
    push_y = y - dy;
    stored_x = Link->X;
    stored_y = Link->Y;
    Link->X = push_x;
    Link->Y = push_y;
    Quit();
   }
   //if(!CanWalk(x,y,Link->Dir,1,true)) Quit();
  }
}
}


// Global Scripts - to combine with other global scripts
global script Slot_2{
void run(){
  //---to do when the quest starts---
  while(true){
   //---to repeat each frame---
   if(push_combo ==1) LinkBack();
   else if(push_combo > 0) PushCombo();
   //---put here other stuff---
   Waitframe();
  }
}
}



// outside global script

void PushCombo(){
Link->Invisible = true;
if(Link->Dir == DIR_UP) Link->InputUp = true;
else if(Link->Dir == DIR_DOWN) Link->InputDown = true;
else if(Link->Dir == DIR_LEFT) Link->InputLeft = true;
else if(Link->Dir == DIR_RIGHT) Link->InputRight = true;
push_combo --;
}

void LinkBack(){
Link->Invisible = false;
Link->X = stored_x;
Link->Y = stored_y;
push_combo --;
}



#3 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 28 May 2010 - 12:09 PM

what does this mean?

"line 24 function canwalk is undecleared"

#4 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 28 May 2010 - 01:41 PM

It compiles just fine my friend. Did you include:
CODE

import "std.zh"

on top of the script file?

#5 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 28 May 2010 - 03:47 PM

i have downloaded the newest version of zc and now it works. thanks! this script is awesome. i will put you on my credit list zepinho. icon_biggrin.gif

EDIT: sorry, but i have found a bug. if you use the items twice very quick it teleports link to where he shoot. and if you shoot to the edge of screen you will be teleportet to the next screen.

Edited by Zelda and Link and I, 30 May 2010 - 07:21 AM.


#6 Zepinho

Zepinho

    Experienced Forumer

  • Members
  • Location:Trieste, Italy

Posted 30 May 2010 - 09:40 AM

Hi! I fixed the bugs and added in a simple way the graphics for Link using the wand and for the wand itself.
It would we better to use a LWeapon for the wand, but I had some strange problem setting the right sprite and I switched to a more simple FastTile even for the wand.

Now you need to speicfy the tiles for Link using wand and for the wand in the four direction.
If you don't want any wand graphic, simply leave the WAND_TILE_... to 0.

Here is the new script:

CODE

// push wand script
import "std.zh"

const int RANGE = 256; // range in pixel
const int TILE_UP = 18206; // tiles for link using wand
const int TILE_DOWN = 18209;
const int TILE_LEFT = 18226;
const int TILE_RIGHT = 18229;
const int INV_COMBO_ID = 25;
const int WAND_TILE_UP = 1132;
const int WAND_TILE_DOWN = 1133;
const int WAND_TILE_LEFT = 1134;
const int WAND_TILE_RIGHT = 1135;


int push_combo;
int push_x;
int push_y;
int stored_x;
int stored_y;

item script PushingWand{
void run(){
  Game->PlaySound(SFX_WAND);
  int dx = 0;
  int dy = 0;
  int x;
  int y;
  int loc;
  if(Link->Dir == DIR_UP) dy = -1;
  else if(Link->Dir == DIR_DOWN) dy = 1;
  else if(Link->Dir == DIR_LEFT) dx = -1;
  else if(Link->Dir == DIR_RIGHT) dx = 1;
  for(int i=0;i<RANGE;i++){
   x = Link->X + i*dx;
   y = Link->Y + i*dy;
   loc = ComboAt(x+8,y+8);
   if(!CanWalk(x,y,Link->Dir,1,false)){
    push_combo = 20;
    push_x = x - dx;
    push_y = y - dy;
    stored_x = Link->X;
    stored_y = Link->Y;
    ffc inv_ffc = Screen->LoadFFC(33);
    inv_ffc->Data = INV_COMBO_ID;
    inv_ffc->X = push_x;
    inv_ffc->Y = push_y;
    if(x>16 && y>16 && x+16<15*16 && y+16<10*16) {
     Link->X = push_x;
     Link->Y = push_y;
    }
    PushCombo();
    Quit();
   }
  }
}
}


// Global Scripts - to combine with other global scripts
global script Slot_2{
void run(){
  //---to do when the quest starts---
  while(true){
   //---to repeat each frame---
   if(push_combo ==1) LinkBack();
   else if(push_combo > 0) PushCombo();
   //---put here other stuff---
   Waitframe();
  }
}
}


// outside global script

void PushCombo(){
Link->Invisible = true;
Link->CollDetection = false;
DrawLinkWandTiles(Link->Dir);
NoAction();
int x = Link->X;
int y = Link->Y;
if(x>16 && y>16 && x+16<15*16 && y+16<10*16) {
  if(Link->Dir == DIR_UP) Link->InputUp = true;
  else if(Link->Dir == DIR_DOWN) Link->InputDown = true;
  else if(Link->Dir == DIR_LEFT) Link->InputLeft = true;
  else if(Link->Dir == DIR_RIGHT) Link->InputRight = true;
}
push_combo --;
}

void LinkBack(){
Link->X = stored_x;
Link->Y = stored_y;
Link->CollDetection = true;
Link->Invisible = false;
ffc inv_ffc = Screen->LoadFFC(33);
inv_ffc->Data = 0;
push_combo --;
}

void DrawLinkWandTiles(int dir){
int link_tile;
int wand_tile;
int dx = 0;
int dy = 0;
if(dir == DIR_UP) {
  link_tile = TILE_UP;
  wand_tile = WAND_TILE_UP;
  dy = -16;
}
else if(dir == DIR_DOWN) {
  link_tile = TILE_DOWN;
  wand_tile = WAND_TILE_DOWN;
  dy = 16;
}
else if(dir == DIR_LEFT) {
  link_tile = TILE_LEFT;
  wand_tile = WAND_TILE_LEFT;
  dx = -16;
}
else if(dir == DIR_RIGHT) {
  link_tile = TILE_RIGHT;
  wand_tile = WAND_TILE_RIGHT;
  dx = 16;
}
Screen->FastTile(1, stored_x,stored_y, link_tile, 6, 128);
Screen->FastTile(1, stored_x+dx,stored_y+dy, wand_tile, 6, 128);
}

void NoAction(){
Link->InputUp = false;
Link->InputDown = false;
Link->InputLeft = false;
Link->InputRight = false;
Link->InputR = false;
Link->InputL = false;
Link->InputA = false;
Link->InputB = false;
}



#7 idontknow8

idontknow8

    Senior

  • Members

Posted 18 August 2016 - 09:43 PM

I'm trying to use this script now (I know, 6 years later!) and it's extremely buggy, to the point where it does just about everything but what it's supposed to.  It always warps Link upwards and we see him the entire time (instead of being invisible) while you hold the B button.  And then when you let go & resume gameplay, Link stays facing up, even when moving left, right, or down.  And it does not appear to push the block at all (just warp Link upward like I said).



#8 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 04 September 2017 - 03:04 PM

I got a problem: I used Zelda Classic the last version but the problem is i drown on water or fail in pits lava script and Link take damage. and when i try to make solid combos to avoid Link reach the blocks to move them the blocks don't move an all.



#9 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 05 September 2017 - 09:13 AM

This is a dead and unsupported script, and newer stuff probably exists that is far cleaner, modern, and known to work in a final build of 2.50.x. The original script was created in the 2.50 beta era, and should not be used without expert review. It does some things that can easily clash with other scripts and it has illegal instructions in it:.
 

ffc inv_ffc = Screen->LoadFFC(33);

That is illegal, and fully unsupported in ZScript. In fact, the ability to load invalid ffcs is deprecated behaviour. Writing to this will cause all sorts of nasty stuff to happen. Changing 33 to a valid ffc that you want to reserve for it might help ( try 30, or use FindFreeFFC() ).


Edited by ZoriaRPG, 05 September 2017 - 09:17 AM.


#10 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 05 September 2017 - 09:22 AM

Alright i'll give it a shot but if that still not works well i guess i'll remove the script from my quest and maybe try to find another item script

#11 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 05 September 2017 - 09:30 AM

That change won't fix the water problem. The script would have to turn all water/pit/lava combos to walkable during the item animation for it to work better. I don't think there's a good way to script this item at all.


Edited by Avataro, 05 September 2017 - 09:30 AM.


#12 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 05 September 2017 - 09:58 AM

Welp i was don't know that the script could cause a skele-tons problems like that.
I think i'll remove the script and try to find a another item script for the moment.

#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 05 September 2017 - 12:53 PM

That change won't fix the water problem. The script would have to turn all water/pit/lava combos to walkable during the item animation for it to work better. I don't think there's a good way to script this item at all.

 

Eh, it'd work if you made global functions that are designed to be compatible with the pit system being used. Short of that, no. You would need to be very careful, with sanity checks for all of the possible situations where it could break.

 

I should also mention that, to put this in perspective, there were no pit scripts, or huge global events scripts in use at the time that this was published.


Edited by ZoriaRPG, 05 September 2017 - 01:00 PM.


#14 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 05 September 2017 - 02:16 PM

I think i start to figured out the problem: If i put waters types or pitlava scripts too close at the pushing block (beside the blocks) the script bugs but however if i do not put those too close at the pushing block (not beside the block) then the scripts works. 



#15 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 06 September 2017 - 09:00 AM

I think i start to figured out the problem: If i put waters types or pitlava scripts too close at the pushing block (beside the blocks) the script bugs but however if i do not put those too close at the pushing block (not beside the block) then the scripts works. 

 

I would still highly advise fixing the instruction to Load FFC Index 33. In 2.53 and above, that may outright crash ZC, or corrupt game data, It does in fact corrupt game data in 2.50.2, as well, but the corruption is less obvious.


  • Evan20000 likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users