Aegis Support Board: Aegis Npc Scripting Guide - Aegis Support Board

Jump to content

ASB News! ASB 5.0 Beta V2 has now been released!. See here for more Info.

  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Aegis Npc Scripting Guide 12 Lessons so far. More to come.

#1 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 26 April 2005 - 01:06 AM

:lol: Aegis Scripting Guide Lesson :P

~This is a Guide continued from Nome's Guide with a better explination and more stuff taught.~
Find a bug or wrong code please tell me and I will change.

Lesson 1


How to start a Npc
npc "map" "Name of Npc" npcspritename xpos ypos direction W H

Example:
npc "prontera" "My Name" 4_f_job_hunter 103 143 4 5 5


Explination of what each thing means:
* npc - Delcares type of npc(npc, trader, guide, warp, mob)
* "map" - You must enter the correct map name (ex. prontera, prt_fild01, moc_field04, etc...)
* "name" - This is the name that appears under the NPC Sprite in game
* spritename - This is where you delcate the sprite to use.(See Example)
* xpos - This is the x postion on the map (the first number from the /where command)
* ypos - This is the y postion on the map (the second number from the /where command)
* dir - This declares the direction the npc will face (This is a number value of 0-7)(7 = UP 6 = UP + RIGHT, 5 = RIGHT, 4 = DOWN + RIGHT, 3 = DOWN, 2 = DOWN + LEFT, 1 = LEFT, 0 = UP + LEFT)
* W - distance around the NPC that will activate it using the OnTouch: command(Thank you Ether)
* H - Distance around the NPC that will activate it using the OnTouch: command(Thank you Ether)


Npc Sprite Names can be found here http://kalen.s79.xre.../npc/npce.shtml


Example Npc:
npc "prontera" "My Name" 4_f_job_hunter 103 153 2 5 5
OnClick:
dialog "[Name]"
dialog "Enter chat here"
wait
dialog "[Name]"
dialog  "Enter chat here"
close

=====================================
Explination:

dialog
--- Tells the Npc what to do---

wait
--- Just type wait. Moves to the next screen---

close
--- Close the npc---
========================================================

Lesson 2
Now that we got through the very beginning stuff lets move into some more advanced stuff

Example Npc:
npc "prontera" "My Name" 4_f_job_hunter 103 153 2 5 5
OnClick:
	dialog "[My Name]"
	dialog "Hello would u like to go to Jawaii"
	wait
	choose menu "Yes" "No"
	
  case 1
  	dialog "[My Name]"
  	dialog "That will cost you 500z"
  	if v[VAR_MONEY] > 499
  	dialog "Thank you"
  	dropgold 500
  	else
  	dialog "[My Name]"
  	dialog "Hmm don't see to have enough"
  	endif
  	close
  	break
  case 2
  	dialog "[My Name]"
  	dialog "Ok then good bye"
  	close
  	return
  	break
  endchoose
return

=======================================================
Explination:

if
if v[VAR_MONEY] > 499
--- This will check to make sure you meet the zeny requirement for the trip. Make sure you say 1z less then required so that you don't have to have more then zeny required---
Example:
--- if v[VAR_MONEY] > 299 will make it so they can check for 300---


else
--- This declares what will happen when the if statement is not met.---

endif
--- This ends the if - else statement---

choose menu
--- This shows the choices that the play has to choose from.---
Example:
choose menu "Option 1" "Option 2" "Option 3" "Option 4"


case #
case 1 --- Declares what will happen if you choose the first option---
case 2 --- Declares what will happen if you choose the second option---

break
--- Just type break, declares when the end of a case has been reached---

endchoose
--- Type by itself declares the end of the choose menu---

getgold
getgold 1000 --- Give the palyer money, number entered behind it is the amount given---

dropgold
dropgold 1000 --- Takes money from the player, number is ammount taken away---

getitem
getitem Jellopy 30 --- Gives item to the player, item's name, ammount to be given---

dropitem
dropitem Jellopy 30 --- Takes item from player, item's name, ammount to be taken---
=======================================================

