View Full Version : how to determine a player?
zagibu
09-26-2000, 10:04 AM
i need a cog, which assigns every player to a thing, so that i can change their skins etc., but i have no idea on how to do it. how do i refer to the players? and i need all players in a game, not just the local...
Hideki
09-26-2000, 10:47 AM
To refer a thing, you must retrieve from certain events, such as touched, entered, damaged, but all of a sudden, if you want every player to do something, then
for(i = 0; i <= GetSectorCount() + 1; i = i + 1)
{
z = FirstThingInSector(i);
while(z != -1)
{
if(GetThingType(z) == 0x400) doWhateverHereToPlayer"z";
z = NextThingInSector(z);
}
}
To everything in level, but only to player thing, execute.
------------------
http://millennium.massassi.net/ - Millennium
Deathbane27
09-26-2000, 11:16 AM
Couldn't you just eliminate the sector thing and just use GetThingCount?
Hideki
09-26-2000, 06:30 PM
My first idea, but messed.
------------------
http://millennium.massassi.net/ - Millennium
zagibu
09-27-2000, 03:07 AM
0x400? hmm...i used GetThingType == 10...but i know, that walkplayers (starting positions) also have Thingtype 10, so...
zagibu
09-27-2000, 03:10 AM
and what about the if condition? is z not always positive or null, i mean, there is always a next thing, isn't there?
zagibu
09-27-2000, 03:19 AM
and why NextThingInSector(z)? Shouldnt it be nextthinginsector(i)?
zagibu
09-27-2000, 03:21 AM
btw...how do you check if it's a starting position or not?
zagibu
09-27-2000, 03:25 AM
ok, thats waht i have till now:
symbols
int potential local
int monkey local
int maxvictims local
int sender local
int numvictims=0 local
int sector local
flex mvflex local
model oldmodel local
model monkeymodel=kya17.3do local
thing victim0 local
thing victim1 local
thing victim2 local
thing victim3 local
thing victim4 local
thing victim5 local
thing victim6 local
thing victim7 local
message trigger
end
code
trigger:
//if(!IsServer) return;
if(GetSourceRef() != 99) return;
sender=GetParam(0);
if(sender!=1)
{
monkey=sender;
SetThingPulse(monkey, 0); // <-old monkey
SetInv(monkey, 116, 0.0); // <-old monkey
}
maxvictims=GetNumPlayers();
for(sector=0; sector<=GetSectorCount()+1; sector=sector+1)
{
potential= FirstThingInSector(sector);
while(potential!=-1)
{
if(GetThingType(potential)==0x400)
{
if(GetInv(potential)!=1.0)
{
victim0[numvictims]=potential;
if(numvictims<maxvictims) numvictims=numvictims+1;
}
}
potential=NextThingInSector(sector);
}
}
numvictims=0;
mvflex=1.0*maxvictims;
monkey=victim0[rand()*mvflex];
oldmodel=GetThingModel(monkey);
SetThingModel(monkey, monkeymodel); // Test
SetInv(monkey, 116, 1.0); // <-new monkey
SetThingPulse(monkey, 120); // <-new monkey
return;
end
its still not working...
zagibu
09-27-2000, 03:27 AM
or is there a bug in this cog?
symbols
message startup
message pulse
end
code
startup:
//if(!IsServer) return;
Sleep(10);
SendTrigger(-1, 99, 1, 0, 0, 0);
return;
pulse:
if(GetInv(GetSenderRef(), 116)!=1.0) return;
SendTrigger(-1, 99, GetSenderRef(), 0, 0, 0);
return;
end
zagibu
09-27-2000, 03:28 AM
what else could be the problem? do i have to include any files in the gob besides items.dat?
Hideki
09-28-2000, 03:08 PM
Well, I'm already forgetting cogs http://forums.massassi.net/html/wink.gif But, 0x400 was the player type to get in FirstThingInView, that was mask?
Anyway, well just get the player thing type that you can get from the jkspec.
And for the "i" and "z".
"i" is the sector number and "z" is the thing ID, so affect "z" to whatever.
NextThingInSector() has to put the thing for the param for some reason, I don't know, it works this way. If not anymore found in that sector, it will return -1 and gets out of the "while" and goes onto the next sector.
It's NextThingIn"The"Sector(), so it checks for the same sector for the next thing.
What do you mean by starting pos?
I'm not sure what you're trying to do from those cogs, but you got a few things wrong in "GetInv", needs 2 params and nextthigninsector is the thing that you put in the parameter.
------------------
http://millennium.massassi.net/ - Millennium
Fernando_the_Hunn
09-28-2000, 06:05 PM
first, the player takes control of the walkplayer thing, so the player IS the walkplayer. they are not separate things.
as for the cog:
monkey=victim0[rand()*mvflex];
You are not supposed to do operations within the []'s. Not sure why, but it dont like it. have:
newflex = rand()*mvflex;
monkey=victim0[newflex];
and anywhere else in the cog that you use that, thats the first one I saw.
------------------
There are no evil coggers, only evil cogs...
mailto:no_oneatall@hotmail.comno_oneatall@hotmail. com</A>
ICQ 81116825
===========================================
Evil Cog master of the Western TC!
zagibu
09-29-2000, 10:25 AM
what im trying to do is to have a randomly chosen player mutated in a monkey every 2 min. and then if the monkey dies or if the 2 mins are over, a new player should be chosen to be the monkey. I got all the things you said, and i have this now:
symbols
int potential local
int monkey local
int maxvictims local
int sender local
int numvictims=0 local
int sector local
flex mvflex local
model oldmodel local
model monkeymodel=monkey.3do local
thing victim0 local
thing victim1 local
thing victim2 local
thing victim3 local
thing victim4 local
thing victim5 local
thing victim6 local
thing victim7 local
message trigger
end
code
trigger:
//if(!IsServer) return;
if(GetSourceRef() != 99) return;
sender=GetParam(0);
if(sender!=1)
{
monkey=sender;
SetThingModel(monkey, oldmodel);
ParseArg(monkey, "puppet=ky.pup");
SetThingPulse(monkey, 0); // <-old monkey
SetInvActivated(monkey, 116, 0); // <-old monkey
}
maxvictims=GetNumPlayers();
for(sector=0; sector<=GetSectorCount()+1; sector=sector+1)
{
potential= FirstThingInSector(sector);
while(potential!=-1)
{
if(GetThingType(potential)==0x400)
{
if(!IsInvActivated(potential, 116))
{
victim0[numvictims]=potential;
if(numvictims<maxvictims) numvictims=numvictims+1;
}
}
potential=NextThingInSector(potential);
}
}
numvictims=0;
mvflex=1.0*maxvictims*rand();
monkey=victim0[mvflex];
oldmodel=GetThingModel(monkey);
SetThingModel(monkey, monkeymodel); // Test
ParseArg(monkey, "puppet=monkey.pup");
SetInvActivated(monkey, 116, 1); // <-new monkey
SetThingPulse(monkey, 120); // <-new monkey
return;
end
i 'd also like to add a sort of mutatormachines, like 4 per level, a random one active, so that the monkey could get back his former lifeform with touching it, but i do not have the time to build new levels, so i thought i could create new things at the players starting positions...
thats why i asked the walkplayer question...
i also got these cogs:
symbols
message startup
message pulse
end
code
startup:
//if(!IsServer) return;
Sleep(10);
SendTrigger(-1, 99, 1, 0, 0, 0);
return;
pulse:
if(!IsInvActivated(potential, 116)) return;
SendTrigger(-1, 99, GetSenderRef(), 0, 0, 0);
return;
end
symbols
int oldscore local
message killed
end
code
killed:
//if(!IsServer) return;
if(!IsInvActivated(GetSenderRef(), 116)) return;
oldscore=GetPlayerScore(GetSourceRef());
SetPlayerScore(GetSourceRef(), oldscore+5);
SendTrigger(-1, 99, GetSenderRef, 0, 0, 0);
return;
end
symbols
message touched
end
code
touched:
//if(!IsServer) return;
if(!IsInvActivated(potential, 116)) return;
SendTrigger(-1, 99, GetSourceRef, 0, 0, 0);
SendTrigger(-1, 98, GetSenderRef, 0, 0, 0);
return;
end
please help me if you can...i can also send you the whole mod project, cause im not sure if i've included everything (im only experienced in weapon mods), thanks in advance
Hideki
09-29-2000, 03:29 PM
startup:
SetTimerEx(2, 0, 0, 0);
return;
timer:
q = 0;
for(i = 0; i <= GetSectorCount() + 1; i = i + 1)
{
z = FirstThingInSector(i);
while(z != -1)
{
if(GetThingType(z) == 0x400)
{
players[q] = z;
q = q + 1;
}
z = NextThingInSector(z);
}
}
chosen = rand() * q; //players[chosen] is the randomly chosen player
//do something here to change him to a monkey or to a donkey
SetTimerEx(2, 0, 0, 0);
return;
killed:
if(GetSenderRef() == players[chosen])
{
KillTimerEx(0);
call timer;
}
return;
Alertnatively, you can use the "join" message and keep on adding player variables to players[x] like this. So you don't rather need the "for" and "while" in above message to check it everytime.
join:
players[q] = GetSenderRef();
q++;
return;
------------------
http://millennium.massassi.net/ - Millennium
[This message has been edited by Hideki (edited September 29, 2000).]
zagibu
09-30-2000, 02:26 PM
i've sent you another mail, Hideki...
Hideki
09-30-2000, 04:37 PM
Oh...
------------------
http://millennium.massassi.net/ - Millennium
zagibu
10-01-2000, 02:51 AM
i have this now, but it is still not working...
kyle.cog
symbols
thing player local
int nextBlock=0 local
int bin local
int rank local
int force_blinding=0 local
int blindingEffectHandle=-1 local
int PulledWeapon local
int playersector local
vector playerpos local
int bub local
template tpl=+FPBryarPistol local
template tpl1=+FPBryarPistol local
template tpl2=+FPBryarPistol local
template tpl3=+FPSTrifle local
template tpl4=+FPDetonator local
template tpl5=+FPCrossbow local
template tpl6=+FPRepeaterGun local
template tpl7=+FPRailGun local
template tpl8=+FPSeqCharge local
template tpl9=+FPConcRifle local
template smoke_tpl=+heavysmoke local
int smoke local
template teleport_particles=+telesparks local
sound teleportsnd=ForceThrow01.WAV local
template bubble_tpl=bubble local
template bubble_tpl2=bubble2 local
template bubble_tpl3=bubble3 local
template splash_tpl=+watersplash local
template splash_tpl2=+watersplash2 local
int a_splash local
int sender local
int source local
keyframe povBlockAnim0=SabVblk0.key local
keyframe povBlockAnim1=SabVblk1.key local
keyframe povBlockAnim2=SabVblk2.key local
keyframe blockAnim0=KYblock0.key local
keyframe blockAnim1=KYblock1.key local
keyframe blockAnim2=KYblock2.key local
int dummy=0 local
int blockPOVTrack=-1 local
int blockTrack=-1 local
int griptrackID=-1 local
int total=0 local
int i=0 local
int m=0 local
flex unlucky=0 local
thing player0 local
thing player1 local
thing player2 local
thing player3 local
thing player4 local
thing player5 local
thing player6 local
thing player7 local
model oldmodel=-1 local
model monkey=monkey.3do local
message startup
message killed
message newplayer
message timer
message blocked
message skill
message damaged
message splash
message user0
message join
message leave
end
# ================================================== ======================================
code
startup:
player = GetLocalPlayerThing();
if(!IsMulti()) call init_kyle;
// Bubbles
if(IsMulti())
SetTimerEx(4 + 5 * rand(), 2, 0, 0);
else
SetTimerEx(2 + 5 * rand(), 2, 0, 0);
SetTimerEx(5, 99, 0, 0);
Return;
# .................................................. ......................................
killed:
if(player != GetSenderRef()) Return;
if(IsMulti())
{
CreateBackpack(player);
ClearActorFlags(player, 0x2000);
}
// clean up force powers stuff
if(blindingEffectHandle!=-1)
{
freeColorEffect(blindingEffectHandle);
blindingEffectHandle = -1;
}
ClearActorFlags(player, 0x800);
KillTimerEx(27);
force_blinding = 0;
ClearActorFlags(player, 0x40000);
if(griptrackID != -1)
{
StopKey(player, griptrackID, 0.1);
griptrackID = -1;
}
if(GetSenderRef() == player0[unlucky])
{
KillTimerEx(99);
SendMessage(GetSelfCog(), timer, 99, 0, 0, 0);
}
Return;
# .................................................. ......................................
damaged:
if(GetParam(1) == 32) call make_bubbles;
ReturnEx(GetParam(0));
Return;
# .................................................. ......................................
make_bubbles:
playersector = GetThingSector(player);
playerpos = VectorAdd(GetThingPos(player), '0 0 0.075');
for(bub = 1; bub < 1 + 3 * rand(); bub = bub + 1)
{
CreateThingAtPosNR(bubble_tpl[3 * rand()], playersector, VectorAdd(playerpos, VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 0 0');
Sleep(0.05);
// Don't create too many bubbles over the network...
if(!IsMulti())
{
CreateThingAtPos(bubble_tpl3, playersector, VectorAdd(playerpos, VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 0 0');
Sleep(0.05);
}
}
Return;
# .................................................. ......................................
newplayer:
call init_kyle;
// If it's multiplayer
if(IsMulti()) call init_multi_kyle;
// Start Bubbles
SetTimerEx(2 + 5 * rand(), 2, 0, 0);
Return;
# .................................................. ......................................
timer:
if(GetSenderId() == 1) // Invulnerable for a while
{
// jkSetInvulnerable(GetParam(0), 0);
ClearActorFlags(GetParam(0), 8);
Return;
}
else
if(GetSenderId() == 2) // Bubbles check
{
if(GetThingHealth(player) < 1) Return;
if((GetThingFlags(player) & 0x2000000) && !(GetPhysicsFlags(player) & 0x100000))
call make_bubbles;
if(IsMulti())
SetTimerEx(4 + 5 * rand(), 2, 0, 0);
else
SetTimerEx(2 + 5 * rand(), 2, 0, 0);
Return;
}
else
if(GetSenderId() == 24)
{
// A pulled weapon must be made takeable again
SetCollideType(GetParam(0), 1);
Return;
}
else
if(GetSenderId() == 27)
{
if(blindingEffectHandle!=-1)
{
freeColorEffect(blindingEffectHandle);
blindingEffectHandle = -1;
}
// Get the effect ramping down
AddDynamicTint(player, 200 + 8 * rank, 210 + 10 * rank, 200 + 8 * rank);
ClearActorFlags(player, 0x800);
force_blinding = 0;
Return;
}
else
if(GetSenderId() == 31)
{
if(griptrackID != -1)
{
StopKey(player, griptrackID, 0.1);
griptrackID = -1;
}
ClearActorFlags(player, 0x40000);
Return;
}
else
if(GetSenderId()==99 | | GetParam(0) == 99)
{
//if there is already a monkey, change him back
if(IsInvActivated(player0[unlucky], 116))
{
SetInvActivated(player0[unlucky], 116, 0);
SetThingModel(player0[unlucky], oldmodel);
ParseArg(player0[unlucky], "puppet=ky.pup");
}
unlucky = rand() * (total-1);
oldmodel=GetThingModel(player0[unlucky]);
SetThingModel(player0[unlucky], monkey);
ParseArg(player0[unlucky], "puppet=monkey.pup");
SetInvActivated(player0[unlucky], 116, 1);
SetTimerEx(10, 99, 0, 0);
}
Return;
# .................................................. ......................................
blocked:
if(player != GetSenderRef()) Return;
if (blockPOVTrack != -1)
{
jkStopPOVKey( player, blockPOVTrack, 0.1 );
blockPOVTrack = -1;
}
if (blockTrack != -1)
{
StopKey( player, blockTrack, 0.1 );
blockTrack = -1;
}
// PlaySoundThing(hitSound14, player, 1.0, -1, -1, 0);
blockPOVTrack = jkPlayPOVKey(player, povBlockAnim0[nextBlock], 2, 0x1a);
blockTrack = PlayKey(player, blockAnim0[nextBlock], 2, 0x1a);
nextBlock = nextBlock + 1;
if(nextBlock > 2)
nextBlock = 0;
Return;
# .................................................. ......................................
// This message is sent from the weap_saber.cog
user0:
if (blockPOVTrack != -1)
{
jkStopPOVKey( player, blockPOVTrack, 0.1 );
blockPOVTrack = -1;
}
if (blockTrack != -1)
{
StopKey( player, blockTrack, 0.1 );
blockTrack = -1;
}
Return;
# .................................................. ......................................
skill:
// player might be dead when skill: arrives over the net...
if(GetThingHealth(player) <= 0) Return;
// Handle multiplayer force power effects
bin = GetParam(0);
rank = GetParam(1);
if(bin == 24) // Force Pull
{
ReturnEx(0);
if(!IsInvActivated(player, 28)) // Absorb makes player immune to Pull
{
if((GetCurWeapon(player) != 1) && (GetCurWeapon(player) != 10))
{
// Create a powerup corresponding to the current weapon
PulledWeapon = CreateThingAtPos(tpl[GetCurWeapon(player)], GetThingSector(player), GetThingPos(player), '0 0 0');
// Make the powerup collide later
SetTimerEx(0.2, 24, PulledWeapon, 0);
// Duplicate for internet games
SetTimerEx(0.25, 24, PulledWeapon, 0);
// Throw the powerup at the player
ApplyForce(PulledWeapon, VectorScale(VectorNorm(VectorSub(GetThingPos(GetSo urceRef()), GetThingPos(player))), 30));
// Remove the weapon from the player
ChangeInv(player, GetCurWeapon(player), -1);
// Switch to fists
SelectWeapon(player, 1);
ReturnEx(1);
}
}
Return;
}
else
if (bin == 27) // Force Blinding
{
if((!force_blinding) && (!IsInvActivated(player, 23))) // Seeing makes player immune to Blinding
{
force_blinding = 1;
blindingEffectHandle = newColorEffect(0, 0, 0, 0, 0, 0, 200 + 8 * rank, 210 + 10 * rank, 200 + 8 * rank, 1.0);
SetActorFlags(player, 0x800);
SetTimerEx(4 * rank, 27, player, 0);
ReturnEx(1);
}
else
{
ReturnEx(0);
}
Return;
}
else
if (bin == 31) // Force Grip
{
if(!IsInvActivated(player, 29)) // Protection makes player immune to Grip
{
griptrackID = PlayMode(player, 25);
SetActorFlags(player, 0x40000);
// Print("You are taking Grip damage");
jkPrintUNIString(player, 300);
DamageThing(player, 2 * rank, 0x8, GetSourceRef());
SetTimerEx(0.5, 31, player, 0);
ReturnEx(1);
}
else
{
ReturnEx(0);
}
Return;
}
else
if (bin == 34) // Deadly Sight
{
// Print("You are taking Deadly Sight damage");
jkPrintUNIString(player, 301);
DamageThing(player, 4 * rank, 0x8, GetSourceRef());
smoke = CreateThingAtPosNR(smoke_tpl, GetThingSector(player), GetThingPos(player), '0 0 0');
// Raise the tint above the normal damage tint
if(GetCurrentCamera() == 0)
AddDynamicTint(player, 0.15, 0.0, 0.07);
ReturnEx(1);
Return;
}
ReturnEx(-1);
Return;
# .................................................. ......................................
splash:
// splash: messages are only sent to the local player's cogs
// (class cog and capture cog) for performance reasons...
sender = GetSenderRef();
source = GetSourceRef();
// actor or player ?
if((GetThingType(sender) == 2) | | (GetThingType(sender) == 10))
{
// whatever source (i.e. enter or leave, don't care)
a_splash = CreateThingAtPosNR(splash_tpl2, GetThingSector(sender), GetThingPos(sender), '0 0 0');
}
// these are mostly the projectiles...
else
{
// on entering only
if(source == 1)
// not if player is submerged, but still do it if he's on the surface
if(!(GetThingFlags(player) & 0x2000000) | | (GetPhysicsFlags(player) & 0x100000))
a_splash = CreateThingNR(splash_tpl, sender);
}
Return;
# .................................................. ......................................
init_kyle:
SetActorFlags(player, 8);
SetTimerEx(1.50, 1, player, 0);
// Set Health to full
SetThingHealth(player, 100);
// Set Mana to full
SetInv(player, 14, GetInv(player, 20) * 50);
// Set Shields to 100 minimum
if(GetInv(player, 60) < 100) SetInv(player, 60, 100);
// Set Battery to 100 minimum
if(GetInv(player, 13) < 100) SetInv(player, 13, 100);
// Set the power boost to 1.0
SetInv(player, 63, 1.0);
// When player starts, give him fists, and a bryar.
SetInv(player, 1, 1.0);
SetInv(player, 2, 1.0);
// Give 50 energy minimum
if(GetInv(player, 11) < 50) SetInv(player, 11, 50.0);
// Bacta
if(GetInv(player, 40) == 0)
SetInvAvailable(player, 40, 0);
else
SetInvAvailable(player, 40, 1);
// IR Goggles
if(GetInv(player, 41))
SetInvAvailable(player, 41, 1);
else
SetInvAvailable(player, 41, 0);
SetInvActivated(player, 41, 0);
// Field Light
SetInv(player, 42, 1);
SetInvAvailable(player, 42, 1);
SetInvActivated(player, 42, 0);
ClearActorFlags(player, 4);
jkEndTarget();
Return;
# .................................................. ......................................
init_multi_kyle:
// Set Weapons
SetInv(player, 1, 1.0);
SetInv(player, 2, 1.0);
SetInv(player, 3, 0.0);
SetInv(player, 4, 0.0);
SetInv(player, 5, 0.0);
SetInv(player, 6, 0.0);
SetInv(player, 7, 0.0);
SetInv(player, 8, 0.0);
SetInv(player, 9, 0.0);
SetInv(player, 10, 1.0);
// Set Ammo
SetInv(player, 11, 50.0);
SetInv(player, 12, 0.0);
SetInv(player, 15, 0.0);
// Remove bacta tank and IR goggles
SetInv(player, 40, 0);
SetInv(player, 41, 0);
SetInvAvailable(player, 40, 0);
SetInvAvailable(player, 41, 0);
// Set shields to 100
SetInv(player, 60, 100);
// Do respawn effects
dummy = CreateThingAtPos(teleport_particles, GetThingSector(player), GetThingPos(player), '0 0 0');
dummy = PlaySoundThing(teleportsnd, player, 1.0, -1, -1, 0x180);
SetFireWait(player, -1);
SetMountWait(player, 0);
SetCurInvWeapon(player, 0);
SelectWeapon(player, AutoSelectWeapon(player, 1));
Return;
join:
player0[total] = GetSenderRef();
total = total + 1;
return;
leave:
for(i=0; i<total; i=i+1)
{
if(player0[i] == GetSenderRef())
{
for(m=i+1; m<=total; m=m+1) player0[m-1] = player0[m];
player0[i] = -1;
}
}
total = total - 1;
return;
end
Put in code. (Hideki)
[This message has been edited by Hideki (edited October 01, 2000).]
Hideki
10-01-2000, 03:43 AM
Use players[0] etc, not player. I fixed in the mail but you made it worse.
Put the stuff you added in the timer after the "unlucky" is defined.
For the "leave" message use this rather.
for(i=0; i<total; i=i+1)
{
if(player0[i] == GetSenderRef())
{
for(m=i+1; m<=total; m=m+1) player0[m-1] = player0[m];
player0[i] = -1;
total = total - 1;
}
}
return;
Don't do messy timer. Do this rather.
SetTimerEx(0.01, 99, 0, 0);
And take away the "| | GetParam" part.
Check syntax if not working at all.
------------------
http://millennium.massassi.net/ - Millennium
zagibu
10-01-2000, 07:44 AM
hey...its working now...partially at least. I got this cog (dunno if the join/leave messages work, though):
# Jedi Knight Cog Script
#
# KYLE.COG
#
# Main script for the player. Handles things like saber info,
# saber blocking animations, invulnerability at respawn, etc.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
thing player local
int nextBlock=0 local
int bin local
int rank local
int force_blinding=0 local
int blindingEffectHandle=-1 local
int PulledWeapon local
int playersector local
vector playerpos local
int bub local
template tpl=+FPBryarPistol local
template tpl1=+FPBryarPistol local
template tpl2=+FPBryarPistol local
template tpl3=+FPSTrifle local
template tpl4=+FPDetonator local
template tpl5=+FPCrossbow local
template tpl6=+FPRepeaterGun local
template tpl7=+FPRailGun local
template tpl8=+FPSeqCharge local
template tpl9=+FPConcRifle local
template smoke_tpl=+heavysmoke local
int smoke local
template teleport_particles=+telesparks local
sound teleportsnd=ForceThrow01.WAV local
template bubble_tpl=bubble local
template bubble_tpl2=bubble2 local
template bubble_tpl3=bubble3 local
template splash_tpl=+watersplash local
template splash_tpl2=+watersplash2 local
int a_splash local
int sender local
int source local
keyframe povBlockAnim0=SabVblk0.key local
keyframe povBlockAnim1=SabVblk1.key local
keyframe povBlockAnim2=SabVblk2.key local
keyframe blockAnim0=KYblock0.key local
keyframe blockAnim1=KYblock1.key local
keyframe blockAnim2=KYblock2.key local
int dummy=0 local
int blockPOVTrack=-1 local
int blockTrack=-1 local
int griptrackID=-1 local
int total=0 local
int i=0 local
int m=0 local
int oldscore=0 local
sound mutatorsnd1=forcelightnin01.wav local
sound mutatorsnd2=forcehealing01.wav local
flex unlucky=0 local
flex oldbryar local
flex oldstrifle local
flex oldthermals local
flex oldbow local
flex oldrepeater local
flex oldraildet local
flex oldseqcharges local
flex oldconcrifle local
flex oldsaber local
flex oldecells local
flex oldpcells local
flex oldbattery local
flex oldmana local
flex oldrailcharges local
flex oldbacta local
flex oldirgoggles local
flex oldshields local
thing player0 local
thing player1 local
thing player2 local
thing player3 local
thing player4 local
thing player5 local
thing player6 local
thing player7 local
model oldmodel=-1 local
model monkey=monkey.3do local
message startup
message killed
message newplayer
message timer
message blocked
message skill
message damaged
message splash
message user0
message join
message leave
message pulse
end
# ================================================== ======================================
code
startup:
player = GetLocalPlayerThing();
if(!IsMulti()) call init_kyle;
// Bubbles
if(IsMulti())
SetTimerEx(4 + 5 * rand(), 2, 0, 0);
else
SetTimerEx(2 + 5 * rand(), 2, 0, 0);
if(IsServer())
{
player0=player;
total=1;
}
SetTimerEx(5, 99, 0, 0);
Return;
# .................................................. ......................................
killed:
if(player != GetSenderRef()) Return;
if(IsMulti())
{
CreateBackpack(player);
ClearActorFlags(player, 0x2000);
}
// clean up force powers stuff
if(blindingEffectHandle!=-1)
{
freeColorEffect(blindingEffectHandle);
blindingEffectHandle = -1;
}
ClearActorFlags(player, 0x800);
KillTimerEx(27);
force_blinding = 0;
ClearActorFlags(player, 0x40000);
if(griptrackID != -1)
{
StopKey(player, griptrackID, 0.1);
griptrackID = -1;
}
if(GetSenderRef() == player0[unlucky])
{
KillTimerEx(99);
oldscore=GetPlayerScore(GetSourceRef());
SetPlayerScore(GetSourceRef(), oldscore+5);
SetTimerEx(1, 99, 0, 0);
}
Return;
# .................................................. ......................................
damaged:
if(GetParam(1) == 32) call make_bubbles;
ReturnEx(GetParam(0));
Return;
# .................................................. ......................................
make_bubbles:
playersector = GetThingSector(player);
playerpos = VectorAdd(GetThingPos(player), '0 0 0.075');
for(bub = 1; bub < 1 + 3 * rand(); bub = bub + 1)
{
CreateThingAtPosNR(bubble_tpl[3 * rand()], playersector, VectorAdd(playerpos, VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 0 0');
Sleep(0.05);
// Don't create too many bubbles over the network...
if(!IsMulti())
{
CreateThingAtPos(bubble_tpl3, playersector, VectorAdd(playerpos, VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 0 0');
Sleep(0.05);
}
}
Return;
# .................................................. ......................................
newplayer:
call init_kyle;
// If it's multiplayer
if(IsMulti()) call init_multi_kyle;
// Start Bubbles
SetTimerEx(2 + 5 * rand(), 2, 0, 0);
Return;
# .................................................. ......................................
timer:
if(GetSenderId() == 1) // Invulnerable for a while
{
// jkSetInvulnerable(GetParam(0), 0);
ClearActorFlags(GetParam(0), 8);
Return;
}
else
if(GetSenderId() == 2) // Bubbles check
{
if(GetThingHealth(player) < 1) Return;
if((GetThingFlags(player) & 0x2000000) && !(GetPhysicsFlags(player) & 0x100000))
call make_bubbles;
if(IsMulti())
SetTimerEx(4 + 5 * rand(), 2, 0, 0);
else
SetTimerEx(2 + 5 * rand(), 2, 0, 0);
Return;
}
else
if(GetSenderId() == 24)
{
// A pulled weapon must be made takeable again
SetCollideType(GetParam(0), 1);
Return;
}
else
if(GetSenderId() == 27)
{
if(blindingEffectHandle!=-1)
{
freeColorEffect(blindingEffectHandle);
blindingEffectHandle = -1;
}
// Get the effect ramping down
AddDynamicTint(player, 200 + 8 * rank, 210 + 10 * rank, 200 + 8 * rank);
ClearActorFlags(player, 0x800);
force_blinding = 0;
Return;
}
else
if(GetSenderId() == 31)
{
if(griptrackID != -1)
{
StopKey(player, griptrackID, 0.1);
griptrackID = -1;
}
ClearActorFlags(player, 0x40000);
Return;
}
else
if(GetSenderId() == 99)
{
//if there is already a monkey, change him back
if(GetInv(player0[unlucky], 116)!=0.0)
{
SetInv(player0[unlucky], 116, 0.0);
SetThingModel(player0[unlucky], oldmodel);
ParseArg(player0[unlucky], "puppet=ky.pup");
SetActorExtraSpeed(player0[unlucky], 0);
SetPulse(0);
//set old statistics
SetInv(player0[unlucky], 2, oldbryar);
SetInv(player0[unlucky], 3, oldstrifle);
SetInv(player0[unlucky], 4, oldthermals);
SetInv(player0[unlucky], 5, oldbow);
SetInv(player0[unlucky], 6, oldrepeater);
SetInv(player0[unlucky], 7, oldraildet);
SetInv(player0[unlucky], 8, oldseqcharges);
SetInv(player0[unlucky], 9, oldconcrifle);
SetInv(player0[unlucky], 10, oldsaber);
SetInv(player0[unlucky], 11, oldecells);
SetInv(player0[unlucky], 12, oldpcells);
SetInv(player0[unlucky], 13, oldbattery);
SetInv(player0[unlucky], 14, oldmana);
SetInv(player0[unlucky], 15, oldrailcharges);
SetInv(player, 40, oldbacta);
SetInv(player, 41, oldirgoggles);
if(oldbacta!=0) SetInvAvailable(player, 40, 1);
if(oldirgoggles!=0) SetInvAvailable(player, 41, 1);
SetInv(player, 60, oldshields);
dummy = CreateThingAtPos(teleport_particles, GetThingSector(player0[unlucky]), GetThingPos(player0[unlucky]), '0 0 0');
dummy = PlaySoundThing(mutatorsnd1, player0[unlucky], 1.0, -1, -1, 0x180);
dummy = PlaySoundThing(mutatorsnd2, player0[unlucky], 1.0, -1, -1, 0x180);
}
Sleep(10);
unlucky = rand() * (total-1);
//get old statistics
oldmodel=GetThingModel(player0[unlucky]);
oldbryar=GetInv(player0[unlucky], 2);
oldstrifle=GetInv(player0[unlucky], 3);
oldthermals=GetInv(player0[unlucky], 4);
oldbow=GetInv(player0[unlucky], 5);
oldrepeater=GetInv(player0[unlucky], 6);
oldraildet=GetInv(player0[unlucky], 7);
oldseqcharges=GetInv(player0[unlucky], 8);
oldconcrifle=GetInv(player0[unlucky], 9);
oldsaber=GetInv(player0[unlucky], 10);
oldecells=GetInv(player0[unlucky], 11);
oldpcells=GetInv(player0[unlucky], 12);
oldbattery=GetInv(player0[unlucky], 13);
oldmana=GetInv(player0[unlucky], 14);
oldrailcharges=GetInv(player0[unlucky], 15);
oldshields=GetInv(player0[unlucky], 60);
oldbacta=GetInv(player0[unlucky], 40);
oldirgoggles=GetInv(player0[unlucky], 41);
SetThingModel(player0[unlucky], monkey);
ParseArg(player0[unlucky], "puppet=monkey.pup");
SetInv(player0[unlucky], 116, 1.0);
SetActorExtraSpeed(player0[unlucky], 1);
dummy = CreateThingAtPos(teleport_particles, GetThingSector(player0[unlucky]), GetThingPos(player0[unlucky]), '0 0 0');
dummy = PlaySoundThing(mutatorsnd1, player0[unlucky], 1.0, -1, -1, 0x180);
dummy = PlaySoundThing(mutatorsnd2, player0[unlucky], 1.0, -1, -1, 0x180);
SetPulse(0.5);
SetTimerEx(20, 99, 0, 0);
}
Return;
# .................................................. ......................................
blocked:
if(player != GetSenderRef()) Return;
if (blockPOVTrack != -1)
{
jkStopPOVKey( player, blockPOVTrack, 0.1 );
blockPOVTrack = -1;
}
if (blockTrack != -1)
{
StopKey( player, blockTrack, 0.1 );
blockTrack = -1;
}
// PlaySoundThing(hitSound14, player, 1.0, -1, -1, 0);
blockPOVTrack = jkPlayPOVKey(player, povBlockAnim0[nextBlock], 2, 0x1a);
blockTrack = PlayKey(player, blockAnim0[nextBlock], 2, 0x1a);
nextBlock = nextBlock + 1;
if(nextBlock > 2)
nextBlock = 0;
Return;
# .................................................. ......................................
// This message is sent from the weap_saber.cog
user0:
if (blockPOVTrack != -1)
{
jkStopPOVKey( player, blockPOVTrack, 0.1 );
blockPOVTrack = -1;
}
if (blockTrack != -1)
{
StopKey( player, blockTrack, 0.1 );
blockTrack = -1;
}
Return;
# .................................................. ......................................
skill:
// player might be dead when skill: arrives over the net...
if(GetThingHealth(player) <= 0) Return;
// Handle multiplayer force power effects
bin = GetParam(0);
rank = GetParam(1);
if(bin == 24) // Force Pull
{
ReturnEx(0);
if(!IsInvActivated(player, 28)) // Absorb makes player immune to Pull
{
if((GetCurWeapon(player) != 1) && (GetCurWeapon(player) != 10))
{
// Create a powerup corresponding to the current weapon
PulledWeapon = CreateThingAtPos(tpl[GetCurWeapon(player)], GetThingSector(player), GetThingPos(player), '0 0 0');
// Make the powerup collide later
SetTimerEx(0.2, 24, PulledWeapon, 0);
// Duplicate for internet games
SetTimerEx(0.25, 24, PulledWeapon, 0);
// Throw the powerup at the player
ApplyForce(PulledWeapon, VectorScale(VectorNorm(VectorSub(GetThingPos(GetSo urceRef()), GetThingPos(player))), 30));
// Remove the weapon from the player
ChangeInv(player, GetCurWeapon(player), -1);
// Switch to fists
SelectWeapon(player, 1);
ReturnEx(1);
}
}
Return;
}
else
if (bin == 27) // Force Blinding
{
if((!force_blinding) && (!IsInvActivated(player, 23))) // Seeing makes player immune to Blinding
{
force_blinding = 1;
blindingEffectHandle = newColorEffect(0, 0, 0, 0, 0, 0, 200 + 8 * rank, 210 + 10 * rank, 200 + 8 * rank, 1.0);
SetActorFlags(player, 0x800);
SetTimerEx(4 * rank, 27, player, 0);
ReturnEx(1);
}
else
{
ReturnEx(0);
}
Return;
}
else
if (bin == 31) // Force Grip
{
if(!IsInvActivated(player, 29)) // Protection makes player immune to Grip
{
griptrackID = PlayMode(player, 25);
SetActorFlags(player, 0x40000);
// Print("You are taking Grip damage");
jkPrintUNIString(player, 300);
DamageThing(player, 2 * rank, 0x8, GetSourceRef());
SetTimerEx(0.5, 31, player, 0);
ReturnEx(1);
}
else
{
ReturnEx(0);
}
Return;
}
else
if (bin == 34) // Deadly Sight
{
// Print("You are taking Deadly Sight damage");
jkPrintUNIString(player, 301);
DamageThing(player, 4 * rank, 0x8, GetSourceRef());
smoke = CreateThingAtPosNR(smoke_tpl, GetThingSector(player), GetThingPos(player), '0 0 0');
// Raise the tint above the normal damage tint
if(GetCurrentCamera() == 0)
AddDynamicTint(player, 0.15, 0.0, 0.07);
ReturnEx(1);
Return;
}
ReturnEx(-1);
Return;
# .................................................. ......................................
splash:
// splash: messages are only sent to the local player's cogs
// (class cog and capture cog) for performance reasons...
sender = GetSenderRef();
source = GetSourceRef();
// actor or player ?
if((GetThingType(sender) == 2) | | (GetThingType(sender) == 10))
{
// whatever source (i.e. enter or leave, don't care)
a_splash = CreateThingAtPosNR(splash_tpl2, GetThingSector(sender), GetThingPos(sender), '0 0 0');
}
// these are mostly the projectiles...
else
{
// on entering only
if(source == 1)
// not if player is submerged, but still do it if he's on the surface
if(!(GetThingFlags(player) & 0x2000000) | | (GetPhysicsFlags(player) & 0x100000))
a_splash = CreateThingNR(splash_tpl, sender);
}
Return;
# .................................................. ......................................
init_kyle:
SetActorFlags(player, 8);
SetTimerEx(1.50, 1, player, 0);
// Set Health to full
SetThingHealth(player, 100);
// Set Mana to full
SetInv(player, 14, GetInv(player, 20) * 50);
// Set Shields to 100 minimum
if(GetInv(player, 60) < 100) SetInv(player, 60, 100);
// Set Battery to 100 minimum
if(GetInv(player, 13) < 100) SetInv(player, 13, 100);
// Set the power boost to 1.0
SetInv(player, 63, 1.0);
// When player starts, give him fists, and a bryar.
SetInv(player, 1, 1.0);
SetInv(player, 2, 1.0);
// Give 50 energy minimum
if(GetInv(player, 11) < 50) SetInv(player, 11, 50.0);
// Bacta
if(GetInv(player, 40) == 0)
SetInvAvailable(player, 40, 0);
else
SetInvAvailable(player, 40, 1);
// IR Goggles
if(GetInv(player, 41))
SetInvAvailable(player, 41, 1);
else
SetInvAvailable(player, 41, 0);
SetInvActivated(player, 41, 0);
// Field Light
SetInv(player, 42, 1);
SetInvAvailable(player, 42, 1);
SetInvActivated(player, 42, 0);
ClearActorFlags(player, 4);
jkEndTarget();
Return;
# .................................................. ......................................
init_multi_kyle:
// Set Weapons
SetInv(player, 1, 1.0);
SetInv(player, 2, 1.0);
SetInv(player, 3, 0.0);
SetInv(player, 4, 0.0);
SetInv(player, 5, 0.0);
SetInv(player, 6, 0.0);
SetInv(player, 7, 0.0);
SetInv(player, 8, 0.0);
SetInv(player, 9, 0.0);
SetInv(player, 10, 1.0);
// Set Ammo
SetInv(player, 11, 50.0);
SetInv(player, 12, 0.0);
SetInv(player, 15, 0.0);
// Remove bacta tank and IR goggles
SetInv(player, 40, 0);
SetInv(player, 41, 0);
SetInvAvailable(player, 40, 0);
SetInvAvailable(player, 41, 0);
// Set shields to 100
SetInv(player, 60, 100);
// Do respawn effects
dummy = CreateThingAtPos(teleport_particles, GetThingSector(player), GetThingPos(player), '0 0 0');
dummy = PlaySoundThing(teleportsnd, player, 1.0, -1, -1, 0x180);
SetFireWait(player, -1);
SetMountWait(player, 0);
SetCurInvWeapon(player, 0);
SelectWeapon(player, AutoSelectWeapon(player, 1));
Return;
join:
player0[total] = GetSenderRef();
total = total + 1;
return;
leave:
for(i=0; i<total; i=i+1)
{
if(player0[i] == GetSenderRef())
{
for(m=i+1; m<=total; m=m+1) player0[m-1] = player0[m];
player0[i] = -1;
}
}
total = total - 1;
return;
pulse:
// Set Weapons
SetInv(player0[unlucky], 2, 0.0);
SetInv(player0[unlucky], 3, 0.0);
SetInv(player0[unlucky], 4, 0.0);
SetInv(player0[unlucky], 5, 0.0);
SetInv(player0[unlucky], 6, 0.0);
SetInv(player0[unlucky], 7, 0.0);
SetInv(player0[unlucky], 8, 0.0);
SetInv(player0[unlucky], 9, 0.0);
SetInv(player0[unlucky], 10, 0.0);
// Set Ammo
SetInv(player0[unlucky], 11, 0.0);
SetInv(player0[unlucky], 12, 0.0);
SetInv(player0[unlucky], 13, 0.0);
SetInv(player0[unlucky], 14, 0.0);
SetInv(player0[unlucky], 15, 0.0);
// Remove bacta tank and IR goggles
SetInv(player, 40, 0);
SetInv(player, 41, 0);
SetInvAvailable(player, 40, 0);
SetInvAvailable(player, 41, 0);
// Set shields to 0
SetInv(player, 60, 0);
if(GetCurWeapon(player0[unlucky])!=1) AutoSelectWeapon(player[unlucky], 1);
return;
end
I still have to test it with other people.
There are also some bugs in it, i.e. after the change back from monkey to player, the model is screwed for 2 secs, or the weapon 3dos should disappear, but i dunno how to do it...anyway, thank you for all the help!
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.