Gleeok
11-04-2007, 04:43 AM
Alright here's my problem and the set up:
Upon use the item script fires an ffc and changes the the ffc->Data. When the data on the ffc script is changed a new statement opens up. Sounds familiar right? Yeah that part works fine. Here's where my scripting knowledge ends:
When the Item is used a second time it opens up a portal and ...oops teleporter* (+2 points to name that reference.) BUT If Link were to teleport just anywhere he wanted to on screen that would be bad. So I need to add on to the Item script that can call from a global function (like if ffc->X && ffc->Y is_walkable for example) so to not permit a teleport if the called ffc is over a non-walkable combo. But I still need it to be able to pass through non-walkable combos.
Unfortunately I have no luck with these.:( Most likely because I don't really understand them. Any help much appreciated.
//================================================== ======
// ITEM SCRIPT MALOR
// translation: teleport
// D0 - the combo to be used as the projectile sprite
// D1 - the speed of the portal projectile sprite
//================================================== =======
item script Malor{
void run (int portalcombo, int speed){
int portal_combo = portalcombo;
ffc portal = Screen->LoadFFC(32);
if (!(portal->Data == portal_combo)){
Game->PlaySound(35);
if(Link->Dir == 0) {
portal->X = Link->X;
portal->Y = Link->Y - 16;
portal->Vy = -speed;
portal->Vx = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 1) {
portal->X = Link->X;
portal->Y = Link->Y + 16;
portal->Vy = speed;
portal->Vx = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 2) {
portal->X = Link->X - 16;
portal->Y = Link->Y;
portal->Vx = -speed;
portal->Vy = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 3) {
portal->X = Link->X + 16;
portal->Y = Link->Y;
portal->Vx = speed;
portal->Vy = 0;
portal->Data = portal_combo;
}
}
else{
if (
(portal->X > 240) ||
(portal->X < 0) ||
(portal->Y > 160) ||
(portal->Y < 0)
){
Game->PlaySound(35);
if(Link->Dir == 0) {
portal->X = Link->X;
portal->Y = Link->Y - 16;
portal->Vy = -speed;
portal->Vx = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 1) {
portal->X = Link->X;
portal->Y = Link->Y + 16;
portal->Vy = speed;
portal->Vx = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 2) {
portal->X = Link->X - 16;
portal->Y = Link->Y;
portal->Vx = -speed;
portal->Vy = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 3) {
portal->X = Link->X + 16;
portal->Y = Link->Y;
portal->Vx = speed;
portal->Vy = 0;
portal->Data = portal_combo;
}
}
else{
Link->X = portal->X; Link->Y = portal->Y;
portal->Data = 0;
Game->PlaySound(36);
}
}
}
}
Upon use the item script fires an ffc and changes the the ffc->Data. When the data on the ffc script is changed a new statement opens up. Sounds familiar right? Yeah that part works fine. Here's where my scripting knowledge ends:
When the Item is used a second time it opens up a portal and ...oops teleporter* (+2 points to name that reference.) BUT If Link were to teleport just anywhere he wanted to on screen that would be bad. So I need to add on to the Item script that can call from a global function (like if ffc->X && ffc->Y is_walkable for example) so to not permit a teleport if the called ffc is over a non-walkable combo. But I still need it to be able to pass through non-walkable combos.
Unfortunately I have no luck with these.:( Most likely because I don't really understand them. Any help much appreciated.
//================================================== ======
// ITEM SCRIPT MALOR
// translation: teleport
// D0 - the combo to be used as the projectile sprite
// D1 - the speed of the portal projectile sprite
//================================================== =======
item script Malor{
void run (int portalcombo, int speed){
int portal_combo = portalcombo;
ffc portal = Screen->LoadFFC(32);
if (!(portal->Data == portal_combo)){
Game->PlaySound(35);
if(Link->Dir == 0) {
portal->X = Link->X;
portal->Y = Link->Y - 16;
portal->Vy = -speed;
portal->Vx = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 1) {
portal->X = Link->X;
portal->Y = Link->Y + 16;
portal->Vy = speed;
portal->Vx = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 2) {
portal->X = Link->X - 16;
portal->Y = Link->Y;
portal->Vx = -speed;
portal->Vy = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 3) {
portal->X = Link->X + 16;
portal->Y = Link->Y;
portal->Vx = speed;
portal->Vy = 0;
portal->Data = portal_combo;
}
}
else{
if (
(portal->X > 240) ||
(portal->X < 0) ||
(portal->Y > 160) ||
(portal->Y < 0)
){
Game->PlaySound(35);
if(Link->Dir == 0) {
portal->X = Link->X;
portal->Y = Link->Y - 16;
portal->Vy = -speed;
portal->Vx = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 1) {
portal->X = Link->X;
portal->Y = Link->Y + 16;
portal->Vy = speed;
portal->Vx = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 2) {
portal->X = Link->X - 16;
portal->Y = Link->Y;
portal->Vx = -speed;
portal->Vy = 0;
portal->Data = portal_combo;
}
if(Link->Dir == 3) {
portal->X = Link->X + 16;
portal->Y = Link->Y;
portal->Vx = speed;
portal->Vy = 0;
portal->Data = portal_combo;
}
}
else{
Link->X = portal->X; Link->Y = portal->Y;
portal->Data = 0;
Game->PlaySound(36);
}
}
}
}