Lesson 3
Now that we got use to some variables and case's lets add some more of both. Lets add some warps in there also =P I think your ready

Example Npc:
npc "prontera" "My Name" 4_f_job_hunter 103 153 2 5 5
OnClick:
	dialog "[My Name]"
	dialog "Welcome to Jawaii"
	dialog "The honeymoons island"
	wait
	dialog "[My Name]"
	dialog "What would you like to do?"
	while(1)
	choose menu "Warp back to Prontera" "Info on Island" "GoodBye"
	
  case 1
  	dialog "[My Name]"	
  	dialog "Have a safe trip"
  	moveto "prontera" 138 208
  	close
  	break
  case 2
  	dialog "[My Name]"
  	dialog "This is the honeymooners Island only people who have recently gotten married should be here"
  	dialog "Did you just get married?"
  	while(1)
  	choose menu "Yes" "No"
  
    case 1
    	dialog "[My Name]"
    	dialog "Well then your ok to be here when you want a house just go to Bob and he will tell you how to rent one"
    	close
    	break
    	
    case 2
    	dialog "[My Name]"
    	dialog "Oooo well then you must leave right now"
    	moveto "prontera" 138 208
    	close
    	break
    	endchoose
  case 3
  	dialog "[My Name]"
  	dialog "Good bye"
  	close
  	break
  	endchoose
  	endwhile
	return


=======================================================
Explination:

while
while(1) --- This keeps a choose menu window open until canceled---

endwhile
endwhile --- Marks the end of the choose menu section to remain open---

exitwhile
exitwhile --- Continues script when window held open by while is closed.---

moveto
moveto --- Moves the player to that location specified.---
Example:
moveto "prontera" xpos ypos
=======================================================

Lesson 4
Now that we have learned how to warp and add more case's lets learn how to check for Gender and give exp and job exp.

Example Npc:
npc "prontera" "My Name" 4_f_job_hunter 103 153 2 5 5
OnClick:
	dialog "[Npc Name]"
	dialog "Welcome to New Training Grounds"
	dialog "Would you like to listen to the Basic Info of Ragnarok"
	wait
	choose menu "Yes" "No"
	
  case 1
  	dialog "[Npc Name]"
  	dialog "Well Yada Yada Yada"
  	wait
  	dialog "[Npc Name]"
  	dialog "Well thanks for listening here ya go for listening"
  	giveexp 9232
  	dialog "and also here"
  	getjexp 9234
  	close
  	break
  case 2
  	dialog "[Npc Name]"
  	dialog "Well then you seem like a smart"
  	if v[VAR_SEX] == 1
  	dialog "[Npc Name]"
  	dialog "boy. Maybe we will meet again"
  	elseif v[VAR_SEX] == 0
  	dialog "[Npc Name]"
  	dialog "young lady. Maybe we will meet again"
  	endif
  	dialog "Good Day"
  	close
  	break
  endchoose
return


=======================================================

Explination:

giveexp
giveexp --- Gives that charcter that amount of exp.---

dropexp
dropexp --- Removes some of that charcters exp.---

givejexp
givejexp --- Gives that charcter that amount of job exp.---

dropjexp
dropjexp ---- Removes some of that charcters exp.----

if v[VAR_SEX] == 0
--- Checks for the charcters gender.---
(0 = Female, 1 = Male)
=======================================================
Lesson 5
Well sench we just learned how to warp and check gender lets learn how to Reset Stat and Skills. Also we are gonna learn how to heal hp or take away hp. Also on a note if you see something wrong in this script please just tell me don't be an ass and be like OMG YOU WERE WRONG ITS THIS AND YA.
Thanks

