View Full Version : Simpler cog: Damaging material
F-Body
06-17-2004, 02:09 PM
grrr... suddenly Im having all these cog problems, but if someone could solve this quickie it would be great:
I am having many surfaces that will damage the player when touched, and they are all the same mat. So, instead of using the 00_damagewall.cog and inputing EVERY SINGLE surface, how about something where if you touch a certain mat you get hurt?
Sorta like combining 00_damagewall and 00_matanim. Like this except it doesnt function:
# Jedi Knight cog Script
#
# Whenever a player touches a material, he gets hurt
#
# [F-Body]
#
# This cog is not made or endorsed by LucasArts Entertainment Co.
# ================================================== ======================================
symbols
message touched
material damagemat desc=damaging_material
flex maxDamage=10.0
flex minDamage=5.0
int victim=-1 local
flex damage=0 local
flex garbage=0 local
end
# ================================================== ======================================
code
touched:
If(GetSurfaceMat(GetSenderRef())!=damagemat) return;
victim = GetSourceRef();
damage = (rand() * (maxDamage - minDamage)) + minDamage;
garbage = DamageThing(victim, damage, 0x2, victim); // self-inflicted damage
return;
end
------------------
nil nip nada zip zero naught lip zil
Edward
06-17-2004, 04:38 PM
Well, the GetSenderRef() only tests for the surfaces you've added to the symbols. As there is no surface, there is nothing to test. Try this:
surface i local
code
touched:
for(i=0; i<=GetSurfaceCount(); i=i+1)
{
If(GetSurfaceMat(i)!=damagemat) return;
Hurt_Me(waytoomuch); http://forums.massassi.net/html/tongue.gif
return;
end
/Edward
[This message has been edited by Edward (edited June 17, 2004).]
F-Body
06-17-2004, 07:59 PM
Thanks for the response, but Im still getting the same response. Heres what I have now:
#Jedi Knight cog Script
#
# Whenever a player touches a material, he gets hurt
#
# This cog is not made or endorsed by LucasArts Entertainment Co.
# ================================================== ======================================
symbols
message touched
material damagemat
surface i local
flex maxDamage=10.0
flex minDamage=5.0
int victim=-1 local
flex damage=0 local
flex garbage=0 local
end
# ================================================== ======================================
code
touched:
for(i=0; i<=GetSurfaceCount(); i=i+1)
{
If(GetSurfaceMat(i)!=damagemat) return;
victim = GetSourceRef();
damage = (rand() * (maxDamage - minDamage)) + minDamage;
garbage = DamageThing(victim, damage, 0x2, victim);
}
return;
end
[This message has been edited by F-Body (edited June 17, 2004).]
lucky_jackpot
06-18-2004, 03:03 AM
Have you tried using the "entered" message instead of "touched"? Give this a whirl, as I believe this could be the solution to your quandry http://forums.massassi.net/html/wink.gif - either way, let us know the outcome http://forums.massassi.net/html/smile.gif
Hope this helps http://forums.massassi.net/html/biggrin.gif
-Jackpot
------------------
"lucky_jackpot is the smily god..." - gothicX
"jackpot is an evil evil man... so evil, in fact, that he's awesome." - Seb
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
F-Body
06-18-2004, 08:39 AM
Well its not like is just a bunch of sectors, but there are many surfaces in the map that will damage. Thx for the idea though
------------------
nil nip nada zip zero naught lip zil
lucky_jackpot
06-18-2004, 08:59 AM
*cough* http://forums.massassi.net/html/wink.gif
<font face="Verdana, Arial" size="2">
Originally posted by GBK:
there is a valuable lesson to be learned here:
Walking on something (when its flagged as walkable), NEVER triggers Touched.
If you walk onto a surface, it sends ENTERED. If you walk onto a thing, it sends ENTERED. If you spit at a thing, it sends ENTERED. An object or surface will only, ONLY, ONLY send TOUCHED if you actully touch it, IE, from the side or bottom, or from the top if the object or surface are not flagged as walkable. ... Touched is not the answer in this case, and never is when the floor is concerned.
</font>
See this thread for more info: http://forums.massassi.net/html/Forum4/HTML/003953.html - this is why I suggested for you to try the "entered" message, as it isn't solely confined to sectors http://forums.massassi.net/html/wink.gif http://forums.massassi.net/html/smile.gif
Hope this helps http://forums.massassi.net/html/biggrin.gif
-Jackpot
------------------
"lucky_jackpot is the smily god..." - gothicX
"jackpot is an evil evil man... so evil, in fact, that he's awesome." - Seb
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
darthslaw
06-18-2004, 12:59 PM
Way to bring back memories jackpot http://forums.massassi.net/html/wink.gif
Oh, how I remember those words... I'll be darned should I ever forget them http://forums.massassi.net/html/redface.gif
------------------
nytfyre m0d (http://www.nightfire.uni.cc/site/page.php) || f33l t3h p0w3r (http://www.geocities.com/qrphome/pwp3/) || t3h l0st c0gz (http://www.tbns.net/GBK/ol/index.htm) || OMF > * (http://www.bkkbazaar.com/omf/)
F-Body
06-18-2004, 01:22 PM
Well thanks for that, it's the first I've heard on the subject. I'll check it out as soon as I get a chance. Gee, it sounds like GBK was unusually *touchy when writing that. (pun intended http://forums.massassi.net/html/wink.gif )
------------------
nil nip nada zip zero naught lip zil
SG-fan
06-18-2004, 10:41 PM
Just one question [in a slightly sarcastic tone] how is entered: or touched: going to be called without declaring any surfaces to call the message? [/sarcastic tone]
What I'm saying is that as far as I know, you can't call a message from a surface without declaring the surface first. You have the surface declarations after the message is called.
------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
lucky_jackpot
06-21-2004, 07:58 AM
I'm guessing (because I haven't tested Slaw's suggestion - lack of time and all in the real world... http://forums.massassi.net/html/wink.gif) that although not identifying a surface to run the "entered" message, any surface that is assigned the "damagemat" material will be used as a damaging surface. Whilst this implementation should work, you do have the overhead that you have to iterate through all the surfaces in the level (which could take a while depending on level size). Whilst a linkid for the surface would be my preference for this type of thing, Slaw's will work equally well, so I guess it's a "horses for courses" decision http://forums.massassi.net/html/smile.gif http://forums.massassi.net/html/biggrin.gif
-Jackpot
NB: Sorry about dregding up those immortal words Slaw http://forums.massassi.net/html/redface.gif http://forums.massassi.net/html/wink.gif - it was just that it was the last thread I could remember where a really detailed discussion of this nature occured... http://forums.massassi.net/html/biggrin.gif
------------------
"lucky_jackpot is the smily god..." - gothicX
"jackpot is an evil evil man... so evil, in fact, that he's awesome." - Seb
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
LKOH_SniperWolf
06-21-2004, 03:15 PM
If this did work, it'd be something of a waste of resources. This would have JK checking and rechecking every surface in the level. The simpler cog F-Body mentioned, modified to take care of more surfaces would probably be the more efficient alternative, though it'd take more work to set up.
------------------
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.