A Disguise script?

Started by Cyril_Grey, Tue 06/07/2010 23:20:35

Previous topic - Next topic

Cyril_Grey

I have a theory, and its just a theory I'm new at this whole thing but I wondered if it had been done before or if I'm just snatching at the impossible...

Lets say I make an Disguise, And when its interacted with it changes the view of the player to something else (Obviously the disguise)

function iDisguise_Interact()
{
player.ChangeView(2)
}

That works fine, but what needs to happen is that -while- disguised all conversations happen differently. i.e everyone drums up conversations like 'who are you?'

So! I know the answer, at least I think I do. There has to be a variable set in place, when you interact with iDisguise it adds a +1, when you interact with anyone with a +1 it brings up another set conversation.

function cAndrew_Talk()
{
if (disguiseCounter =1)
}
  dDisguise.Start() ;
{
if (disguiseCounter =0)
}
  dAndrew.Start() ;
{

Would this work at all? Am I onto something? If its possible, could someone help me do it, as I said... I'm making a wild guess at this and probably going about it all wrong. :P

Also... the disguise would have to be able to be taken off... So in the iDisguise script it would have to
}
  player.Addinventory (iTakeOff);
{
and then take iDisguise out of the inventory (By the way, what -is- the command to do that?). Am I even close? Someone has to explain... I think I might be going a bit deep for a first attempt at a game >.>

Wyz

#1
Yes this is would definitely work, but there are a few scripting errors.

function cAndrew_Talk()
{
   if (disguiseCounter == 1)
   {
      dDisguise.Start() ;
   }
   else
   {
      dAndrew.Start() ;
   }
}

I just realized that you could also use the disguise as an inventory item like this:

Disguise:
Code: ags

player.ChangeView(2);
player.AddInventory(iDisguise);


Interaction:
Code: ags

if (player.HasInventory(iDisguise))
	dDisguise.Start();
else
	dAndrew.Start();


Loose disguise:
Code: ags

player.ChangeView(0);
player.LoseInventory(iDisguise);
Life is like an adventure without the pixel hunts.

Khris

There's no need for variables or inv item checks, simply check the value of player.View.

Code: ags
function cAndrew_Talk() {
  if (player.View == 1) dAndrew.Start();
  else dDisguise.Start();
}

Cyril_Grey

Quote from: Wyz on Tue 06/07/2010 23:50:27
Yes this is would definitely work, but there are a few scripting errors.

function cAndrew_Talk()
{
   if (disguiseCounter == 1)
   {
      dDisguise.Start() ;
   }
   else
   {
      dAndrew.Start() ;
   }
}

I just realized that you could also use the disguise as an inventory item like this:

Disguise:
Code: ags

player.ChangeView(2);
player.AddInventory(iDisguise);


Interaction:
Code: ags

if (player.HasInventory(iDisguise))
	dDisguise.Start();
else
	dAndrew.Start();


Loose disguise:
Code: ags

player.ChangeView(0);
player.LoseInventory(iDisguise);


AH! Thank you! truly!

Cyril_Grey

Quote from: Khris on Wed 07/07/2010 00:11:36
There's no need for variables or inv item checks, simply check the value of player.View.

Code: ags
function cAndrew_Talk() {
  if (player.View == 1) dAndrew.Start();
  else dDisguise.Start();
}


...Its like having my eyes opened for the first time :S
THANKS KHRIS!

Cyril_Grey

Here is a script

cSusan.Walk(194,477,eBlock);
cSusan.ChangeRoom(8);
player.LoseInventory(iKarls);
Wait(40);
player.Walk(325,241,eBlock);
if (player.View == 4 )
player.AddInventory (iDisguiseX);
player.LoseInventory (iRemove);
else
player.AddInventory (iDisguiseX);
player.LoseInventory (iDisguise);
cMother.ChangeRoom(8);
Display("You pick up the woman, slinging her over your shoulder and trudging to the Temple of Morr");
player.ChangeView(7);
stop

I'm pretty sure its the 'else' that I'm doing wrong but... I cant seen to find out just -what- is wrong with this bit of code...

(This is a a bit in the game where you -must- loose your disguise if your wearing it, and you get it back later!)

Crimson Wizard

#6
Remember: if you want more than one command under if/else, put brackets!

Code: ags

 if (player.View == 4 )
 {
    player.AddInventory (iDisguiseX);
    player.LoseInventory (iRemove);
 }
 else
 {
    player.AddInventory (iDisguiseX);
    player.LoseInventory (iDisguise);
 }




Also, please, when you post a code here, put it inside [ code ] [ /code ] tags (without inner spaces), it will be easier to read

Cyril_Grey

Quote from: Crimson Wizard on Fri 09/07/2010 04:34:49
Remember: if you want more than one command under if/else, put brackets!

Code: ags

 if (player.View == 4 )
 {
    player.AddInventory (iDisguiseX);
    player.LoseInventory (iRemove);
 }
 else
 {
    player.AddInventory (iDisguiseX);
    player.LoseInventory (iDisguise);
 }




Also, please, when you post a code here, put it inside [ code ] [ /code ] tags (without inner spaces), it will be easier to read

Thanks so much!

SMF spam blocked by CleanTalk