Example Npc:
npc "prontera" "My Name" 4_f_job_hunter 103 153 2 5 5
OnClick:
	dialog "[Npc Name]"
	dialog "Welcome would you like to restart your stats/skills?"
	wait
	choose menu "Yes" "No"
  case 1 
  	dialog "[Npc Name]"
  	dialog "Well then choose which one"
  	while(1)
  	choose menu "Reset Skills" "Reset Stats" "Nevermind"
  	
    case 1
    	dialog "[Npc Name]"
    	dialog "Well that will be 250,000z"
    	if v[VAR_MONEY] > 249999
    	dropgold 250000
    	dialog "[Npc Name]"
    	dialog "Well then here ya go"
    	ResetSkill
    	else
    	dialog "[Npc Name]"
    	dialog "Well sorry you don't have enough zeny"
    	endif
    	close
    	break
    case 2
    	dialog "[Npc Name]"
    	dialog "Well that will be 250,000"
    	if v[VAR_MONEY] > 249999
    	dropgold 250000
    	dialog "[Npc Name]"
    	dialog "Here ya go"
    	ResetStat
    	else
    	dialog "[Npc Name]"
    	dialog "Not enough zeny"
    	dialog "So take this"
    	hpheal -85
    	endif
    	close
    	break
    case 3
    	close
    	break
    
    endchoose
    endwhile
return


=======================================================
Explination:

ResetSkill
--- Restarts that charcters skills.----

RestartStat
--- Restarts that charcters Stats.-----

hpheal <amount>
--- Heals the charcters hp that amount. You can either take hp or give hp(Give = 85, Take = -85)----

spheal <amount>
--- Heals the charcters sp that amount. You can either take or give sp(Give = 85, Take = -85)------

hpfullheal
--- Heals the charcters hp full.-------

spfullheal
--- Heals the charcters sp full.-------

=======================================================
Lesson 6
In this lesson we are gonna learn how to make a npc say a characters name along with give them skills =).

Example Npc:
npc "prontera" "Npc Name" 4_f_job_hunter 103 153 2 5 5
OnClick:
            dialog "[Npc Name]"
            dialog "+ PcName + How are you doing today"
            wait
            dialog "[Npc Name]"
            dialog "Thats great to hear."
            dialog "So what would you like to do?"
            wait
            choose menu "Get Skills" "Nevermind"

                     case 1
                              dialog "[Npc Name]"
                              dialog "Well then that will be 250,000"
                              if v[VAR_MONEY] > 249999
                              dropgold 250000
                              dialog "Thank you"
                              EventAddSkill CR_DEVOTION 0
                              EventAddSkill CR_GRANDCROSS 0
                              EventAddSkill CR_HOLYCROSS 0
                              EventAddSkill CR_REFLECTSHIELD 0
                              EventAddSkill CR_SHIELDBOOMERANG 0
                              else 
                             dialog "[Npc NAME]"
                             dialog "Sorry not enough zeny"
                             endif
                             close
                             break
                      case 2
                            dialog "[Npc Name]"
                            dialog "Wll then GoodBye"
                            close
                            break
                      endchoose
                      return


=======================================================
Explination:

+ PcName +
--- Has the npc say the charcters name.----

EventAddSkill
--- Add the Skill to that person.--------

EventDelSkill
--- Delete that skill from that person.---------

=======================================================
Lesson 7
Well we have been making great progress haven't we... In this lesson we are gonna learn how to check for Base Level, Job Level, Skill Points, and there Job. I would like to thank Bongun for helping me with this.

Example Npc:
npc "prontera" "Npc Name" 4_f_job_hunter 103 153 2 5 5
OnClick:
              if (v[VAR_JOB] == ARCHER)       
              dialog "[Npc Name]"
              dialog "Would you like to change into a Hunter?"
              wait
              choose menu "Yes" "No"
          
                        case 1
                                  if (v[VAR_JOBLEVEL] > 39)
                                  if (v[VAR_CLEVEL] > 52)
                                  if (v[VAR_SPPOINT] > 0)
                                  dialog "[Npc Name]"
                                  dialog "Well then here ya go"
                                  jobchange HUNTER
                                  close
                                  endif
                                  break
                         case 2
                                  dialog "[Npv Name]"
                                  dialog "Im sorry then good day"
                                  close
                                  endchoose
return


=======================================================
Explination:

if (v[VAR_JOBLEVEL] > 39)
--- This checks for the charcters job level. Make sure to put 1 less then the number you actually want.---

