Announcement

Collapse
No announcement yet.

Karma Damage Question

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

    Karma Damage Question

    I made a karma enabled minecart that races down steep slopes by itself, when it hits a pawn it just pushes them in front of the minecart. What do I have to do to make it so the Minecart damages and kills the pawns when it smashes into them?

    #2
    Youll need to subclass KActor for this. I'm too lazy to explain how to do that, but I'll post some code for you incase you're interested.

    Code:
    var() bool bDamageCausing;	// does this KActor cause damage to other actors
    var() int BaseDamage;		// this is the MINIMUM damage the Kactor can do
    var() int MinDamageSpeed;	// the minimum speed the KActor must be traveling to do damage
    				// damage is scaled based on the ratio of Velocity/MinDamageSpeed
    var() class<DamageType> DamageType;	
    
    event Bump( Actor Other )
    {
    	local vector v;
    
    	// allow pawns and other actors to jump on top of the KActor
    	if (Other.Base == Self)
    		return;
    
    	if (bDamageCausing)
    	{
    		v = VSize(Velocity);
    		if (v >= MinDamageSpeed)
    			Other.TakeDamage((BaseDamage * (v/MinDamageSpeed)),Instigator,Location,Velocity,DamageType);
    	}
    }
    It's simple, not perfect, but should be adequate for your needs. Youll need to define a damage type too, or use one from the game that already exists.

    Comment


      #3
      Oh cool thanks, so where do I put this code? Do I select my karma mesh in the editor and enter this code using the "EDIT SCRIPT" function? Or do I put it somewhere else? Like create my own folder with it's own UC file in it's "Classes" sub folder?

      Comment


        #4
        The edit script function should do it. I'm not 100% sure how to do that, since I've never done it, but you should stick to the mylevel package if possible.

        Comment


          #5
          Actually, try this:

          Go into the actor browser and find KActor. Right click it, select New. Set the package to MyLevel so that it saves with your map and doesnt make a new .u file somewhere. Name the class whatever you want. Paste the script into the editor window, and then compile changed scripts. Place the new actor in your level, replacing the old KActor you had, and it should operate as a normal KActor. Youll have to set the properties I added (they will appear in a group that is the same name as the class you made). That should be all there is to it. The variables are documented, if there is any confusion do ask.

          Comment


            #6
            Oh cool thanks man, I'm not sure how to change the properties though, or what to change them to. Can you please give me an example of what I should do to set the properties to have my kactor kill pawns? Thanks a lot man, I appreciate it.

            Comment


              #7
              Once the actor is in your level, you can change the properties like you change any other property.

              bDamageCausing should be true if you want it to work, heh. BaseDamage should be high, depending on how much damage you want to be caused. If you want the pawn to die, set it to something high, like maybe 100. MinDamageSpeed should be set to something low, but not too low. Low enough that it works, but not too low so that its moving slowly but still is able to kill you. Like getting hit by a car moving 5mph, its not going to cause 500 damage. A good value would be 200, imo. Also damage will be scaled by how much the velocity is over the MinDamageSpeed. So if your velocity is 400, and your MinDamageSpeed is 200, whatever BaseDamage you set will be doubled when the actor hits you (400/200 = 2).

              Values will depend on the overall effect you want, though.

              Comment

              Working...
              X