Author Topic: NESS group script problems  (Read 493 times)

Legacy_Kossuths_Will

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
NESS group script problems
« on: September 08, 2010, 02:26:38 am »


               What I am trying to do is replicate the old 2d10 random encounter tables from older editions of D&D (I believe it was AD&D 2nd ed but i cant be sure).

Anyhow, for some reason, the Spawn function in NESS always spawns a water elemental, and no matter how I try and switch things around, nothing changes. Initially, I had nEncType used in a switch/case statement, but I wasnt sure if you could nest 1 switch inside another, so I did away with it. Unfortunately, that's not the problem, because it's still happening. 
 
Quote
    int nRoll = d12();    
int nMonster = d3();    
int nEncType;    
// determine encounter rarity    
if (nRoll=1)    
{        // very rare encounters        
nEncType = 4;        
nSpawnNumber = 1;    
}    else if (nRoll<4)    
{      
 // rare encounters      
 nEncType = 3;        
nSpawnNumber = 1;    
}    else if (nRoll<7)  
{        
// rare encounters        
nEncType = 2;        
nSpawnNumber = d3()+1;    
}    
else    
{        
// very rare encounters        
nEncType = 1;        
nSpawnNumber = d3(2);    }
    // Moonshaes - coastal encounters    
if (sTemplate == "coastal_low")    
{        
 //determine common encounter        
if (nEncType==1)        
{            
if (nMonster==1)            
{                
switch (d4())              
 {                    
case 1: sRetTemplate = "eots_pirate001"; break;                  
case 2: sRetTemplate = "eots_pirate001"; break;                    
case 3: sRetTemplate = "eots_pirate002"; break;                    
case 4: sRetTemplate = "eots_pirate003"; break;                
}            
}            
else if (nMonster == 2)          
{                
switch (d2())                
{                    
case 1: sRetTemplate = "eots_beachdwell1"; break;                    
case 2: sRetTemplate = "eots_beachdwell2"; break;                
}            
}            
else            
{              
switch (d2())              
{                    
case 1: sRetTemplate = "eots_fish2"; break;                    
case 2: sRetTemplate = "eots_fish3"; break;                
}            
}        
}        
//determine uncommon encounter        
else if (nEncType==2)        
{            
if (nMonster == 1)            
{                
sRetTemplate = "eots_waterbtl";            
}            
else if (nMonster == 2)            
{                
sRetTemplate = "zep_bird_030";            
}            
else            
{                
sRetTemplate = "eots_seaviper_s";          
}        
}        
//determine rare encounter        
else if (nEncType==3)        
{            
if (nMonster == 1)            
{                
sRetTemplate = "eots_waterspid";            
}            
else if (nMonster == 2)            
{                
sRetTemplate = "eots_crabg";            
}            
else            
{                
sRetTemplate = "eots_seaviper_l";            
}        
}      
 //determine very rare encounter        
else if (nEncType==4)        
{            
if (nMonster == 1)            
{              
 sRetTemplate = "zep_elemwaters";            
}            
else if (nMonster == 2)          
{                
sRetTemplate = "eots_umberlee001";            
}            
else          
{                
sRetTemplate = "giantsnake";            
}        
}    
}
}[/quote]
I'm not even sure if you can declare the number of monsters spawned this way, but for now I am just trying to figure out why only the elemental spawns.
               
               

               


                     Modifié par Kossuths_Will, 08 septembre 2010 - 01:43 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
NESS group script problems
« Reply #1 on: September 08, 2010, 05:14:22 am »


               Well I took what you had and started adding switches like you were intending. I didn't get it all the way done. I wanted to just do some of them so you could see the changes. Hope this is what you were looking for.

