View Full Version : Cog Help... again...
Xzero Phoenix
05-25-2005, 05:24 PM
I need someone to help me here, im kinda stuck...
I have a cog, when I use the item it drops the backpack like it should, but then i can go thraugh walls and other stuff and i cant pick it up... whats with that... can someone help?
darthslaw
05-25-2005, 07:24 PM
Sounds like you did a SetCollide(player, 0) somewhere...
Xzero Phoenix
05-25-2005, 07:26 PM
lol heres the cog:
# Jedi Knight Cog Script
#
# ITEM_KEYYELLOW.COG
#
# INVENTORY script - Drop Credits
# Bin 48
#
# [CYW & YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
thing player
model moneyTpl=y-key.3do local
message activated
end
# ================================================== ======================================
code
activated:
player = GetSourceRef();
// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
{
Return;
}
// Check Credits - If we are out, Play a message.
if(GetInv(player, 147) < 10.0)
{
Print("No More Credits");
Return;
}
else
Print("Droped Credits");
{
CreateBackpack(player);
SetCollideType(dummy, 0);
ApplyForce(dummy, VectorScale(VectorNorm(VectorAdd(GetThingLVec(play er), VectorSet(0, 0, 1))), 5));
PlayMode(player, 24);
SetPhysicsFlags(dummy, 0x1);
SetTimerEx(.2, 1, dummy, 0);
locked=1;
SetTimerEx(1.5, 2, 0, 0);
ChangeInv(player, 147, -10.0);
}
return;
Return;
Return;
end
Yeh theres a dummy colide! lol thanks for telling me about that, good :D
Ill post again to let u know if it works.
Xzero Phoenix
05-25-2005, 07:29 PM
Works, but i need to make the backpack move forward, what could i add?
Hell Raiser
05-25-2005, 08:21 PM
You need to get the thing number of the backback before you can do anything with it. From the looks of things, the CreateBackpack() line looks like it should have been dummy=CreateBackpack(). You'll want to do that, and also it looks like the ApplyForce() line should work well for what you want. Just be sure to take out any functions that have dummy in it that you don't want to be executed. :)
Xzero Phoenix
05-25-2005, 09:05 PM
oh yeah, forgot about that lol, thanks
zagibu
05-26-2005, 07:46 AM
Yeah, the missing dummy= in front of the CreateBackpack caused dummy to be unset. And your later reference to it resulted in a 0 being returned, which is usually the first walkplayer in the level (a.k.a. the host). So, all your ApplyForce and SetPhysicsFlags, etc., was applied to yourself.
SG-fan
05-26-2005, 10:00 AM
I'll hop on the bandwagon :p
You need the dummy= before the CreateBackpack. hehe
Anyway though, you have some timers in there being called with no timer message as well as several random variables such as locked.
I would use this cog as a base if I were you, and rewrite it from scratch with ONLY what you need. All this useless code and random timers can only hurt you later on.
zagibu
05-26-2005, 10:07 AM
The timer is for item destruction, I think. It's used in combination with a template flag, if I remember correctly.
Ah, no, that would be SetThingTimer, or something. You are right, those SetTimerEx seem a bit out of place.
darthslaw
05-26-2005, 12:13 PM
Maybe the timer message just hasn't been added yet?
That is, of course, assuming the SetTimerEx() 's serve some purpose.
Xzero Phoenix
05-26-2005, 05:15 PM
Iv modified the cog and got it working, the only problem now is when I jump the backpack goes thraugh the floor...
EDIT: Heres the cog:
# Jedi Knight Cog Script
#
# ITEM_KEYYELLOW.COG
#
# INVENTORY script - Drop Credits
# Bin 48
#
# [CYW & YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
thing player
model moneyTpl=y-key.3do local
message activated
end
# ================================================== ======================================
code
activated:
player = GetSourceRef();
// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
{
Return;
}
// Check Credits - If we are out, Play a message.
if(GetInv(player, 147) < 10.0)
{
Print("No More Credits");
Return;
}
else
Print("Droped Credits");
{
dummy=CreateBackpack(player);
ApplyForce(dummy, VectorScale(VectorNorm(VectorAdd(GetThingLVec(play er), VectorSet(0, 0, 1))), 5));
PlayMode(player, 24);
ChangeInv(player, 147, -10.0);
}
return;
Return;
Return;
end
Quib Mask
05-26-2005, 05:53 PM
Gah, that COG is horrible. Since it looks like it's supposed to drop some sort of currency, I'd guess it's from some "RPG" mod.
# Jedi Knight Cog Script
#
# ITEM_KEYYELLOW.COG
#
# INVENTORY script - Drop Backpack
# Bin 48
#
# [XP]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
thing player=-1 local
thing dummy=-1 local
message activated
end
# ================================================== ======================================
code
activated:
player = GetSourceRef();
// Check that the player is still alive.
if(GetThingHealth(player) <= 0) Return;
// Check Credits - If we are out, display a message.
if(GetInv(player, 147) < 10.0)
{
Print("No More Credits");
Return;
}
else
{
Print("Dropped Credits");
dummy = CreateBackpack(player);
SetCollideType(dummy, 1);
ApplyForce(dummy, VectorScale(GetThingLVec(player), 1));
PlayMode(player, 24);
ChangeInv(player, 147, -10.0);
}
Return;
endNow, there's the chance you'll instantly regrab the item because the collide is being set right away; I don't remember all the rules for powerups created inside a player. If that happens, a timer to set the collide after a short delay will be needed.
I don't know how hard you want the backpack to be shoved forwards. The 1 at the end of the "ApplyForce(" line is a scalar to increase or decrease how hard the backpack is pushed forward after dropping.
There are a lot of things missing to make this a good COG; namely items.dat would have to unreference most bins as adding to a backpack, or this COG needs to strip you of all items after dropping it, else you could just throw out a handful of backpacks and fill your ammo supply.
QM
Xzero Phoenix
05-26-2005, 06:03 PM
I was hoping to drop a different power up but that didnt work out well.
Im now hoping to remove the loss of ammo and stuff and only loose credits.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.