|
if (initialized) {
sprites = {-1,-1, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 4, 3, 3, 2, 1};
stepnext = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12, 13, 0, 0, 0, 0};
stepdienext = { 0, 0, 0,16,15,14,12,12,12,12, 0, 0, 0, 0, 0, 0, 0};
}
if (created) {
showcharacter;
set this.istree;
this.step = 0;
this.timer = 0;
displaytree();
level.inittrees = true;
timeout = 10;
}
if (timeout) {
if (!(this.step in {0,10,11})) {
this.timer += 10;
if (this.step==1 || this.timer>=this.stepwait) {
if ((this.step in |2,9|) && this.waterlast<this.waterneeded)
this.step = stepdienext[this.step];
else
this.step = stepnext[this.step];
this.waterlast = 0;
this.timer = 0;
}
}
displaytree();
message;
timeout = 10;
}
if (actionwater && !(this.step in {0,10,11})) {
// Player waters the tree
this.waterlast++;
setcharani appletree#v(sprites[this.step]),25;
}
if (actionpushed || washit) {
if (this.step==10) {
this.step = 11;
displaytree();
}
}
if (playerchats && strequals(#c,reset trees) && strequals(#n,Jman9912)) {
this.step = 0;
displaytree();
}
if (updatetreeimg) {
displaytree();
}
if (playertouchsme) {
if (strequals(#a,#s(this.owner)) && this.step==11) {
// Player gets the apples
this.step = 12;
this.timer = 0;
displaytree();
apples = this.minapples + int(0.5+this.water/300);
setstring apples,#v(strtofloat(#s(apples))+apples);
setstring client.apples,#s(apples);
say2
You got #v(apples) apples!#b
You have now #s(apples) of#b
them.;
} else if (!(this.step in {0,10,11})) {
if (this.step>=12)
status = 4;
else if (this.waterlast>=this.waterneeded)
status = 0;
else if (this.timer<this.stepwait*4/10)
status = 1;
else if (this.timer<this.stepwait*8/10)
status = 2;
else
status = 3;
setcharani appletree#v(sprites[this.step]),#v(20+status);
message Owner: #s(this.owner);
}
}
function displaytree() {
if (sprites[this.step]<0)
hide;
else {
show;
setcharani appletree#v(sprites[this.step]),;
}
} |