if (v[VAR_CLEVEL] > 52)
--- This checks for the charcters base level. Make sure it is one less then you actually want so it checks to see if the charcter is 53 or greater.---

if (v[VAR_JOB] == ARCHER)
--- This checks to see what job the charcter is.----

if (v[SPPOINT] > 0)
--- Checks to see if the charcter has used all of there skillpoints.---

=======================================================
Lesson 8(Checking on this use at risk)
In this lesson you won't really learn any new commands but I wanna teach you what is the difference between ==, !=, >, <. So ya here ya go =P.

Explination
== means equal to xy
!= not equal to
> greater then xy
< less then xy

=======================================================

Lesson 9 (By Kasuha Full Credit)

Aegis normally handles negative numbers.
var a = 40
var b = 80
var c = a - b
dialog "" + c
wait


Gives you "-40"
however, aegis compiler does not support unary minus. Therefore if you want to assign a negative number to a variable, you must do it this way:

var a = 0 - 40


break command is not really necessary.
choose menu "first" "second"
case 1
   dialog "one"
case 2
   dialog "two"
endchoose
wait

It compiles without a problem and if you choose "first" you get only "one" output, not "one \ two".
However I still think you should use breaks.

Non-displayable choices are just skipped

var a = "one"
var b = 2
var c = ""
var d = "four"
choose menu a b c d
case 1
   dialog "first"
   break
case 2
   dialog "second"
   break
case 3
   dialog "third"
   break
case 2
   dialog "fourth"
   break
endchoose
wait

This presents you with menu containing just "one" and "four" and if you choose "four", you get "second" as output.

Warps can talk
warp <blahblahblah>
OnTouch:
   dialog "Ouch! You stepped on me!"
   wait
   moveto <somewhere>
   return


Works as you'd expect - displays you the message and after clicking on 'next' moves you to the destination. I expect the same (though I didn't test it) for hidden warps.

Beware dialogs around moveto!
The moveto commands closes the dialog window and removes displayed image (e.g. Kafra image) and does not let the dialog window appear again.

dialog "something before"
moveto <somewhere>
dialog "something after"
close
return


This code does not display anything, though the close command remains active until it times out, preventing you to use other NPCs.

And one curiosity at the end - relative movement warp.

warp "jawaii" "test warp 1" 200 230 5 5
OnTouch:
   var x = v[VAR_CURXPOS] + 20
   var y = v[VAR_CURYPOS]
   moveto "jawaii" x y
   return


This warp moves you exactly 20 tiles east. This ofcourse works for movements between maps so it can be used to avoid warping all people to the same point if they enter the warp at different points.



=======================================================
No Explination(Still learning this one also =P)
Thanks Again Kasuha
=======================================================

Lesson 10(By Kasuha Full Credits to him)

I have been experimenting with Aegis scripting recently and here are some of my findings. Let's call it "advanced do's and don'ts":

The choose construct does not work only with the menu - you can put variable into it, too:

choose v[VAR_SEX]
case 0
   dialog "You're a girl!"
   break
case 1
   dialog "You're a boy!"
   break
endcase
close 




The break command is only usable on base level of the choose construct.
Correct:

choose <something>
case 1
   ...
   break
endchoose




Wrong:

choose <something>
case 1
   if <condition>
       break <-- translation error here
   endif
endchoose 




The break command is not mandatory. Putting break after return is just a waste of a perfect text line.

The moveto command does not stop script execution, even if it moves the player to another map. If the execution flow meets some wait or close command then, it locks the script and prevents the player to use NPCs until the script times out.

Integer division is possible, for instance 27 / 7 = 3.

The menu function can be used out of the choose command, for instance var a = menu "jedna" "dva" is correct, it displays the menu and lets you select, however the a variable contains zero afterwards.

If you forget to put the last close to your script and then perform the return command, the close command is added implicitly.

Attempts to comment out several lines using the /* and */ comment marks do not work. The compiler just ignores the two lines and compiles everything between them. Generally the compiler is very tolerant to errors if it does not recognize a command on the line - such a line is just skipped.

