|
| Subscribe now to receive important news, game releases and site updates |
|
Gemstone Dragon Desktop version for Windows
Download a demo
Full version download immediately after purchase!
You can use any credit card.
|
|
|
Download a demo
Full version download immediately after purchase!
You can use any credit card.
|
|
In some instances you may want to implement random chances of combat? whether it's out of doors or in a dungeon. This can be done by scripting in a random roll when entering a location.
First go to the Creatures folder and create a new monster. Name it 'Spider' and set its Max Endurance to 2 and Endurance to 2. Go to the Battle tab and set the Damage Type to Pierce and Attack Type to Melee. Click on the Use Damage Table and set the values to 1,1,1,2,2,2. This will make the spider do 1 point of damage on a roll of 1-3 and 2 points of damage on a roll of 4-6.
Now go to the Locations folder and create a new location. Name this location "Attic" and link it to the Wild Rats Inn. Now click on the Script tab in the Attic and cut and paste this code into the script:
UseLib("def.js");
function OnEnter(){
i = Rnd(1,3); //a random number from 1 to 3
if ( i == 1){
AddContent(6001001,1001004,3,0); //add three rats
EnterCombat();
}
else if ( i == 2){
AddContent(6001004,1001004,2,0); //add two spiders
EnterCombat();
}else{
//do nothing here
}
return true;
}
function OnExit(){
foreach(4,"AlterVisibility(Current.ID,false);");
}
Here you have two functions. OnEnter and OnExit. OnEnter means every time you enter this location it will activate the code defined within the OnEnter function. In This code the OnEnter function is a Random Roll between 1 and 3. If the roll = 1 then 3 mice are placed into the location specified in the AddContent, and then they immediately engage you in combat. If the random roll is 2 then it adds 2 Spiders into the room and they immediately engage you in combat. On a roll of 3 since it is not defined, nothing happens.
OnExit means that every time you exit the location it will activate the code defined within the function. When exiting from this location the engine will do a search for each global variable defined in the def.js under Foreach. Here the search is for all Dead which are hidden when you exit the room using the altervisibility code. This is used so the random combat generators and OnEnter combat functions don't create so many dead corpses in a room that you have to sift through them to find the ones that have loot.
Now? Save your project and launch the engine to test your random generators. |
|
|
on June 22 2007 23:02:34
For anyone looking to make a game. Random encounters a must. They make any game more interesting. (Late by a few months, but) Nice job on the script. |
on July 11 2007 20:37:58
Random everything can keep a project interesting. The same act with multiple different consequences give it a slight sense of reality too. |
on November 29 2007 19:04:04
Randomness is the spice of life, if a person play through a game twice, they don't want to see the same exact game again. |
|
|
| Please Login to Post a Comment.
|
|
|
Top-Down action RPG
 |
|
Isometric action RPG
 |
|
Isometric action RPG
 |
|
Flash version of Dragon Age
 |
|
Isometric flash RPG
 |
|
Flash miniature RPG game
 |
|
Platform RPG
 |
|
Action Fantasy Game
 |
|
Isometric Flash RPG
 |
|
Zelda classic RPG for Flash
 | | Seeds Of Darkness |
 |
|
Top-down classic RPG
 |
|
Isometric Action RPG
 |
|
Fun WoW based RPG game
 |
|
Classic dungeon crawl RPG
 |
|
Strategy RPG game
 |
|
| Legendary Tales Online is a PBBG. |
|