Scripting: Human-controlled instance of MovementObject

Post Reply
User avatar
DorkeyDear
Posts: 5
Joined: Fri Nov 11, 2011 12:08 pm

Scripting: Human-controlled instance of MovementObject

Post by DorkeyDear » Sun Jan 29, 2012 12:56 pm

Is there a way to check if an instance of a MovementObject is human controlled? Maybe a way to get the instance of a human-controlled object?

I am messing with hotspots, and am trying to make a counter of the number of players in a hotspot, and display it on the screen only if you are in the hotspot. Currently, when a non-human player enters a hotspot, it also displays (and removes from display when leaving) the text, which is undesired behavior.

An aside question:
I've seen some video demonstrating splitscreen in OG. Is there a method to display text on only one of the screens, and not the other (preferably a method to designate which player I am displaying the text to)?
I probably should at least test to see if I can get splitscreen working before I try to fix that problem that my script may have with it, but I figured I would ask while I had it in mind.

Another aside:
Yay; my first post! Hehe

User avatar
Johannes
Posts: 1374
Joined: Thu Dec 18, 2008 1:26 am
Contact:

Re: Scripting: Human-controlled instance of MovementObject

Post by Johannes » Sun Jan 29, 2012 2:59 pm

Hey there, I love first posts like this =)

As far as I know neither of those are currently possible, but should be eventually.

I may be wrong on the first one though, I haven't looked into it very much, but I'm positive that the game doesn't differentiate well between the split screens yet. I'm sure some of the other guys that have done more scripting can better answer the first part though.

User avatar
Endoperez
Posts: 5668
Joined: Sun Jan 11, 2009 7:41 am
Location: cold and dark and lovely Finland

Re: Scripting: Human-controlled instance of MovementObject

Post by Endoperez » Sun Jan 29, 2012 3:29 pm

I have a hazy memory of there being a variable in aschar.as that defines an AI-controlled character. I'm not very certain though.

User avatar
Korban3
Posts: 4146
Joined: Tue May 31, 2011 9:14 pm
Location: 42nd St E, Hell

Re: Scripting: Human-controlled instance of MovementObject

Post by Korban3 » Sun Jan 29, 2012 10:39 pm

Well, if you have the id of any character you can use ReadCharacterID(int id) to get a MovementObject@ and you can pass integer and float functions to them, but I don't think we can count player's yet.

carn1x
Posts: 28
Joined: Mon Sep 12, 2011 9:58 am

Re: Scripting: Human-controlled instance of MovementObject

Post by carn1x » Sat Feb 11, 2012 6:08 am

The following code is repeated in numerous places throughout level.as, should tell you what you need?

Code: Select all

    int num = GetNumCharacters();
    for(int i=0; i<num; ++i){
        MovementObject@ char = ReadCharacter(i);
        if(char.controlled){
            ...
        }
    }

User avatar
DorkeyDear
Posts: 5
Joined: Fri Nov 11, 2011 12:08 pm

Re: Scripting: Human-controlled instance of MovementObject

Post by DorkeyDear » Sat Feb 11, 2012 11:29 am

Thank you this has helped. char.controlled was exactly what I needed.

User avatar
Johannes
Posts: 1374
Joined: Thu Dec 18, 2008 1:26 am
Contact:

Re: Scripting: Human-controlled instance of MovementObject

Post by Johannes » Sat Feb 11, 2012 11:37 am

For consistency's sake I'm moving this to the modding subforum.

Post Reply