Username:    Password:    Remember Me?         

Reverie World Studios Forums - View Single Post - Miscellanous units
View Single Post
  #17  
Old 08-29-2009, 08:36 AM
Andy Joslin's Avatar
Andy Joslin Andy Joslin is offline
Reverie World Studios - Lead Gameplay Scripter
 
Join Date: May 2008
Posts: 495
Andy Joslin is just really niceAndy Joslin is just really niceAndy Joslin is just really nice
Default

Making a new unit is easy. Here is a tiny example:

Code:
local T=NewCreatureTemplate("Orc-Units-Rabid Monster")

T.Mesh[1]="MyFolderPath/RabidMonster/mesh"
T.Texture[1]="MyFolderPath/RabidMonster/texture"

T.Animation[1]="MyFolderPath/RabidMonster/idle"
...
T.Animation[10]="MyFolderPath/RabidMonster/death"
..

T.DefaultMesh=1
T.DefaultTexture=1
T.DefaultAnimation=1

T.DefaultScale={3,3,3}
T.HasCollision=false


T.WalkSpeed=2934
T.RunSpeed=32459
T.FatigueCap=430
T.HitPoints=230
You set all the stats here

T.CustomProperties={
Rabid=false,
RabidTimer=false,
}

local Button=T:AddActioner("Rabid")
Button.Icon=""
Button.Details=""
Button.ExtendedDetails=""
Button.Func=function(Self)
  Self:PlaySfx(UiIconLeft)
  if Self.Fatigue>=50 then
    Self.Rabid=true
    Self.RabidTimer=10
  
    Self.DefenceRating=Self.DefenceRating+100
    Self.Weapon[1].Slashing=Self.Weapon[1].Slashing+100

    Self:GreyActioner("Rabid")
    Self.Fatigue=Self.Fatigue-50
  elseif Self.Fatigue<50 then
    Self:NotifyPlayer("Not enough fatigue, need "..50-Self.Fatigue.." more to use Rabid")
end

T.OnHeartBeat=function(Self)
  if Self.Rabid==true and Self.RabidTimer>0 then
    Self.RabidTimer=Self.RabidTimer-1
  elseif Self.Rabid==true and Self.RabidTimer==0 then
    Self.DefenceRating=Self.DefenceRating-100
    Self.Weapon[1].Slashing=Self.Weapon[1].Slashing-100

    Self.Rabid=false
    Self:UngreyActioner("Rabid")
  end
end

Tons of events you can use, including T.OnCreation, T.OnDeath, T.OnEndDying, T.OnDecaying, T.OnWalk, T.ClickOnUnit, T.ClickOnLocation, etc
This is but a tiny example of our unit-scripting. It is nearly limitless. It can interact with the scenario-scripting and interface scripting easily, too.
Reply With Quote