Page 1 of 1

Weird Problem.

PostPosted: Thu Feb 01, 07 10:33 pm
by Cozmo
Well, until today, from last Friday, my internet didn't work. So I coded alot. :)
One thing I made was a dodgy mod that lets you 'talk' to NPC's. It compiled and it's all ok, but there's weird bugs. Example, instead of taking the players name it just says MTLPRI. And it uses the pawn chess piece instead of a mesh. And it doesn't use its name. :shock:

Big, untidy code here. :D If anyone feels like going through it.

Code: Select all
//====================================================
// MPConvoPawn
//
// Cozmo
//
//====================================================
Class MPConvoPawn2 extends ScriptedPawn;

Var DeusExPlayer ConvoPlayer;
Var() class<Pawn> AppearAsClass;
Var bool bHasWarned;
Var() String PawnsName;
//--------------
// ConvoInfo
//--------------
Var(Convo) int ConvoMessages;
Var(Convo) String BusyMessage;
Var(Convo) int TalkTurn;
Var(Convo) String TheWaitMessage;
Var int OnMessage;
Var int PreviousSpeed;
Var String Message;
Var bool bWasSpeaking;
Var bool IsSpeaking;
Var Float deltaTime2;
Var(Messages) String aMessage1;
Var(Messages) String bMessage2;
Var(Messages) String cMessage3;
Var(Messages) String dMessage4;
Var(Messages) String eMessage5;
Var(Messages) String fMessage6;
Var(Messages) String gMessage7;
Var(Messages) String hMessage8;
Var(Messages) String iMessage9;
Var(Messages) String jMessage10;
Var(Messages) String kMessage11;
Var(Messages) String lMessage12;
Var(Messages) String mMessage13;
Var(Messages) String nMessage14;
Var(Messages) String oMessage15;
Var(Messages) String pMessage16;
Var(Messages) String qMessage17;
Var(Messages) String rMessage18;
Var(Messages) String sMessage19;
Var(Messages) String tMessage20;

function BeginPlay()
{
   if(AppearAsClass != None)
   {
      UnfamiliarName=AppearAsClass.PawnsName;
      FamiliarName=AppearAsClass.PawnsName;
           BindName=AppearAsClass.PawnsName;
      Mesh=AppearAsClass.default.Mesh;
      MultiSkins[0]=AppearAsClass.default.MultiSkins[0];
      MultiSkins[1]=AppearAsClass.default.MultiSkins[1];
      MultiSkins[2]=AppearAsClass.default.MultiSkins[2];
      MultiSkins[3]=AppearAsClass.default.MultiSkins[3];
      MultiSkins[4]=AppearAsClass.default.MultiSkins[4];
      MultiSkins[5]=AppearAsClass.default.MultiSkins[5];
      MultiSkins[6]=AppearAsClass.default.MultiSkins[6];
      MultiSkins[7]=AppearAsClass.default.MultiSkins[7];
      Texture=AppearAsClass.default.Texture;
      SetCollisionSize(AppearAsClass.default.CollisionRadius,AppearAsClass.default.CollisionHeight);
      BaseEyeHeight=AppearAsClass.default.BaseEyeHeight;
      AmbientSound=AppearAsClass.default.AmbientSound;
      SoundRadius=AppearAsClass.default.SoundRadius;
      SoundVolume=AppearAsClass.default.SoundVolume;
   }
   else
   {
      Destroy();
   }
}