Empty strings and numbers do not appear in the menu function. Example:

var a = "one"
var b = ""
var c = 1
var d = "four"
choose menu a b c d



This lets you choose from two choices - one and four. However I am not really sure which case parts get executed.

=======================================================
No Explination(Still learning this also =P)
Thanks Again Kasuha
=======================================================
Lesson 11(Full Credit to Kasuha)

Another article, today about cmdothernpc command.

The cmdothernpc command is used to invoke an OnCommand: code block on another or the same NPC. However, they are not subroutine calls; they are treated as events. Each event is added to the NPC's event queue and as soon as the script execution ends, another event is taken form the queue and processed.

Example:

npc "jawaii" "Command Tester" 4W_KID 200 240 4 1 1
OnClick:
   strlocalvar 0 "myvalue"
   SetLocalVar "myvalue" 10
   broadcastinmap "1"
   cmdothernpc "Command Tester" "one"
   broadcastinmap "2"
   cmdothernpc "Command Tester" "two"
   broadcastinmap "3"
   cmdothernpc "Command Tester" "three"
   broadcastinmap "4"
   cmdothernpc "Command Tester" "four"
   broadcastinmap "5"
   SetLocalVar "myvalue" 20
   return

OnCommand: "one"
   broadcastinmap "6"
   return

OnCommand: "two"
   broadcastinmap "7"
   cmdothernpc "Command Tester" "five"
   broadcastinmap "8"
   return

OnCommand: "three"
   broadcastinmap "9"
   return

OnCommand: "four"
   broadcastinmap "10"
   return

OnCommand: "five"
   broadcastinmap "11"
   broadcastinmap "Value = " + lv["myvalue"]
   return





This NPC produces a nice series of broadcasts:


Command Tester : 1
Command Tester : 2
Command Tester : 3
Command Tester : 4
Command Tester : 5
Command Tester : 6
Command Tester : 7
Command Tester : 8
Command Tester : 9
Command Tester : 10
Command Tester : 11
Command Tester : Value = 20 




If they were actually subroutine calls, we would get the following output, but it doesn't happen:


Command Tester : 1
Command Tester : 6
Command Tester : 2
Command Tester : 7
Command Tester : 11
Command Tester : Value = 10
Command Tester : 8
Command Tester : 3
Command Tester : 9
Command Tester : 4
Command Tester : 10
Command Tester : 5 




Also note that NPC's local variables declared through strlocalvar can be used to transfer values between NPC's code blocks.
Commands grouped together need to be used together.
=======================================================
Explination
Well he did it pretty well =P
=======================================================

**Exception: Else does not always need to be used with an if statement, however it cannot be used outside an if statement.

=======================================================

Lesson 12
Darn its been a while sence I updated this :blink: but I guess ill start work on it again so you guys will get smarter :o. Well lets see maybe today we should learn Strength,Vit,Agi,Dex upgrade :P.

Coming Soon!


=======================================================

Lesson 13(Another Lesson from Kasuha)
Wanna know how much any of your NPCs is used? Wanna know how many people go through a particular warp? Wanna know things that are not logged otherwise? Here is a simple solution:

npc "jawaii" "Spy" 4_M_02 195 240 0 0 0
OnClick:
   SavePPL 0
   dialog "[Spy]"
   dialog "You have been reported."
   close
   return


=======================================================
The SavePPL command stores the current player location, time and the number specified in the command to the presentLog database table.
You can put a lot of useful information into the number specified in the command.




Installing a NPC Script(Full Credit to Nome)
Foreword
Since this question comes up and most likely will come up a bit more. I'll try to make an easy-to-use painless guide to getting your custom made NPCs into the game.

There are 2 ways you can do it.

Option 1



Get your NPC script

Go to zone/npcdata/npc/folder

Click on npc.sc

Add the new NPC script to the end of npc.sc

I suggest making a comment that lets you know what script it is when you go back to it.

Save the file

Close the file

Load up Zone Server

If you get a failed to compile npc.sc error


Close Zone

Go back to npc.sc

