• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Small Help Needed?

This is the other side of the coin from the projects thread.
Please post here if your small mod (or big project, or whatever) has run into a little snag and you need help.

Please don't post big things like, "our project needs a `full-time` texturer/coder/whatever", but small things like "this bloc of code crashes POTC. Any ideas?" or "I've got this texture `half-done`, but it needs some work. Any ideas?" or "How do I..."
 
Without this line, things work. With this line, things crash. This is a global.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->bool bQuicksaving = false;<!--c2--></div><!--ec2-->
So I don't get it. I'm not useing it, I'm not referencing it; it's just sitting there. It crashes with some error message about 'Ghost A Reference'.

Is there something else I have to do to create a global variable? This is a wee bit frustrating... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/urgh.gif" style="vertical-align:middle" emoid=":urgh" border="0" alt="urgh.gif" />
 
Hmm.
That _is_ weird.
It's in globals.c, or something directly #included?
There are plenty of bool xxx = true / false, so it should work.
Have you tried appending some random numbers to the name, to be sure it's unique? (Though in a quick grep I didn't notice any other references).
 
I tried globals.c, I tried seadogs.c, and I tried in something I included.

I've also tried changing the name, it didn't work either. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /> And yeah, I also checked for uniqueness, and didn't find anything by the same name.

So yeah, I'm a little confused about this. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/huhh.gif" style="vertical-align:middle" emoid=":eek:k" border="0" alt="huhh.gif" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/oops3.gif" style="vertical-align:middle" emoid=":eek:ops2" border="0" alt="oops3.gif" />
 
I'm not sure why it was happening with the boolean there, but it turns out that the boolean had nothing to do with it.
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/bookish.gif" style="vertical-align:middle" emoid=":mm" border="0" alt="bookish.gif" />
I think I've figured out what the 'ghost reference' messages mean; I've updated the Wiki accordingly:

<a href="http://robotsdontbleed.com/wacko/wakka.php?wakka=GhostReferences&v=788" target="_blank">http://robotsdontbleed.com/wacko/wakka.php...eferences&v=788</a>

As I find stuff of note I'll continue putting it there.

At some point, it might be worth the time to start a 'documenting project' but frankly I think most of us are more interested in coding than in documenting. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/pirate2.gif" style="vertical-align:middle" emoid=":p:" border="0" alt="pirate2.gif" />
 
Nathan, thanks for offering this! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />

I've been wondering about the random item variables for my sneaky trader mod. He's a walking vendor, and has about twenty items to offer - I only want him to actually carry about ten. SOME of these items should be more rare than others.

This is the original code for a walking vendor:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->  case "Items":

     if(CheckAttribute(Pchar, "quest.tutorial.Spyglass"))

     {

   TakeNItems(Npchar,"blade1", Rand(4)+1);

   TakeNItems(Npchar,"blade2", Rand(4)+1);

   TakeNItems(Npchar,"blade3", Rand(4)+1);

   TakeNItems(Npchar,"blade4", Rand(4)+1);

   TakeNItems(Npchar,"blade5", Rand(4)+1);



   TakeNItems(Npchar,"spyglass2", 1);

   TakeNItems(Npchar,"potion1", Rand(10)+1);

   TakeNItems(Npchar,"potion2", Rand(3)+1);

   

   TakeNItems(Npchar,"jewelry1", Rand(4)+1);

   TakeNItems(Npchar,"jewelry2", Rand(4)+1);

   TakeNItems(Npchar,"jewelry4", Rand(4)+1);

   TakeNItems(Npchar,"indian4", Rand(4)+1);

   TakeNItems(Npchar,"indian13", Rand(4)+1);

   

     //    DeleteAttribute(Pchar, "quest.tutorial.Spyglass");

     }

     else

     {

   if (npchar.quest.Meeting != lastspeak_date)

   {

       GiveItemToTrader(npchar);

       npchar.quest.Meeting = lastspeak_date;

   }

     }

     NextDiag.CurrentNode = NextDiag.TempNode;

     DialogExit();



     LaunchItemsTrade(NPChar);

 break;<!--c2--></div><!--ec2-->And this is what I fiddled together but have not tested yet.:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->  case "Items":

     TakeNItems(Npchar,"lockpick", Rand(4)+1);

     TakeNItems(Npchar,"prybar", Rand(4)+1);

     TakeNItems(Npchar,"compass", Rand(4)+1);

     TakeNItems(Npchar,"deed", Rand(4)+1);



     TakeNItems(Npchar,"corvette", Rand(4)+1);

     TakeNItems(Npchar,"idol3", Rand(3)+1);

     TakeNItems(Npchar,"stolen1", Rand(10)+1);

     TakeNItems(Npchar,"stolen2", Rand(3)+1);

   

     TakeNItems(Npchar,"sword", Rand(4)+1);

     TakeNItems(Npchar,"gun", Rand(4)+1);

     TakeNItems(Npchar,"idol1", Rand(4)+1);

     TakeNItems(Npchar,"idol2", Rand(4)+1);



     TakeNItems(Npchar,"map", Rand(4)+1);

     TakeNItems(Npchar,"keys", Rand(4)+1);

     TakeNItems(Npchar,"stolen3", Rand(4)+1);

     TakeNItems(Npchar,"stolen4", Rand(4)+1);



     TakeNItems(Npchar,"wallet", Rand(4)+1);

     TakeNItems(Npchar,"map2", Rand(4)+1);

     TakeNItems(Npchar,"map3", Rand(4)+1);

     TakeNItems(Npchar,"map4", Rand(4)+1);



     Diag.CurrentNode = Diag.TempNode;

     DialogExit();



     LaunchItemsTrade(NPChar);

 break;<!--c2--></div><!--ec2-->Right now the rand numbers don't really mean anything to me. Please, can you explain to me how they work so I can do this correctly?

