Quote:
Originally Posted by cbk1994
Can you post the code that is placing the NPC?
|
The problems I seem to be having in general is anything that tells the script to read something from a different side. Problem is, since the editor never required such a thing for scripts to work, I never had to tell anything which side to use. The wiki tends to just complicate the hell out of things (also the place where I first saw the putnpc2(32, 32, "join(\"classname\");"); variation of putnpc2.). And I quickly gave up on testbed since nearly everything players put on there is GS1 or doesnt work or something.
My 5-6 years of scripting experience on the editor only required 2 things:
1. Some GS1 knowledge.
2. The "If it works the way you want it to one way, There's no reason to change it" mindset. Which allowed me to skip practicing with //#CLIENTSIDE completely. Also with the fact that since the editor IS clientside, i just mistook the thing as a //comment since it didn't seem to change or do anything.
Which also makes it seem very VERY hard for me to get anything off clientside. Since I have nearly zero first-hand experience with calling parts of a script serverside FROM clientside and vice-versa. Since the editor uses nothing but clientside, I'm fairly comfortable with clientside. Of course, when I have something that needs to be serverside, tons of complications tend to arise.
Also, another problem is I'd love to hire a scripter or two who knows what they're doing.. But the problem there is that there's no one I feel I could trust (Ever get those people who either randomly, out of the blue, pop up on your server asking to be Co-Manager, or Manager or some high up staff? Or those players who just want to be staff mainly for the RC and, as scripters go anyways, the manipulative scripts they can give themselves?)
So right now, I really feel I'm stuck doing this solo for now.
Anyways, If you want to take a look at the script. This is the best "working" version.
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;
Reason why 'working' is in quotes is because since the whole thing is clientsided. So although it appears to work. Other players see the NPC moving in a different direction and whatnot.
Also, the player is supposed to be able to improve the "skill level" of the weapon being the client.summonarcherallylevel variable. However, again, since it's all clientsided, Lets say, if i have a high skill level with it, i fire it, it explodes at the end. my friend nearby won't see the explosion since his client.summonarcherallylevel = 0. But now this also means when he uses it, since my client.summonarcherallylevel > 2, the explosion is on his too. though he doesn't see it.
..Along with the destroy() still being clientsided.
I have 2 other attempts at this. I'm not quite sure which one (if either) is closer to what I need:
PHP Code:
doSpawnArcherAlly(){
// 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 = 0;
hurtdx = 0;
hurtdy = 0;
hearts = 1+strtofloat(#s(client.summonarcherallylevel))/5;
move random(-15,15),random(-15,-20)-strtofloat(#s(client.summonarcherallylevel)),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){
doArcherShot();this.startershot=0;
}
else if(this.timeout2<=0.1 && !movementfinished){
this.timeout2=random(1,2);
}
if(wa****){
hearts -= playerswordpower/2;
}
if(hearts<=0){
move 0,0,0,0;
setcharani dead,;
sleep 3;
lay darts;
destroy();
}
function onTimeout(){
this.timeout1-=0.1;
this.timeout2-=0.1;
}
setTimer(0.1);
//#CLIENTSIDE
function onCreated(){
doSpawnArcherAlly();
}
function doArcherShot(){
shoot x,y,npc.z+1.5,getangle(vecx(dir),vecy(playerdir)),0.75,1.2,arrow,barrow0;
}
And
PHP Code:
function moveArcher(){
move random(15,20)+strtofloat(#s(client.summonarcherallylevel)),random(-15,15),random(1.5,2.5),8;
}
function destroyArcher(){
if(strtofloat(#s(client.summonarcherallylevel))>8){
putexplosion2 3,2,x+0.5,y+0.5;
destroy();
}
else if(strtofloat(#s(client.summonarcherallylevel))>5){
putexplosion2 3,1,x+0.5,y+0.5;
destroy();
}
else if(strtofloat(#s(client.summonarcherallylevel))>2){
putexplosion2 3,0,x+0.5,y+0.5;
destroy();
}
else if(strtofloat(#s(client.summonarcherallylevel))>=0){
destroy();
}
}
//#CLIENTSIDE
if (created) {
// 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 = 3;
hurtdx = 0;
hurtdy = 0;
hearts = 1+strtofloat(#s(client.summonarcherallylevel))/5;
moveArcher();
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){
destroyArcher();
}
if(this.timeout1<=0.1&& !movementfinished && this.startershot=1){
shoot x,y,npc.z+1.5,getangle(vecx(dir),vecy(dir)),0.75,1.2,arrow,barrow0;
this.startershot=0;
}
else if(this.timeout2<=0.1&&!movementfinished){
shoot x,y,npc.z+1.5,getangle(vecx(dir),vecy(dir)),0.75,1.2,arrow,barrow0;
this.timeout2=random(1,2);
}
if(wa****){
hearts -= playerswordpower/2;
}
if(hearts<=0){
move 0,0,0,0;
setcharani dead,;
sleep 3;
lay darts;
destroyArcher();
}
function onTimeout(){
this.timeout1-=0.1;this.timeout2-=0.1;
}
timeout(0.1);
Somewhere in the last few hours, I tried the thing with the triggerserver command on the second one. But when it didn't work, I tried changing it to define a function on one side, then excecute it on the other side. (For some reason, that tends to work sometimes, but not at most other times. And by the way, would it be triggerserver("npc", name, "dropSpawnArcherAlly"); that I would use? instead of "gui" I mean.)
And one more problem is that I don't quite know how to do is turn something like
PHP Code:
if(this.timeout1<=0.1&& !movementfinished && this.startershot=1){
doArcherShot();this.startershot=0;
}
into its own function. (If thats what you do anyway)
Sorry for the HUGE post.