Please Help Support E-Mods.net by Donating

e-mods.net

  • 2017-11-17, 15:02:43
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Looking for VTMR Modding Tutorials? Check out the Open Nod Development section of e-mods.net.

Author Topic: Need help with scripts  (Read 3113 times)

Barnabas

  • Member
  • *
  • Karma: 3
  • Offline Offline
  • Posts: 125
Need help with scripts
« on: 2011-02-28, 10:32:06 »

Hi all,

I made some conversations for my maps. Some of them work as planned, but I had to write an own script for every conversation and add them to NPCs in the NOTEditor to make them work. I tried to use Javo´s tutorialscripts with the strings, but they didn´t work. When I tried to add the scripts to a NPC with override in Embrace, the scripts didn´t work, so I had to add them in NOTEditor.
Now I wanted to write a script, that has some variables, so that I only need one script for all of my conversations. All I want to do is to add the script in Embrace to a NPC and set the conversation files in the codex linker. For that I wrote the following script:

public class StartConvo extends Codex
{
   public StartConvo(String convoFile, String convoGiveName)
   {
      this.convoFile="";
      this.convoGiveName="";
   }   
   public void clicked (int guid, int clickerGuid, int captureID)
   {
      ExecuteConversation(clickerGuid, guid, convoGiveName, convoFile, CONV_XFLAG_WANTFEEDBACK);
}
public void convreached(int starterGuid, int curEvent, int curLine, int lineDuration, int speakerGuid)
{
   CodexCamera.SetupCutscene(starterGuid, GetClassThing(), 0);
   CodexCamera.SetShot(starterGuid, CAM_SHOT_POV_A, CAM_ANGLE_HIGH, CAM_DIST_MEDIUM, 1, 0);
}
public void convended(int starterGuid,  boolean bAborted , int returnValue)
{
   CodexCamera.Release(starterGuid);
}
private String convoGiveName;
private String convoFile;
public static String _params[] = {
    "Conversation Name", "Conversation File (NCO)"
};
}


Eclipse didn´t find an error, but the script does not work. I added it to a talkable NPC, set the conversationfile via codex linker, started the chronicle (after full export of course...), went to the NPC, clicked on him and .... nothing.

What did I do wrong? Please help.


Logged
Sorry for my bad english ...

Signothorn

  • Team
  • Member
  • ******
  • Karma: 3
  • Offline Offline
  • Posts: 163
Re: Need help with scripts
« Reply #1 on: 2011-03-01, 21:55:59 »

Hopefully someone knowledgeable will be able to help you. Idk if you knew this but Jav lost his internet so he won't be around much for a while, didn't want you to think he's ignoring you.
Logged

Barnabas

  • Member
  • *
  • Karma: 3
  • Offline Offline
  • Posts: 125
Re: Need help with scripts
« Reply #2 on: 2011-03-02, 08:55:28 »

Thanks for telling me that :-D - was afraid, that I was bugging Javo too much with my problems in the past^^
Logged
Sorry for my bad english ...

Barnabas

  • Member
  • *
  • Karma: 3
  • Offline Offline
  • Posts: 125
Re: Need help with scripts
« Reply #3 on: 2011-03-06, 04:39:13 »

I really can´t imagine, what´s wrong with that script.Why doesn´t it work?
Logged
Sorry for my bad english ...

Javokis

  • Horses Dick
  • Member
  • *****
  • Karma: 21
  • Offline Offline
  • Posts: 2373
    • E-Mods.net
Re: Need help with scripts
« Reply #4 on: 2011-03-06, 13:08:40 »

Your script should be working. The only thing I can think of is that ExecuteConversation can't find the nco file and/or convo name in the nco file. Make sure you're implicitly imputing filename.nco (include the nco extension). Also make sure the nco file is in the right location. Make sure you stick with ansi for the file names because the engine wont read them in UTF-8.

[edit]

Oh... just noticed this:

public StartConvo(String convoFile, String convoGiveName)
   {
      this.convoFile="";
      this.convoGiveName="";
   }   

You're setting convoFile and convoGiveName to an empty string. If you want it to work in codex linker you need to do this:

public StartConvo(String convoFile, String convoGiveName)
   {
      this.convoFile=convoFile;
      this.convoGiveName=convoGiveName;
   }   

The script you had before always set the values to an empty string no matter what you put in codex linker.
« Last Edit: 2011-03-06, 13:17:40 by Javokis »
Logged
"There's nothing wrong with horses dicks, there's nothing wrong with sucking horses dicks." -Signo

