API Character.Following property

Started by eri0o, Fri 22/11/2024 01:14:27

Previous topic - Next topic

eri0o

I have a custom module I use myself that looks like this

CustomFollow.ash
Spoiler
Code: ags
// 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
Code: ags
// 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?

Crimson Wizard

#1
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)

SMF spam blocked by CleanTalk