• 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!

AOP programming thread

Calvert

Landlubber
So far i've found several interresting code bits.

Ive found out how to add characters to the city and make them talk to you, also do simple actions. Ill post more extensive about it later when ive played around with it some more.

It seems that to make a quest for example you need:
- A character with a linked dialog file.
- A script sequence for the outcome of the dialog
- An attached AI controller for more advanced use of the npc's

This seems to be the general attitude in the scripting, even though some times they ignore their own principle and script directly in the dialog files. <img src="style_emoticons/<#EMO_DIR#>/modding.gif" style="vertical-align:middle" emoid=":modding" border="0" alt="modding.gif" />


I have a few problems that maybe someone can help with.

1) Has anyone found out how to script an attack? Ive searched high and low in the files how you after a dialog session switch to the npc attacks the character.

2) The LandEncouner files, it seems that this area can be used to make random events, ie in the jungle. But I cant get anything to activate out there. Anyone have some positive experience with the Landencounter folder?



Ive come quite some way in the last 5-6 hours, so hopefully next week i can present some real stuff for the game.

Feel free to add comments or tips and tricks for the script modding of the game. (Beware that im a designer not a programmer though. <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /> )
 
great news, always wonderfull to hear that others are working on it to. I to been playing around with it, however i did not have much time to work on it as we are also designing our own pirate game which also takes a lot of time and yes im a programmer (developer) but not such great with graphics design we have others for that, everyone has it's own field he blinks out in . In any case thanks for helping out im sure u will be getting wonderfull new characters in the jungle and other places.
 
How were you able to add new chracters the towns?, I have a vague idea of how it could be done, but my interest is primiarly giving the citizens and soldiers new voices.
 
oh boy, this is gonna be a kickass game with everyone do so much modding, the supermod with all new additions is gonna be a big one lol.
 
ARGGGGG!

Theres no consistence in the scripting what so ever. Theres no list of npc actions and theres no place to "copy" their behaviour. Theres no english comments in the quest/script directories and im getting fed up with this bs.

Sorry for my rant - but i've tried most of the day to get one character to behave in different ways - but im constantly running into a brick wall on numerous issues. <img src="style_emoticons/<#EMO_DIR#>/modding.gif" style="vertical-align:middle" emoid=":modding" border="0" alt="modding.gif" />
 
HELL YEAH!

I just cracked it!!!



Ive scripted a pirate to attack you depending on what reply you give to him! It dosnt seem as much I know, but its a maaaajor step towards everything else scripted in the game.



All it took was half a bottle of red wine (tonight) and 10 hours of solid reading through the code.
 
lol congrats mate, let us know how u did and make something cool that we can add to the mod, at least it would be great if u can get something working in the jungles.
 
<!--quoteo(post=164039:date=Sep 27 2006, 12:26 AM:name=Cyberops)--><div class='quotetop'>QUOTE(Cyberops @ Sep 27 2006, 12:26 AM) [snapback]164039[/snapback]</div><div class='quotemain'><!--quotec-->
lol congrats mate, let us know how u did and make something cool that we can add to the mod, at least it would be great if u can get something working in the jungles.
<!--QuoteEnd--></div><!--QuoteEEnd-->


Alrigjht - my initial thought about it was correct.

You need to make a Script file, a dialog file and a 'quest situation'.


Heres the deal for a Pirate attacking you in the farm field outside Bridgetown (mind you i have edited Bridgetown to have a farm field instead of the duel field. Ill work on a mod for the Super mod soonish):

farmduel.c (placed in the script folder)
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
void FarmDuel()
{
    ref chr = CharacterFromID("dueler13");
    LAi_SetHP(CharacterFromID("dueler13"), 30.0, 30.0);
    LAi_SetActorType(chr);
    LAi_ActorAttack(chr, pchar, "");
    
    
}
<!--c2--></div><!--ec2-->

To register a script you have to place a string in scripts/utils.c
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
#include "scripts\farmduel.c"
<!--c2--></div><!--ec2-->

