Adventure Game Studio

AGS Development => Engine Development => Topic started by: eri0o on Fri 22/11/2024 01:14:27

Title: API Character.Following property
Post by: eri0o on Fri 22/11/2024 01:14:27
I have a custom module I use myself that looks like this

CustomFollow.ash
Spoiler
// new module header

import function Follow(this Character*, Character* toFollow, int dist=10, int eagerness=67);
import bool IsFollowing(this Character*);
import Character* Followed(this Character*);
[close]

CustomFollow.asc
Spoiler
// new module script
bool _isFollowing[];
Character* _following[];

void game_start(){
  _isFollowing = new bool[Game.CharacterCount];
  _following = new [/spoiler]Character[Game.CharacterCount];

}

function Follow(this Character*, Character* toFollow, int dist, int eagerness){
  _following[this.ID] = toFollow;
  if(toFollow!=null){
    _isFollowing[this.ID] = true;
  } else {
    _isFollowing[this.ID] = false;
  }
  this.FollowCharacter(toFollow, dist, eagerness);
}

bool IsFollowing(this Character*){
  return _isFollowing[this.ID];
}

Character* Followed(this Character*){
  return _following[this.ID]; 
}
[close]

I've been thinking of just having a readonly property for the character named Following, as Character::get_Following that returns null if no character is being followed or a pointer to the character that this character is following. Does this makes sense? Would this be useful for anyone else?
Title: Re: API Character.Following property
Post by: Crimson Wizard on Fri 22/11/2024 01:29:46
For a completion sake there has to be:
- Following or FollowsCharacter or FollowTarget property - tells whom this character is following now; returns null if not following.
- FollowerCount;
- Followers[] indexed property, let iterate everyone who follows this char;
- maybe readonly attributes that tell distance and eagerness (?) not sure if necessary. (Also, I never learnt what these mean precisely, except for FOLLOW_EXACTLY)