User talk:Dst

From BF2 Technical Information Wiki
Jump to: navigation, search

I wanted to know how to kill a player, and stumbled upon the vehicleObject.setDamage() method. With a little guidance from KoC, one thing led to another and I wrote a slap script. The only thing missing is an imp slap sound from Dungeon Keeper playing on slap. It gives you 'tinnitus', moves you around a bit, and takes away 5 health (or sets it to 0.01 if you're already below 5). I can't see the point of putting this up in 'Scripts', since to me it's only a toy.

import bf2
import host
import random

def slapPlayer(playerObject):
	bf2.gameLogic.sendGameEvent(playerObject, 13, 1)
	vehicle = playerObject.getDefaultVehicle()
	pos = vehicle.getPosition()
	X = pos[0]
	Y = pos[2]
	Z = pos[1]
	#Alter Z up only...BF coords are 'X Z Y'...
	newX = X * float(random.randrange(95, 105)) * .01
	newY = Y * float(random.randrange(95, 105)) * .01
	newZ = Z * float(random.randrange(100, 102)) * .01
 
	vehicle.setPosition( (newX, newZ, newY ) )

	damage = vehicle.getDamage()
	if damage > 5.0: newdamage = damage - 5.0
	else: newdamage = 0.1
	vehicle.setDamage(newdamage)
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox