Jump to content


Photo

Random weapons, and armor


  • Please log in to reply
18 replies to this topic

#1 Kwen

Kwen

    Vileartist

  • T3A Staff
  • 4,865 posts
  • Location:Korea I wish
  • Projects:It'sa secreeet
  •  T3A's First N00b
  • Division:BFME
  • Job:T3A Expert
  • Donated

Posted 08 January 2007 - 09:53 PM

I've seen it done, i've tried to do it, and i VERY dislike the idea of making 287 different orc models (dont ask) I would much rather make 5 different orc models and randomize them... But i know not how to pull this off. A little assistance, or even hints of code would be nice.....

                           https://www.twitch.tv/vileartist - Yes shameless self-promotion

          ----------------------------------------------------------------------------------------------------------------------

                            "Old modders never die, they just fade away" ~ Hostile


#2 zimoo

zimoo

    Ecthelion of the Fountain

  • Project Team
  • 2,009 posts
  • Location:Devon, England
  • Projects:Lurking until the off topic begins...
  •  Guardian of the Books

Posted 08 January 2007 - 10:03 PM

Data.big, LUA, random number generating, IF commands, functions :D

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.

Posted Image
Posted Image
Posted Image
Posted Image
Posted Image
Posted Image

Playing games? Ah, you'll never be a good modder if you get involved in actually playing them!


#3 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 08 January 2007 - 10:56 PM

Doing these scripts is pretty dumb, you can have mine. It's probably a bit more detailed than you're gonna have it (because we also have helmet-depending objects), but the basic stuff is there:

And no, taking no codeboxes was on purpose (I hate them), and I'm too lazy to upload a txt file now :D

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

revorapresident.jpg
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.


#4 Master Windu

Master Windu

    The Master.

  • Advisors
  • 2,150 posts
  • Location:Houston, Texas
  • Projects:Galaxy at War, Rhovanion Alliance
  •  T3A Team Chamber Member

Posted 08 January 2007 - 11:18 PM

Wow... Thats really helpful, you could probably make a tutorial-like thing and post your code in there, that would be really useful to alot of people.
Posted Image
Posted Image

#5 cahik_

cahik_

    Sage engine ruler

  • Project Team
  • 1,896 posts
  • Location:Czech Republic
  • Projects:Rhovanion Alliance
  •  T3A Team Chamber Member and Crazy animator

Posted 09 January 2007 - 10:08 AM

really nice script Sithy :p i agree with Windu that commented version could help to a lot of people. me consider it quite easy but for someone who cannot program it could be a problem to understand it.

Posted Image

Posted Image
Posted Image


#6 Lauri

Lauri

    Old man Lauri

  • Hosted
  • 10,436 posts
  • Location:Norway
  • Projects:The 4th Age
  •  The very worst T3A Team Chamber Member

Posted 09 January 2007 - 01:21 PM

well, another tip.... Hide the weapons in RenX\Max.... you know, export Geometry, Normal, Hide.... then you get away with alot of codes :p I've never used scripts for hiding stuff :p exept one thing I did for Nazgûl :?:

T4A_Logo_-_article.png

The 4th Age version 0.8 has been released: Link


#7 N19HtmAr3

N19HtmAr3

    title available

  • Project Team
  • 553 posts
  • Location:Sweden
  • Projects:Kicking ass...
  •  "who's that guy, anyways?"

Posted 09 January 2007 - 01:59 PM

It's not a lot of code you get away from... But sure... You can do that too... :p

#8 Lauri

Lauri

    Old man Lauri

  • Hosted
  • 10,436 posts
  • Location:Norway
  • Projects:The 4th Age
  •  The very worst T3A Team Chamber Member

Posted 09 January 2007 - 03:32 PM

makes it easier :p atleast for me :p :?:

T4A_Logo_-_article.png

The 4th Age version 0.8 has been released: Link


#9 Herunor

Herunor

    Louis

  • Project Team
  • 157 posts
  • Location:Germany

Posted 09 January 2007 - 03:42 PM

this is really helpful, i had another idea in my mind, but yours is miles better :p

"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 zimoo