function Frob(Actor Frobber, Inventory frobWith)
{

//===================================================
//
// THIS SECTION IS TAKEN FROM THE  PAWN.UC
//
//===================================================
   local name animseq;
   local float rnd;
   local float tweentime;

   // update the animation timers that we are using
   animTimer[0] += deltaTime2;
   animTimer[1] += deltaTime2;
   animTimer[2] += deltaTime2;

   if (bIsSpeaking)
   {
      // if our framerate is high enough (>20fps), tween the lips smoothly
      if (Level.TimeSeconds - animTimer[3]  < 0.05)
         tweentime = 0.1;
      else
         tweentime = 0.0;

      // the last animTimer slot is used to check framerate
      animTimer[3] = Level.TimeSeconds;

      if (nextPhoneme == "A")
         animseq = 'MouthA';
      else if (nextPhoneme == "E")
         animseq = 'MouthE';
      else if (nextPhoneme == "F")
         animseq = 'MouthF';
      else if (nextPhoneme == "M")
         animseq = 'MouthM';
      else if (nextPhoneme == "O")
         animseq = 'MouthO';
      else if (nextPhoneme == "T")
         animseq = 'MouthT';
      else if (nextPhoneme == "U")
         animseq = 'MouthU';
      else if (nextPhoneme == "X")
         animseq = 'MouthClosed';

      if (animseq != '')
      {
         if (lastPhoneme != nextPhoneme)
         {
            lastPhoneme = nextPhoneme;
            TweenBlendAnim(animseq, tweentime);
         }
      }
   }
   else if (bWasSpeaking)
   {
      bWasSpeaking = False;
      TweenBlendAnim('MouthClosed', tweentime);
   }

   // blink randomly
   if (animTimer[0] > 2.0)
   {
      animTimer[0] = 0;
      if (FRand() < 0.4)
         PlayBlendAnim('Blink', 1.0, 0.1, 1);
   }
//===================================================
//
// BACK TO MY OWN WORK.
//
// It's always best to avoid the Engine.u It confuses me.
//
//===================================================

   if(ConvoPlayer == None)
   {
      ConvoPlayer = DeusExPlayer(Frobber);
      SetTimer(2.5, true);
      ConvoPlayer.ConsoleCommand("DeactivateAllAugs");
      ConvoPlayer.SetRotation(Rotation+rot(0,0,32808));
      //PreviousSpeed = ConvoPlayer.mpGroundSpeed;
      //ConvoPlayer.mpGroundSpeed = 0;
   }
   else
   {
      DeusExPlayer(Frobber).ClientMessage("|p1"@BindName@": "@BusyMessage);
   }
}

function Timer()
{
   if(OnMessage == 0)
   {
      Message = TheWaitMessage;
   }

   if(OnMessage == 1)
   {
      Message = aMessage1;
   }

   if(OnMessage == 2)
   {
      Message = bMessage2;
   }

   if(OnMessage == 3)
   {
      Message = cMessage3;
   }

   if(OnMessage == 4)
   {
      Message = dMessage4;
   }

   if(OnMessage == 5)
   {
      Message = eMessage5;
   }

   if(OnMessage == 6)
   {
      Message = fMessage6;
   }

   if(OnMessage == 7)
   {
      Message = gMessage7;
   }

   if(OnMessage == 8)
   {
      Message = hMessage8;
   }

   if(OnMessage == 9)
   {
      Message = iMessage9;
   }

   if(OnMessage == 10)
   {
      Message = jMessage10;
   }

   if(OnMessage == 11)
   {
      Message = kMessage11;
   }

   if(OnMessage == 12)
   {
      Message = lMessage12;
   }

   if(OnMessage == 13)
   {
      Message = mMessage13;
   }

   if(OnMessage == 14)
   {
      Message = nMessage14;
   }

   if(OnMessage == 15)
   {
      Message = oMessage15;
   }

   if(OnMessage == 16)
   {
      Message = pMessage16;
   }

   if(OnMessage == 17)
   {
      Message = qMessage17;
   }

   if(OnMessage == 18)
   {
      Message = rMessage18;
   }

   if(OnMessage == 19)
   {
      Message = sMessage19;
   }

   if(OnMessage == 20)
   {
      Message = tMessage20;
   }

   if(ConvoPlayer != None)
   {
      if(TalkTurn == 0)
      {
         if(OnMessage <= ConvoMessages)
         {
            ConvoPlayer.ClientMessage("|p1"@BindName@": "@Message);
            TalkTurn = 1;
            OnMessage += 1;
         }
         else
         {
            //ConvoPlayer.mpGroundSpeed = PreviousSpeed;
            ConvoPlayer = None;
            TalkTurn = default.TalkTurn;
            OnMessage = 0;
            SetTimer(0.0, false);
         }
      }
      else
      {
         ConvoPlayer.ClientMessage("|p1"@ConvoPlayer.PlayerReplicationInfo.Name@": "@Message);
         TalkTurn = 0;
         OnMessage += 1;
      }
   }
   else
   {
      LoopAnim('BreatheLight',, 0.4);
   }

   if(OnMessage == 0)
   {
      LoopAnim('BreatheLight',, 0.4);
   }

}

