Author Topic: on conversationscript check for race and subrace?  (Read 576 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
on conversationscript check for race and subrace?
« on: August 16, 2015, 10:29:32 pm »


               

okay well I want to make a race restriction on my module, HOWEVER I am not entirely sure how to go about it and I do not want to ban every race entirely so I had decided to create a small script (with help of Lilac) to make the object it has a conversation with if the player is the appropriate race (for now only allowing humans & the subrace werewolf/vampire), or when they got a widget that allows them to play the race, then it will teleport the player into the game.


 


here is the script but when I put the restriction in then the porting does not work. It is possibly something entirely simply I am missing here >.< 



 


void ClearAndJumpToObject(object oDestination);

void ClearAndJumpToObject(object oDestination)

{

    ClearAllActions();

    JumpToObject(oDestination);

}

 

 

void main()

{

    effect eVFX;

    object oTarget;

 

    // Get the PC who is in this conversation.

    object oPC = GetPCSpeaker();

 

    // If the PC is not a certain race.

    if ( GetRacialType(oPC) != RACIAL_TYPE_DWARF  &&

         GetRacialType(oPC) != RACIAL_TYPE_ELF  &&

         GetRacialType(oPC) != RACIAL_TYPE_GNOME  &&

         GetRacialType(oPC) != RACIAL_TYPE_HALFLING  &&

         GetRacialType(oPC) != RACIAL_TYPE_HALFELF  &&

         GetRacialType(oPC) != RACIAL_TYPE_HALFORC )

    {

        // Find the location to which to teleport.

        oTarget = GetWaypointByTag("WP_INGAME");

 

        // Teleport the PC.

        eVFX = EffectVisualEffect(VFX_IMP_UNSUMMON);

        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oPC);

        DelayCommand(3.0, AssignCommand(oPC, ClearAndJumpToObject(oTarget)));

}

 

 



 


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #1 on: August 16, 2015, 11:15:24 pm »


               I may be wrong, but I suspect A != B && C might be interpreted as A != (B && C), Better to write

if (( GetRacialType(oPC) != RACIAL_TYPE_DWARF)  && (...
which is unambiguous.


The code would be simpler if you tested for human or vampire or werewolf.
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #2 on: August 17, 2015, 02:10:20 am »


               

I may be wrong, but I suspect A != B && C might be interpreted as A != (B && C)


That's the best practice, yeah, but boolean operators evaluate before logical operators, so it's not what's causing the problem.

If you look, you'll see you're missing a } at the bottom of the script, so it's not compiling. When I added that, it worked fine for me. If that still doesn't fix it, make sure your waypoint has the proper tag and that you're actually using a human as your test subject.
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #3 on: August 18, 2015, 11:53:09 am »


               Ahhh ok thanks for the imput guys!! Will give it a try and will let you guys know if it worked '<img'>
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #4 on: August 27, 2015, 11:16:37 pm »


               

okay it generally worked although I think I made a small error on the vampire subrace part, not entirely sure how to fix this so I will place it here in hope someone can point out the epic error I made and makes me feel all silly-nilly '<img'> 


 




void main()

{

    object oTarget;

 

    // Get the creature who triggered this event.

    object oPC = GetEnteringObject();

 

    // Only fire for (real) PCs.

    if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )

        return;

 

    // Abort if the PC is not a certain race.

    if ( GetRacialType(oPC) != RACIAL_TYPE_DWARF  &&

         GetRacialType(oPC) != RACIAL_TYPE_ELF  &&

         GetRacialType(oPC) != RACIAL_TYPE_GNOME  &&

         GetRacialType(oPC) != RACIAL_TYPE_HALFLING  &&

         GetRacialType(oPC) != RACIAL_TYPE_HALFELF  &&

         GetRacialType(oPC) != RACIAL_TYPE_HALFORC )

        return;

 

    // Find the location to which to teleport.

    oTarget = GetWaypointByTag("EternalRest");

 

    // Teleport the PC.

    AssignCommand(oPC, ClearAllActions());

    AssignCommand(oPC, JumpToObject(oTarget));

 

    // If the PC's subrace is blank.

    if ( GetSubRace(oPC) == "" )

    {

    }

    else

    {

    }

 

    // If the PC's subrace is VAMPIRE.

    if ( GetSubRace(oPC) == "VAMPIRE" )

    {

    }

    // Else, if the PC is a certain class.

    else if ( GetLevelByClass(CLASS_TYPE_CLERIC, oPC) > 0  ||

              GetLevelByClass(CLASS_TYPE_PALADIN, oPC) > 0 )

    {

    }

    else

    {

    }

 

    // Find the location to which to teleport.

 

    // Teleport the PC.

    AssignCommand(oPC, ClearAllActions());

    AssignCommand(oPC, JumpToObject(oTarget));

}

                                    `

 

 



 



Basically what the script does is that it checks for the races that should be transported to the EternalRest zone for characters that are not allowed on the module/server. Now that works (for the most part) 


 


The only problem here is that I want the script to check for the SUBRACE: VAMPIRE and if the vampire has a class in either Paladin or Cleric so than that vampire will be transported to the eternal reszone. Since cleric and paladin are non playable classes for vampires on my server (or are supposed to be)  though not entirely sure how else to lock them '<img'> 



               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #5 on: August 28, 2015, 02:50:31 am »


               

There are a number of problems here. First, your script is returning before the jump if your race is human, so it never gets to the point where it should check if your subrace is vampire. Second, you're jumping players to the same waypoint twice. Third, your if/else checks are out of whack. Here's a fixed version.



void main()
{
    // Get the creature who triggered this event.
    object oPC = GetEnteringObject();
 
    // Only fire for (real) PCs.
    if (!GetIsPC(oPC) || GetIsDMPossessed(oPC))
        return;
 
    // If the PC is a human and a vampire, check his class.
    if (GetRacialType(oPC) == RACIAL_TYPE_HUMAN)
    {
        // If he's not a vampire, abort.
        if (GetSubRace(oPC) != "VAMPIRE")
            return;
       
        // If he doesn't have divine classes, abort.
        if (!GetLevelByClass(CLASS_TYPE_CLERIC, oPC) &&
            !GetLevelByClass(CLASS_TYPE_PALADIN, oPC))
            return;
    }
 
    // We fell through to this point, so the PC either has a disallowed race or
    // is a vampire with divine classes. Teleport him to the holding area.
   
    // Find the location to which to teleport.
    object oTarget = GetWaypointByTag("EternalRest");
 
    // Teleport the PC.
    AssignCommand(oPC, ClearAllActions());
    AssignCommand(oPC, JumpToObject(oTarget));


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #6 on: August 28, 2015, 06:00:14 am »


               


 


There are a number of problems here. First, your script is returning before the jump if your race is human, so it never gets to the point where it should check if your subrace is vampire. Second, you're jumping players to the same waypoint twice. Third, your if/else checks are out of whack. Here's a fixed version.



void main()
{
    // Get the creature who triggered this event.
    object oPC = GetEnteringObject();
 
    // Only fire for (real) PCs.
    if (!GetIsPC(oPC) || GetIsDMPossessed(oPC))
        return;
 
    // If the PC is a human and a vampire, check his class.
    if (GetRacialType(oPC) == RACIAL_TYPE_HUMAN)
    {
        // If he's not a vampire, abort.
        if (GetSubRace(oPC) != "VAMPIRE")
            return;
       
        // If he doesn't have divine classes, abort.
        if (!GetLevelByClass(CLASS_TYPE_CLERIC, oPC) &&
            !GetLevelByClass(CLASS_TYPE_PALADIN, oPC))
            return;
    }
 
    // We fell through to this point, so the PC either has a disallowed race or
    // is a vampire with divine classes. Teleport him to the holding area.
   
    // Find the location to which to teleport.
    object oTarget = GetWaypointByTag("EternalRest");
 
    // Teleport the PC.
    AssignCommand(oPC, ClearAllActions());
    AssignCommand(oPC, JumpToObject(oTarget));



thanks! Although when I try to add the script I get: 


void main()                             <-  ERROR: UNKNOWN STATE IN COMPILER.


 


also when testing the script the subrace Vampire is not being transported :S


               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #7 on: August 28, 2015, 10:14:02 am »


               

It compiled fine for me. Sometimes that error means there's a curly brace missing somewhere. Did you check and make sure you copied the whole thing exactly?


Also, when the compiler encounters an error, it stops building the script. When you test the module, the last version that compiled correctly will be the one it runs. So the failure to transport the vampire subrace is due to the fact that it's still trying to run your original script, not the one I fixed for you.



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #8 on: August 28, 2015, 10:42:13 am »


               I copied the entire script and it only compiled once I put it in a clean script though then the Vampire subrace did npt ported to the destination....
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #9 on: August 28, 2015, 06:48:50 pm »


               

Maybe I'm confused about what you're trying to do. Is this the script that moves any races that aren't allowed to the "jail" area where they can't get to the rest of the module? And vampires should only go there if they have levels in Cleric or Paladin, right?



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #10 on: August 28, 2015, 09:38:52 pm »


               Yes, problem is here that it does not do that for the vampire subrace (while with cleric/paladinlvls) it just stops at the entrance room where you can get into the module.
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
on conversationscript check for race and subrace?
« Reply #11 on: August 28, 2015, 10:00:37 pm »


               


Maybe I'm confused about what you're trying to do. Is this the script that moves any races that aren't allowed to the "jail" area where they can't get to the rest of the module? And vampires should only go there if they have levels in Cleric or Paladin, right?




 


okay its fixed! The problem was all on my en d, missing an } in the end XD  but thanks a lot for this monk! '<img'>