Steven1985
Active member
Hi, I would like to know how to play an animation when the player gets a life having achieved a certain score like Cadillacs and Dinosaurs.
Thank you in advance.
Thank you in advance.
void main()
{
int PScore = getplayerproperty(0, "score");
int PLives = getplayerproperty(0, "lives"); // Get player 1's lives
int P1S = getglobalvar("1M"); //Get player 1's score status
int ScoReq = 20000;
if(P1S == NULL()){
P1S = 0;
}
//Player notif
if(PScore >= ScoReq*(P1S+1)){
setglobalvar("1Win", "W");
}
//Player 1
while(PScore >= ScoReq*(P1S+1)){
changeplayerproperty(0, "lives", PLives+1)...
Look at 19' 50'' until 20' 00''I can't recall if I ever had such animation before in Cadillacs and Dinosaurs but I did see one in Kings of Dragons.
Anyways, I can imagine how to implement this with script but it won't be simple aka might include multiple files for stability.
void main()
{
int PScore = getplayerproperty(0, "score");
int PLives = getplayerproperty(0, "lives"); // Get player 1's lives
int P1S = getglobalvar("1M"); //Get player 1's score status
int ScoReq = 20000;
if(P1S == NULL()){
P1S = 0;
}
//Player notif
if(PScore >= ScoReq*(P1S+1)){
setglobalvar("1Win", "W");
}
//Player 1
while(PScore >= ScoReq*(P1S+1)){
changeplayerproperty(0, "lives", PLives+1); // Give life
P1S = P1S + 1;
}
setglobalvar("1M", P1S);
}
anim idle
@script
if(frame>=1){
void self = getlocalvar("self");
char Win = getglobalvar("1Win"); //Get player 1's notif
if(Win=="W"){
setglobalvar("1Win", 0);
performattack(self, openborconstant("ANI_FOLLOW1"));
}
}
@end_script
...
if(openborvariant("in_menuscreen") || openborvariant("in_titlescreen")){
setglobalvar("1M", NULL()); // resets 1up bonus counter
}
setglobalvar("1Win", 0);
1) I think score1.c must be declared in the character header: data/scripts/score1.c
2) If I already have a script in an animation, is it possible to insert another one?
Example:
anim idle
@script
....
@endscript
@script
...
@endscript
3) if there is no update.c and endlevel.c in the game, do I create them in the scripts folder and just put the lines you wrote?
Thank you for your quick responseNo, it doesn't need to declared anywhere.
I think it is but it's best to merge them into one script.
Yes, if you don't have any of those, create them.
Can I see your update.c?
if(openborvariant("in_menuscreen") || openborvariant("in_titlescreen")){
setglobalvar("1M", NULL()); // resets 1up bonus counter
}
void main() as a starting point in update.c. That's why it crashes. It should be like this:void main(){
if(openborvariant("in_menuscreen") || openborvariant("in_titlescreen")){
setglobalvar("1M", NULL()); // resets 1up bonus counter
}
}
if(openborvariant("in_menuscreen") || openborvariant("in_titlescreen")){ setglobalvar("1M", NULL()); // resets 1up bonus counter }
Yes, I created update.c only for these lines.Is that all the content of your update.c?