defaultproperties
{
     PawnsName="Warning, no name set!"
     GroundSpeed=0
     TheWaitMessage="(Please wait...)"
     TalkTurn=0
     ConvoMessages=0
     BusyMessage="I'm already talking to someone... Wait a minute."
}

PostPosted: Thu Feb 01, 07 11:07 pm
by MainMan
To make it have a mesh, set DrawType=DT_Mesh (or alternatively make it extend HumanCivilian or HumanMilitary, etc).

For the problem of the Player's name, change
Code: Select all
ConvoPlayer.PlayerReplicationInfo.Name

to
Code: Select all
ConvoPlayer.PlayerReplicationInfo.PlayerName


Wow, i'm surprised how similar this is to the conversation system in my mod. Great minds think alike eh?

PostPosted: Fri Feb 02, 07 9:09 pm
by Cozmo
Thanks MainMan. :D

Wow, i'm surprised how similar this is to the conversation system in my mod. Great minds think alike eh?


I actually thought I'd done it really weirdly. :D

PostPosted: Sat Feb 03, 07 6:52 pm
by Allan
Wow, nice work Cozmo :D

PostPosted: Sat Feb 03, 07 10:07 pm
by Spiderbot01
I have no idea why I asked for access to this section.

I just don't like being left out :(

PostPosted: Sat Feb 03, 07 10:58 pm
by Cozmo
Thanks Allan. :D

Re: Weird Problem.

PostPosted: Sun Feb 04, 07 1:01 am
by Allan
I've just had a look at it again, as NTL's internet's being up and down like a very bouncy something.
Prehaps to save on eye-strain, If statements, and Global Variables, you should make all the parts like "Var(Messages) String aMessage1;" into one big array, then change the If's in Timer. I think it should work like this:

Code: Select all
//====================================================
// MPConvoPawn
//
// Cozmo
//
//====================================================
Class MPConvoPawn2 extends ScriptedPawn;

Var DeusExPlayer ConvoPlayer;
Var() class<Pawn> AppearAsClass;
Var bool bHasWarned;
Var() String PawnsName;
//--------------
// ConvoInfo
//--------------
Var(Convo) int ConvoMessages;
Var(Convo) String BusyMessage;
Var(Convo) int TalkTurn;
Var(Convo) String TheWaitMessage;
Var int OnMessage;
Var int PreviousSpeed;
Var String Message;
Var bool bWasSpeaking;
Var bool IsSpeaking;
Var Float deltaTime2;
Var(Messages) string ConvoMessage[19]; // This is 19 "Var String"s, compressed into one bit. I think.

function BeginPlay()
{
   if(AppearAsClass != None)
   {
      UnfamiliarName=AppearAsClass.PawnsName;
      FamiliarName=AppearAsClass.PawnsName;
           BindName=AppearAsClass.PawnsName;
      Mesh=AppearAsClass.default.Mesh;
      MultiSkins[0]=AppearAsClass.default.MultiSkins[0];
      MultiSkins[1]=AppearAsClass.default.MultiSkins[1];
      MultiSkins[2]=AppearAsClass.default.MultiSkins[2];
      MultiSkins[3]=AppearAsClass.default.MultiSkins[3];
      MultiSkins[4]=AppearAsClass.default.MultiSkins[4];
      MultiSkins[5]=AppearAsClass.default.MultiSkins[5];
      MultiSkins[6]=AppearAsClass.default.MultiSkins[6];
      MultiSkins[7]=AppearAsClass.default.MultiSkins[7];
      Texture=AppearAsClass.default.Texture;
      SetCollisionSize(AppearAsClass.default.CollisionRadius,AppearAsClass.default.CollisionHeight);
      BaseEyeHeight=AppearAsClass.default.BaseEyeHeight;
      AmbientSound=AppearAsClass.default.AmbientSound;
      SoundRadius=AppearAsClass.default.SoundRadius;
      SoundVolume=AppearAsClass.default.SoundVolume;
   }
   else
   {
      Destroy();
   }
}

