View previous topic :: View next topic |
Author |
Message |
TargetPractice
Joined: 30 Nov 2006 Posts: 17
|
Posted: Fri Dec 01, 2006 4:45 am Post subject: Noob setting too big a goal- would like assistance |
|
|
It seems I've run into a programming difficulty I hadn't expected, and could use some assistance from someone with more skill than I.
I was trying to figure out how to have scrags and zombies do acid damage from their blows after their hits. Originally, I figured I could tell the spike, in spike_touch:
if (self.owner.classname == "wizard")
{
Poison_it(self, self.owner, other, 9);
}
else
{
T_Damage (other, self, self.owner, 9);
}
and attach a later construct (w/ prior prototype) that would attack a poison entity to the target, and have an internal loop which would ping the player each second with a succeedingly less amount of damage(by multiplying the previous damage by .5, rounding down).
Then I realized I'd bitten off more than my fair share, because my example code (Shockman's poison axe tut) didn't explain how to decrement damage per thought like that, and I don't know how to round a float in quakeC yet.
Could someone please explain to me what I'm doing wrong?
(This is only my second mod, and yes, I know I'm still a bit inexperienced for this kinda thing.)
Thank you in advance. |
|
Back to top |
|
 |
Preach
Joined: 25 Nov 2004 Posts: 122
|
Posted: Fri Dec 01, 2006 9:55 am Post subject: Re: Noob setting too big a goal- would like assistance |
|
|
That sounds like a pretty sensible way to do things. There are three functions you can use to get an integer from a floating point value(don't worry, it's not as complicated as it sounds!)
rint(a) returns the nearest integer to a, so rounds up if the decimal is .5 or more, and rounds down otherwise:
rint(3.276) = 3
rint(4.576) = 5
floor(a) returns the greatest integer less than a, so basically just chops off all the decimal places from the number:
floor(22.15983) = 22
ceil(a) returns the smallest integer greater than a, which is like doing floor and then adding 1.
ceil(22.15983) = 23
rint is probably the best one to use. Also make sure that you have a check to see when the damage the entity is doing is rounded to 0, and remove the entity at that point. Otherwise you'll have all these entities doing nothing, and eventually the engine may run out of entities.
To make the entity take damage off each frame, set the owner field of the poisoning entity to the self.owner you sent to Poison_it, and the enemy field to the other you sent. Then in the think function you create, have a line
T_Damage (self.enemy, self, self.owner, a);
where a is the amount of damage you have computed. This line tells quake to damage self.enemy (the player), that the damage is inflicted by self(the poison), that the damage was originally caused by self.owner(a scrag), and that the amount of damage to do is a.
Hope that helps somewhat, let us know if you have any more problems. |
|
Back to top |
|
 |
TargetPractice
Joined: 30 Nov 2006 Posts: 17
|
Posted: Sat Dec 02, 2006 5:27 am Post subject: |
|
|
I read the comment Carmack (or whoever) planted in the code about T_Damage being the only proper damagesource, so I was intending to utilize that function. Thank you for making sure I noticed this. I didn't know about floor(), rint() or ceiling(), though.
I should also note that the mod works now! I was anticipating coding it so that any additional acidSplatter(rename) pings would increment the .acidDamage in Skippy's acid entity; however, I like the effect of multiple acid entities picking at his health in quick rate. Almost a siren's call to hunt health packs.
I never thought hearing pained, fearful screams could make one feel so... uplifted.
Also: Is it possible to search for 'attached entity' on a given model like this? I'm thinking of having medikits contain antacids (ingested or external depends on your sense of humor), and so picking one up cuts all acid.acidDamage on Skippy to 0. _________________ I never thought hearing pained, fearful screams could make one feel so... uplifted.
What? |
|
Back to top |
|
 |
Lardarse

Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK
|
Posted: Sat Dec 02, 2006 11:03 pm Post subject: |
|
|
You will need to use a find loop, searching for the classname of the entity that is doing the acid damage (make sure that you set one when it is created), and then for each one, check that it belongs to the player in question. |
|
Back to top |
|
 |
TargetPractice
Joined: 30 Nov 2006 Posts: 17
|
Posted: Sun Dec 03, 2006 3:53 am Post subject: |
|
|
I think I have it working now. I anticipate a problem with it if anything besides humans get acid burns when someone grabs a medikit, but I rather doubt that to be the case for now. (Will improve it if that ceases to be the case.)
Thank you all for the help. _________________ I never thought hearing pained, fearful screams could make one feel so... uplifted.
What? |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|