Announcement

Collapse
No announcement yet.

Controllers, Players, bots.. ahhhhhhhhh

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Controllers, Players, bots.. ahhhhhhhhh

    It's all so confusing.

    I am having one heck of a time making scripts with AIController, ScriptedTriggers, etc.

    I think I finally figured out the root cause. I have no clue how the controller system works.

    I did an editactor class=xpawn
    to edit my own self (I was on the only one in the game).

    Turns out my ControllerClass was XGame.XBot!!!!


    I thought that being a human, I would have a PlayerController controller and was using a cast to that class to determine whether I was a player in a script I am trying to get working.

    I am so utterly thoroughly confused and fustrated. The information on these things is very scant on the web.

    I also want some clarification on AIControllers and scripted sequences. The whole class hierarchy of that part of the engine seems really discheveled, and I still don't understand when a script is activated by triggers or game objectives, or just a bot being near it, etc etc, etc.

    What really boiled my blood was that when I did this, where Somevehicle was the tank I just entered:
    Code:
    if(Somevehicle.Driver.Controller == None)
       log("wth!???");
    I got the wth message . Above that bit of code I have checks to make sure the vehicle and driver are non-none. Why does it think I have no controller when I'm in the tank?????

    Help!

    P.S. Atari please remove that stupid "Reset Message" button which does nothing but cause posters to lose all their typing when their mouse lags out a bit!

    #2
    Is it that when you enter a vehicle, your pawn ceases to be controlled and your controller links directly to the tank pawn itself?

    How do I determine whether a controller is a human or not? bIsPlayer according to UDN does *not* mean Human (bots are also players), and as I mentioned, the cast to PlayerController did not work. Does anyone know how to correctly and reliably determine humaness?

    Comment


      #3
      To determine whether a controller is a human player or not, cast it into a PlayerController.

      Code:
      if(PlayerController(Ctrl) != none) {
        //player is human
      } else {
        //player is AI
      }
      If you're looking at a Pawn subclass, use the IsHumanControlled() function call.

      Comment


        #4
        Do you know why the Editactor class=xpawn

        on myself said that this pawn's Controller was of type Xplayer, and its "ControllerClass" was XGame.XBot?

        I don't understand how this is consistent with the fact that I should be a PlayerController.

        P.S. I made sure it really was my character's pawn. He uses the model Jakob, (I confirmed that this was using Jakob in its Mesh property) and there were no other players/bots in the game. Also, I still don't know why I was getting that bad cast .

        Comment


          #5
          xPlayer is a PlayerController subclass.

          What are you trying to do here? Are you spawning a Pawn subclass in a map? I believe that causes it to be automagically possessed by a AIController unless it's has bDontPossess=true in its defaultproperties.

          You need to describe what you're doing and what you expect to happen.

          Comment


            #6
            Originally posted by PNutButterSnake
            Do you know why the Editactor class=xpawn

            on myself said that this pawn's Controller was of type Xplayer, and its "ControllerClass" was XGame.XBot?
            Because doing that just shows you the default properties.

            ControllerClass=Class'XGame.xBot'

            Comment


              #7
              That is the trap you will fall into looking in the editactor properties (and with trying to script using UnrealEd as it uses the same properties dialog), you get a heck of a lot of properties which are not even used because of inheritance. To use editactor properly you really need to have a very good idea of what you are looking at and how things work, I use it to check that things have worked usually.. like when I implemented my own controller the controller was myBot intead of xBot.

              Its sorta sad that you cant summon xgame.xpawn then set the controller to xBot and have it start playing. Doing that does nothing because it doesnt go through all the initialisation and possessing etc *sigh*.

              As NakedApe said what are you actually trying to do? I know your trying to understand controllers, but for what reason, are you intending to make a deathmatch bot, turret controller, scripted controller...??

              Comment


                #8
                Actually there were two things in a modificaiton of ONS-Primeval.

                1) Each team has a sniper tower overlooking the former manta-in-trees-exploit (now converted to a treehouse). The tower has a lightning gun and also has an Assault minigun turret in it (not sure if i needed to do this but I extended it just in case to make sure the teams are set correctly each round). I can not get the bots to correctly use this tower to kill treehouse campers. They either don't use it at all or they all camp there at the same time.

                2) Something really silly that does not sound controller related, but... I was trying to make the music track change when someone gets into the tank (but only for the tank driver). I tried doing this with a Scripted Trigger and it was just totally unreliable and inconsistent. What I did was set up a regular trigger with a Proximity class of ONSHoverTank. Then when someone gets into the tank and moves it a little bit, they activate that trigger, which in turn activates the ScriptedTrigger. The factory that produces the tank had its tag set to 'TankDied' so that when the tank died, it would raise the event by the same name (if you check the code for ONSVehicleFactory, it sets the Event of the vehicle it spawns to be the same as its Tag).

                THe ScripterTrigger had the following steps:

                1. Wait for event 'TankEntry' (event raised by the regular proximity trigger)
                2. Change music track for the instigator only to SDG-ONS06 (fast paced fragging music).
                3. Give this message to tank driver: "Smash thine enemies!"
                4. Wait for event TankDied.
                5. Change music track back to KR-Atlantis (default track for Primeval).
                6. Taunt player who lost the tank with a message.
                7 Goto Step 1.

                The ScripptedTrigger was executing at least some of the time as shown by the fact that #5 and #6 would (sometimes) execute when the tank died, but for some reason the music track was not changing during #2.

                So I delved into the code to find out if the correct reference to myself was being passed as the instigator from the proximity trigger. I am still not sure but it seemed like it was. (There is code in the Trigger class specifically to detect when a vehicle has caused the triggering and then (possibly?? not sure) to convert that into the driver instead when calling TriggerEvent.

                Well I gave up on that system and instead just programmed my own custom "VehicleAwesomenessTrigger" which detects when the vehicle of a certain factory has been entered, and changes the track for the driver's controller and then changes it back when he leaves the tank/dies. It worked better and gave me more control to make the things happen precisely as I want them to.

                I was trying to access the driver's controller through LastSpawned.Driver.Controller (where LastSpawned is a property of the factory pointing to the last spawned vehicle). This failed miserably.

                I finally realized that the Driver property points to a relatively lifeless false pawn so to speak. The *actually* human Controller is just accessed directly through the Controller property directly on the vehicle itself. This works now.

                I still don't get all this stuff though.

                Comment

                Working...
                X