Adding new Guard Types

Discussion about Mods for Prison Architect

Moderator: NBJeff

Karrade
level1
level1
Posts: 44
Joined: Sat Feb 01, 2014 7:53 pm

Adding new Guard Types

Postby Karrade » Wed Oct 07, 2015 3:21 pm

With the release of V1.0 the main thing that is missing for me from this great game is a sniper and his tower.

Has anyone had any luck adding new types of characters, any at all? I was doing a search on steam and only found replacers, I am looking to learn how and want to know where to start.

Thanks.
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: Adding new Guard Types

Postby Brento666 » Wed Oct 07, 2015 3:58 pm

I'm busy creating surgeons and nurses atm...
it's possible to make custom entities, but they won't be able to do chores like escort prisoners, and they will have a hard time trying to open locked doors atm.

If your just beginning to program it will be hard to jump straight into entity behavior;
-Lua, the script language used, is quite ok, but the feedback you get on errors is pretty bad. It will give you vague error descriptions and non existing line numbers... or the complete game just crashes!

Once I've got my mod released you're welcome to learn from my code and/or reuse some structures, but that will be at the least a couple of weeks onward. If you want to learn the basics on entities, you can maybe check;
-Chad's drink mod; has a callout service repairman, he does his job and leaves the map after.
-Creature Comforts; has a cat that wanders around doing little else

When you get to a point where you have all your graphics sorted, and have a wandering sniper and tower onscreen, I might be around to help you along further!

Some tips;
-Select any modded item or entity and press F3 for it's debug output. With the pulldown menu in the debug console, you can 'explore' objects and methods (in the modded object's 'scope'), by selecting 'Explorer'.
-Use Game.DebugOut("testing!") in your scripts to write stuff to the debug console, so you can track your own messages to see what's going on.

Good luck!
Karrade
level1
level1
Posts: 44
Joined: Sat Feb 01, 2014 7:53 pm

Re: Adding new Guard Types

Postby Karrade » Wed Oct 07, 2015 4:28 pm

I took a software engineering degree and my favored language was C++, I never finished it as I bored easily :) but I would call myself a hobby programmer as far as poking around with mods, and as far as coding goes I am always able to pick things up relatively easily.

So I am not afraid to dive in, thanks for telling me where to start. I am at work but will take a look when I get back.

For the sniper guards, not being able to open doors is fine, they can sit in their towers :) Essentially all they'd be is a 'turret' type of guard, as long as they don't need a 'staff room' type of move.
User avatar
aubergine18
level2
level2
Posts: 231
Joined: Sun Jul 05, 2015 3:24 pm

Re: Adding new Guard Types

Postby aubergine18 » Wed Oct 07, 2015 5:21 pm

Do you even need a custom entity for a turret guard? IMHO it would be better to do the following:

* Create a new room type: Turret Foundation
* Create a new object: Turret
* Make Turret Foundation require a Turret
* Script the turret so it only 'works' when there's a Guard nearby
* User then deploys guard in the Turret Foundation room

This way the game will do things like changing guard shifts, etc.

The turret does periodical checks to see if there's a guard present - for example if TurretFoundation is 4x4 tiles, your Turret object would do something like

Code: Select all

local find = this.GetNearbyObjects -- shortcut
local turretRange = 10 -- map tiles

function Update()
  -- note Update() gets called many times per second so you'd probably want to add some despamming code here

  if next( find( "Guard", 2 ) ) then -- turret is active, find nearby prisoners

    local targets = find( "Prisoner", turretRange )
    -- etc...

  end

end


You can detect if a prisoner is escaping via properties on their object btw. What we know so far is listed in this guide (please let us know if you find anything new): http://steamcommunity.com/sharedfiles/f ... =480978426
Karrade
level1
level1
Posts: 44
Joined: Sat Feb 01, 2014 7:53 pm

Re: Adding new Guard Types

Postby Karrade » Fri Oct 09, 2015 10:46 am

aubergine18 wrote:Do you even need a custom entity for a turret guard? IMHO it would be better to do the following:

* Create a new room type: Turret Foundation
* Create a new object: Turret
* Make Turret Foundation require a Turret
* Script the turret so it only 'works' when there's a Guard nearby
* User then deploys guard in the Turret Foundation room

This way the game will do things like changing guard shifts, etc.

The turret does periodical checks to see if there's a guard present - for example if TurretFoundation is 4x4 tiles, your Turret object would do something like

Code: Select all

local find = this.GetNearbyObjects -- shortcut
local turretRange = 10 -- map tiles

function Update()
  -- note Update() gets called many times per second so you'd probably want to add some despamming code here

  if next( find( "Guard", 2 ) ) then -- turret is active, find nearby prisoners

    local targets = find( "Prisoner", turretRange )
    -- etc...

  end

end


You can detect if a prisoner is escaping via properties on their object btw. What we know so far is listed in this guide (please let us know if you find anything new): http://steamcommunity.com/sharedfiles/f ... =480978426


Thanks for the code, it'll help me a lot :) I'd probably still go with a guard as its better for aesthetics, the turrets would be nice though in a sci fi or near future mod.

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 7 guests