View Single Post
  #7  
Old 06-27-2009, 12:43 PM
Draenin Draenin is offline
Magnificent Bastard
Draenin's Avatar
Join Date: Dec 2004
Location: Bermuda Triangle
Posts: 6,790
Draenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud ofDraenin has much to be proud of
Send a message via AIM to Draenin Send a message via MSN to Draenin Send a message via Yahoo to Draenin
Sorry to double-post, but I've dredged up some scripts that I was working on.

Keep in mind these are kind of amateurish, but I did these while learning on testbed. They're sort of primitive attempts at assembling a battle system from scratch with very little experience. It's mostly for input / output purposes, and testing to make sure numbers are calculated as they should be.

PHP Code:
//d20-Style Attack Roll

//#CLIENTSIDE
function onKeyPressed() { 
   if (
keydown(5)) {
     
findWeapon("Shared/DraeninPolyhedrals").Rolld20();
     if (
client.d20 == 1){
       
player.chat = "Miss! 0 Damage!";
       }
     
//Melee Attack//
     
else if (client.d20 == 20){
       
player.chat = "Critical! " @ (client.level+client.atk+client.str+int(random(1,6)))*2 @ " Damage!";
       }
     else
       
player.chat = client.level+client.atk+client.str+int(random(1,6)) @ " Damage!";
   }
} 
PHP Code:
//Commands

//#CLIENTSIDE
 
function onPlayerChats(){
   
temp.tokens = player.chat.tokenize();
   if (
tokens[0] == ":setlevel"){
     
client.level = tokens[1];
     
client.maxhp = (client.con+client.level)*5;
     
client.maxmp = (client.int+client.level)*3;
     
client.hp = client.maxhp;
     
client.mp = client.maxmp;
   }
} 
PHP Code:
//Equips

//#CLIENTSIDE
function onPlayerChats(){
    if(
player.chat = ":sword"){
      
client.atktype = "melee";
      
client.atk = 10;
    }
    if(
player.chat = ":bow"){
      
client.atktype = "ranged";
      
client.atk = 6;
    }
    if(
player.chat = ":wand"){
      
client.atktype = "magic";
      
client.atk = 4;
    }
    if(
player.chat = ":unarmed"){
      
client.atktype = "melee";
      
client.atk = 2;
    }
    if(
player.chat == ":drink poison"){
      
client.hp -= 5;
    }
    else if(
player.chat == ":drink potion"){
      
client.hp += 10;
    }
    
findWeapon("Shared/DraeninStatRoll").checkhp();
    
findWeapon("Shared/DraeninStatDisplay").drawhp();
} 
PHP Code:
//Stat Roll

//#CLIENTSIDE
public function Rolld20(){
     
client.d20 = int(random(1,21));
}

public function 
Rolld12(){
     
client.d12 = int(random(1,13));     
}

public function 
Rolld10(){
     
client.d10 = int(random(1,11));
}

public function 
RolldPercent(){
     
client.dpercent = int(random(1,11)*10);
}

public function 
Rolld6(){
     
client.d6 = int(random(1,7));
}

public function 
Rolld4(){
     
client.d4 = int(random(1,5));
} 
PHP Code:
//Stat Display

//#CLIENTSIDE
function onCreated() {
  
this.img1 = findimg(1);
  
with (this.img1) {
    
style = "c";
    
zoom = 0.75;
  }
  
setTimer(0.05);
}

function 
onTimeout() {
  
with (this.img1) {
    
text = "Level: " @ client.level @ "     " @ client.hp @ " / " @ client.maxhp @ " HP     " @ client.mp @ " / " @ client.maxmp @ " MP";
    
x = player.x + 1.5;
    
y = player.y - 1.5;
  }
  
setTimer(0.05);
} 

Numbers and stuff like that are mainly what I'm interested in working with, though I'm sure with some practice I could easily get used to working with movements and so on as well. I also would like to learn how to work with classes so new object NPCs could possibly be made, and even perhaps dabble in event sequences.

I know I may not be the best for the job compared to others, but I've never had any sort of real mentoring, and it could make a difference.
Reply With Quote