Barnabas

  • Member
  • *
  • Karma: 3
  • Offline Offline
  • Posts: 125
Re: Need help with scripts
« Reply #5 on: 2011-03-06, 14:04:46 »

Ok, the scrips looks now like this:

public class StartConvo extends Codex
{
   public StartConvo(String convoFile, String convoGiveName)
   {
      this.convoFile=convoFile;
      this.convoGiveName=convoGiveName;
   }   
   public void clicked (int guid, int clickerGuid, int captureID)
   {
      ExecuteConversation(clickerGuid, guid, convoGiveName, convoFile, CONV_XFLAG_WANTFEEDBACK);
}
public void convreached(int starterGuid, int curEvent, int curLine, int lineDuration, int speakerGuid)
{
   CodexCamera.SetupCutscene(starterGuid, GetClassThing(), 0);
   CodexCamera.SetShot(starterGuid, CAM_SHOT_POV_A, CAM_ANGLE_HIGH, CAM_DIST_MEDIUM, 1, 0);
}
public void convended(int starterGuid,  boolean bAborted , int returnValue)
{
   CodexCamera.Release(starterGuid);
}
private String convoGiveName;
private String convoFile;
public static String _params[] = {
    "Conversation Name", "Conversation File (NCO)"
};
}


Unfortunally it still doesn´t work.

Make sure you stick with ansi for the file names because the engine wont read them in UTF-8.



Hmm - what do you mean with this? What´s UTF-8?
« Last Edit: 2011-03-06, 14:07:13 by Barnabas »
Logged
Sorry for my bad english ...

Javokis

  • Horses Dick
  • Member
  • *****
  • Karma: 21
  • Offline Offline
  • Posts: 2373
    • E-Mods.net
Re: Need help with scripts
« Reply #6 on: 2011-03-06, 15:14:07 »

That means the files need to be in ENGLISH. Engine can't read a file name in a foreign language. The only place foreign languages will work is inside an nls file and only if that nls file name is in English.
Logged
"There's nothing wrong with horses dicks, there's nothing wrong with sucking horses dicks." -Signo

Barnabas

  • Member
  • *
  • Karma: 3
  • Offline Offline
  • Posts: 125
Re: Need help with scripts
« Reply #7 on: 2011-08-01, 21:17:32 »

Does a script exist, that plays random sounds from a defined stock of sounds?
Logged
Sorry for my bad english ...

Paine

  • Member
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 23
Re: Need help with scripts
« Reply #8 on: 2011-08-02, 10:30:11 »

Does a script exist, that plays random sounds from a defined stock of sounds?

This should work:
Code: [Select]
import java.io.BufferedReader;
import java.io.FileReader;

import java.util.Vector;

public class ItemRandomSound extends Codex
{
Vector sounds = new Vector();

public ItemRandomSound()
{
try
{
String line = "";
BufferedReader reader = new BufferedReader(new FileReader("randomsounds.txt"));
while((line = reader.readLine()) != null)
        sounds.add(line);
reader.close();
}
catch(Exception e)
{
}

}

public void clicked(int guid, int clickerGuid, int captureID)
{
int random = (int)Math.random() * sounds.size();
String soundName = (String)sounds.elementAt(random);
CodexSound.StartMusic(soundName, 100 );
}
}
Logged

Barnabas

  • Member
  • *
  • Karma: 3
  • Offline Offline
  • Posts: 125
Re: Need help with scripts
« Reply #9 on: 2011-08-04, 23:59:25 »

Looks interesting - unfortunally, I do not really understand that script  ::) How am I able to use this?
Logged
Sorry for my bad english ...

Paine

  • Member
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 23
Re: Need help with scripts
« Reply #10 on: 2011-08-06, 01:50:55 »

Looks interesting - unfortunally, I do not really understand that script  ::) How am I able to use this?

You need to compile it with the java development kit (output must be JRE 1.1 compliant) this will produce a .class file which goes in the Codex folder.
In the main vampire directory you need to create a .txt file called "randomsounds.txt".
In the random sounds.txt you should have sounds listed like:
randomsound1.mp3
randomsound2.mp3
randomsound3.mp3 etc..
Then you'll need to create a prop with the not editor, attach the ItemRandomSound script and make sure it's clickable.

All the sound files will need to go in Sounds\Music.
Logged
 

Page created in 0.073 seconds with 19 queries.