Jump to content

Home

Credit give and recive


Tomb King

Recommended Posts

Originally posted by Tomb King

Is there a script that you can attach to dialogue to give or recive credits?

 

There is a standard script in TSL called "a_givecredits" that exists for that purpose. Attach it to the dialog node of your choice, and set the first script parameter (P1 if you are using the DLG Editor) of that dialog node to the number of credits you wish to give.

Link to comment
Share on other sites

Originally posted by stoffe -mkb-

There is a standard script in TSL called "a_givecredits" that exists for that purpose. Attach it to the dialog node of your choice, and set the first script parameter (P1 if you are using the DLG Editor) of that dialog node to the number of credits you wish to give.

Any thoughts on how you could use this script (or one similiar to it) to change the amount of credits you win playing Pazaak? I checked the various dialogs, but was unable to find the a_givecredit script, which leads me to suspect that some action within each "play pazaak" script (all compiled :() determines winnings.
Link to comment
Share on other sites

Originally posted by Achilles

Any thoughts on how you could use this script (or one similiar to it) to change the amount of credits you win playing Pazaak? I checked the various dialogs, but was unable to find the a_givecredit script, which leads me to suspect that some action within each "play pazaak" script (all compiled :() determines winnings.

 

I don't think you can use that.

There is a command run pazaak game:

 

/ 364: Starts a game of pazaak.
// - nOpponentPazaakDeck: Index into PazaakDecks.2da; specifies which deck the opponent will use.
// - sEndScript: Script to be run when game finishes.
// - nMaxWager: Max player wager.  If <= 0, the player's credits won't be modified by the result of the game and the wager screen will not show up.
// - bShowTutorial: Plays in tutorial mode (nMaxWager should be 0).
void PlayPazaak(int nOpponentPazaakDeck, string sEndScript, int nMaxWager, int bShowTutorial=FALSE, object oOpponent=OBJECT_INVALID);

 

 

You put it in a script and run that from dialog. I assume your winnings are in proportional relation to your wager.

 

You can also use this

 

// 365: Returns result of last Pazaak game.  Should be used only in an EndScript sent to PlayPazaak.
// * Returns 0 if player loses, 1 if player wins.
int GetLastPazaakResult();

 

to determin if PC has won, and give extra credits/bonusses accordingly.

Link to comment
Share on other sites

I think those might be a holdover from the first KotOR. While digging around, I noticed that each of the NPCs that you can play pazaak with have their own scripts (c_nikko_pazaak, k_paz_mebla, a_pato_pazaak, respectively) which are fired by their dialogs. I assume that these are the actual scripts that contain wagers/winnings, however they are compiled and I cannot read machine language :D

 

Perhaps the scripts that you mentioned are the key and I just need to look harder. Thanks for your input!

 

EDIT: It just occurred to me that you may have been suggesting that I replace the existing scripts with those. While I'm sure that might work, I guess I would be concerned about messing up something that the current scripts are tied to (globals, etc). *shrug*

 

I'll just have to find another way to git my dead emperors...

Link to comment
Share on other sites

Originally posted by Achilles

I think those might be a holdover from the first KotOR. While digging around, I noticed that each of the NPCs that you can play pazaak with have their own scripts (c_nikko_pazaak, k_paz_mebla, a_pato_pazaak, respectively) which are fired by their dialogs. I assume that these are the actual scripts that contain wagers/winnings, however they are compiled and I cannot read machine language :D

 

EDIT: It just occurred to me that you may have been suggesting that I replace the existing scripts with those. While I'm sure that might work, I guess I would be concerned about messing up something that the current scripts are tied to (globals, etc). *shrug*

 

I'll just have to find another way to git my dead emperors...

 

Those "personal" pazaak scripts do control the winnings, but they appear linked to the wagers and the PlayPazaak() function seem to handle giving out the credits by its own.

 

I looked at the Dantooine Ithorian's script you posted above as an example, and this is how they look:

 

// ST: a_pato_pazaak.nss (a_pato_pazaak.ncs in 601DAN_s.rim)

void main() {
int nParam = GetScriptParameter(1);
int nDeck  = GetLocalNumber(OBJECT_SELF, 14);
int nCount = GetLocalNumber(OBJECT_SELF, 15);

if (nParam == 0) {
	SetLocalBoolean(OBJECT_SELF, 49, TRUE);
}
if (nParam == 1) {
	SetLocalNumber(OBJECT_SELF, 14, 1);
	nDeck = 1;
}

// ST: Bug? The increment would never be stored?
SetLocalNumber(OBJECT_SELF, 15, nCount++);
SetLocalBoolean(OBJECT_SELF, 40, TRUE);

if (nParam == 3) {
	PlayPazaak(3, "k_pato_donepzk", 0);
	return;
}
PlayPazaak(nDeck, "k_pato_donepzk", nDeck * 250);	
}

 

And the script fired when the game is over:

 

// ST: k_pato_donepzk.nss (k_pato_donepzk.ncs in 601DAN_s.rim)

void main() {
object oPato = GetObjectByTag("npc_pato");
int bResult  = GetLastPazaakResult();
int nRecord  = GetLocalNumber(oPato, 13);
int nDeck    = GetLocalNumber(oPato, 14);

string sValue = IntToString(nRecord);
AurPostString("Record prior to math: " + sValue, 5, 3, 5.0);

sValue = IntToString(nDeck);
AurPostString("Bet: " + sValue, 5, 4, 5.0);

if (bResult) {
	nRecord += nDeck;
	sValue = IntToString(nRecord);
	AurPostString("Player won. Record updated: " + sValue, 5, 5, 5.0);	
	SetLocalNumber(oPato, 13, nRecord);
}

string sTotal = IntToString(nRecord);
AurPostString("The player has won a total of " + sTotal + "*250 credits from Pato.", 5, 6, 5.0);

AssignCommand(oPato, ClearAllActions());
AssignCommand(oPato, ActionStartConversation(GetFirstPC(), "pato"));
}

 

As you can see the max wager/winning is determined by 250 * Difficulty, and no other rewards are given out in those scripts. A series of local variables are adjusted though, which I suppose are used by other scripts in the Ithorian's dialog to keep track of the progress of the game and set the difficulty/deck to use.

Link to comment
Share on other sites

Originally posted by Achilles

EDIT: It just occurred to me that you may have been suggesting that I replace the existing scripts with those. While I'm sure that might work, I guess I would be concerned about messing up something that the current scripts are tied to (globals, etc). *shrug*

 

Oh, no.. LOL! I wasn't suggesting anything, because you didn't say what exactly it was you wanted to make. :p

(modify current games, create new ones, etc, etc)

That was just general info on how pazaak works. :)

Link to comment
Share on other sites

Posted by me: Any thoughts on how you could use this script (or one similiar to it) to change the amount of credits you win playing Pazaak?
This about sums it up the extent of my ambition. All I was looking for was general information, however it appears that I need specific information to increase wager amounts :(
Link to comment
Share on other sites

Originally posted by Achilles

Any thoughts on how you could use this script (or one similiar to it) to change the amount of credits you win playing Pazaak?

 

This about sums it up the extent of my ambition. All I was looking for was general information, however it appears that I need specific information to increase wager amounts :(

 

I think the easiest way to give a reward that doesn't match the wager would be to modify the scripts that fires when the game is over.

 

If GetLastPazaakResult() returns TRUE in that script (ie the player has won), give some extra credits with GiveGoldToCreature() .

 

I could have a look at making source for those scripts if you tell me which ones you need.

Link to comment
Share on other sites

Originally posted by Achilles

I appreciate the offer. I'll PM you with the names of the four scripts when I get home this afternoon.

 

For the most part these scripts turned out to be fairly simple. Seems the dialog files of the players handle most of the work (if any) by other means. Here's the source for the scripts you wanted:

 

The Champ:

// ST: a_playpazaak301.nss (a_playpazaak301.ncs in 306NAR_s.rim)

// ST: NOTE - This is a shared script used by The Champ, Dahnis, Geredi and the
//            "female" droid in the Nar Shadaa Pazaak Den to start their
//            matches. The specifics are set by parameters in the dialog.

void main() {
// ST: StrParam - ResRef of script to fire at end of match.
string sEndScript 	= GetScriptStringParameter(); 
// ST: P1 - Index in pazaakdecks.2da
int nDeck 			= GetScriptParameter(1);	
// ST: P2 - Max wager in credits
int nWager 			= GetScriptParameter(2);	
// ST: P3 - Set to 1 for tutorial mode, 0 for normal play
int nTutorial 		= GetScriptParameter(3);	
// ST: P4 - Delay start of game by this many seconds. Leave at 0 for no delay.
int nDelay	 		= GetScriptParameter(4);	

DelayCommand(IntToFloat(nDelay), PlayPazaak(nDeck, sEndScript, nWager, nTutorial));
}

 

The Champ's "End of match" script:

// ST: a_pazchamp.nss (a_pazchamp.ncs in 306NAR_s.rim)

void main() {
object oChamp = GetObjectByTag("champ");

AssignCommand(oChamp, ClearAllActions());
AssignCommand(oChamp, ActionStartConversation(GetFirstPC()));
}

 

Mebla's script:

// ST: k_paz_mebla.nss (k_paz_mebla.ncs in 207TEL_s.rim)

void main() {
int nParam = GetScriptParameter(1);

SetGlobalBoolean("G_Paz_JustPlayed", TRUE);

if (nParam == 1) {
	PlayPazaak(1, "k_pazend_mebla", 0);
}
if (nParam == 2) {
	SetGlobalNumber("202TEL_MeblaP", 1);
	PlayPazaak(1, "k_pazend_mebla", 40);
}
}

 

Mebla's End Of Match script:

// ST: k_pazend_mebla.nss (k_pazend_mebla.ncs in 207TEL_s.rim)

void main() {
object oMebla = GetObjectByTag("mebla");

AssignCommand(oMebla, ClearAllActions());
AssignCommand(oMebla, ActionStartConversation(GetFirstPC(), "mebla"));
}

 

Nikko's script:

// ST: a_pazaak_play.nss (a_pazaak_play.ncs in 503OND_s.rim)

void main() {
int nParam = GetScriptParameter(1);

switch (nParam) {
	case 0:
		PlayPazaak(2, "a_nikko_talk", 250);
		break;
	case 1:
		CreateItemOnObject("g_i_pazcard_005", GetFirstPC());
		CreateItemOnObject("g_i_pazcard_013", GetFirstPC());
		CreateItemOnObject("g_i_pazcard_015", GetFirstPC());
		break;
}
}

 

Nikko's End of Match script:

// ST: a_nikko_talk.nss (a_nikko_talk.ncs in 503OND_s.rim)

void main() {
AssignCommand(GetObjectByTag("npc_nikko"), ActionStartConversation(GetFirstPC()));
}

 

Pato's script:

// ST: a_pato_pazaak.nss (a_pato_pazaak.ncs in 601DAN_s.rim)

void main() {
int nParam = GetScriptParameter(1);
int nDeck  = GetLocalNumber(OBJECT_SELF, 14);
int nCount = GetLocalNumber(OBJECT_SELF, 15);

if (nParam == 0) {
	SetLocalBoolean(OBJECT_SELF, 49, TRUE);
}
if (nParam == 1) {
	SetLocalNumber(OBJECT_SELF, 14, 1);
	nDeck = 1;
}

// ST: Bug? The increment would never be stored?
SetLocalNumber(OBJECT_SELF, 15, nCount++);
SetLocalBoolean(OBJECT_SELF, 40, TRUE);

if (nParam == 3) {
	PlayPazaak(3, "k_pato_donepzk", 0);
	return;
}
PlayPazaak(nDeck, "k_pato_donepzk", nDeck * 250);	
}

 

Pato's End of Match script:

// ST: k_pato_donepzk.nss (k_pato_donepzk.ncs in 601DAN_s.rim)

void main() {
object oPato = GetObjectByTag("npc_pato");
int bResult  = GetLastPazaakResult();
int nRecord  = GetLocalNumber(oPato, 13);
int nDeck    = GetLocalNumber(oPato, 14);

string sValue = IntToString(nRecord);
AurPostString("Record prior to math: " + sValue, 5, 3, 5.0);

sValue = IntToString(nDeck);
AurPostString("Bet: " + sValue, 5, 4, 5.0);

if (bResult) {
	nRecord += nDeck;
	sValue = IntToString(nRecord);
	AurPostString("Player won. Record updated: " + sValue, 5, 5, 5.0);	
	SetLocalNumber(oPato, 13, nRecord);
}

string sTotal = IntToString(nRecord);
AurPostString("The player has won a total of " + sTotal + "*250 credits from Pato.", 5, 6, 5.0);

AssignCommand(oPato, ClearAllActions());
AssignCommand(oPato, ActionStartConversation(GetFirstPC(), "pato"));
}

Link to comment
Share on other sites

Wow stoffe -mkb- you are churning out decompiled scripts like theres no tomorrow :D

 

You know a great "mod" for you to release is a collection of decompiled scripts :cool:

 

That would be very helpful to have, especially all the onenter scripts for the different modules ;) That would be cool :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...