ID:1259541
 
(See the best response by Albro1.)
Code:
mob
verb
Wall()
set name = "Wall"
set category = "Build"
new/obj/Wall(usr.loc)



Problem description:

Okay, my last post for a good bit.

Okay, so I need help making a new element type deal with my game.

In my game im helping to work on, players can build walls. With these walls, they can make buildings.

However, there is no players safe because someone can just walk by and blow up the walls.

What I need is a knowledge system. A knowledge system is where that knowledge always grows when ever you open a tab. (the Science tab.)

With your knowledge, you can upgrade the walls to have a health equal to what ever the knowledge makes it.


That is the system I want help with. The challenges is making the walls parent to each other when they are connected, and making the knowledge upgrades the walls health, BUT NOT equal the knowledge exactly. We could probably make it that knowledge = health *2.

Another challenge is to make the knowledge cap. So that if the whole servers a certain level, the knowledge wont go above the cap.



So, can you guys help me? I know its a lot to ask for, but it would help me a bunch! I am kinda clueless how to go about doing this.
Best response
Add a variable to the wall that stores the mob who created it in it.
obj/wall
var
mob/owner
health = 100
New(mob/m)
if(m)
owner = m
..()
health_loop()
proc/health_loop()
health = owner.health/2
spawn(10) health_loop() // There isn't much gleaned from calling this every tick, so just call it every second

mob/proc/build_wall()
var/obj/o = new /obj/wall(src)
o.loc = src.loc


I didn't explain what's going on here, so feel free to ask any questions.
In response to Albro1
About the health loop. I understood everything else.

Is the health loop to make it where it is the health of the owner constantly? Like as if the owner levels up, and he obtains more health, the wall would also?
Yes. The loop calls itself over and over again, constantly updating the health. This way isn't advisable in all cases, but it works here.
In response to Albro1
But theres a small problem.

What if the owner gets hurt in battle. The walls would update and be hurt too. So if I kill the owner, the walls will be destroyed.
Then use the max health?
In response to Albro1
o-o

DUHHHHH. Thanks Albro. I think im going to try this idea. I dont know if the owner of the game will take up on the idea, but might as well ask.
In response to Albro1
Noob question

            icon='wall.dmi'
icon_state="wall"
density=1
destructable=1
opacity = 1


Where would I place these variables? o-o.

I know, big noob question. But I tired and I cant seem to place them into the code.

In response to TheScatman95
You'd want to place them under your definition for /obj/wall.

obj
wall
icon='wall.dmi'
// etc...
In response to LordAndrew
Oh, okay thank you.
I am on my phone right now so can't use code tags but instead of using max Health in the above example use the mobs knowledge seeing as that is the var that will have an effect on the wall health. So like the following pseudocode, you will not be able to copy and paste this for it to work, its only a concept.

Mob/player
Knowledge = level * 5

Obj/(whatever stuff here)
Healthloop()
obj/wall/proc/healthloop()
Spawn(10)
Wall.health = m.knowledge**(.5 * m.level)

Using the exponet gives the graph (character progression) a nice curve that helps keeps the player from itting to much of a plateu.