Random weapons, and armor
#1
Posted 08 January 2007 - 09:53 PM
https://www.twitch.tv/vileartist - Yes shameless self-promotion
----------------------------------------------------------------------------------------------------------------------
"Old modders never die, they just fade away" ~ Hostile
#2
Posted 08 January 2007 - 10:03 PM
EDIT. Ah to hell with it, I'll explain a bit more detailed:
You need to give your unit an AIUpdate block, which links to a functions thing in one of the files in data.big (sorry for the lack of detail but I don't want to open the files right now). Give them a script when they're created which does the following:
1) Hides all the subobjects by default (except the orc mesh of course)
2) Use LUA to generate random numbers for variables (call them things like: weapon, armour, shield etc)
3) Make an If statement for each thing you wish to randomise (i.e. 1 for weapon, 1 for shield)
4) Make it so that if the random number is between two certain values, you unhide a certain object.
5) Copy and paste a lot
Edited by zimoo, 08 January 2007 - 10:06 PM.
#3
Posted 08 January 2007 - 10:56 PM
And no, taking no codeboxes was on purpose (I hate them), and I'm too lazy to upload a txt file now
function OnMordorOrcFighterCreated(self) -- comments: -- this function is very long, because of all the different subobjects we have to choose from -- the basic order is: hide everything, choose a helmet, choose all other equipment depending on the fact if a helmet is shown or not -- hide all heads ObjectHideSubObjectPermanently( self, "HEAD02", true ) ObjectHideSubObjectPermanently( self, "HELMET_HEAD01", true ) ObjectHideSubObjectPermanently( self, "HELMET_HEAD02", true ) ObjectHideSubObjectPermanently( self, "HELMET_HEAD03", true ) ObjectHideSubObjectPermanently( self, "NOHELMET_HEAD01", true ) ObjectHideSubObjectPermanently( self, "NOHELMET_HEAD02", true ) ObjectHideSubObjectPermanently( self, "NOHELMET_HEAD03", true ) ObjectHideSubObjectPermanently( self, "NOHELMET_HEAD04", true ) -- hide all hair ObjectHideSubObjectPermanently( self, "NOHELMET_HAIR01", true ) ObjectHideSubObjectPermanently( self, "NOHELMET_HAIR02", true ) ObjectHideSubObjectPermanently( self, "HELMET_HAIR01", true ) -- hide all helmets ObjectHideSubObjectPermanently( self, "HELMET_01", true ) ObjectHideSubObjectPermanently( self, "HELMET_02", true ) ObjectHideSubObjectPermanently( self, "HELMET_03", true ) ObjectHideSubObjectPermanently( self, "HELMET_04", true ) ObjectHideSubObjectPermanently( self, "HELMET_05", true ) ObjectHideSubObjectPermanently( self, "HELMET_06", true ) ObjectHideSubObjectPermanently( self, "HELMET_07", true ) ObjectHideSubObjectPermanently( self, "HELMET_08", true ) ObjectHideSubObjectPermanently( self, "HELMET_09", true ) --hide all right hand equipments (only weapons) ObjectHideSubObjectPermanently( self, "RIGHT_SWORD01", true ) ObjectHideSubObjectPermanently( self, "RIGHT_SWORD02", true ) ObjectHideSubObjectPermanently( self, "RIGHT_SWORD03", true ) ObjectHideSubObjectPermanently( self, "RIGHT_SWORD04", true ) ObjectHideSubObjectPermanently( self, "RIGHT_SPEAR01", true ) ObjectHideSubObjectPermanently( self, "RIGHT_SPEAR02", true ) ObjectHideSubObjectPermanently( self, "RIGHT_SPEAR03", true ) ObjectHideSubObjectPermanently( self, "RIGHT_SPEAR04", true ) ObjectHideSubObjectPermanently( self, "RIGHT_AXE01", true ) ObjectHideSubObjectPermanently( self, "RIGHT_AXE02", true ) ObjectHideSubObjectPermanently( self, "RIGHT_AXE03", true ) ObjectHideSubObjectPermanently( self, "RIGHT_AXE04", true ) ObjectHideSubObjectPermanently( self, "RIGHT_MACE01", true ) ObjectHideSubObjectPermanently( self, "RIGHT_MACE02", true ) ObjectHideSubObjectPermanently( self, "RIGHT_MACE03", true ) --hide all left hand equipments (shields and weapons) ObjectHideSubObjectPermanently( self, "LEFT_SHIELD01", true ) ObjectHideSubObjectPermanently( self, "LEFT_SHIELD02", true ) ObjectHideSubObjectPermanently( self, "LEFT_SHIELD03", true ) ObjectHideSubObjectPermanently( self, "LEFT_SHIELD04", true ) ObjectHideSubObjectPermanently( self, "LEFT_SHIELD05", true ) ObjectHideSubObjectPermanently( self, "LEFT_SHIELD06", true ) ObjectHideSubObjectPermanently( self, "LEFT_SWORD01", true ) ObjectHideSubObjectPermanently( self, "LEFT_SWORD02", true ) ObjectHideSubObjectPermanently( self, "LEFT_SWORD03", true ) ObjectHideSubObjectPermanently( self, "LEFT_SWORD04", true ) ObjectHideSubObjectPermanently( self, "LEFT_AXE01", true ) ObjectHideSubObjectPermanently( self, "LEFT_AXE02", true ) ObjectHideSubObjectPermanently( self, "LEFT_AXE03", true ) -- define the locals as random numbers local head = GetRandomNumber() local helmet = GetRandomNumber() local hair = GetRandomNumber() local righthand = GetRandomNumber() local lefthand = GetRandomNumber() local hashelmet = false --////////////////////////////////////////// -- HELMET --////////////////////////////////////////// -- start picking a helmet -- this comes first because some heads and hair must have a helmet, some must not if helmet <= 0.1 then hashelmet = false elseif helmet <= 0.2 then ObjectHideSubObjectPermanently( self, "HELMET_01", false ) hashelmet = true elseif helmet <= 0.3 then ObjectHideSubObjectPermanently( self, "HELMET_02", false ) hashelmet = true elseif helmet <= 0.4 then ObjectHideSubObjectPermanently( self, "HELMET_03", false ) hashelmet = true elseif helmet <= 0.5 then ObjectHideSubObjectPermanently( self, "HELMET_04", false ) hashelmet = true elseif helmet <= 0.6 then ObjectHideSubObjectPermanently( self, "HELMET_05", false ) hashelmet = true elseif helmet <= 0.7 then ObjectHideSubObjectPermanently( self, "HELMET_06", false ) hashelmet = true elseif helmet <= 0.8 then ObjectHideSubObjectPermanently( self, "HELMET_07", false ) hashelmet = true elseif helmet <= 0.9 then ObjectHideSubObjectPermanently( self, "HELMET_08", false ) hashelmet = true else ObjectHideSubObjectPermanently( self, "HELMET_09", false ) hashelmet = true end --////////////////////////////////////////// -- HEAD --////////////////////////////////////////// -- set the heads that require a helmet if hashelmet == true then if head <= 0.25 then ObjectHideSubObjectPermanently( self, "HEAD02", false ) elseif head <= 0.5 then ObjectHideSubObjectPermanently( self, "HELMET_HEAD01", false ) elseif head <= 0.75 then ObjectHideSubObjectPermanently( self, "HELMET_HEAD02", false ) else ObjectHideSubObjectPermanently( self, "HELMET_HEAD03", false ) end end -- now set the heads that must not have a helmet if hashelmet == false then if head <= 0.25 then ObjectHideSubObjectPermanently( self, "NOHELMET_HEAD01", false ) elseif head <= 0.5 then ObjectHideSubObjectPermanently( self, "NOHELMET_HEAD02", false ) elseif head <= 0.75 then ObjectHideSubObjectPermanently( self, "NOHELMET_HEAD03", false ) else ObjectHideSubObjectPermanently( self, "NOHELMET_HEAD04", false ) end end --////////////////////////////////////////// -- HAIR --////////////////////////////////////////// -- set helmet-hair if hashelmet == true then -- 33% chance of getting helmet-hair if hair <= 0.33 then ObjectHideSubObjectPermanently( self, "HELMET_HAIR01", false ) end end -- set non-helmet-hair if hashelmet == false then -- 50% chance of getting non-helmet-hair if hair <= 0.25 then ObjectHideSubObjectPermanently( self, "NOHELMET_HAIR01", false ) elseif head <= 0.5 then ObjectHideSubObjectPermanently( self, "NOHELMET_HAIR02", false ) end end --////////////////////////////////////////// -- RIGHT HAND --////////////////////////////////////////// -- set the right hand subobject; note: we need one of them, so there's no "empty" possibility if righthand <= 0.066 then ObjectHideSubObjectPermanently( self, "RIGHT_SWORD01", false ) elseif righthand <= 0.133 then ObjectHideSubObjectPermanently( self, "RIGHT_SWORD02", false ) elseif righthand <= 0.2 then ObjectHideSubObjectPermanently( self, "RIGHT_SWORD03", false ) elseif righthand <= 0.266 then ObjectHideSubObjectPermanently( self, "RIGHT_SWORD04", false ) elseif righthand <= 0.333 then ObjectHideSubObjectPermanently( self, "RIGHT_SPEAR01", false ) elseif righthand <= 0.4 then ObjectHideSubObjectPermanently( self, "RIGHT_SPEAR02", false ) elseif righthand <= 0.466 then ObjectHideSubObjectPermanently( self, "RIGHT_SPEAR03", false ) elseif righthand <= 0.533 then ObjectHideSubObjectPermanently( self, "RIGHT_SPEAR04", false ) elseif righthand <= 0.6 then ObjectHideSubObjectPermanently( self, "RIGHT_AXE01", false ) elseif righthand <= 0.666 then ObjectHideSubObjectPermanently( self, "RIGHT_AXE02", false ) elseif righthand <= 0.733 then ObjectHideSubObjectPermanently( self, "RIGHT_AXE03", false ) elseif righthand <= 0.8 then ObjectHideSubObjectPermanently( self, "RIGHT_AXE04", false ) elseif righthand <= 0.866 then ObjectHideSubObjectPermanently( self, "RIGHT_MACE01", false ) elseif righthand <= 0.933 then ObjectHideSubObjectPermanently( self, "RIGHT_MACE02", false ) else ObjectHideSubObjectPermanently( self, "RIGHT_MACE03", false ) end --////////////////////////////////////////// -- LEFT HAND --////////////////////////////////////////// -- set the left hand subobject; note: we don't necessarily need one of them, so we can have some unused possibilities if lefthand <= 0.066 then ObjectHideSubObjectPermanently( self, "LEFT_SHIELD01", false ) elseif lefthand <= 0.133 then ObjectHideSubObjectPermanently( self, "LEFT_SHIELD02", false ) elseif lefthand <= 0.2 then ObjectHideSubObjectPermanently( self, "LEFT_SHIELD03", false ) elseif lefthand <= 0.266 then ObjectHideSubObjectPermanently( self, "LEFT_SHIELD04", false ) elseif lefthand <= 0.333 then ObjectHideSubObjectPermanently( self, "LEFT_SHIELD05", false ) elseif lefthand <= 0.4 then ObjectHideSubObjectPermanently( self, "LEFT_SHIELD06", false ) elseif lefthand <= 0.466 then ObjectHideSubObjectPermanently( self, "LEFT_SWORD01", false ) elseif lefthand <= 0.533 then ObjectHideSubObjectPermanently( self, "LEFT_SWORD02", false ) elseif lefthand <= 0.6 then ObjectHideSubObjectPermanently( self, "LEFT_SWORD03", false ) elseif lefthand <= 0.666 then ObjectHideSubObjectPermanently( self, "LEFT_SWORD04", false ) elseif lefthand <= 0.733 then ObjectHideSubObjectPermanently( self, "LEFT_AXE01", false ) elseif lefthand <= 0.8 then ObjectHideSubObjectPermanently( self, "LEFT_AXE02", false ) elseif lefthand <= 0.866 then ObjectHideSubObjectPermanently( self, "LEFT_AXE03", false ) else -- do nothing end end
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#5
Posted 09 January 2007 - 10:08 AM
#7
Posted 09 January 2007 - 01:59 PM
#9
Posted 09 January 2007 - 03:42 PM
"The path of the righteous man is beset on all sides
By the inequities of the selfish and the tyranny of evil men.
Blessed is he who, in the name of charity and good will,
Shepherds the weak through the valley of darkness,
For he is truly his brother's keeper and the finder of lost children.
And I will strike down upon thee with great vengeance and furious anger
Those who attempt to poison and destroy my brothers.
And you will know my name is the Lord when I lay my vengeance upon you."
#10
Posted 09 January 2007 - 03:47 PM
#11
Posted 09 January 2007 - 03:54 PM
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#12
Posted 09 January 2007 - 06:12 PM
I must have been very sleepy, or high or something... I didn't think of lua at all...
(And I got to somewhere around MordorFighter2350 before Sithy reminded me of it... )
#13 Guest_Guest_*
Posted 10 January 2007 - 08:52 PM
--kwen--
#14
Posted 10 January 2007 - 09:23 PM
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#15
Posted 14 January 2007 - 09:06 PM
https://www.twitch.tv/vileartist - Yes shameless self-promotion
----------------------------------------------------------------------------------------------------------------------
"Old modders never die, they just fade away" ~ Hostile
#16
Posted 14 January 2007 - 09:24 PM
Then you need the eventlist itself, so add it in scriptevents.xml (also in the scripts folder):Behavior = AIUpdateInterface ModuleTag_03
AutoAcquireEnemiesWhenIdle = Yes
MoodAttackCheckRate = 20
; AILuaEventsList = MordorFighterFunctions
AILuaEventsList = MordorOrcFighterFunctions
MaxCowerTime = 10000
MinCowerTime = 3000
AttackPriority = AttackPriority_Infantry
End
and finally you add the function to scripts.lua:<EventList Name="MordorOrcFighterFunctions" Inherit="MordorOrcFunctions">
<!-- This contains events specific to the MordorFighter. Kris -->
<EventHandler EventName="OnCreated" ScriptFunctionName="OnMordorOrcFighterCreated" DebugSingleStep="false"/>
</EventList>
function OnMordorOrcFighterCreated(self)
[...]
end
Edited by Dark Lord of the Sith, 14 January 2007 - 09:26 PM.
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#17
Posted 18 January 2007 - 11:13 AM
we definitely have things to talk about next time I catch you on msn DlotS
#18
Posted 18 January 2007 - 04:19 PM
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#19
Posted 31 January 2007 - 07:30 PM
i was gonna say that, but apparently i don't need to anymoreI must say that 2playgames first made this kind of script (at least openly), though only because I had shown lua to him
what does "manus manum lavat" mean?
edit: One hand washes the other...
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users