the fake one
|
 |
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
|
|
Quote:
Originally Posted by Jiroxys7
And I quickly gave up on testbed since nearly everything players put on there is GS1 or doesnt work or something.
|
Most good scripters are working on projects, and don't hang around testbed. However, I'm happy to get on some time and help you out. Just let me know when.
Quote:
PHP Code:
//#CLIENTSIDE
function onCreated(){
// Initialize the attributes
this.startershot=1;
this.timeout1=random(0.05,0.25);
showcharacter;
dontblock;
setcharprop #3,archersummon.png;
setcharprop #C0,orange;
setcharprop #C1,green;
setcharprop #C2,black;
setcharprop #C3,green;
setcharprop #C4,black;
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 1;
hurtdx = 0;
hurtdy = 0;
hearts = 1+strtofloat(#s(client.summonarcherallylevel))/5;
move -random(15,20)-strtofloat(#s(client.summonarcherallylevel)),random(-15,15),random(1.5,2.5),8;
setcharani bowwalk,wbow1.png;
if(strtofloat(#s(client.summonarcherallylevel))>8){
this.timeout2=random(0.25,0.50);
}
else if(strtofloat(#s(client.summonarcherallylevel))>5){
this.timeout2=random(0.50,0.75);
}
else if(strtofloat(#s(client.summonarcherallylevel))>2){
this.timeout2=random(0.75,1);
}
else if(strtofloat(#s(client.summonarcherallylevel))>=0){
this.timeout2=random(1,1.25);
}
}
if(movementfinished && strtofloat(#s(client.summonarcherallylevel))>8){
putexplosion2 3,2,x+0.5,y+0.5;destroy();
}
else if(movementfinished && strtofloat(#s(client.summonarcherallylevel))>5){
putexplosion2 3,1,x+0.5,y+0.5;destroy();
}
else if(movementfinished && strtofloat(#s(client.summonarcherallylevel))>2){
putexplosion2 3,0,x+0.5,y+0.5;destroy();
}
else if(movementfinished && strtofloat(#s(client.summonarcherallylevel))>=0){
destroy();
}
if(this.timeout1<=0.1&& !movementfinished && this.startershot=1){
shootarrow 1;this.startershot=0;
}
if(this.timeout2<=0.1&&!movementfinished){
shootarrow 1;this.timeout2=random(1,2);
}
if(wa****){
hearts -= playerswordpower/2;
}
if(hearts<=0){
move 0,0,0,0;
setcharani classic_dead,;
sleep 3;
lay darts;
destroy();
}
if(timeout){
this.timeout1-=0.1;
this.timeout2-=0.1;
}
timeout = 0.1;
|
I'll rescript this, and leave comments for you.
PHP Code:
// we're doing this on serverside, because there's no reason
// to show the character clientside
//
// in the future, for showing characters, try using this
// script to generate them:
// http://forums.graalonline.com/forums/showthread.php?t=82880
function onCreated() {
// Initialize the attributes
this.starterShot = 1;
this.timeout1 = random(0.1, 0.25); // serverside does not support timeouts faster than .1 seconds
showcharacter();
dontblock();
this.head = "archersummon.png";
this.colors[0] = "orange";
this.colors[1] = "green";
this.colors[2] = "black";
this.colors[3] = "green";
this.colors[4] = "black";
this.shield = "no-shield.png"; // png > gif
// shieldpower = 1; does nothing as far as I know, and
// was only added by Stefan's thing in the level editor
// because of the scripted baddies he made
// hurtdx and hurtdy also do nothing as far as I know
this.dir = 1;
// here's where you're going to hit problems, and you will
// have to find a way to get around it.
//
// the problem is that, because serverside affects all
// players, which "player" is being loaded?
//
// however, I'll let you figure out the best way to deal
// with this
this.hearts = 1 + (client.summonarcherallylevel / 5); // no reason to use strtofloat, ever, in GS2
setCharAni("bowwalk", "wbow1.png");
move((- random(15, 20) - client.summonarcherallylevel), random((- 15), 15), random(1.5, 2.5), 8);
// this simplifies your if-else tree a bit
temp.levels = { // {level, min timeout2, max timeout2}
{8, .25, .5},
{5, .5, .75},
{2, .75, 1},
{(- 1), 1, 1.25}
};
for (temp.lvl : levels) { // using 'lvl' instead of 'level' because 'level' refers to 'this.level', which is the level object
if (client.summonarcherallylevel > lvl[0]) {
this.timeout2 = random(lvl[1], lvl[2]);
break; // leave the for loop; equivalent to the 'if-else', it ends the tree
}
}
setTimer(0.1); // this can't be outside of a function block; this replications 'timeout = 0.1'
}
// all things must happen when an event is called;
// before, the script was being scanned to see if
// conditions were met.
//
// now, it looks for an event to call, which is much more
// efficient, and makes more sense
function onMovementFinished() {
// not sure why you are destroying the NPC when it finishes
// moving, anyway... i'll let you fix that if it needs
// fixing
// simplifying your if-else tree
temp.levels = {
{8, 2},
{5, 1},
{2, 0},
{(- 1)} // will add a check to make it place no explosions
};
for (temp.lvl : levels) {
if (client.summonarcherallylevel > lvl[0]) {
if (lvl[0] > (- 1)) {
putexplosion2(3, lvl[1], this.x + 0.5, this.y + 0.5);
}
destroy();
// no need to 'break' because destroy is stopping everything
// and removing the NPC
}
}
}
// keep in mind you need to remove the **** and replace it with
// WasHi.t, removing the period
function onWa****() {
this.hearts -= (player.swordpower / 2);
}
function onTimeOut() {
if (this.hearts <= 0) { // this has to be inside a function block
move(0, 0, 0, 0);
setCharAni("classic_dead", null);
scheduleevent(3, "Die"); // using this instead of sleep
return;
}
this.timeout1 -= 0.1;
this.timeout2 -= 0.1;
// there is no reason to use "&& ! movementfinished" because
// the NPC is destroying when the movement finishes, apparently
if (this.timeout1 <= 0.1 && this.startershot == 1) {
// you MUST use var == val because otherwise you are
// assigning var to val
shootarrow(1);
this.startershot = 0;
}
if (this.timeout2 <= 0.1) {
shootarrow(1);
this.timeout2 = random(1, 2);
}
setTimer(0.1); // I think you meant to put this in here
}
function onDie() {
// using this instead of sleep
lay("darts");
destroy();
}
|
|