function Frob(Actor Frobber, Inventory frobWith)
{

//===================================================
//
// THIS SECTION IS TAKEN FROM THE  PAWN.UC
//
//===================================================
   local name animseq;
   local float rnd;
   local float tweentime;

   // update the animation timers that we are using
   animTimer[0] += deltaTime2;
   animTimer[1] += deltaTime2;
   animTimer[2] += deltaTime2;

   if (bIsSpeaking)
   {
      // if our framerate is high enough (>20fps), tween the lips smoothly
      if (Level.TimeSeconds - animTimer[3]  < 0.05)
         tweentime = 0.1;
      else
         tweentime = 0.0;

      // the last animTimer slot is used to check framerate
      animTimer[3] = Level.TimeSeconds;

      if (nextPhoneme == "A")
         animseq = 'MouthA';
      else if (nextPhoneme == "E")
         animseq = 'MouthE';
      else if (nextPhoneme == "F")
         animseq = 'MouthF';
      else if (nextPhoneme == "M")
         animseq = 'MouthM';
      else if (nextPhoneme == "O")
         animseq = 'MouthO';
      else if (nextPhoneme == "T")
         animseq = 'MouthT';
      else if (nextPhoneme == "U")
         animseq = 'MouthU';
      else if (nextPhoneme == "X")
         animseq = 'MouthClosed';

      if (animseq != '')
      {
         if (lastPhoneme != nextPhoneme)
         {
            lastPhoneme = nextPhoneme;
            TweenBlendAnim(animseq, tweentime);
         }
      }
   }
   else if (bWasSpeaking)
   {
      bWasSpeaking = False;
      TweenBlendAnim('MouthClosed', tweentime);
   }

   // blink randomly
   if (animTimer[0] > 2.0)
   {
      animTimer[0] = 0;
      if (FRand() < 0.4)
         PlayBlendAnim('Blink', 1.0, 0.1, 1);
   }
//===================================================
//
// BACK TO MY OWN WORK.
//
// It's always best to avoid the Engine.u It confuses me.
//
//===================================================

   if(ConvoPlayer == None)
   {
      ConvoPlayer = DeusExPlayer(Frobber);
      SetTimer(2.5, true);
      ConvoPlayer.ConsoleCommand("DeactivateAllAugs");
      ConvoPlayer.SetRotation(Rotation+rot(0,0,32808));
      //PreviousSpeed = ConvoPlayer.mpGroundSpeed;
      //ConvoPlayer.mpGroundSpeed = 0;
   }
   else
   {
      DeusExPlayer(Frobber).ClientMessage("|p1"@BindName@": "@BusyMessage);
   }
}

function Timer()
{
   if(OnMessage <= 0) // Set to "Less than, or Equal to", as you never
know what prat's going to try and f**k with your pawns using admin.
   {
      Message = TheWaitMessage;
   }

   else
   {
      Message = ConvoMessage[OnMessage-1];
      // This is -1, because Arrays start from 0, and count up, not 1.
      //Sadly, it's how the language was made, and we can't make it make more sense... :(
   }

   if(ConvoPlayer != None)
   {
      if(TalkTurn == 0)
      {
         if(OnMessage <= ConvoMessages)
         {
            ConvoPlayer.ClientMessage("|p1"@BindName@": "@Message); // Hmm... This might give some weird results when it's put in a ClientMessage. Not sure though
            TalkTurn = 1;
            OnMessage += 1;
         }
         else
         {
            //ConvoPlayer.mpGroundSpeed = PreviousSpeed;
            ConvoPlayer = None;
            TalkTurn = default.TalkTurn;
            OnMessage = 0;
            SetTimer(0.0, false);
         }
      }
      else
      {
         ConvoPlayer.ClientMessage("|p1"@ConvoPlayer.PlayerReplicationInfo.PlayerName@": "@Message);
         TalkTurn = 0;
         OnMessage += 1;
      }
   }
   else
   {
      LoopAnim('BreatheLight',, 0.4);
   }

   if(OnMessage == 0)
   {
      LoopAnim('BreatheLight',, 0.4);
   }

}

