Tutorial #1 The game part of the project is where we get a little screwy. If you don't agree with my coding, or how I went about something. Sorry, I have my style, and my errors.....but it gets the job done. Anyways.....on with the project..... We will start with g_local.h in a struct called gclient_s about line 260. This is where the client info is stored like if fire is held...and who hurt us last. etc. Here we need to keep track of who poisoned us last, so if we die from it...They get the frag. A ton better than just dying and losing a damn frag. So... here is what is looks like originally.... And here is what we are going to add so the game has a place to store who poisoned us last..... The way we decided to go about poison is this... If you have regen, it compensates for being poisoned. In that, you will not take damage from being poisoned if you have the regen powerup as well. So..this being said, open up g_active.c and inside the function ClientTimerActions around line 468..we have the following: We need to put our code between the G_Addevent and the else with an else if. We want this because like I said a minute ago..check regen first, then if no regen, check poisoned. After all that and you have none...then start the last part. So our code resembles this: Hmm... Seem a little odd.. Well here goes the explanation. We do the if to see if the have been Poisoned. Then we are defining an entity name attacker. And setting the attacker info as whomever poisoned us last. Then we are calling the G_Damage function, telling it we are getting damaged..from the attacker, with a means of death of Poison. The damage we are dealing is 5 points.....(pretty low...but..it gets called every second..so it adds up). So we have covered how we take damage from being poisoned...but how do we get infected? Well this is mostly contained in the g_combat.c file. The first thing we need to do here though is make sure we are not dropping the powerup of Poisoned. You should not drop this as it doesn't lend itself to what we wanted. So in a function named TossClientItems (line 37) we see the code that tosses items carried when someone dies... So this is where it says all powerups are dropped. If no team game, then drop every powerup the client is carrying. We want to check if the powerup is PW_POISONED before we go throwing it out. So we need to add some simple code....if i == PW_POISONED then continue. Don't drop it....
Now on to MOD defs again... somewhere around line 140 should be a char *modNames[] = { . We need to add the MOD_POISON again for logging sake. Orig looks like: We need to add the MOD_POISON at the end.....now unlike last time...you need a coma at the end of every line in a char def. So we should read as follows: Oh boy...here comes the part where I lose some people because.... My brain is whacked out..and I code weird, and I do what seems logical to me. That said.. still in g_combat.c looking for the function G_Damage.... scroll down until you see the following.... So...you find it? OK... This is just checking if there target hit was actually a client. Seems simple enough..then it changes the targets settings and says last person who hurt me was whoever. And the means of death was whatever. This is where we are going to add the motherload. The part of the code that check if you are already poisoned, and if so checks which has more time on it..etc..etc..etc.. Then infects your ass. So here is what we added... OK explanations.... First line added is basically checking if the damage dealt should even check for Poison. This is done, because sometimes it won't matter. Like gibbing a dead body. If we did checking of a dead body for poison, we would kill the machine. Dead bodies don't have all the same functions as alive players. So that is all this line is doing. Also checking if the MOD was already poison. We don't want double poisoning going on. Next line just checks for the attacker having already been poisoned. If so it goes on and sets the attacker as being the last person to poison the target. Then checks for the target already being poisoned. If they are already poisoned it compares to see who has the longer time left. If the attacker has the longer time left, it sets the targets time left to the attackers time left. If the target does not have poisoned, then it give them poisoned with the same amount of time left as the attacker had left. Next it checks if the attacker has poison instead of poisoned. And basically goes through the same routine. Pretty simple actually. But round about? dunno...It works though. Now then.... We need to make sure that PW_POISONED is loaded on every map so the game doesn't freak out when someone gets poisoned.... open up g_items.c and look for a function named ClearRegisteredItems. Inside that we need to add the following.... Now we are on to misc cleanup...and bot implementation........ | ||||
news | projects | FoF | tactics | download | tutorials | team | ||||