MODULE: CharacterControl v0.84b

Started by strazer, Wed 04/05/2005 04:07:17

Previous topic - Next topic

strazer

This is my CharacterControl script module for AGS v2.71/2.72.

To quote the CCS plugin by Scorpiorus:

"Imagine you have a lot of characters in the game and want them to perform different tasks at the same time. Yep, a tons of scripting seems unavoidable. However, another way out is to use CCS which provides easy command control system so you define all needed character commands and then just call the execution function. The most powerful is the MOVE command as it works room-independently!"

I really like the idea, but as a Linux user I can't use plugins and I like to do things natively whenever possible. So I wrote the entire thing from scratch as a script module.

Features:

* NPCs can walk around in other rooms, talk, animate etc. _in the background_
* Compatible with CCS plugin command strings
(That may change at any time so you're encouraged to use this module's commands.)

Advantages to the CCS plugin:

+ Cross-platform compatibility
+ Additional and extended, more flexible control commands
+ No need for a dedicated blank view
+ Extensible & customizable

Note that this is still a BETA version.
I have only a simple test game to test this with so I need other users to report any bugs they may encounter.

Download here (Requires AGS v2.71 or higher!)
This download includes the script module(s), documentation and a small demo game.

Edit:

Check this post by monkey_05_06 for an AGS 3+ compatible version

Pumaman


Scorpiorus

Nice work strazer!

It's cool to see this as a script module since the CCS plugin doesn't really use any of AGS plugin API specific functions. And it infact was made as an AGS script that was eventually converted into C. But that's because I just didn't want people to mess with "installing" it by copy and pasting portions of script code around the main global script. It's cool we have the module feature, indeed.

:)

strazer

#3
Version 0.81 now up:

  - Characters now play talking animation when talking*
  - Added check if character is .on before executing command
  - Renamed internal control command enums

See link above.

Edit:

*No lip-sync or voice speech though

Blitzerland

Oh, just think what's possible with this. You could even make a game recreating the chaos of Wall Street.

*Shudder of geeky joy*

Or not. But you get the idea.

Awesomeness, Strazer. Pure awesomeness.

strazer

#5
Version 0.82 now up:

- Fixed problems with rooms > 21
- Fixed characters stuck speaking if not in current room

See download link above.

I'm still not quite satisfied with the internal workings of the module, but this will do for now. It's a Beta after all. ;)

Candle

Thanks strazer, nice work and you sure do a lot .
Thanks again.

strazer

Version 0.83 now up:

- Code rewrite and thus now requiring AGS v2.71!
- Added SAY control command for entering speech directly into command string
- RunScript add-on module now uses String parameters instead of Ints, so you
   may have to update your custom code and paste it into v0.83 of the RunScript
   module. Sorry for the inconvenience.
- Fixed characters occasionally getting stuck when changing rooms

See download link in first post.

(For AGS v2.70, here is v0.82a that includes the bugfix above. This is the last version for AGS v2.70. All future versions including v0.83 will require at least AGS v2.71!)

Kinoko

#8
I'm converting a lot of my script over, but now I get a Type Mismatch for the line in bold:

