Ir para conteúdo
  • Cadastre-se

[SCRIPT] Controlar um char por outro Char (Magebomb)


Posts Recomendados

//////////////////COMANDOS
///move up, down, left, right
///say text
///turn up, down, left, right
///follow name
///attack name
///sd name
//////////////////FIM DOS COMANDOS

const
MasterList = ['Kilecore', 'Hoobastank'] //Nome dos chars que vão dar os comandos, ponha entre as '.'

function GetCreatureByName(Name: string): TCreature;
begin
Result := nil;
for x := 0 to Creatures.Count - 1 do
begin
if x >= Creatures.Count then
Break;
if AnsiLowerCase(Creatures.Creature[x].Name) = AnsiLowerCase(Name) then
begin
Result := Creatures.Creature[x];
Exit;
end;
end;
end;

function CommandSay(Text: String);
begin
Self.Say(Text);
end;

function CommandAttack(Name: String);
var
Creature: TCreature;
begin
Creature := GetCreatureByName(Name);
if Creature <> nil then
Creature.Attacking := True;
end;

function CommandFollow(Name: String);
var
Creature: TCreature;
begin
Creature := GetCreatureByName(Name);
if Creature <> nil then
Creature.Following := True;
end;

function CommandSD(Name: String);
var
Creature: TCreature;
begin
Creature := GetCreatureByName(Name);
if Creature <> nil then
Self.Containers.UseItemWithCreature(3155, Creature);
end;

function CommandTurn(Dir: String);
begin
Dir := AnsiLowerCase(Dir);
case Dir of
'up': Self.FaceUp;
'right': Self.FaceRight;
'down': Self.FaceDown;
'left': Self.FaceLeft;
end;
end;

function CommandMove(Dir: String);
begin
Dir := AnsiLowerCase(Dir);
case Dir of
'up': Self.MoveUp;
'right': Self.MoveRight;
'down': Self.MoveDown;
'left': Self.MoveLeft;
end;
end;

function ExecuteCommand(Command, Parameter: String);
begin
case Command of
'say': CommandSay(Parameter);
'attack': CommandAttack(Parameter);
'follow': CommandFollow(Parameter);
'sd': CommandSD(Parameter);
'turn': CommandTurn(Parameter);
'move': CommandMove(Parameter);
end;
end;

function GetCommand(Text: String);
var
Command: String;
Parameter: String;
StrPos: Integer;
begin
StrPos := Pos(' ', Text);
Command := AnsiLowerCase(Copy(Text, 1, StrPos - 1));
Parameter := Copy(Text, Length(Command) + 2, Length(Text) - (Length(Command) + 1));
ExecuteCommand(Command, Parameter);
end;

procedure Event_Message(Channel: integer; Name, Text: String);
begin
for x := Low(MasterList) to High(MasterList) do
begin
if AnsiLowerCase(MasterList[x]) = AnsiLowerCase(Name) then
GetCommand(Text);
end;
end;

while not Terminated do
begin
UpdateWorld;
ProcessEvents;
Sleep(100);
end;

Créditos: ngmax

Editado por Larissa Azhaurn (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo