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 → Cog Help... again...
Cog Help... again...
2005-05-25, 2:24 PM #1
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?
2005-05-25, 4:24 PM #2
Sounds like you did a SetCollide(player, 0) somewhere...
May the mass times acceleration be with you.
2005-05-25, 4:26 PM #3
lol heres the cog:
Quote:
# 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(player), 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.
2005-05-25, 4:29 PM #4
Works, but i need to make the backpack move forward, what could i add?
2005-05-25, 5:21 PM #5
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. :)
-Hell Raiser
2005-05-25, 6:05 PM #6
oh yeah, forgot about that lol, thanks
2005-05-26, 4:46 AM #7
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.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-05-26, 7:00 AM #8
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.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-05-26, 7:07 AM #9
The timer is for item destruction, I think. It's used in combination with a template flag, if I remember correctly.

[edit] Ah, no, that would be SetThingTimer, or something. You are right, those SetTimerEx seem a bit out of place. [/edit]
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-05-26, 9:13 AM #10
Maybe the timer message just hasn't been added yet?

That is, of course, assuming the SetTimerEx() 's serve some purpose.
May the mass times acceleration be with you.
2005-05-26, 2:15 PM #11
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:

Quote:
# 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(player), VectorSet(0, 0, 1))), 5));
PlayMode(player, 24);
ChangeInv(player, 147, -10.0);
}


return;
Return;

Return;

end
2005-05-26, 2:53 PM #12
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.
Code:
# 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;

end
Now, 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
2005-05-26, 3:03 PM #13
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.

↑ Up to the top!