Look over your new script and make sure it's coded right


Dialog should have both quotes ""

if statements should use [ ] and not { }

Make sure you use the database names for items from itp.txt

Make sure your other variables match up to database names

Choose menu needs and Endchoose

If statements need endif

case statements need break

should always end an npc script with return







Option 2
**This is for those of you who plan to make more than 1 or 2 NPC



Have your NPC script ready in its own .sc file

Make a folder, name it whatever you want (for this guide I'll call it mynpc)
QUOTE
Make sure the folder is located in the zone/npcdata directory


Put the new .sc file into the folder mynpc

Go to zone/npcdata

Open the List.txt file

I suggest near the top, put:
CODE
// mynpc Data
./npcdata/mynpc/scriptfilename.sc


Save List.txt as a text file and close

Run Zone Server to see if it loads

If it fails, see trouble shooting list from Option 1


* mynpc can be replaced with whatever name you want
** you should keep scriptfilename relativly short (some long names don't work)
*** if you put the wrong file name in list.txt, your zone server will not start.
**** You can also check the nps.asm file if an error pops up. It shoudl give you the exact line that is erroneous. (Thanks guryushka)

Credits:
Who/What they did

Nome -- For some of the Definitions & the explination parts at the beginning of the guide and Installing Npc Guide 

Aukeri -- Directions

Bongun -- Variables

Ether -- Variables

Mass Zero -- Help 


Changelog
10/15/05
               ++Redid the Guide made it look a little better :O 

This post has been edited by Nate: 01 December 2005 - 09:58 PM

0

#2 User is offline   akito112 

  • Advanced Member
  • PipPipPipPipPip
  • Group: Members
  • Posts: 295
  • Joined: 08-March 04

Posted 26 April 2005 - 06:27 AM

I'm sure this guide will help some aspiring scripters. thanks for writing it, I'll be sure to link it to my gm's who want to learn how to script,saves me typing out tutorials over and over T_T
thanks
0

#3 User is offline   Ether 

  • Kaijin
  • PipPipPipPipPip
  • Group: Members
  • Posts: 285
  • Joined: 04-January 04

Posted 26 April 2005 - 07:54 PM

Quote

* W - No idea what this does(Just put 5)
* H - No idea what this does(Just put 5)


That would be the distance around the NPC that will activate it using the OnTouch: command.

Also, in your ResetStat and ResetSkill NPCs, you reversed the functions of each case. You have case 1 which is labeled as reset stats, using ResetSkill. On the converse as well, you have the labeled reset skills case using ResetStat.

Then, in your explanations section..

Quote

ResetSkills
--- Restarts that charcters skills.----

RestartStats
--- Restarts that charcters Stats.-----


One, it should be ResetSkill. No s at the end. Two, the second part says RestartStats. The correct would be ResetStat. (Again, make sure there is no s at the end).

Thanks.

~Ether
0

#4 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 26 April 2005 - 08:05 PM

Ooo thanks =P. Ill update it now
0

#5 User is offline   TwistedHeaven 

  • Spriter
  • PipPipPipPipPip
  • Group: Members
  • Posts: 292
  • Joined: 19-March 04
  • Location:California
  • Interests:Anime, CG Graphics, MMORPG, FPS, Girls, Cars, Computers, Programs, Editing, Modding

Posted 26 April 2005 - 08:14 PM

Whats the command to get exp from an NPC?
0

#6 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 26 April 2005 - 08:23 PM

lesson 4

giveexp <amount>
dropexp <amount>
givejexp <amount>
dropjexp <amount>
0

#7 User is offline   Mass Zero 

  • Old Skool Ownage
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1709
  • Joined: 06-March 04
  • Gender:Male
  • Location:Amsterdam, NL
  • Interests:Private

Posted 27 April 2005 - 09:40 AM

Regarding lesson 6, PcName is the right variable for a character's name and it works yeah. o.o;
0

#8 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 27 April 2005 - 08:52 PM

oo ya I forgot to remove that from last night I figured that out.
0

#9 User is offline   AznSoldier 

  • Elite member
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1364
  • Joined: 03-May 03

Posted 29 April 2005 - 07:13 AM

Sweet scripting guide. I'll be sure to use this and I've been waiting for something like this for a while. I'm beginning to bring back my RO server, and this is what I need. Thanks for creating something like this, and I can't wait for the full lessons.

With all the possible variables and what not.

Thanks a lot for this guide. :D

Out,
~AznSoldier
0

#10 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 29 April 2005 - 10:12 AM

I have been experimenting with Aegis scripting recently and here are some of my findings. Let's call it "advanced do's and don'ts":

The choose construct does not work only with the menu - you can put variable into it, too:
choose v[VAR_SEX]
case 0
    dialog "You're a girl!"
    break
case 1
    dialog "You're a boy!"
    break
endcase
close


The break command is only usable on base level of the choose construct.
Correct:
choose <something>
case 1
    ...
    break
endchoose


Wrong:
choose <something>
case 1
    if <condition>
        break <-- translation error here
    endif
endchoose


The break command is not mandatory. Putting break after return is just a waste of a perfect text line.

The moveto command does not stop script execution, even if it moves the player to another map. If the execution flow meets some wait or close command then, it locks the script and prevents the player to use NPCs until the script times out.

Integer division is possible, for instance 27 / 7 = 3.

The menu function can be used out of the choose command, for instance var a = menu "jedna" "dva" is correct, it displays the menu and lets you select, however the a variable contains zero afterwards.

If you forget to put the last close to your script and then perform the return command, the close command is added implicitly.

Attempts to comment out several lines using the /* and */ comment marks do not work. The compiler just ignores the two lines and compiles everything between them. Generally the compiler is very tolerant to errors if it does not recognize a command on the line - such a line is just skipped.

Empty strings and numbers do not appear in the menu function. Example:
var a = "one"
var b = ""
var c = 1
var d = "four"
choose menu a b c d

This lets you choose from two choices - one and four. However I am not really sure which case parts get executed.

This post has been edited by Kasuha: 29 April 2005 - 10:14 AM

0

#11 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 29 April 2005 - 08:16 PM

Thanks for adding that Kashua never knew that if its ok with you Ill add that to part of my guide and ill give u full creidt of course =).
Also sorry about not updateing it yet I was busy yesterday so im releasing two lessons tonight

~Nate

P.S. It will take me 1-2 days to update this cause I gotta test some of the stuff I want to post before I post it. Don't want to give you guys bad info. =P So Im gonna test them on the deticated box I getting soon :D sorry about the inconvience.

This post has been edited by Nate: 30 April 2005 - 03:39 PM

0

#12 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 02 May 2005 - 08:50 AM

It's perfectly ok if you put my comments to your guide, Nate.

Some more:

Aegis normally handles negative numbers.
var a = 40
var b = 80
var c = a - b
dialog "" + c
wait

Gives you "-40"
however, aegis compiler does not support unary minus. Therefore if you want to assign a negative number to a variable, you must do it this way:
var a = 0 - 40


break command is not really necessary.
choose menu "first" "second"
case 1
    dialog "one"
case 2
    dialog "two"
endchoose
wait

It compiles without a problem and if you choose "first" you get only "one" output, not "one \ two".
However I still think you should use breaks.

Non-displayable choices are just skipped

var a = "one"
var b = 2
var c = ""
var d = "four"
choose menu a b c d
case 1
    dialog "first"
    break
case 2
    dialog "second"
    break
case 3
    dialog "third"
    break
case 2
    dialog "fourth"
    break
endchoose
wait

This presents you with menu containing just "one" and "four" and if you choose "four", you get "second" as output.

Warps can talk
warp <blahblahblah>
OnTouch:
    dialog "Ouch! You stepped on me!"
    wait
    moveto <somewhere>
    return

Works as you'd expect - displays you the message and after clicking on 'next' moves you to the destination. I expect the same (though I didn't test it) for hidden warps.