In the Characters/Init/Barbados.c: (This is the actual character you meet)
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
    makeref(ch,Characters[n]);        // Dueler
    ch.id        = "dueler13";
    ch.model    = "citiz_1";
    ch.sex = "man";
    ch.greeting = "soldier_arest_1";
    ch.location = "Bridgetown_FarmField";
    ch.location.group = "rld";
    ch.location.locator = "aloc1";
    ch.Dialog.Filename = "dueler1.c";
    ch.nation = PIRATE;
    LAi_SetCitizenType(ch);
    LAi_RemoveLoginTime(ch);
    LAi_group_MoveCharacter(ch, "PIRATE_CITIZENS");
    LAi_SetImmortal(ch, false);
    GiveItem2Character(ch, "blade1");
    LAi_CharacterReincarnation(ch, true, true);
    EquipCharacterByItem(ch, "blade1");
    n = n + 1;
<!--c2--></div><!--ec2-->

In the dialogs/english/dueler1.c
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
void ProcessDialogEvent()
{
ref NPChar;
aref Link, NextDiag;

DeleteAttribute(&Dialog,"Links");

makeref(NPChar,CharacterRef);
makearef(Link, Dialog.Links);
makearef(NextDiag, NPChar.Dialog);

switch(Dialog.CurrentNode)
{
case "First time":
dialog.text = = "Hey you! What are you doing here?";
link.l1 = "uhm... just going for a walk, ill get out of your hair.";
link.l1.go = "exit";
link.l2 = "Are you talking to me! I'll kill you for talking like that to me";
link.l2.go = "fight1";
NextDiag.TempNode = "First time";
break;

case "Exit":
NextDiag.CurrentNode = NextDiag.TempNode;
DialogExit();
break;

case "Fight1":
NextDiag.CurrentNode = NextDiag.TempNode;
AddDialogExitQuest("Farm_Duel");
DialogExit();
break;
}
}
<!--c2--></div><!--ec2-->

The last thing is to place the executioner for the AddDialogExitQuest in the quests/quests_reaction.c
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
case "Farm_Duel":
    FarmDuel();
Break;
<!--c2--></div><!--ec2-->


Theres a bug in the code though. When you use the LAi_ActorAttack it dosnt display the healthbar and energy, im working on that as well but I think its a hardcoded error from Akella, since Ive seen numerous places where that command has been commented out and replaced with some rather dodgy work arounds.

All this really dosnt do anything but get you attacked if you choose the wrong answer for this feller, but its a rather big step towards finding out how the whole Quest/Dialog/Script programming is build. From here on it should be more easy to create scripted events for the game.
 
Calvert, where you able to figure out how citizens and soldiers just seem to randomly spawn in towns? Id like to add new voices but it seems like the only way to is by adding them to the chracters/init files.
 
Just started investigating the program files myself. Just kind of browsing, seeing if I can spot anything glaring. **grins**

Some things I'd like to see us attempt to add to the game are items such as follows:

New area map (Custom designed map, with a much larger range of locations. If at all possible doing all of the caribbean, parts of the gulf of mexico and at least a small portion of the southern US like florida and some of the other states close to that area.)

Possibly adding some new 'factions' to the game, possibly 'gangs' of pirates, so you can possibly get involved with inter-pirate conflicts and missions.

A whole pile of additional ship models and types. The 18 we have available is nice, but would be real nice if we could have custom models for each of the political entities. Slightly different from each country, with pirates using a random sampling of everyones ships.

Adding in some additional ship mods and hopefully doing some historical research and correcting any glaring errors we notice with the current set of ships mods.

Anyhow, theres a beginning set of ideas, I'll add more in future as I think of them.

Cap'n Drow
 
I think our next to aid in reprogramming might be the need for a list of normally used commands and what they mean so we all don't have to pour though the code to understand everything by context.

For example we understand the "<" and ">" as less than and greater than. "=" is equal. But what is "==" ?
What about "!=" ?