void main()
{
int nRoll = d12();
int nMonster = d3();
int nEncType;
int nSpawnNumber;
string sTemplate;
string sRetTemplate;
// determine encounter rarity
switch (nRoll)
    {
    //very rare encounters
    case 1: nEncType = 4; nSpawnNumber = 1; break;
    //rare encounters
    case 2:case 3: nEncType = 3; nSpawnNumber = 1; break;
    //rare encounters
    case 4:case 5:case 6: nEncType = 2; nSpawnNumber = d3()+1; break;
    //very rare encounters
    case 7:case 8:case 9:case 10:case 11:case 12:
    nEncType = 1; nSpawnNumber = d3(2); break;
    }
    // Moonshaes - coastal encounters
if (sTemplate == "coastal_low")
    {
    //determine common encounter
    if (nEncType==1)
        {
        switch (nMonster)
            {
            case 1:
            switch (d4())
                {
                case 1: sRetTemplate = "eots_pirate001"; break;
                case 2: sRetTemplate = "eots_pirate001"; break;
                case 3: sRetTemplate = "eots_pirate002"; break;
                case 4: sRetTemplate = "eots_pirate003"; break;
                }
            case 2:
            switch (d2())
                {
                case 1: sRetTemplate = "eots_beachdwell1"; break;
                case 2: sRetTemplate = "eots_beachdwell2"; break;
                }
            case 3:
            switch (d2())
                {
                case 1: sRetTemplate = "eots_fish2"; break;
                case 2: sRetTemplate = "eots_fish3"; break;
                }
            }
        }
//determine uncommon encounter
else if (nEncType==2)
{
if (nMonster == 1)
{
sRetTemplate = "eots_waterbtl";
}
else if (nMonster == 2)
{
sRetTemplate = "zep_bird_030";
}
else
{
sRetTemplate = "eots_seaviper_s";
}
}
//determine rare encounter
else if (nEncType==3)
{
if (nMonster == 1)
{
sRetTemplate = "eots_waterspid";
}
else if (nMonster == 2)
{
sRetTemplate = "eots_crabg";
}
else
{
sRetTemplate = "eots_seaviper_l";
}
}
 //determine very rare encounter
else if (nEncType==4)
{
if (nMonster == 1)
{
 sRetTemplate = "zep_elemwaters";
}
else if (nMonster == 2)
{
sRetTemplate = "eots_umberlee001";
}
else
{
sRetTemplate = "giantsnake";
}
}
}
}


It compiles now anyhow. '<img'>
               
               

               


                     Modifié par GhostOfGod, 08 septembre 2010 - 04:15 .
                     
                  


            

Legacy_Kossuths_Will

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
NESS group script problems
« Reply #2 on: September 08, 2010, 05:18:48 am »


               thanks, I'll try it. it compiled before, but it was that darn elemental every single time. i even had a debug where it would send a message to the PC what nRoll was, and no matter what it came up with, that elemental was always sitting there. after a couple hours or more i just got frustrated and figured i'd ask for help from people more skilled than myself.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
NESS group script problems
« Reply #3 on: September 08, 2010, 05:22:22 am »


               Hmm..This must have just been a piece of the whole script then? I tried to compile it and it was missing some bits. where is the part of this that actually does the spawning? Aslo sRetTemplate is not beind defined anywhere. I had to declare it at the top so that the script would compile. So that first, if (sTemplate == "coastal_low"), won't really do anything from what I can see.
               
               

               


                     Modifié par GhostOfGod, 08 septembre 2010 - 04:32 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
NESS group script problems
« Reply #4 on: September 08, 2010, 05:31:33 am »


               grr...hit quote on accident. ':whistle:'
               
               

               


                     Modifié par GhostOfGod, 08 septembre 2010 - 04:33 .
                     
                  


            

Legacy_Kossuths_Will

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
NESS group script problems
« Reply #5 on: September 08, 2010, 05:50:55 am »


               its a script in the NESS spawning system, this function is actually a void() called by another function. I just posted that part because I know the other parts work fine, it is something with the ifs, variable setting, or case statements that is goofing up somewhere
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NESS group script problems
« Reply #6 on: September 08, 2010, 06:03:56 am »


               On the very first check you have.  



if (nRoll=1)    



It will always be true.  



Try

if (nRoll==1)
               
               

               
            

Legacy_Kossuths_Will

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
NESS group script problems
« Reply #7 on: September 08, 2010, 06:08:16 am »


               ugh, tried your version, same problem. nRoll = 7, yet it still calls in the water elemental, which shouldnt happen unless nRoll = 1. It should have spawned something in the case statement under nEncType==1, but no dice.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NESS group script problems
« Reply #8 on: September 08, 2010, 06:14:25 am »


               Just reposting it so I can see what is going on

int nRoll = d12();
int nMonster = d3();
int nEncType;
// determine encounter rarity
if (nRoll==1)
{ // very rare encounters
nEncType = 4;
nSpawnNumber = 1;
} else if (nRoll<4)
{
// rare encounters
nEncType = 3;
nSpawnNumber = 1;
} else if (nRoll<7)
{
// rare encounters
nEncType = 2;
nSpawnNumber = d3()+1;
}
else
{
// very rare encounters
nEncType = 1;
nSpawnNumber = d3(2); }
// Moonshaes - coastal encounters
if (sTemplate == "coastal_low")
{
//determine common encounter
if (nEncType==1)
{
if (nMonster==1)
{
switch (d4())
{
case 1: sRetTemplate = "eots_pirate001"; break;
case 2: sRetTemplate = "eots_pirate001"; break;
case 3: sRetTemplate = "eots_pirate002"; break;
case 4: sRetTemplate = "eots_pirate003"; break;
}
[/list]}
else if (nMonster == 2)
{
switch (d2())
{
case 1: sRetTemplate = "eots_beachdwell1"; break;
case 2: sRetTemplate = "eots_beachdwell2"; break;
}
[/list]}
else
{
switch (d2())
{
case 1: sRetTemplate = "eots_fish2"; break;
case 2: sRetTemplate = "eots_fish3"; break;
}
[/list]}
[/list]}
//determine uncommon encounter
else if (nEncType==2)
{
if (nMonster == 1)
{
sRetTemplate = "eots_waterbtl";
}
else if (nMonster == 2)
{
sRetTemplate = "zep_bird_030";
}
else
{
sRetTemplate = "eots_seaviper_s";
}
[/list]}
//determine rare encounter
else if (nEncType==3)
{
if (nMonster == 1)
{
sRetTemplate = "eots_waterspid";
}
else if (nMonster == 2)
{
sRetTemplate = "eots_crabg";
}
else
{
sRetTemplate = "eots_seaviper_l";
}
[/list]}
//determine very rare encounter
else if (nEncType==4)
{
if (nMonster == 1)
{
sRetTemplate = "zep_elemwaters";
}
else if (nMonster == 2)
{
sRetTemplate = "eots_umberlee001";
}
else
{
sRetTemplate = "giantsnake";
}
[/list]}
[/list]}
[/list]}


               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NESS group script problems
