UE3 - UDK AI triggering Kismet event / Dialogue / AI "seeing" another AI

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

alchoris

New Member
Sep 13, 2010
14
0
0
Hi all,

I'm new in these forums and I'm probably still considered a newbie when it comes to Unreal Script.

Anyway, I'm working on a game with classmates and we need to figure out some things.

1) We have an enemy that instantly kills the player when it touches them. We think there are two methods but we don't know how to do either. The first we thought of using "event Touch", but we can't find help on how to use it properly. So far we have this:

Code:
event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
{
    local UTPawn HitPawn;
    HitPawn = UTPawn(Other);
    if(HitPawn != None)
    {
        if( PlayerController(HitPawn.Controller) != None )
        {    
            HitPawn.TakeDamage( 9999, None, HitPawn.Location, vect(0,0,0) , class'UTDmgType_ShockPrimary');
            
        }
    }
}

The above is placed in our EnemyController.uc but when we go up to the enemy, it doesn't kill us.

The second method we though of was making the AI trigger a Kismet event which kills the player. If we recall, there is a way in Kismet to deal lethal damage to the player via triggers.

So far, we can get the player to trigger a kismet event via this:

Code:
PlayerController(Pawn.Controller).ServerCauseEvent('flashlight');

But we don't know how to change the above code so that it allows an enemy to trigger it.

2) First of all, does anyone here know how we can make a dialogue system? Currently, we are following one made by ShadGratte:

http://www.youtube.com/watch?v=MniOpcfhgwE

We got the code from him and basically, if we followed his instructions, it works. But when we try implementing it to our game, we get this error:

http://img.photobucket.com/albums/v727/jhawks/dia_msg.jpg

We believe it's referring to this code:

Code:
/*
    -----------------------------------------------------------------------------
    D I A L O G U E
    -----------------------------------------------------------------------------
    Class : SeqAct_DIA_Message
    -----------------------------------------------------------------------------
    Description : this is the Kimset node used to show
    a simple message during a dialogue.
    -----------------------------------------------------------------------------
    Author : Aloïs "Shad" Deniel
    Contact : haloice@homtail.fr
    -----------------------------------------------------------------------------
    Version : 0.1 (July)
    -----------------------------------------------------------------------------
*/

class SeqAct_DIA_Message extends SeqAct_Latent;

var PlayerController Player;
var String Text;
var String SpeakerName;
var CameraActor Camera;

var() bool bDialogueBoxTop;

event bool Update(float DeltaTime)
{
    local MyGamePlayerController PC;
    
    if(Player != none)
    {
        PC = MyGamePlayerController(Player);
        
        if(InputLinks[0].bHasImpulse)
        {
            PC.UpdateCurrentMessage(SpeakerName,Text,Camera,bDialogueBoxTop);
            PC.UpdateCurrentChoices();
        }
        
        if(PC.bNextMessage)
        {
            PC.bNextMessage = false;
            ActivateOutputLink(0);
            return false;
        }
    
        return true;
    }
    else
    {
        ActivateOutputLink(0);
        return false;
    }
}

defaultproperties
{
   ObjName="Message"
   ObjCategory="Dialogue"
   
   ObjColor=(R=195,G=248,B=66,A=255)
   
   bCallHandler=false
   
   OutputLinks.Empty
   OutputLinks(0)=(LinkDesc="Next")
   
   VariableLinks.Empty
   VariableLinks(0)=(ExpectedType=class'SeqVar_Object',LinkDesc="Player",bWriteable=true,PropertyName=Player)
   VariableLinks(1)=(ExpectedType=class'SeqVar_Object',LinkDesc="Camera",bWriteable=true,PropertyName=Camera)
   VariableLinks(2)=(ExpectedType=class'SeqVar_String',LinkDesc="Text",bWriteable=true,PropertyName=Text)
   VariableLinks(3)=(ExpectedType=class'SeqVar_String',LinkDesc="Name",bWriteable=true,PropertyName=SpeakerName)
   
}

From Shad's original code, the only thing we changed in the code above is that instead of DIA_PlayerController (Shad's which extends PlayerController), we replaced it with the above, MyGamePlayerController (ours which extends GamePlayerController).

We don't know another dialogue system and we don't know how to make the above work.

3) We are trying to make an enemy Bot 1 "see" an enemy Bot 2.

We have this so far:

Code:
    event SeeMonster(Pawn SeenFirefly)
    {
        theFirefly = SeenFirefly;
        distanceToFirefly = VSize(theFirefly.Location - Pawn.Location);
        if (distanceToFirefly < LightPerceptionDistance)
        {
            Worldinfo.Game.Broadcast(self, "I see the firefly!!!");
            GoToState('ChaseFirefly');
        }
    }

But the above doesn't work and we know because we don't get the message "I see the firefly!!!". We know that "Worldinfo.Game.Broadcast();" works because we used it in other sections of the code to see if functions or events are called.