Beware dialogs around moveto!
The moveto commands closes the dialog window and removes displayed image (e.g. Kafra image) and does not let the dialog window appear again.
dialog "something before"
moveto <somewhere>
dialog "something after"
close
return

This code does not display anything, though the close command remains active until it times out, preventing you to use other NPCs.

And one curiosity at the end - relative movement warp.

warp "jawaii" "test warp 1" 200 230 5 5
OnTouch:
    var x = v[VAR_CURXPOS] + 20
    var y = v[VAR_CURYPOS]
    moveto "jawaii" x y
    return

This warp moves you exactly 20 tiles east. This ofcourse works for movements between maps so it can be used to avoid warping all people to the same point if they enter the warp at different points.

This post has been edited by Kasuha: 03 May 2005 - 07:50 AM

0

#13 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 02 May 2005 - 08:29 PM

There we go =). Lessons 9 and 10 just keep adding and ill keep adding to my guide =P thanks for the info.

~Nate
0

#14 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 03 May 2005 - 07:54 AM

I edited my last entry with one more detail about negative numbers and changed display commands (wrong) to dialog commands (correct).

And Nate, my nick is Kasuha, not Kashua...
0

#15 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 03 May 2005 - 08:07 PM

Ooo sry about that dude. I updated the guide with ur new info.