« Reply #9 on: September 08, 2010, 06:35:44 am »


               How are you testing it.    If you are doing a Test module From the toolset and have the script auto Firing when you enter.  You may just alway be getting the same 'random' numbers every time.  



Note: random numbers are not random.   random Numbers are built from a seed that produces a list of numbers.   First number in the list is the first random number. second number in the list is the second random number.   ect.    If you are running a test from the tool set you are most likely just pulling the same numbers every time.  



If that is not the Problem I would nee to the the top of the script.
               
               

               
            

Legacy_Kossuths_Will

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
NESS group script problems
« Reply #10 on: September 08, 2010, 06:43:46 am »


               ok why would it always be true? d12() should generate a random # between 1 and 12, so why would that always return true? not arguing, just curious so I know what I'm dealing with.



I tried entering the extra '=' in there but it is still always that blasted elemental lol.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NESS group script problems
« Reply #11 on: September 08, 2010, 06:49:48 am »


               It would always be true because you are saying: nRoll is equal to one as a statment. (=)

(==) asks the question: Is nRoll equal to one.

Edit:
(=) is an assignment operator.
(==) is a compairsion
               
               

               


                     Modifié par Lightfoot8, 08 septembre 2010 - 05:52 .
                     
                  


            

Legacy_Kossuths_Will

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
NESS group script problems
« Reply #12 on: September 08, 2010, 06:52:31 am »


               well i tested it by loading the module and playing as a regular character. i have the script whisper nRoll as a string via GetFirstPC and IntToString, and it's telling me a different number each time.

That said, what you are saying seems to be true. despite what the whisper says nRoll is, it's always the same monster. problem is nEncType shouldnt even allow that monster to spawn unless nRoll is 1.

not sure how much you know about the NESS spawning system, but the blurb of the script above is part of a script that is called by another script. the reason i only included that part is because it's the only part that i altered, it works perfectly otherwise. is there any difference between using d12() and perhaps random(11)+1?. it sounds like from what you are saying that even though i am trying to tell the script to randomly choose between 1 and 12, it is always choosing 1. i think you are right i just don't know how to fix it. Perhaps a 'return;' somewhere would fix this? I am lost, i thought it would be pretty straightforward, but this script has been mopping the floor with me ':blink:'
               
               

               


                     Modifié par Kossuths_Will, 08 septembre 2010 - 05:54 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NESS group script problems
« Reply #13 on: September 08, 2010, 07:06:07 am »


               But once you say:
if (nRoll=1)

It does not matter what nRoll was equal to before. you just gave it a value of 1.

I edited my answer above. To give more information.

To put the statment into english you are saying. Make nRoll equal to 1. If nRoll is True (1) do this.



EDIT: I am assuming that this is an include File in For your script?   Are you recompileing  the main script after you make changes to this one.    Also Are you making sure you save the include befor recompiling.  If you recompile without saving the Include.  the main script is still getting compiled with the file that is saved to the disk. not the edited version that is open in the script editor.
               
               

               


                     Modifié par Lightfoot8, 08 septembre 2010 - 06:11 .
                     
                  


            

Legacy_Kossuths_Will

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
NESS group script problems
« Reply #14 on: September 08, 2010, 07:09:16 am »


               gotcha, but i did put in the == and the same thing happens. also like i said, the string spoken that nRoll is converted to is always different. why would it, for example, be telling the PC that nRoll was 4 when it was really 1, resulting in the elemental?

yes i have been re-compiling the script calling it after altering it. jeez this seems like it should be cake, i can't believe it's this difficult to get a random encounter set up ':pinched:'
               
               

               


                     Modifié par Kossuths_Will, 08 septembre 2010 - 06:13 .