defaultproperties
{
     PawnsName="Warning, no name set!"
     GroundSpeed=0
     TheWaitMessage="(Please wait...)"
     TalkTurn=0
     ConvoMessages=0
     BusyMessage="I'm already talking to someone... Wait a minute."
     DrawType=DT_Mesh
}


That makes it look more neat IMO :) (I've fixed what MainMan brought up in this too :)

PostPosted: Sun Feb 04, 07 1:05 am
by MainMan
True, but I've kinda given up on neatness in coding. For example, this is a real extract from some code in my mod:
Code: Select all
if(bullshit != none)
{
klopisgay += 1;
bbq.destroy();
}

PostPosted: Sun Feb 04, 07 1:14 am
by Allan
ROFL. What class uses a variable called "KlopIsGay"? A ScrollingScriptedTexture with "Klop Is Gay!" as the message?

PostPosted: Sun Feb 04, 07 2:32 pm
by Mastakilla
Why are people still obsessed with Klop's sexual preference :(

PostPosted: Sun Feb 04, 07 3:51 pm
by Dae
[A]MastaKilla wrote:Why are people still obsessed with Klop's sexual preference :(

Doesn't "gay" in traditional English mean something like "happy"?

PostPosted: Sun Feb 04, 07 4:09 pm
by Gishank
Indeed it does.

And Mainman... I think you'll find i'm not gay in your terms of speech.

PostPosted: Sun Feb 04, 07 9:12 pm
by Cozmo
@ Allan, yeah, I should've used arrays, but I only asked Nobody about them yesterday. :)

PostPosted: Sun Feb 04, 07 9:32 pm
by ~ô¿ô~Nobody~
I was about to give you an example, about loops, but you needed to go. :(

PostPosted: Sun Feb 04, 07 9:33 pm
by Cozmo
~[A]N00body~ wrote:I was about to give you an example, about loops, but you needed to go. :(


Then post it here please? :D

PostPosted: Sun Feb 04, 07 10:00 pm
by ~ô¿ô~Nobody~
Umm.. now I don't have time, but I will when I have.

PostPosted: Sun Feb 18, 07 11:05 pm
by ~ScArFaCe~
thnx for sendin this mod 2 me. i tried it earlier and its excellent. gd job mate.
could u add some more stuff to it like item transfers? if not fair enuff :D

PostPosted: Sun Feb 18, 07 11:10 pm
by Cozmo
{DXC}ScArFaCe wrote:thnx for sendin this mod 2 me. i tried it earlier and its excellent. gd job mate.
could u add some more stuff to it like item transfers? if not fair enuff :D


I was planning to, but at the time I didn't have an idea how to change it without having LOADS of variables. I'll try when I got time. :)

PostPosted: Thu Apr 19, 07 1:20 pm
by Andrievskaya Veronika
I have problem with MissionScript.

here is fragment (used in Function Timer()):

Code: Select all

   if (!flags.GetBool('Skills1_given')) // Если это еще не сделано...
      ForEach AllActors(class'Greasel',G)
      Count++;
      If (count==0)
      {   // то сделать это....
         DXP.ClientMessage("You killed all greasels! So get bonus: 2000 points of skillpoints ;)");
         DXP.SkillPointsAdd(2000);
         flags.SetBool('Skills1_given', true); // и защитить от повторного получения навыка...
      }
      



When all greasels killed, player should get 2000 skillpoints only ONE TIME. But skillpoints are added infinitely. What wrong? :o

PostPosted: Thu Apr 19, 07 2:05 pm
by Alex
How is your Timer initiated? by SetTimer(TIME HERE, True);?

That True value, means it loops. The function syntax is like this:
Code: Select all
SetTimer(Time, bLoop);
(With loop it is meant that it repeats itself.)

PostPosted: Thu Apr 19, 07 5:23 pm
by Andrievskaya Veronika
I never seen this in MissionScript.

Code: Select all
function Timer()
{
local Switch2 P;
local Greasel G;
local int Count;
local DeusExPlayer DXP;

DXP=DeusExPlayer(GetPlayerPawn());

      Super.timer();
.............


Anyway, i think timer in MissionScript should always loop, to check what happening on map, etc. :)

PostPosted: Thu Apr 19, 07 5:28 pm
by Alex
I see. And I also see you use flags, to check if the player already has the reward. I personally have no experience with flags, I usually just use a boolean in the script, and check if that is set to true or false.

PostPosted: Fri Apr 20, 07 7:55 am
by Andrievskaya Veronika
oh, i solved my problem :D

Code: Select all
function Timer()
{
   local Switch2 P;
   local Greasel G;
   local int Count;
   local DeusExPlayer DXP;

   DXP=DeusExPlayer(GetPlayerPawn());

               Super.timer();
//-------------------------------------                              
// Защита от повторного нажатия кнопки. Не самая лучшая, BTW.
   if (flags.GetBool('Generator_is_on'))
   {   
      foreach AllActors(class'Switch2', P)
      {   //-------------------------------------
         P.SetCollisionSize(0, 0);
      }   //-------------------------------------
   }   
//-------------------------------------
// Бонус для любителей отстрела гризелов: если убили всех то дать 2000 очков навыка.
   if (!flags.GetBool('Skills1_given'))  // Если это еще не сделано...
//   if (!K)
   {
      ForEach AllActors(class'Greasel',G)
      Count++;
      log("Count greaSelS....");
      If (count==0)
      {   // то сделать это....
   log("No greasels for now.......");
         DXP.ClientMessage("You killed all greasels! So get bonus: 2000 points of skillpoints ;)");
         DXP.SkillPointsAdd(2000);
   log("Set K to true..........");
//         K=true;
         flags.SetBool('Skills1_given', true); // и защитить от повторного получения навыка...
      }
   }
}





i forgot about additional brackets (after // if (!K)) :)

PostPosted: Mon Sep 24, 07 12:21 pm
by Andrievskaya Veronika
I want to randomly change skins for Greasels, using MissionScript, but i don't have idea how i can do this. Of course, i can edit my map change tag for greasels, but i don't want to touch the map...

Any ideas? For example i have 100 greasels on map and i want to change TAG to something other only for 50 of them.

PostPosted: Mon Sep 24, 07 12:33 pm
by Dae
dunno if it's what you wanted, but each object has a name which consists of a class name + index, e.g Greasel1, or Greasel14. You could create an iteration, which would run through the indexes until it reaches 50.

PostPosted: Mon Sep 24, 07 2:46 pm
by Alex
Code: Select all
  local Greasel graySeal;
  local int i;
  ForEach AllActors(Class'Greasel', greySeal)
  {
    if(i < 50 && greySeal != None)
    {
      i++;
      greySeal.Tag      = 'SomeTagName';
    }
  }


Perhaps that works? I haven't tested it, just wrote it in this quick-post-form.

PostPosted: Tue Sep 25, 07 12:18 pm
by Andrievskaya Veronika
Yes, it woks. Thanks :)

Code: Select all
 If (!flags.GetBool('GreaelsMarkedRed'))
      ForEach AllActors(class'Greasel', G)
      {
    if(i < 10 && G != None)
       {
      i++;
      G.Tag = 'RedGreasel';
         G.Skin=texture'GreaselTex2'; // Red Greasels
         G.carcassType=class'RedGreaselCarcass'; // Red carcass
         RebuildRedGreasel();
         Flags.SetBool('GreaelsMarkedRed', true);
         }
      }

PostPosted: Tue Sep 25, 07 4:59 pm
by Cozmo
Just out of curiosity, what's ++? Is that the same as +=1?

PostPosted: Tue Sep 25, 07 5:09 pm
by Dae
yer

PostPosted: Thu Sep 27, 07 7:45 pm
by Alex
~Cozmo~ wrote:Just out of curiosity, what's ++? Is that the same as +=1?

Not sure if it's the same in UC, but in php you have this stuff:
for($i = 0; $i < 10; $i++) (Count $i+1)
but you can also have this:
for($i = 0; $i < 10; ++$i) (Count $i+1 AFTER this current loop)
I never use ++$i though. I think it's correct, as I wrote it in the previous line. Not 100% sure though.