Party members script
#1
Posted 29 November 2012 - 04:18 PM
-Be able to have at least 3 party members + head party member
-Have all party members use different sprite tiles.
-Only head party member uses action sprite tiles when the player uses an item
-Party members follow the head party member
-Item adds party member
- Party members use BS animation
-All party members use this sprite format:
That's it. Thanks! Bye! ~c00ln3rd
#2
Posted 29 November 2012 - 04:58 PM
#3
Posted 29 November 2012 - 06:08 PM
Edited by c00ln3rd, 29 November 2012 - 06:28 PM.
#4
Posted 29 November 2012 - 06:33 PM
-Party members follow link through water and on land
-Party members do EXACTLY the same thing as link except when he uses the "action tiles" (Shown above) or uses an item. An exception to that would be the party members jump with link.
-There can be 3 party members at a time, plus Link.
-Use BS animation
-Have to be obtainable through item.
-Party members use different tiles that are in the same format as link
EXTRAS: If it isn't to much of a hassle, maybe there could be a way to make it so you need a certain amount of party members to trigger a secret?
Edited by c00ln3rd, 29 November 2012 - 06:38 PM.
#5
Posted 29 November 2012 - 07:04 PM
The party members -> secret script would actually be easier (as in, fewer than 15 lines of code) than the party member script itself, so that won't be a problem.
EDIT: Third draft, compiles but still does not support jumping. Give it a try.
#6
Posted 29 November 2012 - 08:50 PM
Edited by c00ln3rd, 30 November 2012 - 05:08 PM.
#7
Posted 30 November 2012 - 04:55 PM
NPC FOLLOWER SCRIPT
const int M_NORMAL = 0;
const int M_MOVINGTOPOS = 1;
const int M_SOLIDATPOS = 2;
ffc script FollowLink{
void run(){
int orig = this->Data;
int lastDir;
int MovementState;
int CurrentScreen;
int idle;
while(true){
int x = Link->X; int y = Link->Y;
if(Link->Dir == DIR_UP||Link->Dir == DIR_DOWN) y -= Link->Dir*32-16;
else x -= (Link->Dir-2)*32-16;
if(CurrentScreen != Game->GetCurScreen()) MovementState = NormalPlacement(this,x,y);
if(MovementState == M_NORMAL){
if(lastDir != Link->Dir) MovementState = MoveToPosition(this,x,y);
else MovementState = NormalPlacement(this,x,y);
}else if(MovementState == M_MOVINGTOPOS) MovementState = WhileMoving(this,x,y,idle);
else if(MovementState == M_SOLIDATPOS) MovementState = CheckPos(this,x,y);
SetGraphics(this,orig);
CurrentScreen = Game->GetCurScreen();
idle = (idle+1)%6;
lastDir = Link->Dir;
Waitframe();
}
}
int NormalPlacement(ffc this,int x,int y){
if(Solid(this,x,y)) return M_SOLIDATPOS;
this->X = x; this->Y = y;
return M_NORMAL;
}
int MoveToPosition(ffc this,int x,int y){
if(Solid(this,x,y)) return M_SOLIDATPOS;
int speed = Distance(x,y,this->X,this->Y)/8;
if(speed < 0.5) return M_NORMAL;
else if(speed < 1.2) speed *= 2;
FFCToPoint(this,x,y,speed);
return M_MOVINGTOPOS;
}
int WhileMoving(ffc this,int x,int y,int idle){
if(Abs(this->X-x) < 3 && Abs(this->Y-y) < 3){
this->Vx = 0; this->Vy = 0;
return M_NORMAL;
}
if(idle == 0) return MoveToPosition(this,x,y);
return M_MOVINGTOPOS;
}
int CheckPos(ffc this,int x,int y){
if(Solid(this,x,y)) return M_SOLIDATPOS;
return MoveToPosition(this,x,y);
}
bool Solid(ffc this,int x,int y){
if(Screen->isSolid(x+8,y+8)){
this->Vx = 0; this->Vy = 0;
return true;
}
}
void SetGraphics(ffc this,int orig){
int moving;
if(Link->InputUp || Link->InputDown || Link->InputLeft || Link->InputRight
|| this->Vx != 0 || this->Vy != 0) moving = 4;
this->Data = orig+moving+Link->Dir;
}
int FFCToPoint(ffc f,int x,int y,int speed){
if(speed == 0) return -1;
int dx = x-f->X; int dy = y-f->Y;
int dis = Abs(dx) + Abs(dy);
int d = dis/speed;
f->Vx = dx/d; f->Vy = dy/d;
return d;
}
}
#8
Posted 30 November 2012 - 05:09 PM
#9
Posted 30 November 2012 - 06:29 PM
#10
Posted 30 November 2012 - 08:42 PM
Edited by c00ln3rd, 30 November 2012 - 08:59 PM.
#11
Posted 30 November 2012 - 09:16 PM
The global script part is very simple - copy/paste the part inside the void run() part into the part of your global script between void run() and while(true). The global script will automatically call the FFC scripts for you.
#12
Posted 30 November 2012 - 09:30 PM
Edited by c00ln3rd, 30 November 2012 - 10:27 PM.
#13
Posted 01 December 2012 - 01:39 AM
if ( Link->Item[I_MEMBER1] ){
ffc member = Screen->LoadFFC(FFC_MEMBER1);
member->X = Link->X;
member->Y = Link->Y;
member->Data = CMB_MEMBER1;
member->Script = FFCS_PARTYMEMBER;
member->Flags[FFCF_CARRYOVER] = true;
member->InitD[0] = 1;
}
if ( Link->Item[I_MEMBER2] ){
ffc member = Screen->LoadFFC(FFC_MEMBER2);
member->X = Link->X;
member->Y = Link->Y;
member->Data = CMB_MEMBER2;
member->Script = FFCS_PARTYMEMBER;
member->Flags[FFCF_CARRYOVER] = true;
member->InitD[0] = 2;
}
if ( Link->Item[I_MEMBER3] ){
ffc member = Screen->LoadFFC(FFC_MEMBER3);
member->X = Link->X;
member->Y = Link->Y;
member->Data = CMB_MEMBER3;
member->Script = FFCS_PARTYMEMBER;
member->Flags[FFCF_CARRYOVER] = true;
member->InitD[0] = 3;
}
But first grab my latest update above to allow each party member to be a different distance behind Link.
#14
Posted 01 December 2012 - 07:20 AM
#15
Posted 01 December 2012 - 09:06 AM
Line 78: syntax error, unexpected rbrace, expecting $end, on token }
Tehluls xD
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users