"//" means ignore what comes after for the program.
"void" means to undo the previous reference binding done of the name that follows i.e. "string sQuest=soandso" would later be followed by "void sQuest" to remove that connection.
"ref" means to have it look for the last time the word following it was defined.

What does "aref" mean? "sti" ?

Anyone got a better list?
 
Sorry but in c < and > do not always mean less and greater then, to explain exactly what everything means would be writing a programming manual, i suggest if u want to learn how to program u pick up one of the self teaching guides that are available for download as pdf format
 
<!--quoteo(post=165714:date=Oct 5 2006, 09:18 PM:name=Cyberops)--><div class='quotetop'>QUOTE(Cyberops @ Oct 5 2006, 09:18 PM) [snapback]165714[/snapback]</div><div class='quotemain'><!--quotec-->
Sorry but in c < and > do not always mean less and greater then
<!--QuoteEnd--></div><!--QuoteEEnd-->
It doesn't? I have been the modpack compiler for the PotC Build mod for over a year and the only use of < and > I know of in C is as less and greater than. Could you give an example of another possible meaning?

<!--quoteo(post=165710:date=Oct 5 2006, 09:01 PM:name=windwolf7)--><div class='quotetop'>QUOTE(windwolf7 @ Oct 5 2006, 09:01 PM) [snapback]165710[/snapback]</div><div class='quotemain'><!--quotec-->
For example we understand the "<" and ">" as less than and greater than. "=" is equal. But what is "==" ?
What about "!=" ?
<!--QuoteEnd--></div><!--QuoteEEnd-->
"=" is used when a variable is set. For example: int number = 1;
This line will make an integer (nondecimal number value) called "number" and set it to 1.

"==" is used in if constructions. For example: if(number == 1)
This line will check if the "number" value (as set in previous example) is 1.

"!=" means "is not" and is used in if constructions. For example: if(number != 1)
This line will return "true" if "number" is NOT 1.

"sti" means "string to integer". At some places in the program numbers are stored as strings. Strings are basically text. However, you can't calculate with strings. You need to calculate with floats (decimal number value) and/or integers (nondecimal number value).
For example: string stringvalue = "1";
If you now want to calculate with the string, you must use sti to convert it to an integer with which you can do calculations:
if(sti(stringvalue) + 1 > 1)
if(stringvalue + 1 > 1) wouldn't work, because "stringvalue" is a string and not an integer.

Please see attached file. That might explain a lot more than I just did. Please note that this file comes from the PotC Build mod and that things might work slightly different in AoP.
 
Thanks a lot, Boelen!

I didn't realize this was C programing. I just thought it was the data sets used by the program. A data driven program. I thought these were used to make modding easier. Hmph. Forgive my noobness.

But given I already started learning some, do you have any recommendations on the downloadable pdfs your mentioned cyberops? I really like to learn more to aid in further modding.
 
here u go it's just 1 pdf book but hey it's a start and might help u to lay down your roots in programming. It was the only one i could find this fast in my collection.

<a href="http://rapidshare.de/files/35703314/Visual_C_2005_-_How_to_Program__2nd_Edition.chm.html" target="_blank">http://rapidshare.de/files/35703314/Visual...dition.chm.html</a>
 
<!--quoteo(post=165835:date=Oct 6 2006, 08:41 AM:name=Cyberops)--><div class='quotetop'>QUOTE(Cyberops @ Oct 6 2006, 08:41 AM) [snapback]165835[/snapback]</div><div class='quotemain'><!--quotec-->
here u go it's just 1 pdf book but hey it's a start and might help u to lay down your roots in programming. It was the only one i could find this fast in my collection.

<a href="http://rapidshare.de/files/35703314/Visual_C_2005_-_How_to_Program__2nd_Edition.chm.html" target="_blank">http://rapidshare.de/files/35703314/Visual...dition.chm.html</a>
<!--QuoteEnd--></div><!--QuoteEEnd-->

Thanks alot!
 
Back
Top