Thanks! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" />
 
I have updated the wiki to document the 'rand' function; perhaps this will clear things up a bit. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

<a href="http://robotsdontbleed.com/wacko/wakka.php?wakka=FunctionList&v=113z" target="_blank">http://robotsdontbleed.com/wacko/wakka.php...tionList&v=113z</a>

I'm guessing that it does +1 to get rid of the zero return value. So, rand(4)+1 means a number from: 1, 2, 3, 4, 5.
 
Thanks a lot for contributing to the Wiki <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" /> Keep it up and the Wiki may one day become the "documentary project" <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" />
 
Thank you, David... I prefer to come to a lot of these coding answers myself, with a slight nudge in the correct direction, because that means I LEARN something instead of being lazy and asking someone to do it for me.

Unfortunately though, that was not much of a clue for <i>me.</i> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /> I am *still* a coding newbie, <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> and I do not understand what this rand stuff does. Numbers are all well and good, and I understand 4+1, that's easy enough. But what does it do in this instance?

Perhaps I should have asked more specifically...

I want to make some of these items more rare than others in the random choice of ten (or maybe even six) items out of twenty.

What comand here will give me a random choice of ten (or six) items out of twenty?

How do I use these numbers to make some of these items rarer than others?

I would like to understand this *myself* so I can change my mind about this function in the middle of the night and not have to come here and ask someone to do it for me. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />

Thanks! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" />
 
Certainly. These functions aren't actually making items more or less rare; they are determining the *quantity* of items.

It seems that what you want to do is always have the same quantity (10, or 6) from a 'pool' of 20, but that some of these items have more chances to appear than others.

Unfortunately, I don't believe there's a command that will do this for you straight away. You'll have to do it the hard way, that is, by using the mathematics of probability to determine if something appears. I know that sounds complicated and ominous but it isn't. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/pirate2.gif" style="vertical-align:middle" emoid=":p:" border="0" alt="pirate2.gif" />

