Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → npc for multiplayer help!!!
npc for multiplayer help!!!
2006-02-04, 11:56 PM #1
has anyone already made any sort of a cog to allow npc type characters in a mp game? not like bots, but like civilians and such? i am attempting to make a cog for it right now, but am running into a few problems, mostly with playing and stopping keyframes.

basically when the "npc" gets killed hes supposed to play a death animation and then stop at the last frame until the next command thing.

looks something like this... PlayKey(civilian, diekey, 1, 14); i believe,

well my problem is, it will go through the animation only instead of falling down like in single player, the npc gets stuck on the last frame leaning at a 45 degree angle :confused: any ideas?
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2006-02-06, 9:54 PM #2
not at the moment, but what are you working on? :)
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2006-02-06, 10:19 PM #3
basically what i have so far is a civilian who stands there and edles, you can walk up to him and talk to him with a limited number of responses, you can also kill him and he will drop powerups(im having trouble with the death animations though.) i am starting to work on figuring out how to make him move around at least some, even if it just like between 2 or 3 points.

well, heres the code for the cog thus far...


Quote:
# new male civilian for mp?
#
# ========================================================================================

symbols

message created
message damaged
message activated

int civ local
int channel local

flex civhealth local
flex damage local

template powerup=+DHealthPack local
template powerup1=+DBactaTank local
template powerup2=+DShield local

thing newThing local
thing player local
thing pusher local

keyframe idlekey=mnidle.key local
keyframe hitkey=mnhit.key local
keyframe diekey=mndie.key local

flex rval local
flex rate=4.0 local
flex delay=0.5 local

sound bodySnd=bodyfall01.wav local

end

# ========================================================================================
code

created:

SetThingUserData(GetSenderRef(), 20); // set the initial user data (i.e. "health")

playkey(GetSenderRef(),idlekey,1,0); //plays idle animation

return;

# ............................................................................................

damaged:
civ = GetSenderRef();
damage = GetParam(0);
civhealth = GetThingUserData(civ); // calls civilian health

if(GetParam(1) == 1) Return; // if damage is from fists then return

if(civhealth <= totaldamage) // is this enough damage to kill the civilian?
{
rval = Rand(); // create a random value to determine what powerup will be droped on death
if (rval < 0.30)
{
newthing = CreateThing(powerup, GetSenderRef());
SetLifeleft(newThing, 200.0);
}
else if (rval < 0.60)
{
newthing = CreateThing(powerup2, GetSenderRef());
SetLifeleft(newThing, 200.0);
}
else if (rval < 0.90)
{
newthing = CreateThing(powerup1, GetSenderRef());
SetLifeleft(newThing, 200.0);
}

playkey(civ,diekey,1,14); //plays death animation, buggy
StopKey(civ,idlekey,delay); // buggy
Print("AGGHH!!");
channel = PlaySoundThing(bodySnd, civ, 1, -1, -1, 0x80);

Sleep(rate);
DestroyThing(GetSenderRef()); // Destroy the civ
return;

}

SetThingUserData(civ, civhealth - damage); // if civ is not dead, take away additional health
Print("ouch!");
playkey(GetSenderRef(),hitkey,1,14); //plays hit animation, buggy
return;

# ........................................................................................

activated:

pusher = GetSourceRef();
player = GetLocalPlayerThing();

if (player != pusher) return;

rval = Rand();
if (rval < 0.15)
{
Print("What do you want!?");
}
else if (rval < 0.30)
{
Print("I cant help you!?");
}
else if (rval < 0.45)
{
Print("Get away!!!");
}

return;

end
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2006-02-06, 10:22 PM #4
oh, and so far it has been tested and works in multiplayer, except for the few problems with the death animation :(
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2006-02-06, 10:33 PM #5
I meant what kind of level. :P
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2006-02-06, 10:40 PM #6
oh, lol :o im not actually working on a level at this moment, i made a small one to test the civilian cog in, but its not too fancy... before i start doing serious level editing again i need to get 16-bit mats working in jed again, i donno what happened...
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2006-02-07, 3:22 PM #7
Is there some reason you have to play it through cog? I would just add a pup file to the civilian template, and add your custom key under the "death" entry of the pup. Then when he dies it should play automatically.
Jedi Knight Enhanced
Freelance Illustrator

↑ Up to the top!