Aller au contenu

Photo

NESS group script problems


  • Veuillez vous connecter pour répondre
18 réponses à ce sujet

#1
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
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 .


#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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. ;)

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


#3
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
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.

#4
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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 .


#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
grr...hit quote on accident. :whistle:

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


#6
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
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

#7
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
On the very first check you have.



if (nRoll=1)



It will always be true.



Try

if (nRoll==1)

#8
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
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.

#9
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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]}



#10
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.

#11
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
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.

#12
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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 .


#13
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
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 .


#14
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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 .


#15
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
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 .


#16
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
I dont know. I can not tell because i do not see where you have it at. If it was before your If statment that is changing the value of nRoll the answer is that it was not changed to 1 yet.



Sorry added more above again .


#17
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Ok but have you also been saving the Include before recompiling.

Edit.  I need to get some sleep.  If you donnt get it fixed by tomorrow.  Ill download it and see what i can see.  

Hopfully someone who knows the system better will come along in the mean time.

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


#18
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
I think I got it figured out, thanks. I was indeed saving the include before re-compiling, and I did a complete mod build and the == seems to have been the difference so thanks, i would have never thought of that. i'll be back if things still end up not working right ;-)

#19
Kossuths_Will

Kossuths_Will
  • Members
  • 14 messages
ok so with 1 creature its fine, but if it spawns more than 1 creature, it can spawn something from any of the nEncType parts. The way it SHOULD work is that if it spawns multiple creatures, all of those creatures are limited by the nEncType. So I guess basically that part of the script is doing absolutely nothing.