Raelyn |
04-29-2009 02:17 AM |
Ok, I've wrote 2 scripts while I did not have internet access, but now I have it back and I am going to try and get them to work on my server, but I wanted to post here first and get critique on the scripting itself (to better improve my noob self) and advice on the best way to upload it to work, like not sure how the various parts will be read by the server, since offline it all works in 2 weapons.
They are both still works in progress, so any pointers/changes/improvements would be appreciated!
Anyway, have a look, this first one is a basic baddy:
PHP Code:
//scripted(poorly) by Raelyn
if (created){
timeout = .05;
setshape 1,32,32;
NpcStats();
}
if (wa**** || waspelt){
NpcWa****();
if (this.cur_hp =< 0){
NpcDeath();
}
}
if (timeout){
NpcChase();
message #v(this.cur_hp)/#v(this.max_hp);
timeout = .05;
}
if ((x+1) > playerx && (x-1) < playerx && (y+1) > playery && (y-1) < playery){
hitplayer ,0,x,y;
}
function NpcDeath(){
clientr.cur_exp += 10;
message dead!;
destroy;
}
function NpcWa****(){
this.cur_hp -= 1;
message #v(this.cur_hp)/#v(this.max_hp);
timeout = .5;
}
function NpcStats(){
this.cur_hp = 5;
this.max_hp = 5;
}
// NPC chases the player until wall
function NpcChase(){
if (playerx>x){
x += .3;
if (onwall(x+1,y+1)){
x -= .3;
}
}
else
x -= .3;
if (onwall(x+1,y+1)){
x+= .3;
}
if (playery>y){
y+= .3;
if (onwall(x+1,y+1)){
y-= .3;
}
}
else
y-= .3;
if (onwall(x+1,y+1)){
y+= .3;
}
}
And this one is the whole player system I have thus far..
PHP Code:
//scripted(poorly) by Raelyn
// index key
//
// 0411 - help interface
// 0412 - help interface
// 0001 - level up
// 0002 - exp display
// 205 - hud head
// 202 - hud background
// 200 - hud current hp
// 2001 - hud hp /
// 2002 - hud max hp
// 201 - hud current mp
// 2011 - hud mp /
// 2012 - hud max mp
// initialize the stuff
if (created){
SetStats();
UpdateGui();
ThisLevel();
removetiledefs;
addtiledef2 raelyn_tiles_sand.png,scripting,0,0;
addtiledef2 raelyn_tiles_sand-trailmark.png,scripting,0,32;
addtiledef2 raelyn_tiles_sand-footprint.png,scripting,0,48;
timeout = .05;
}
if (playerhurt){
clientr.cur_hp = clientr.cur_hp - 1;
UpdateGui();
}
if (clientr.cur_hp < 1){
message Dead!;
}
if (keypressed){
if (strequals(#p(1),C)){
message woot;
}
}
if (timeout){
UpdateGui();
timeout = .05;
}
// chat commands
if (playerchats){
if (strequals(#c,/setstats)){
SetStats();
}
if (strequals(#c,/help)){
Help();
}
if (strequals(#c,/updategui)){
UpdateGui();
}
if (strequals(#c,/levelup)){
LevelUp();
UpdateGui();
}
if (strequals(#c,/sethead)){
sethead head25.png;
UpdateGui();
}
}
// stuff for this level
function ThisLevel(){
showimg 2022,raelyn_desert_trailmarker.png,35,24;
changeimgvis 2022,1;
}
// in-game help
function Help(){
showtext 0411,400,400,tempus sans itc,,The available commands are:;
changeimgvis 0411,4;
sleep 2;
showtext 0411,,,,,;
showtext 0412,400,400,tempus sans itc,,/help, /setstats, /updategui, /sethead, /levelup;
changeimgvis 0412,4;
sleep 2;
showtext 0412,,,,,;
}
// leveling up the player
function LevelUp(){
clientr.max_exp += clientr.max_exp * 1;
clientr.str += clientr.str / 100 *10;
clientr.end += clientr.end / 100 *10;
clientr.dex += clientr.dex / 100 *10;
clientr.int += clientr.int / 100 *10;
clientr.max_hp = clientr.end * 2;
clientr.cur_hp = clientr.max_hp;
clientr.max_mp = clientr.int;
clientr.cur_mp = clientr.max_mp;
showtext 0001,playerx,playery-2,tempus sans itc,,Level up!;
UpdateGui();
sleep 2;
showtext 0001,,,,,;
}
// setting up newb stats
function SetStats(){
clientr.cur_exp = 0;
clientr.max_exp = 10;
clientr.str = 10;
clientr.end = 10;
clientr.dex = 10;
clientr.int = 10;
clientr.max_hp = clientr.end * 2;
clientr.cur_hp = clientr.max_hp;
clientr.max_mp = clientr.int;
clientr.cur_mp = clientr.max_mp;
}
// refreshing the interface
function UpdateGui(){
disableselectweapons;
disablemap;
showstats 1024;
if (clientr.cur_exp => clientr.max_exp){
LevelUp();
}
showtext 0002,100,100,tempus sans itc,,Exp: #v(clientr.cur_exp) / #v(clientr.max_exp);
changeimgvis 0002, 5;
showimg 205,#3,12,12;
changeimgpart 205,0,62,32,32;
changeimgvis 205,6;
showimg 202,raelyn_hud.png,10,10;
changeimgpart 202,0,0,140,36;
changeimgvis 202,5;
if (clientr.cur_hp == clientr.max_hp){
showimg 206,raelyn_hud.png,46,12;
changeimgpart 206,0,36,100,16;
changeimgvis 206,6;
} else {
showimg 206,raelyn_hud.png,46,12;
changeimgpart 206,0,36,(clientr.cur_hp * 100) / clientr.max_hp,16;
changeimgvis 206,6;
}
showimg 207,raelyn_hud.png,46,29;
changeimgpart 207,0,36,100,16;
changeimgvis 207,6;
showtext 200,50,11,tempus sans itc,,#v(int(clientr.cur_hp));
showtext 2001,90,11,tempus sans itc,,/;
showtext 2002,100,11,tempus sans itc,,#v(int(clientr.max_hp));
changeimgvis 200,7;
changeimgzoom 200,.75;
changeimgvis 2001,7;
changeimgzoom 2001,.75;
changeimgvis 2002,7;
changeimgzoom 2002,.75;
showtext 201,50,28,tempus sans itc,,#v(int(clientr.cur_mp));
showtext 2011,90,28,tempus sans itc,,/;
showtext 2012,100,28,tempus sans itc,,#v(int(clientr.max_mp));
changeimgvis 201,7;
changeimgzoom 201,.75;
changeimgvis 2011,7;
changeimgzoom 2011,.75;
changeimgvis 2012,7;
changeimgzoom 2012,.75;
}
Be gentle, please.
|