Let me try to explain it in general terms before actually talking about programming it (which is usually more complicated since you have to express things in the specific language, instead of English... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" /> )

So we have a collection of objects we want to draw from. Let's call this our 'pool'. Each object has a number interval associated with it, which determines how 'rare' it is.

For starters, let's say our pool has 10 objects in it. Each object occupies a range of 10, so, there is an equal probability to get each object.
Object 1: 0...9. Object 2: 10...19. Object 3: 20...29. etc.

So, let's assume we want to pick 3 objects. We simply have to roll a `100-sided` die three times, and when we get the result, we go look in our set and see which range we landed in.

Alright, now for a more complicated example - but it's really the same thing. Our pool is now of size 20. You assign a number range to each object, and then we roll the dice as many times as needed.

Here is some `pseudo-code`:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->while ( we haven't reached the number of items wanted )

{

    int num = rand(99); // 0 to 99, inclusive

    string itemName = GetItemFromProbability(num);

    TakeNItems(Npchar, itemName, 1);

}



// somewhere else in the code...



string GetItemFromProbability(int num)

{

    if ( num >= 0 && num <= 9 )

 return "blade1";

    if ( num >= 10 && num <= 19 )

 return "jewelry1";

    ...

}<!--c2--></div><!--ec2-->

I hope this clears things up. The hard part now is getting it into code just as you want it. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Let me know if you have any other questions. As you said, it is <b>much</b> better to learn for yourself, ask all the questions and sludge through it, than it is to have somebody do it for you and not learn anything in the process.
 
Thanks, David, yes, that's much clearer! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" /> Now I'll be able to do some testing from this end to see how much of that sunk into my feeble cerebral tentacle. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />

A small bit of background on my experiences with code - I make websites - can write html in notepad if necessary, as I know what it means and how to use it without any macros or wysiwyg programs to do it for me. I am `self-taught` in CGI scripting (to a very small degree), most of which comes from looking at the code and understanding what it does and then repeating it where I can put it to use. No real formal training for either, just picked it up.

Same with PotC code. If you'd asked me in January of this year if I'd ever find myself doing this, I'd have laughed and said, ME??? NO WAY!

I used to look at code (cgi & anything else) as extensions of mathematics, a subject I was only average in, after a lot of hard work, in high school. The sight of code (or calculus!) used to turn my brain into an aching pretzel and I'd just lock up.

It was a major accomplishment to me that I bulled my way through a cgi script and altered it to do what I needed it to do ON MY OWN.

I've looked at code much differently since then. I treat PotC code as a giant puzzle, one that, if I can take the correct pieces and interlink them, will turn out a fairly workable end product. I am quite proud that I was able to turn out the Fred Bob quest without much more than what has been listed publicly on how to work with PotC coding and some hints from the boards here.

My main talent is with texturing as I am a graphics artist, however the code has taken a stranglehold on me, and I find myself wanting to dig back into it if I am away from it for too long... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" />

It's no mistake that I made this smiley and titled it "Modding" --> <img src="http://www.ganotherapyusa.com/extras/modding.gif" border="0" class="linked-image" /> There <i><b>is</b></i> a very fine line between "hobby" and "mental illness"! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />
 
I'm glad that I could help. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Hey, I think your way of proceeding is a fine way to do it. It's how I learned, in any case.

I started out in 1991 with dinky little 10 line programs in QBasic and slowly, slowly moved up to dinky little programs in Visual Basic. Of course, they were highly cool at the time! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" /> My parents are both computer scientists so I admit to having some predisposition since computers have always been around in my world. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

I then discovered 'modding' in 1997 at age 13 with the Star Wars games. At first it wasn't actually proper code, but editing binary files, tweaking values here and there. That was before games were scripted. I think discovered Jedi Knight and Quake 2 - both of these games are highly scripted, and Quake 2 somewhat more so than PotC. In fact, scripting isn't even the right term for Quake2, since you actually wrote *real* C code which you then compiled into a DLL, which represented the game logic called by the core engine.

Anyways, Jedi Knight uses a language called 'Cog', with a syntax somewhat similar to C but with even more differences than `PotC-C`. However, since the differences are much more obvious, it's easier to realize that you're not actually writing C code.

I learned by doing just what you said - looking at other people's code for simple things and trying to piece together how it worked. From there, I made my own modifications which, most of the time, did not work. :<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/cool.gif" style="vertical-align:middle" emoid="8)" border="0" alt="cool.gif" /> After some time I started getting the hang of it, and to be honest my first step into the 'real programming world' was with real C code in Quake 2. Having my parents around to learn from certainly didn't hurt anything.

Mathematics and programming are actually quite similar in methodolgy: both are extremely, unforgiveably logical. Programming allows no mistakes. You can't say "well that's what I <i>meant</i>..." The computer won't let you get away with that. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/no.gif" style="vertical-align:middle" emoid=":no" border="0" alt="no.gif" /> But your comparison to a puzzle is I would say spot on; a program is nothing more than a giant puzzle, and to write code means to put the pieces together and/or create new pieces that fit where you need them.

Sorry for rambling a bit. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/oops3.gif" style="vertical-align:middle" emoid=":eek:ops2" border="0" alt="oops3.gif" /> I love programming so if I get started on it I can go on forever. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" /> The short version of all of this is to say more power to you! Don't be afraid to make mistakes and most importantly have fun! May you find what you seek. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/keith.gif" style="vertical-align:middle" emoid=":keith" border="0" alt="keith.gif" />
 
Oh... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /> I'm supposed to have fun? <img src="http://www.ganotherapyusa.com/extras/modding.gif" border="0" class="linked-image" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />

Durnit, I'm gonna put my modding smiley in the queue! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" />
 
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />
Can't wait for use it
<img src="http://www.ganotherapyusa.com/extras/modding.gif" border="0" class="linked-image" />
 
Heck yeah, if you don't end up having fun then you won't learn as much. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> It's not supposed to be painful! (Well, it can be painful in the short term, as long as the rewards are great... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/pirate2.gif" style="vertical-align:middle" emoid=":p:" border="0" alt="pirate2.gif" />)
 
AIShip.c, at the top, change the MAST_XXXX_SCL values, they are scalars for the different things that hit the mast.
(Note that damage is also scaled based on cannon caliber and target ship's size)
 
Eventually, yes. That _is_ the point, after all. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
Those values are so you can change how many shots it takes for each type of ammo.
 
Before I used Build 11 it took 5000 - 10000 to increase my rep.

With Build 11 it took 1,000,000 to increase my rep. from swindler to neutral....

How can you change the amount of money you have to donate to church to increase your rep.?
 
Back
Top