Files

114 lines
1.9 KiB
Markdown

# IScriptEntity.unlockRotation
[← IScriptEntity](index.md) · [← Master](../../wiki.md)
Parça 9/17 · [önceki](unlockRotation-8.md) · [sonraki](unlockRotation-10.md)
// Kills all cows within 5 blocks of the player
function main(c)
{
var tracker = c.getSubject();
var trackedEntities = c.getServer().getEntities("@e[type=cow]");
for each (var trackedEntity in trackedEntities)
{
if (trackedEntity.isEntityInRadius(tracker, 5))
{
trackedEntity.kill();
}
}
}
isInBlock
default boolean isInBlock(int x,
int y,
int z)
Check if this entity is standing in a given block.
var s = c.getSubject();
if (s.isInBlock(0, 0, 0))
{
c.send(s.getName() + " is at (0, 0, 0)!");
}
isInArea
boolean isInArea(double x1,
double y1,
double z1,
double x2,
double y2,
double z2)
Check if this entity is standing in a given area.
var s = c.getSubject();
if (s.isInArea(20, 3, 100, 30, 8, 110))
{
c.send(s.getName() + " is within given area!");
}
damage
void damage(float health)
Inflict some damage on this entity (use kill() to kill the entity though).
c.getSubject().damage(1); //dealt you 1 damage
damageAs
void damageAs(IScriptEntity entity,
float health)
Damage this entity as given entity was the source of attack.
function main(c)
{
var player = c.getSubject();
var result = player.rayTrace(32);
if (result.isEntity())
{
result.getEntity().damageAs(player, 1);
}
}
damageWithItemsAs
void damageWithItemsAs(IScriptPlayer player)
Damage this entity as given player was the source of the attack with its equipment.
function main(c)
{
var player = c.getSubject();
var result = player.rayTrace(32);
if (result.isEntity())
{
result.getEntity().damageWithItemsAs(player);
}
}
mount
void mount(IScriptEntity entity)
Mount this entity to given entity.
function main(c)
{