function charCharColDetectEx(int CharID1, int slot1, int CharID2, int slot2) {
int room1;
int room2;
if (CharID1 != GetPlayerCharacter()) room1 = CharacterControl.GetRoom(CharID1);
else room1 = character[CharID1].room;
if (CharID2 != GetPlayerCharacter()) room2 = CharacterControl.GetRoom(CharID2);
else room2 = character[CharID2].room;
if (room1 == room2) {

...etc

Cannot convert int to character. I'm honestly not sure what to change here. Can anyone help?

strazer

Kinoko, in contrast to the plugin, this module uses new-style scripting exclusively and takes pointers as parameters, not numbers/IDs.
This allows you to use the new character pointers for functions, e.g.:
  int roomid = CharacterControl.GetRoom(cGeorge);

So change
  CharacterControl.GetRoom(CharID1)
to
  CharacterControl.GetRoom(character[CharID1])

(and the same for CharID2)

Kinoko

#10
Thanks. Another probem I have is that I have a longish cutscene that needs to start with various triggers and timers, so the code ends up in pieces in repeatedly_execute.

Now, what would really solve my problem would be the ability to call blocking functions from repeatedly_execute. The fact that AGS won't allow it is what's physically stopping me. I can prevent any problems myself, by triggering the code with a variable value and then immediately changing that value but letting the rest of the script run line by line, but AGS doesn't allow for this.

SSH

I thought you can call blocking functions in rep_ex, but not rep_ex_always...


12

mchammer

great module, its very useful to me. But last time I run the game, it crashed and I got this message:

ACI ver. 2,71,894
in CharacterControl(line 158)
from CharacterControl(line 372)

Error:Move Character: Character not in current room.

I dont know much about these things so im not sure is it either a bug or my own scripting error.
My 40 bullets - An action/war game.

JD

Nice work Strazer, will certainly play around with this at some point :)

strazer

#14
Version 0.84 now up:

- Fixed characters not fully initializing when not starting with ROOM command
- Fixed SAY command not working with characters that have no speech view set

mchammer: This should fix your problem. I (wrongly) assumed each chain starting off with a ROOM change command, so the character wasn't fully initialized yet.

llien

Hi

I'm having trouble getting CCS103 or charactercontrol 0.84 to work. As far as I know, I've read through all the docs, searched through the forums etc, but still not closer to an answer. I'm trying to get 4 npc's to walk on set paths around 1 room in the background. First I tried charactercontrol, but as soon as I import them through modules, the game doeesn't compile any longer, I just get a tonne of "undefined symbol..." errors. Is there somewhere I need to add the scripts to a header? Tried (as a test) to comment out all instances of undefined symbols, but that, of course, broke the script  :)

Also tried CCS, all seems fine, but when, in game_start, I call ccCreateCommand(1, "WALK:1,1;"), I get an error stating it can't convert a const string to a string. Though all documentation states that this is the way to do it...

Both demo games don't run as well.

Am I missing something painly obvious???

using ags 2.72

thanks.

strazer

Version 0.84b now up. I have hopefully updated the module to work with both AGS v2.71 and v2.72.

Oddysseus

Sorry for digging up this old post, I just wanted to point out that the AGS Resource page still links to version 0.84, the version that doesn't work in AGS 2.72.

GarageGothic


strazer

Thanks, I've sent jasonkay a pm, he maintains that site.

Rocco

thx for updating this great module.  :)

i have one question:
what is the easiest way, to change walkspeed between chain-commands?
i want to assign a random walkspeed after some walk commands in the chain.

mchammer

Quote from: Rocco on Sun 16/09/2007 17:48:34
thanks for updating this great module.  :)

i have one question:
what is the easiest way, to change walkspeed between chain-commands?
i want to assign a random walkspeed after some walk commands in the chain.


I think easiest way is to use RunScript module (comes with Character Control module).
Add RunScript module BEFORE CharacterControl module in your game.

Script you use inside RunScript module:
Code: ags

   if (parameter1.AsInt == ExampleValue) {
    int WalkingSpeed = Random(MaxWalkspeed - MinWalkspeed) + MinWalkspeed;
    thechar.SetWalkSpeed(WalkingSpeed,WalkingSpeed);
  return 0; 


Then you add to chain a command 'RUN:ExampleValue;' when you want change the walking speed.

Replace ExampleValue with a number 1 or above.
My 40 bullets - An action/war game.

Rocco

thanks mchammer, works perfect  :)
i will use this module in 2 of my upcoming games.

strazer


Rocco

#24
i tried something like this

Code: ags
   	CharacterControl.CreateChain(1, "ROOM:3, random(80)+250,270; RUN:1; WALK:Random(250)... 


and get the error message that only numbers are allowed,

i need the whole values randomly all the time.
i know the example in the demo which sets the chain values randomly,
but the problem is, when the chain is finished one time and returns to the beginning, (GOTO 1 )
it should generate new random values again, and dont use the values generated one loop earlier.

the only solution i can imagine, is to make a new chain for every loop, but then i need a very huge ammount of chains.
is there another possible solution?

Rocco

sorry for doppelposting, i have another question.  :)

i noticed that the chars arent in the given position when i change room,
and come back to the room, where the CC module is running.

Can this happen, when the roomsize is different?
The main room with the Controled Chars is 4time bigger as the other room.

Rocco

Ok here i go again.  :)

The situation is as follow:
I have one character walking in one room with the CC-module, this character activates some events every few seconds when he steps on a specified region.
This is important for the game, regardless if the player is in the same room or not.
Ok so when im leaving the room with the CC controlled chars, the events doesnt occurs anymore.

My thought was, when all the CC-controlled chars are taken to the rooms where the player is,
and act invisible, i draw the same regions in another room and the events can go on.
But this approach doesnt work either.

strazer please help!!!  :),
MAGS deadline is coming very close now.

strazer

Rocco, I'd like to help but I'm totally out of the loop at the moment, haven't worked with AGS in months and am quite busy at work.
I'm sorry, I hope someone else will be able to help you out.

Khris

Quote from: Rocco on Thu 24/07/2008 18:22:38
i tried something like this