Sorry for the long post but I didn't want to make 3 separate threads. So in the end, can anyone help us with the 3 above? Any help would be greatly appreciated and if anyone needs more information about something, just ask and we will provide it as much as we can. We really need help with these because these matter a lot in our game.

Thanks for your time.

Regards
Alchoris
 

brold9999

New Member
Apr 5, 2009
142
0
0
Firstly,

I didn't want to make 3 separate threads.

Why not? Three separate threads would be more useful to people who search for threads like this in the future, and will keep the discussion on each issue more focused. Unless the issues are inter-related, there is no clear advantage to putting it all in one thread.

Your code in the touch event for #1 mostly looks right, but see the thread "ProcessTouch not getting called" - normally you only Touch() an actor if you overlap with it, and actors which "block" other actors (ie have space-occupying behaviour) don't overlap with others that also "block" other actors. I think Bump does what you need.

I'd put in some log messages or more level.game.broadcasts to investigate the SeeMonster issue. I'm not 100% sure with that call, but similar calls only get called the first time it sees the other pawn, and subsequent times if if loses sight of the pawn, but it does not get called repeatedly while the visibility remains the same. So for example, if the firefly is spotted but is farther away than LightPerceptionDistance, and the pawn moves closer to the firefly, the code will not work because SeeMonster won't get called again at the closer distance. Some investigation will be necessary to determine if that is what is actually happening.
 

alchoris

New Member
Sep 13, 2010
14
0
0
That is true. I'll keep that in mind next time.

Anywhos... In my bot's pawn, I saw there was a "BlockActors=true", so I made that false and tried it. I also placed a log command in the touch event to see if it actually called it:

Code:
event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
{
    local UTPawn HitPawn;
    HitPawn = UTPawn(Other);
    if(HitPawn != None)
    {
        if( PlayerController(HitPawn.Controller) != None )
        {    
            'log("I am attacking player");
            HitPawn.TakeDamage( 9999, None, HitPawn.Location, vect(0,0,0) , class'UTDmgType_ShockPrimary');
            
        }
    }
}

In the game, I can walk through my bot now but I saw in the log that it didn't call the touch event. I also tried changing that PlayerController into GamePlayerController but to no avail (my PlayerController extends GamePlayerController).

As for the SeeMonster, I placed a log there in there too but it also doesn't call SeeMonster at all.

EDIT: Would it help if I post up my playercontroller and enemy controllers?
 
Last edited:

brold9999

New Member
Apr 5, 2009
142
0
0
Are you putting this code in the controller or the pawn? There is some native code that does some (sometimes undesirable magic) here. If a pawn has a controller, the controller gets the pawn's touch events and some other events. (I don't have a complete list of the events that have this behaviour and I'm not sure that it is well documented)

Having said that, if you don't want to be able to walk through the bot, what you probably want to do is keep BlockActors=true and use the Bump event instead of Touch.
 

alchoris

New Member
Sep 13, 2010
14
0
0
I placed the touch event in my enemy's controller.

Do you know where we can find an example of a completed bump event? We just don't want to get ahead of ourselves, start coding and then mess things up.

Also, do you by any chance know if ai bots can trigger kismet events? I fugured that instead of using touch or bump events and the like, we can try make it so that if the player is within a certain distance from the enemy, trigger a kismet event that kills the player.
 

alchoris

New Member
Sep 13, 2010
14
0
0
We just had an idea. What if instead of the AI kill the player, we play a cinematic.

Basically, once the AI touches the player (or even gets within a proximity of them), it plays a cinematic of the enemy killing the player?

We're currently trying to figure out how to make the AI trigger a cinematic and have the cinematic play full screen. If anyone knows, don't hesitate to post =D

EDIT: Oh one of my friends said that if I can figure out how to make the AI trigger a kismet event, I can use 'Toggle Cinematic Mode' and 'Open GFx Movie' to play a death cinematic. I guess my need of figuring out how to make the AI trigger a kismet event will solve 2 of my problems.

Hopefully someone knows.
 
Last edited:

alchoris

New Member
Sep 13, 2010
14
0
0
I found a solution about the AI triggering a kismet event. It involves creating a dynamic trigger, making it follow the player and allowing only enemies to trigger it. So that is 1 out of 3 of my problems solved. Woo hoo!
 

brold9999

New Member
Apr 5, 2009
142
0
0
Do you know where we can find an example of a completed bump event? We just don't want to get ahead of ourselves, start coding and then mess things up.

UTOnslaughtFlagBase (in the UT3 source) uses the Bump method.

Also, do you by any chance know if ai bots can trigger kismet events? I fugured that instead of using touch or bump events and the like, we can try make it so that if the player is within a certain distance from the enemy, trigger a kismet event that kills the player.

There are various ways for an AI to trigger Kismet events. Usually Kismet is only used for map-specific or UI-specific scripting though, so it's probably not the best way of killing the player.
 

alchoris

New Member
Sep 13, 2010
14
0
0
Oh ok. I'll take a look at that 'UTOnslaughtFlagBase' and see if we can implement it into our game.

Thanks.