~Nate
0

#16 User is offline   Scriptor 

  • Average Member
  • PipPipPipPip
  • Group: ASB Staff
  • Posts: 243
  • Joined: 05-May 05
  • Gender:Male

Posted 05 May 2005 - 09:26 PM

if you use a name like "#Scriptor" the name will not appear ingame.
Bots will recognize that name, but you won't see them ingame.
0

#17 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 05 May 2005 - 11:06 PM

Well I guess its cause of the #? No idea about that though >.<;
0

#18 User is offline   Scriptor 

  • Average Member
  • PipPipPipPip
  • Group: ASB Staff
  • Posts: 243
  • Joined: 05-May 05
  • Gender:Male

Posted 06 May 2005 - 03:08 PM

yeah, i know.

i thinks its useful to declare internal npcs.

if you have a script for the jawaii house renting.

there are 4 NPCs all with the same Name:
Attendant

So i named my NPCs in my jawaii scripts:

Attendant#Sweetness Suite
Attendant#Classic Suite
Attendant#Honeymoon Suite
Attendant#Villa Suite

So i know which NPC depends to which Suite.
I think it is very useful for the cleaness of your npc scripts.

You can use it for Quest NPCs with same Name.

Prontera Citizen#Quest Start
Prontera Citizen#Quest Part 2
Prontera Citizen#Reward

so you got it orderd ^^

found another reason for those #comments ^^

If you have 3 NPCs:
npc "geffen" "Vender" 100 100
npc "geffen" "Vender" 110 110
npc "geffen" "Vender" 120 120
this are not real npc commands. just to show:
3 NPCs, same Name, diffrent coordinates.

you want them to hide and to show:
enablenpc "Vender"

now you got a Problem, which one will appear? All? Don't know. Better use:

npc "geffen" "Vender#Number1" 100 100
npc "geffen" "Vender#Number2" 110 110
npc "geffen" "Vender#Number3" 120 120

and

enablenpc "Vender#Number1"
enablenpc "Vender#Number2"
enablenpc "Vender#Number3"

so it is no problem ^^

This post has been edited by Scriptor: 07 May 2005 - 09:57 PM

0

#19 User is offline   Nate 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 145
  • Joined: 10-February 05
  • Location:Usa
  • Interests:Stuff

Posted 09 May 2005 - 01:02 AM

Just wondering why put # why not just put Vender1, Vender2?

Anyways sorry about lack of updates taking longer then I thought to get a deticated box >.> *looks evil at Mass Zero* Anyways ya Ill try and update with some Variables instead of the commands =P.

~Nate

This post has been edited by Nate: 09 May 2005 - 01:03 AM

0

#20 User is offline   Q_Q 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 91
  • Joined: 13-March 05

Posted 09 May 2005 - 11:34 AM

because its ugly if you have npc names with numbers in it ^^
0

Share this topic:


  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users