Code: ags
   	CharacterControl.CreateChain(1, "ROOM:3, random(80)+250,270; RUN:1; WALK:Random(250)... 


and get the error message that only numbers are allowed,

Code: ags
   	CharacterControl.CreateChain(1, String.Format("ROOM:3, %d, 270; RUN:1; WALK:%d...",random(80)+250, Random(250))); 

Revonx

Hi,

Having a problem with the module that I can't figure out. When I run the game it works fine except for sometimes at random removing either a character from the game entirely or incorrecly placing a character into a non designated room scrolling up and down the right side of the room itself, quite bizzare.
Hopefully its a simple explanation that I failed to acknowledge.

Heres the code:

function game_start() // called when the game starts, before the first room is loaded
  {
    CharacterControl.CreateChain(1, "ROOM:7,30,170; WALK:319,176;");
CharacterControl.AppendChain(1, "ROOM:3,0,175; WALK:319,174;");
CharacterControl.AppendChain(1, "ROOM:16,0,182; WALK:140,172; WAIT:100; WALK: 300,170; WAIT: 100; WALK:140,172; WAIT:100; WALK:0,179;");
CharacterControl.AppendChain(1, "ROOM:3,319,174; WALK:0,175;");
CharacterControl.AppendChain(1, "ROOM:7,319,176; WALK:30,170; GOTO:1;");
CharacterControl.StartExecuting(cGoliath, 1);
CharacterControl.CreateChain(2, "ROOM:11,165,152; WAIT: 100; LOOK: 160,160; WAIT: 100; ANIMATE:4,0,0; WAIT: 100; WALK: 274,153; WAIT: 200; WALK: 266,111; WAIT: 200; WAIT: 100;");
CharacterControl.AppendChain(2, "WALK:274,153; WAIT: 100; WALK:165,152; GOTO:1;");
CharacterControl.StartExecuting(cCop, 2);
}

Hoping someone knows whats going on.  ;D

Revonx.

beomoud

I can't get it to work.... i get this message:

CharacterControl_084b.asc(52): Error (line 52): Array size must be constant value

strazer

I don't think it works with AGS 3 at the moment. Aside from not having the time at the moment, I can't run the new editor so I'm unable to debug this.

Unless someone else is willing to step in, I'm afraid this module is orphaned for now...sorry.

monkey0506

#32
Hey strazer, no worries.

Download (Mirror)

This is pretty much just a 1-to-1 conversion.

Changelog:

  • Converted CharacterControl_Character struct into local variables (ccCharacter_ChainID, ccCharacter_ChainPosition, etc.)
  • Replaced AGS_MAX_CHARACTERS with dynamic arrays of size Game.CharacterCount.
  • Replaced all short variables with ints, because they're faster.
  • Replaced AGS_MAX_VIEWS parameter checks with Game.ViewCount.
  • Added "CharacterControl module error: " to the beginning of error messages to clarify the meaning to the user.
  • Changed version info to 0.85.
  • Added dependency for AGS 3.0+; AGS 2.72- users can continue to use prior versions of the module.
  • Removed all AGS 2.72 IFVER checks as they're redundant with 3.0 dependency.


NOTE: The above download link only includes the SCM for the module. It does not include any documentation, the CharacterControl_RunScript module, demo game, etc., etc. You must download the 0.84 package for these files.

I did test the 0.84 demo game with 0.85 of the module and it appeared to function fine. I didn't do any extensive testing, but based on the minimal changes I made, none of the actual module functionality should have been affected anyway. All prior module commands (for the end-user) should work exactly the same.

strazer



monkey0506

You're both welcome. It was a simple fix really. :)

As a matter of fact...it wouldn't be that difficult to throw in some #ifdef-s to make the entire thing backwards compatible to 2.71...maybe on my next day off from work. ;)

Dualnames

Sorry for the bump, but downloaded and greatest of implementations so far Monkey..
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Matti

Whoa, this Module could come in handy. Thanks in advance, strazer and monkey..

Dualnames

Quote from: Mr Matti on Tue 28/04/2009 23:49:57
Whoa, this Module could come in handy. Thanks in advance, strazer and monkey..

And dual, for bumping it up for no reason.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Dualnames

Can I ask if there's a license of any sort coming with this module? For from all I can see there's not.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

strazer

From the readme coming with the original package:

Quote
You are free to use this for any game, free or commercial. A credit would be
nice but is not necessary.

So no license, you're free to do with it as you please. :)

Dualnames

Quote from: strazer on Wed 06/05/2009 12:38:28
From the readme coming with the original package:

Quote
You are free to use this for any game, free or commercial. A credit would be
nice but is not necessary.

So no license, you're free to do with it as you please. :)

So nothing? Like CharacterModule v0.84b is property of Strazer and revised by Monkeyo5o6 or something..?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

strazer

Yep, I've written the module to help fellow AGSers and I expect nothing in return. :)

Tanique

Hi guys, first of all thanks in advance for such a great module.  This thing is FABULOUS.

I know this thread hasn't been used in a while but I think it makes more sense to post it here than start a new one.  I was playing with this module for my game (monkey's .85 version using AGS 3.1.2) and I've noticed what might be a bug in the WALK scripting.  If I ever program my background character to walk to any x,y coordinates with odd values, she'll walk there, but won't continue the rest of the script.  As long as her WALK coordinates are even numbers, the script runs smoothly.  Is this a known bug?  I'm thinking it may have something to do with AGS 3's ability to run high resolution coordinates in the script.....but I'm really not sure.  The project I'm having problems with is 640*400 resolution.

