Announcement

Collapse
No announcement yet.

How to force a flag drop?

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

    How to force a flag drop?

    I've been working on a sort of team meeting room of sorts for one of my CTF Maps and I've run into a small problem. Since the room is team based, and only opens for ones own team, I need a way to force a flag drop before entering. Otherwise you could hide inside with the flag, and well you get the picture. It would take all the fun out of shooting the flag carrier. Any method would work for me. I was thinking maybe using a teleporter that would force a flag drop, or a volume. The research I've done seems to point to a common function used by vehicles and translocators when a person is forced the drop the flag, but I can't seem to figure out how to use it.

    #2
    Careful with that, someone might figure out a way to "throw" the flag into the room.

    Comment


      #3
      If the teleporter concept was used, throwing would not be a problem. But I can see your point. Careful design is called for.

      Comment


        #4
        My original idea was sort of a staff room, where you could restock safely. Which makes the flag dropping a requirement. As I said earlier, there is some method, I think it was called flagdrop (or was it dropflag?) that is called to have a player drop the flag. But when I looked into the code more, I realized that the pawn was not the obhedct calling the function. Some sort of controller was instead. I really have no idea whats going on here, but I'm pretty sure someone else will.

        Comment


          #5
          The Translocator forces you to drop the flag like so:
          Code:
          if (Instigator.PlayerReplicationInfo.HasFlag != None)
                  Instigator.PlayerReplicationInfo.HasFlag.Drop(0.5 * Instigator.Velocity);
          Instigator is a pawn obviously... And Drop just needs a vecotr pased to it....


          So you could make your own volume, where on entry it forces you to drop the flag, to prevent 'throwing' making it so the volume also detects any flag entries by itself and kills all velocity on it.

          Comment


            #6
            Thats one thing I don't understand: How would one "throw' a flag? I didnn't think you could manually drop one, besides commiting suicide that is. And in doing so the flag would just drop, not like throwing a weapon, where it moves a good distance. So how could one throw it?

            Comment


              #7
              Lamers have their ways. Just set the velocity to (0,0,0) when it's dropped and you should be ok.

              Comment


                #8
                Lamers are terribly ingenious when it comes to finding new ways to take an advantage unknow to most...

                Comment


                  #9
                  I currently am using two different computers, one for internet and the other for unreal, so i've had trouble transfering code back and forth, but this is what I've come up with with your suggestions:

                  Code:
                  class AntiFlagVolume extends Volume
                  	native;
                  
                  
                  State AssociatedTouch
                  {
                  	event touch( Actor Other )
                  	{
                  		AssociatedActor.touch(Other);
                  	}
                  
                  	event untouch( Actor Other )
                  	{
                  		AssociatedActor.untouch(Other);
                  	}
                  
                  	function BeginState()
                  	{
                  		local Actor A;
                  		local Pawn  B;
                  		
                                                    
                  		ForEach TouchingActors(class'Pawn', B)
                  		{
                  			if (B.PlayerReplicationInfo.HasFlag != None)
                  			        B.PlayerReplicationInfo.HasFlag.Drop(0.5 * B.Velocity);
                  		}
                  
                  		ForEach TouchingActors(class'Actor', A)
                  			Touch(A);
                  	}
                  }
                  I tried adding the flag drop code right before the volume preforms the touch on the touching actors, but no luck. Maybe I need move it into the touch event itself?

                  I have a strong background with other languages, but I have limited experince with UnrealScript, which explains, I'm sure, why this code isn't working. I've tried inserting log messages, but none ever seem to appear in the logs. Sometimes its really frustrating to program without a good debugging system.

                  Comment


                    #10
                    Here is how I would fix that so it might work..., I've added coments to explain...
                    Code:
                    class AntiFlagVolume extends PhysicsVolume;
                    /*I removed the native declaration since you are not and cannot add  native code, i'm not sure if it will not compile if there is no native dll/headers to be found, but better safe then sorry.  Second I made it extend PhysicsVolume since they already have native events set up to handle the entry/exit of pawns...*/
                    
                    //called as you enter the volume, can be called an event or function, they count as the same thing, most functions that are called natively are declared as events...
                    simulated event PawnEnteredVolume(Pawn Other)
                    {
                        Super.PawnEnteredVolume(Other); //tells the volume to do what physics volume already does in the super class...
                    
                        Other.PlayerReplicationInfo.HasFlag.Drop(Other.Velocity * -1 * 0.5); //You already had this figured out... The velocity I'm passing should be opposite and half of the entering pawn so that the flag kicks bakc a bit, so other people can pick it up without running into the volume and dropping it (i can see this being abused to prevent the flag returning...)
                    }
                    I woudl also add the follwing to prevent any monkey business involving throwing the flag in...
                    Code:
                    event ActorEnteredVolume(Actor Other)
                    {
                        if(Other.IsA('CTFFlag'))
                            Other.Velocity = Other.Velocity * -1
                    }
                    The above should make it bounce out (of my math is right)

                    Comment


                      #11
                      Thanks for your advice. I'll try the changes as soon as I get back to my computer at home.

                      Comment


                        #12
                        I've done some work on the volume and it seems to be working alright, except for one thing. I've noticed that if one's timing is just right, you can carry the flag into the volume. Is there anyway to have the volume check every few moments or so? My biggest concern is that periodic checking will slow things down. Or would it be a good idea to use two volumes, with one closely nested in the other, so the second can catch what the first missed? If no good solution is found, I am thinking of using a teleporter instead. At least then the touch event will be instantious and not drawn out like being inside a volume.

                        Comment


                          #13
                          Touches should happen just as you enter the volume, it's how water volumes spawn entry/exit effects...


                          could you post your final code??

                          Comment


                            #14
                            Originally posted by Hsoolien
                            Touches should happen just as you enter the volume, it's how water volumes spawn entry/exit effects...


                            could you post your final code??
                            yes please...

                            and keep looking for the solution, because i need it also...


                            (i don't want that players go in their own spawnrooms with the flag of the other team :cry: )

                            Comment

                            Working...
                            X