zimoo

    Ecthelion of the Fountain

  • Project Team
  • 2,009 posts
  • Location:Devon, England
  • Projects:Lurking until the off topic begins...
  •  Guardian of the Books

Posted 09 January 2007 - 03:47 PM

Hehe I know what you mean. First time I tried to do random weapons I used the random peasant code, and ended up with about 100 child-objects named MordorFighter followed by some numbers :p
Posted Image
Posted Image
Posted Image
Posted Image
Posted Image
Posted Image

Playing games? Ah, you'll never be a good modder if you get involved in actually playing them!


#11 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 09 January 2007 - 03:54 PM

Someone else wanted to do that too... Nigh...*ahem* :p

revorapresident.jpg
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 N19HtmAr3

N19HtmAr3

    title available

  • Project Team
  • 553 posts
  • Location:Sweden
  • Projects:Kicking ass...
  •  "who's that guy, anyways?"

Posted 09 January 2007 - 06:12 PM

Shush! :)

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... :p )

;)

#13 Guest_Guest_*

Guest_Guest_*
  • Guests

Posted 10 January 2007 - 08:52 PM

lol, yea. I'm not very skilled at this stuff, so i wouldn't have figured it out on my own, thanks guys.


--kwen--

#14 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 10 January 2007 - 09:23 PM

No problem. I wanted to write a tutorial about this a long time ago, but never actually did it. And it looks like it's not going to happen anymore...

revorapresident.jpg
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 Kwen

Kwen

    Vileartist

  • T3A Staff
  • 4,865 posts
  • Location:Korea I wish
  • Projects:It'sa secreeet
  •  T3A's First N00b
  • Division:BFME
  • Job:T3A Expert
  • Donated

Posted 14 January 2007 - 09:06 PM

hmmm, well i'm not teriblyskilled in this field and have probably have gotten something wrong because it does not work for me, is there any specific way its supposed to go into the code?

                           https://www.twitch.tv/vileartist - Yes shameless self-promotion

          ----------------------------------------------------------------------------------------------------------------------

                            "Old modders never die, they just fade away" ~ Hostile


#16 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 14 January 2007 - 09:24 PM

You need to add the eventlist to the AIUpdate:

Behavior = AIUpdateInterface ModuleTag_03
AutoAcquireEnemiesWhenIdle = Yes
MoodAttackCheckRate = 20
; AILuaEventsList = MordorFighterFunctions
AILuaEventsList = MordorOrcFighterFunctions
MaxCowerTime = 10000
MinCowerTime = 3000
AttackPriority = AttackPriority_Infantry
End

Then you need the eventlist itself, so add it in scriptevents.xml (also in the scripts folder):

<EventList Name="MordorOrcFighterFunctions" Inherit="MordorOrcFunctions">
<!-- This contains events specific to the MordorFighter. Kris -->
<EventHandler EventName="OnCreated" ScriptFunctionName="OnMordorOrcFighterCreated" DebugSingleStep="false"/>
</EventList>

and finally you add the function to scripts.lua:

function OnMordorOrcFighterCreated(self)
[...]
end


Edited by Dark Lord of the Sith, 14 January 2007 - 09:26 PM.

revorapresident.jpg
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 ched

ched

    .

  • Undead
  • 4,431 posts
  • Location:Angers (France)
  • Projects:Rhovanion Alliance
  •  T3A Team Chamber Member
  • Division:BFME
  • Job:Previous Division Leader

Posted 18 January 2007 - 11:13 AM

aah, some advanced lua scripting. I was under the impression I was the only dork out there that used it to code :D

we definitely have things to talk about next time I catch you on msn DlotS :p
Software is like sex; it's better when it's free ~Linus Torvald

#18 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 18 January 2007 - 04:19 PM

I must say that 2playgames first made this kind of script (at least openly), though only because I had shown lua to him... manus manum lavat :lol:

revorapresident.jpg
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 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 31 January 2007 - 07:30 PM

I must say that 2playgames first made this kind of script (at least openly), though only because I had shown lua to him

i was gonna say that, but apparently i don't need to anymore :)

what does "manus manum lavat" mean?

edit: One hand washes the other...
bartvh | Join me, make your signature small!
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