VariousWeapon's Guide to GS1

I’m feeling generous, I’ll even take it retardedly slow. Here are the first two chapters of my new guide that implements my not patented step by step approach to scripting.

Chapter 1 Flags:

Flags are the shit (conditions) that set the conditions for when an npc hurts a player (or something);

Say you want to hurt somebody just for entering your level:

//This NPC hurts a player when they enter a level
if (playerenters) {
hurt 1;
}

Or maybe you’d like to hurt somebody for talking in your level:

//This NPC hurts a player for talking
if (playerchats) {
hurt 1;
}

You might just hurt them for touching the npc, maybe if they touch a lamp and burn themselves:

//This NPC hurts a player for talking
if (playertouchsme) {
hurt 1;
}

Chapta 1b Multiple Conditions:

Sometimes you’re going to want to test for several conditions, so here we fucking go again…

Say you want to give the player some say in whether they’re going to be hurt, this simple npc gives them that option.

//This NPC hurts a player when they say “hit me”
if (playerchats && strequals(#c,hit me)) {
hurt 1;
}

I bet you’re thinking, what the shit, that script got huge. Well you’re fucking observant, so lemme explain what the shit just went down. First off there are two flags being tested, as you needed to know whether the player said something, AND what they said. The second flag “strequals(#c,hit me)” is testing the player’s chat script “#c” to see if it’s “hit me”. If you can’t figure it out from there take off.

Say you just want to automate pissing off a certain player, like Spooon, well here’s your solution.

//This NPC kills Spooon every time he enters the level
if (playerenters && strequals(#a,spooon)) {
hurt 40;
}

This time strequals is checking the account string (#a) to see if the player is Spooon, if and only if the player entering is Spooon will they be terminated.

Say you figure out that Spooon’s been dodging your npc by using another account, this is how you’d check for both.

//This NPC kills Spooon every time he enters the level with either of his accounts.
if (playerenters && (strequals(#a,spooon) || strequals(#a,spooontoo))) {
hurt 40;
}

In this case you simply enclose the second set of conditions in parenthesis and separate them with a logical the or “||”. (Those aren’t one’s or lower case L’s, they’re what you get when you hold shift and press the “” key.)

Chapter 2 Weapons:
Now that we’re pretending you have a grip on flags, it’s high time you learn how to make a weapon.

//A weapon that fires a single nuke if you have any darts.
if (playertouchsme) {
toweapons Bayne’s Fricken Awesome Weapon;
}
if (weaponfired && playerdarts>=1) {
freezeplayer .1;
setani shoot,wbow4.png;
shootnuke playerdir;
playerdarts–;
}

So say you're a whiner and you're all like VW I want to fire a butload of nukes, well shit here you go damnit:

//A weapon that fires a “butload” of nukes if you have a “butload” of nukes to fire.
if (playertouchsme) {
toweapons Bayne’s Fricken Awesome Weapon;
}
if (weaponfired && playerdarts>=30) {
freezeplayer 3;
for(i=0; i<30; i++) {
setani shoot,wbow4.png;
shootnuke playerdir;
playerdarts–;
sleep .1;
}
}

What’s different is the loop: for(i=0; i<amountoftimesyouwantsomethingtohappen; increase i by 1) {}

Chapter 2b Buying Weapons:
So assuming you ever make a server, you’ll probably want to know how to sell that piece of shit:

//A weapon the player can buy if they have 30,000 rupees and say “buy Bayne’s Fricken Awesome Weapon”
//A weapon that fires a “butload” of nukes if you have a “butload” of nukes to fire.
if (playerchats && strequals(#c,buy bayne’s fricken awesome weapon) && playerrupees>=30000 && !hasweapon(Bayne’s Fricken Awesome Weapon)) {
toweapons Bayne’s Fricken Awesome Weapon;
playerrupees-=30000;
}
if (weaponfired && playerdarts>=30) {
freezeplayer 3;
for(i=0; i<30; i++) {
setani shoot,wbow4.png;
shootnuke playerdir;
playerdarts–;
sleep .1;
}
}

In that script the player can buy the weapon by saying “buy Bayne’s blah blah blah blah…”, and if they have the money and haven’t already bought the weapon it will be added to their inventory, while the cost is deducted from their total rupees.

There you have it, everything I know about scripting, thanks for reading and all that jazz.

Copied here in hopes Various will expand upon this idea.

What happened to Alex’s?