ID:158973
 
I'm having trouble figuring out how to write a bit of code for when a player kills a player-king and then the first player mentioned would become the king of that castle.

I know what the processes are but I don't know much of the language of this program. There's no doubles yet for the code because I'm going to have the codes for the different kingdoms in different code-files. Also, I think I messed up something in this setup, but I forgot to put documentation in there.

If player kills rulerA
If(rulerB title = "King")
and heir = 0
If(player class = "Ruler")
make rulerB title = "Conquerer"
else
make player class = "Ruler"
make player castleAlignment = "CastleA"
and heir = 1
If(player class = "Ruler")
make rulerB title = "Conquerer of CastleA"
make rulerA title = "Puppet King"
else
make heirA class = "King"
else
If(rulerB title = "Conquerer")
If(heir = 0)
If(usr.class = "Ruler")
If(usr.castleAllignment = CastleC)
make rulerB title = "King"
make rulerC title = "Conquerer"
else //User Class Allignment
return()
else //User Class
make usr.class = "Ruler"
make usr.castleAlignment = "CastleA"
else //Heir
If(player class = "Ruler")
make rulerB title = "Conquerer of CastleA"
make rulerA title = "Puppet King"
else //User Class (Yes Heir)
Return()

If player kills rulerB
and rulerB title = "Conquerer of CastleA"
If(player class = Peasant)
make rulerB title = "King"
make rulerA title = "King"
make usr.class = "Knight"
make usr.title = "Saviour"
make usr.castleAlignment = "CastleA"
else
If(usr.class = Knight)
if(usr.castleAlignment = "CastleA")
make rulerB title = "King"
make rulerA title = "King"
make player title = "Saviour"
if(usr.castleAlignment = "CastleB")
make rulerB title = "Usurper Conquerer of A"
else
Return()
else
make rulerB title = "King"
make rulerA title = "King"
else
If(usr.castleAlignment = "CastleC")
make rulerC title = "Conquerer of Castle B")
make rulerB title = "Puppet King"

If usr.health = 0
and usr.class = "Ruler"
and castleAlignment = "CastleA"
set usr.class = "Peasant"
set usr.castleAlignment = ""
make rulerA = 0

If usr.title = "HeirA"
and rulerA = 0
make usr.class = "Ruler"
make usr.castleAlignment = "CastleA"
make rulerA = 1

Logout()
and usr.class = "RulerA"
make usr.class = "Peasant"
make usr.castleAlignment = ""
make rulerA = 0

---

populationCastleA = ((number of kingdom tiles in the overworld)/20)+5

Every 24 minutes
If(RulerA = 1)
treasuryA = treasuryA + populationCastleA
If(rulerA title = "Puppet King")
If(rulerB title = "Conquerer of A")
treasuryB = treasuryB + (treasuryA*.01)
treasuryA = (treasuryA*.01)
else
If(rulerC title = "Conquerer of A")
treasuryB = treasuryB + (treasuryA*.01)
treasuryA = (treasuryA*.01)
and usr.class = "Knight"
If(treasuryA > knightFee)
subtract knightFee from treasury A
add knightFee to usr.money
Looks really close to pseudocode o.o;

You could make kings a seperate mob (/mob/king) and others a normal character (/mob/player). Set other variables and areas with owners to that mob, (you could even set kings per kingdom, like /mob/kings/Scotland or anything), set variables and stuff per king, then change the client.mob on assassination, so everything is changed real easily.
In response to Mysame
Thanks, I'm fairly new to programing and I'm just having trouble figuring out certain things. Most of the code (when it comes to variables) is easy to understand because it's just algebra, but stuff like Platformer Gravity, the part of combat code which has the attack hit the opponent, and some Location stuff confuses me.