You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create-unit: added 'quantity' and random caste selection
- added 'quantity' argument for spawning several units simultaneously
- implemented random caste selection for use upon omission of 'caste' argument
- changed several instances of 'error' to 'qerror'
-- sets baby/child profession and mood for creatures of the appropriate age where relevant
11
11
-- properly assigns civ_id to historical_figure to eliminate a number of hostility issues
12
12
-- removes the arena-generated string of numbers from the first name of units
13
+
-- added 'quantity' arg for spawning multiple creatures simultaneously
14
+
-- creature caste is now randomly selected if left unspecified
15
+
13
16
--[[
14
17
TODO
15
18
confirm body size is computed appropriately for different ages / life stages
@@ -36,6 +39,7 @@ Creates a unit. Usage::
36
39
HUMAN
37
40
-caste casteName
38
41
specify the caste of the unit to be created
42
+
if not specified, the caste is randomly selected
39
43
examples:
40
44
MALE
41
45
FEMALE
@@ -54,14 +58,20 @@ Creates a unit. Usage::
54
58
Can be used instead of -civId \\LOCAL and -groupId \\LOCAL
55
59
-name entityRawName
56
60
set the unit's name to be a random name appropriate for the
57
-
given entity. examples:
61
+
given entity
62
+
examples:
58
63
MOUNTAIN
64
+
EVIL
59
65
-nick nickname
60
66
set the unit's nickname directly
61
67
-location [ x y z ]
62
68
create the unit at the specified coordinates
63
69
-age howOld
64
70
set the birth date of the unit by current age
71
+
chosen randomly if not specified
72
+
-quantity howMany
73
+
replace "howMany" with the number of creatures you want to create
74
+
defaults to 1 if not specified
65
75
-flagSet [ flag1 flag2 ... ]
66
76
set the specified unit flags in the new unit to true
67
77
flags may be selected from df.unit_flags1, df.unit_flags2,
@@ -316,7 +326,7 @@ function createNemesis(trgunit,civ_id,group_id)
316
326
he_group.nemesis_ids:insert("#",id)
317
327
he_group.nemesis:insert("#",nem)
318
328
end
319
-
nem.figure=createFigure(trgunit,he,he_group)
329
+
nem.figure=trgunit.hist_figure_id~=-1anddf.historical_figure.find(trgunit.hist_figure_id) orcreateFigure(trgunit,he,he_group)-- the histfig check is there just in case this function is called by another script to create nemesis data for a historical figure which somehow lacks it
320
330
returnnem
321
331
end
322
332
@@ -470,7 +480,8 @@ validArgs = utils.invert({
470
480
'nick',
471
481
'location',
472
482
'age',
473
-
'setUnitToFort' -- added by amostubal to get past an issue with \\LOCAL
483
+
'setUnitToFort', -- added by amostubal to get past an issue with \\LOCAL
484
+
'quantity'
474
485
})
475
486
476
487
ifmoduleModethen
@@ -487,8 +498,8 @@ local race
487
498
localraceIndex
488
499
localcasteIndex
489
500
490
-
ifnotargs.raceornotargs.castethen
491
-
error'Specfiy a race and caste for the new unit.'
501
+
ifnotargs.racethen
502
+
qerror('Specify a race for the new unit.')
492
503
end
493
504
494
505
--find race
@@ -501,25 +512,27 @@ for i,v in ipairs(df.global.world.raws.creatures.all) do
501
512
end
502
513
503
514
ifnotracethen
504
-
error'Invalid race.'
515
+
qerror('Invalid race: '..args.race)
505
516
end
506
517
507
-
fori,vinipairs(race.caste) do
508
-
ifv.caste_id==args.castethen
509
-
casteIndex=i
510
-
break
518
+
ifargs.castethen-- if args.caste is omitted, casteIndex is randomly selected within the spawn loop below
0 commit comments