ID:149586
 
Ok I almost have my combat code working in Star Traders, I just need to get the lasers to work now. They shot out, head 3 tiles and del src as expected. But they are not doing any damage. I'm using the projectile by Shadowdarke that someone suggested. Of course its modified a bit, but I need help on getting the weapons var from who. (per firing the laser) and being able to use that in my damage calculations. Since weapons can be anywhere from 0 - 100 I can't just set a standard damage value like I did for the torpedos in the game.

LJR

Below is the related code.


Bump(mob/pc/M, obj/O)

if(ismob(M))

if(M.shields > 0)

if(isobj(/obj/projectile/laser_green))

M.shields -= who:weapons

if(isobj(/obj/projectile/laser_blue))

M.shields -= who:weapons

if(isobj(/obj/projectile/laser_red))

M.shields -= who:weapons

goto weaponskip

if(M.hull > 0)

world << "[who]'s [name] hits [M] for [damage] damage!"

if(isobj(/obj/projectile/laser_green))

M.hull -= who:weapons

if(isobj(/obj/projectile/laser_blue))

M.hull -= who:weapons

if(isobj(/obj/projectile/laser_red))

M.hull -= who:weapons

else

M.hull -= damage

if(M.hull < 1)

world << "[M] has been destroyed by [who]."

M << "You can play the game again, just rejoin."

del (M)

else

world << "[who]'s [name] hits [M]."

return
</1>
Those aren't objects, those are types so those if statements will never evaluate to true. I'm not sure why it's set up that way though so I can't really give an alternative.

Ok, I lied. I'll try to give an alternative :p

Bump(var/mob/pc/M) //bump only has one argument
if(istype(M,/mob/pc))
if(istype(src,/obj/projectile/laser)) //seperate lasers from other projectiles
M.hull -= who:weapons //not sure what who or weapons are so I'll leave it like it was
//do a similar change for the rest

This does depend on the setup though. You could have a seperate Bump for each weapon type (torpedo, laser, etc.) so then you wouldn't need that second if statement to test the objects type.
Ok always thinking.. wonder if I define the var for damage like this will it carry over and be able to be called upon with the var dam?

var/
mob/who // the mob that fires the projectile

mob/damage/dam // the mob's damage

LJR

PS. Well I really need help with this bit of code on how to extract the damage var from the person who is shooting it, taggin it onto the laser obj/projectile's damage so when it hits, it does the correct amount of damage, determined by the person's ship who shot it's Weapon Class.

In response to LordJR
That would try to create a new mob type called damage with a variable of it's type called dam. This is what the compiler would look for:

mob
damage
In response to English
Hey Shadow I'm trying to use ur projectile code you know an answer to my problem posted above??

Maybe ur the best person to ask for this?

LJR
LordJR wrote:
Ok I almost have my combat code working in Star Traders, I just need to get the lasers to work now. They shot out, head 3 tiles and del src as expected. But they are not doing any damage. I'm using the projectile by Shadowdarke that someone suggested. Of course its modified a bit, but I need help on getting the weapons var from who. (per firing the laser) and being able to use that in my damage calculations. Since weapons can be anywhere from 0 - 100 I can't just set a standard damage value like I did for the torpedos in the game.

LJR

As English pointed out, your main problem is with these lines:

if(isobj(/obj/projectile/laser_green))

That line means is the type path /obj/projectile/laser_green an obj instance? It evaluates false, because /obj/projectile/laser_green is a typepath, and the line for who:weapon is never called. You want

if(istype(src,/obj/projectile/laser_green))

to see if this projectile is a laser_green projectile.

The snippet you are using is actually designed so that each type of projectile may have it's own routines. You can avoid checking the src type altogether, by simply overiding the appropriate procs. I suppose I should write a more detailed version.

Here is an example:
obj/projectile
laser
Bump(O)
if(ismob(O))
var/mob/M = O // get a mob alias to O
if(istype(who, /mob/pc)) // make sure who is a valid pc
M.shields -= who:weapons
if(M.shields<0) // if the shields have a negative value
// reduce the hull by the shield overflow
M.hull += M.shields // since shields are <0, this reduces hull
M.shields = 0 // reset the shields to 0
if(M.hull < 1)
world << "<font color=red><B>[M] has been destroyed by [who].</B></font>"
M << "You can play the game again, just rejoin."
del (M)

blue
icon = 'laser_blue.dmi'
green
icon = 'laser_green.dmi'
red
icon = 'laser_red.dmi'

torpedo
icon = 'bigandnastynuke.dmi'
damage = 10

Bump(O)
if(ismob(O))
var/mob/M = O // get a mob alias to O
M.hull -= damage
if(M.hull < 1)
world << "<font color=red><B>[M] has been destroyed by [who].</B></font>"
M << "You can play the game again, just rejoin."
del (M)


I took some liberties with your damage system, but I think the laser Bump() is more like what you intended for it to be. With your old code, if someone with weapons 10 fired on someone with 1 shield, the shield would absorb all the damage. The system I use above will transfer the other 9 points of damage to the ships hull.

I made torpedos bypass shields in the above example, just to demonstrate a different behaviour. It would probably be best to make a mob/damaged() proc so that you can just send the ammount of damage to the proc, and let it be applied consistently, no matter where the damage comes from.

Also, if you change the definition of who to var/mob/pc/who, you won't have to use the : operator when you access who.weapons.

On a final note, you definately didn't find this line in my snippet:
goto weaponskip
Where is weaponskip, and why are you using a goto?
In response to Shadowdarke
Never mind that man behind the curtain, I...aG$T^$ I mean the goto (sheepish grin) Well I see now what I need to read up on. Everything looks ok but I noticed the following problems with the code ur purpose.

1) It seems you can not shoot your lasers till another mob comes in site.
2) When the lasers do fire it looks like it shows the 1st tile screen and anything after you don't see.
3) Would be nice know to know how to do an area check for the projectiles and if in a certain area, explode like before entering Fed Space. Right now those with weapons take aim at those suppose to be in a protective area.

LJR

Thanks for ur help!
In response to LordJR
LordJR wrote:
Never mind that man behind the curtain, I...aG$T^$ I mean the goto (sheepish grin) Well I see now what I need to read up on. Everything looks ok but I noticed the following problems with the code ur purpose.

1) It seems you can not shoot your lasers till another mob comes in site.

The original projectile snippet allows you to fire a projectile at any time, mob or not. How are you starting the projectile?

2) When the lasers do fire it looks like it shows the 1st tile screen and anything after you don't see.

I'd have to see your modifications for missileloop() too.

3) Would be nice know to know how to do an area check for the projectiles and if in a certain area, explode like before entering Fed Space. Right now those with weapons take aim at those suppose to be in a protective area.

area/FedSpace // replace with your area, I just guessed
Enter(O)
if(istype(O,/obj/projectile))
del(O)
else
return ..()