Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- an example of how i would like to see a bird that maybe runs away from people for example
- function __get__helper()
- {
- retval = {
- "_friendlyname":"Pigeon",
- "Object Name":this.Name,
- };
- }
- function OnCreated()
- {
- this.NextMove = Game.GetTicks()+2000+(random(0,2000)%2000);
- this.OriginalPosition = this.Position;
- this.SetAnimation("pidgeon","idle");
- this.TriggerEvent("Think",1);
- }
- function Think()
- {
- near_players = Game.GetNearbyPlayers(this,10);
- if (near_players.size() > 0)
- {
- for ( i in near_players )
- {
- Player player_i = i;
- if ( player_i.CurrentMoveSpeed() > 10 )
- {
- this.Flee();
- }
- }
- } else
- {
- if ( this.NextMove < Game.GetTicks() )
- {
- this.SetAnimation("pidgeon","walk");
- Position new_pos = new Position(
- random(this.OriginalPosition.x-20,this.OriginalPosition.x+20),
- random(this.OriginalPosition.y-20,this.OriginalPosition.y+20) );
- this.MoveTowards(new_pos,3,1);
- // move towards new_pos at 3 tiles a second for 1 second
- }
- }
- this.TriggerAction("Think",1);
- }
- function Flee()
- {
- // play one of 4 of the premade fly away animations
- this.SetAnimation("pigeon","fly_away_"+(random()%4));
- this.Sleep(10); // wait 10 seconds
- // set animation and block execution till it finishes
- this.SetAnimation("pigeon","return",true);
- this.TriggerAction("Think",1); // go back to Think loop
- }
Add Comment
Please, Sign In to add comment