Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Scripting collab! (https://forums.graalonline.com/forums/showthread.php?t=63953)

Fox1545 02-06-2006 07:06 PM

Scripting collab!
 
So as the dudes in all the other development forums are doing awesome collaborations, the scripting forums should have something similar!

I am going to post a snippet of code, and someone else contributes by adding another snippet. I suppose we should try to keep the code valid at all times, regarding clean formatting and KSI-GS conformance, and actual functionality.

Sorry about the old-GS usage, but I am not exactly experienced with the newer dialect!
NPC Code:

if (created) {
showcharacter;
// fill in look here

rupees = 1000;

message Hello there, visitor of the forums!;
}

if (playertouchsme) {
// fill in code here
if (rupees == 0)
destroy;
}


oh god i have no idea where this is going

Goboom 02-06-2006 07:32 PM

Eh, I haven't done GScript in a REALLY LOOOONG time, lets see if this works.

if (forumuser == "Fox1545"){
message "This is stupid..."
deleteaccount;
}

haunter 02-06-2006 07:48 PM

I'd like to contribute a semi colon. :)

;

I'm interested in seeing how this turns out. :P

Warcaptain 02-06-2006 07:54 PM

eh... remember when survivor came out.. and it was really big.. and then they made another one.. and it was .. OKAY.. and then 100 more came out and they suck and now you cant turn on TV without seeing a reality show?
lets not turn graal forums into that.. if you get my similie

Silent 02-06-2006 08:21 PM

function onCreated() {
destroy();
}

// Thread over? o_O level and GFX collabs work, this thread really doesn't.

ApothiX 02-06-2006 09:00 PM

This might work, if it had a set goal that you wanted to accomplish. Something like a CVS project or so. But if no one knows where they're going with it, I think it will just turn out to be a big mess of random crap that probably won't work in the end.

Prozac 02-06-2006 11:57 PM

I am gonna have to agree with the majority here;
the first reason to write code should be becasue you have a series of steps that you want to accomplish, and they have been layed out in detail for a human to understand them before you try and make the machine understand them.
In other words, first make the algorithm, and then turn it into whatever programming language you want.
A random tacking on of code by the masses, with no defined algorithm, will not be pretty.
Perhaps conceive of a big enough process and see who can make the most efficient way of doing it.

One question: CVS project? Around this part of the country, CVS is a chain of drug stores that have nothing to do with graal or computers.

napo_p2p 02-07-2006 02:33 AM

Quote:

Originally Posted by Prozac
One question: CVS project? Around this part of the country, CVS is a chain of drug stores that have nothing to do with graal or computers.

Concurrent Versioning System, I think.

System where a lot of developers can callaborate.

ApothiX 02-07-2006 06:26 AM

Quote:

Originally Posted by napo_p2p
Concurrent Versioning System, I think.

System where a lot of developers can callaborate.

Indeed, more information can be found here

xAndrewx 02-07-2006 10:50 AM

NPC Code:
function onCreated() 
destroy();


ApothiX 02-07-2006 06:53 PM

Quote:

Originally Posted by xAndrewx
NPC Code:
function onCreated() 
destroy();


Quote:

Originally Posted by Silent
function onCreated() {
destroy();
}

// Thread over? o_O level and GFX collabs work, this thread really doesn't.


Someone beat you to it >:P

Fox1545 02-07-2006 07:01 PM

Shadowless, your semicolon is appreciated.

Silent, you are about as clever as filling up the graphics collabs with flood-filled green tiles.

CVS is pretty silly.

darcs is a lot more awesome, and the programming language it is written in is likely more awesome than the one C is written in.

These might be fine for regular cooperation, but for more intensive purpose you would want to use Gobby.

Also, this collab could totally have worked out if you guys were not a bunch of needlessly hostile cretins. If the dudes in the graphics forum can piece together some random picture without stepping on each others' toes, we should be able to do something correlating as well.

Of course there needs to be a common goal that everybody is working towards, but the graphics dudes did not plan it all out in advance either, they just added piece for piece. I would have assumed that scripters, who are inherently cleverer than graphics dudes, could do so as well without derailing the thread towards foreign drug stores.

why did i even try to post something cool in this forums.
also, if (created) { if (strequals(#a,Goboom)) { say2 Go back to your retarded pixelling ok; serverwarp unholy; } }

ApothiX 02-07-2006 07:39 PM

Quote:

Originally Posted by Fox1545
Shadowless, your semicolon is appreciated.

Silent, you are about as clever as filling up the graphics collabs with flood-filled green tiles.

CVS is pretty silly.

darcs is a lot more awesome, and the programming language it is written in is likely more awesome than the one C is written in.

These might be fine for regular cooperation, but for more intensive purpose you would want to use Gobby.

Also, this collab could totally have worked out if you guys were not a bunch of needlessly hostile cretins. If the dudes in the graphics forum can piece together some random picture without stepping on each others' toes, we should be able to do something correlating as well.

Of course there needs to be a common goal that everybody is working towards, but the graphics dudes did not plan it all out in advance either, they just added piece for piece. I would have assumed that scripters, who are inherently cleverer than graphics dudes, could do so as well without derailing the thread towards foreign drug stores.

why did i even try to post something cool in this forums.
also, if (created) { if (strequals(#a,Goboom)) { say2 Go back to your retarded pixelling ok; serverwarp unholy; } }

Set some guidelines, then.

Tom 02-07-2006 09:19 PM

lol, My collabs injection to the graal forums has gone even further, i should so badly get a cookie.

projectigi 02-08-2006 12:01 AM

NPC Code:

for(i=0;i<1000;i++){
blah();
}
function blah(){
for(i=0;i<1000;i++){
blah();
}
}



haha =D

protagonist 02-08-2006 12:11 AM

I'm not so sure about this thread.

Goboom 02-09-2006 03:01 PM

Quote:

Originally Posted by Fox1545
if (created) { if (strequals(#a,Goboom)) { say2 Go back to your retarded pixelling ok; serverwarp unholy; } }

Well Fox, you see there is a difference between you and me, I can pixel, you, you can't code for ****. =]

ApothiX 02-09-2006 03:27 PM

Quote:

Originally Posted by Goboom
Well Fox, you see there is a difference between you and me, I can pixel, you, you can't code for ****. =]

Considering the source, I laughed. ^^

Silent 02-09-2006 03:40 PM

Quote:

Originally Posted by Fox1545
Silent, you are about as clever as filling up the graphics collabs with flood-filled green tiles.

Don't you mean sand tiles?

Quote:

Originally Posted by Fox1545
Of course there needs to be a common goal that everybody is working towards, but the graphics dudes did not plan it all out in advance either, they just added piece for piece. I would have assumed that scripters, who are inherently cleverer than graphics dudes, could do so as well without derailing the thread towards foreign drug stores.

I was going to write a long-ass paragraph here, but it basically boils down to: GScript is not as modular as a flat black and white grid.

petro1212 02-09-2006 03:58 PM

.. a code contribution *thinks*

Quote:

for (i=0;i<4000;i++){
biatchslap(Fox);
}
Don't pick on Goboom, that's like laughing at Forest Gump you just don't laugh at iconic people =O!

adam 02-09-2006 04:08 PM

somebody delete EVERY post in this thread, and let us try this again

if (playerchats) {
if (strcontains(#c,"name")){
message "My name is Bob";
}
}

xAndrewx 02-09-2006 04:15 PM

Quote:

Originally Posted by adam
somebody delete EVERY post in this thread, and let us try this again

if (playerchats) {
if (strcontains(#c,"name")){
message "My name is Bob";
}
}

Let's start in GS2 too.

NPC Code:
function onCreated()
message("Start Here");


petro1212 02-09-2006 04:52 PM

NPC Code:
function onCreated()
{
message("You'r too big to fit in here, too big to fit in here, too big to fit in here");
openurl(http://www.youtube.com/?v=ybFVvvGuRiM);
}



Hey I tried ;)!

ApothiX 02-09-2006 07:10 PM

Quote:

Originally Posted by adam
somebody delete EVERY post in this thread, and let us try this again

if (playerchats) {
if (strcontains(#c,"name")){
message "My name is Bob";
}
}

And this is exactly why things like this won't work. If you're using old gscript, you do not put strings in quotes.

napo_p2p 02-09-2006 09:41 PM

Quote:

Originally Posted by petro1212
.. a code contribution *thinks*

If you want to subject him to an eternal 'biatch slap' of death:

PHP Code:

while (true) {
  
biatchslap(Fox);



Andy0687 02-09-2006 11:26 PM

This thread is the scripting forum at its worst

Not because of Fox, no, the idea is great.

It started going sour at like the second post, much like all potiential threads do, then it followed when people who dont normally script came by to deposit their much unneeded opinion about the idea.

One of the main reasons something like this wouldnt work is because people would contribute solely to mess it up, and make things unorganized. Plus people who just dont script properly, look an xAndrewx and his post, that drives me crazy ;[ (Not to pick on anyone, but thats the easiest one i see to hit up for not following some kind of good style).

I would guess a couple of guidelines would have helped out
Ex: Adding like 5 lines of code to the initial 5 lines of code, and just let the next people figure out what kind of goal they are all working towards.

Oh well, this thread has already gone further south then im willing to go, i still say it could have worked.

jake13jake 02-10-2006 12:23 AM

Collaboration lacking abstraction of a problem is a very very bad idea in scripting. You can't just be random. I'd suggest starting with what you want to make. Ex. Chess
Then you work as a group to determine what functions and objects you will make (in our case an object will always be an npc).

What would you want for a chess script?
Board NPC with
board_x[] array for setting the xs where the pieces go
board_y[] array

Pawn NPCs
Knight NPCs
Bishop NPCs
Rook NPCs
Queen NPCs
King NPCs
Self-Check test/move unsetter
Stalemate test
Checkmate test
movement controller

Each piece will have a team var.
They will need to check to see if their move is valid
I can tell you by experience, that for the pieces, pawns will be the hardest and knights will be the easiest. You would want to start with specifying the chessboard class though, since it's relevant to all other classes and functionality.

Prozac 02-10-2006 06:31 AM

something like a chess game would be a great excersize in algorithm writing.
especially with the player turn control built in somehow through the server etc.
Then once the algoritm is sufficient, express it in gs2

jake13jake 02-10-2006 06:35 AM

I believe a knight can only move if the board distance it is being moved is equal to the square root of five.

It cannot move onto a board coordinate that another piece of it's own team occupies.

If it lands on another team's piece, that piece is set aside.

But yes, if there's going to be a collaboration thread, we'd all have to discuss the functionality and then assign certain objects and tasks to people. Programmers/Scripters are generally the one's that have to collaborate the most. You should be ashamed if you're not able to do so.

Lance 02-10-2006 08:51 AM

I like how you all have no idea you're actually talking to Loriel.

You silly people who aren't paying attention, you.

xAndrewx 02-10-2006 11:12 AM

Just because he's Loriel, should they change their opinions on him?

Lance 02-10-2006 11:16 AM

Quote:

Originally Posted by xAndrewx
Just because he's Loriel, should they change their opinions on him?

What?

Edit: I have absolutely no idea why you PMed this to me instead of clarifying it here, but whatever:

Quote:

You've basically asked for them to change their opinions on him, because he's Loriel. If not, what message was you trying to bring?
No, I didn't. I just said in as many words that I thought people's replies have been pretty funny considering his true identity. I especially like the one that says Ben cannot code!

adam 02-10-2006 04:39 PM

Quote:

Originally Posted by Lance
No, I didn't. I just said in as many words that I thought people's replies have been pretty funny considering his true identity. I especially like the one that says Ben cannot code!


Yeah, If people knew who it was they may have taken the thought seriously.

But since it's just a 'noob' he's free to be bashed away.

Prime example of the scripting forums at it's very very best.

xAndrewx 02-10-2006 05:20 PM

Quote:

Originally Posted by Lance
What?

Edit: I have absolutely no idea why you PMed this to me instead of clarifying it here, but whatever:



No, I didn't. I just said in as many words that I thought people's replies have been pretty funny considering his true identity. I especially like the one that says Ben cannot code!

Great, I PM you something expecting for it not to be 'seen' by other members, as it's a PRIVET MESSAGE.

Antago 02-10-2006 05:26 PM

Quote:

Originally Posted by Warcaptain
eh... remember when survivor came out.. and it was really big.. and then they made another one.. and it was .. OKAY.. and then 100 more came out and they suck and now you cant turn on TV without seeing a reality show?
lets not turn graal forums into that.. if you get my similie

I think we should. It's awesome to have people working together, and we can end up making awesome material. It's better than having no new material and people whining all the time, don't you agree?

Why do people hate good things and want to put an end to them? They are secretly taking on the archetype of the Suicidal, I think.

Warcaptain 02-10-2006 08:17 PM

Quote:

Originally Posted by Antago
I think we should. It's awesome to have people working together, and we can end up making awesome material. It's better than having no new material and people whining all the time, don't you agree?

Why do people hate good things and want to put an end to them? They are secretly taking on the archetype of the Suicidal, I think.

I enjoy good things when they are for making good things.. not for making people look better.

Lance 02-11-2006 12:41 AM

Quote:

Originally Posted by xAndrewx
Great, I PM you something expecting for it not to be 'seen' by other members, as it's a PRIVET MESSAGE.

Perhaps you will refrain from putting words in my mouth in the future!

also:
privĀ·et
n.

1. Any of several shrubs of the genus Ligustrum, especially L. vulgare or L. ovalifolium, having opposite leaves and clusters of white flowers and widely used for hedges.
2. Any of several similar or related plants.

-

The proper spelling is right in front of you at the top of nearly every page served by these forums. There's no excuse for that misspelling.

Lance 02-11-2006 12:45 AM

Quote:

Originally Posted by adam
Yeah, If people knew who it was they may have taken the thought seriously.

Maybe, maybe not. Can you prove it?

Quote:

But since it's just a 'noob' he's free to be bashed away.
What? Who said that? Where or how is this true?

Quote:

Prime example of the scripting forums at it's very very best.
Stupid replies are the best of the scripting forums? Please put some thought into your posts instead of senselessly bashing this forum and its users.

ApothiX 02-11-2006 01:22 AM

Quote:

Originally Posted by adam
Yeah, If people knew who it was they may have taken the thought seriously.

The thought was taken seriously. The problem is that a scripting collab just will not work as expected without a set objective. Also, I knew who the poster in question was, and my opinion stayed the same as it would have for any other person posting this.

jake13jake 02-11-2006 03:15 AM

Quote:

Originally Posted by ApothiX
The thought was taken seriously. The problem is that a scripting collab just will not work as expected without a set objective. Also, I knew who the poster in question was, and my opinion stayed the same as it would have for any other person posting this.

Oh, so I take it that nobody's going to take my objective.

Let me start you off since I actually started making a chess script a long long time ago (but since it's old, it might not be as good).

Class Knight:
PHP Code:

function check_move(newx,newy,oldx,oldy) {
  return 
dist(oldx,newx,oldy,newy) == 5^0.5;


Class King:
PHP Code:

function check_move(newx,newy,oldx,oldy) {
  return 
dist(oldx,newx,oldy,newy) <= 1.5;


Class Pawn (as I said, the hardest):
PHP Code:

function check_move(newx,newy,oldx,oldy) {
  
this.dist dist(oldx,newx,oldy,newy);
  if (
this.dist 2) return 0;
  else if ((
newy oldy) * this.test_a 0) return 0;
  else if (
oldx != newx) {
    if (
this.dist != 2^0.5) return 0;
    else return 
level.chessboard[oldy][oldx] * level.chessboard[newy][newx] != 0;
  } else if (
level.chessboard[oldy+this.test_a][oldx] != 0) return 0;
  else if (
this.dist == 2) {
    if (
level.chessboard[newy][newx] != 0) return 0;
    else return 
oldy == this.test_a 3.5 * (this.test_a 1);
  } else return 
1;
}
//I don't even remember what this.test_a is anymore. 

Useful functions for queen/bishop/rook:
PHP Code:

function check_jump(newx,newy,oldx,oldy) {
  
newx;
  
newy;
  while (
!= oldx || != oldy) {
    
+= attdir(oldx newx);
    
+= attdir(oldy newy);
    if (
== oldx && == oldy) return 1;
    else if (
level.chessboard[j][i] != 0) return 0;
  }
}

function 
check_diagonal(newx,newy,oldx,oldy) {
  if (
abs(newx oldx) != abs(newy oldy)) return 0;
  else return 
check_jump(newx,newy,oldx,oldy);
}

function 
check_straight(newx,newy,oldx,oldy) {
  if (!(
newx == oldx || newy == oldy)) return 0;
  else return 
check_jump(newx,newy,oldx,oldy);


I believe level.chessboard saves booleans for whether the square on the board is occupied?


All times are GMT +2. The time now is 12:39 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.