Just thought I'd bring this to your attention.  Thanks again for this magical piece of scripting, keep up the good work!

placyd

When I try to run my game with this module, it writes the following error message:
CharacterControl module error: This module requires at least v0.83 of the CharacterControl RunScript module.
I'm using AGS 3.1.2 SP1 with CharacterControl v0.85
What could be the problem?

placyd


Dualnames

Quote from: placyd on Tue 10/08/2010 17:53:45
When I try to run my game with this module, it writes the following error message:
CharacterControl module error: This module requires at least v0.83 of the CharacterControl RunScript module.
I'm using AGS 3.1.2 SP1 with CharacterControl v0.85
What could be the problem?

I found that line on the header and I removed it. And the Character control seems to work fine with me. Even released a game with it. :D
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

placyd

Quote from: Dualnames on Tue 17/08/2010 14:03:58
I found that line on the header and I removed it. And the Character control seems to work fine with me. Even released a game with it. :D

Wow, I would have never thought that, but it's working! :D
Thanks!

placyd

#48
I've run into another problem  :(

My code is:
CharacterControl.CreateChain(1, "ROOM:6,360,360; WALK:625,400; WAIT: 40,80; WALK:760,420; WALK:625,400;");
CharacterControl.StartExecuting(cSecur, 1);

The character does everything, except the last part - he stops at coordinates 760,420.
And I can't write anything after it, he always stops that point...
???

Edit:
I've read back and found this quote by Tanique, that he had the same problem, when not even numbers was used as coordinates.
If I use 624 instead of 625 in the script it works perfectly!  ;)

monkey0506

Sorry I haven't responded yet, but I got a chance to look at this..from my previous post:

Quote from: monkey_05_06NOTE: The above download link only includes the SCM for the module. It does not include any documentation, the CharacterControl_RunScript module, demo game, etc., etc. You must download the 0.84 package for these files.

You should not simply be deleting the line in question, as the module does expect the RunScript module to be present. As noted, you must download both the 0.84 and 0.85 packages since I was too lazy to include all of the 0.84 files as required.

For any issues beyond that..well I didn't write the module, just the conversion for AGS 3.0+.. ::)

placyd

Ok, but I can't import both module. How shold I make it work?

Pinback

Quote from: placyd on Fri 20/08/2010 13:34:09
Ok, but I can't import both module. How shold I make it work?

Huh, I had this same problem too.

monkey0506

Just replace the CC module v0.84 with the v0.85 one..but the CC RunScript module still needs to be imported.

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Rocco

#54
I'm trying to use this module, but the ChainId and ChainPosition values gets screwed somehow.
The first chainposition is executed and the NPC(s) walks to the first waypoint, but when they reaches the first chain position they are stucked and don't execute the next chainpositions.
When i trace the ChainId i get values like 105466709 and for the ChainPosition similar ones like 106843457, and all CC_controlled have the same values for ChainID and Chainposition.
Dont know what causes this bug.  :cry:
I have 33 chars, and try to use the Module for Char 27 and 28, maybe this causes the strange behavior?

EDIT;
Quote from: placyd on Fri 20/08/2010 08:59:08
I've read back and found this quote by Tanique, that he had the same problem, when not even numbers was used as coordinates.
If I use 624 instead of 625 in the script it works perfectly!  ;)

Quote from: Tanique on Mon 16/11/2009 01:02:06
I know this thread hasn't been used in a while but I think it makes more sense to post it here than start a new one.  I was playing with this module for my game (monkey's .85 version using AGS 3.1.2) and I've noticed what might be a bug in the WALK scripting.  If I ever program my background character to walk to any x,y coordinates with odd values, she'll walk there, but won't continue the rest of the script.  As long as her WALK coordinates are even numbers, the script runs smoothly.  Is this a known bug?  I'm thinking it may have something to do with AGS 3's ability to run high resolution coordinates in the script.....but I'm really not sure. 

Oh man, cost me a sleepless night (and day) to figure that out bymself.  :P
It works fine with even values, maybe a hint in Monkeys posting could prevent others from the same scenario....




SMF spam blocked by CleanTalk