| Home Page | Recent Changes

Sparrow

boop.

Summon Creature Code for UT (not working).

In weapon class :

//=============================================================================
// WizardKatana.
//=============================================================================
class WizardKatana extends TournamentWeapon;

simulated exec function NextCategory() {
  if (Pawn(Owner).PlayerReplicationInfo.Isa('SDPlayerInfo')){
    SDPlayerInfo(PlayerPawn(Owner).PlayerReplicationInfo).NextCategory();
  }
}

simulated exec function NextCreature() {
  if (Pawn(Owner).PlayerReplicationInfo.Isa('SDPlayerInfo')){
    SDPlayerInfo(PlayerPawn(Owner).PlayerReplicationInfo).NextCreature();
  }
}

simulated exec function SDSummon() {
  if (Pawn(Owner).PlayerReplicationInfo.Isa('SDPlayerInfo')){
    SDPlayerInfo(PlayerPawn(Owner).PlayerReplicationInfo).SDSummon();
  }
}

//replication {
//  reliable if ( Role == ROLE_Authority )
//    UpdateCatInfo,UpdateCreatureInfo,NextCategory,PreviousCategory,
//    NextCreature,PreviousCreature,SDSummon;
//}

defaultproperties{
   PickupMessage="You have found a Wizard Katana."
   ItemName="Wizard Katana"
}

In SDPlayerInfo

//=============================================================================
// SDPlayerInfo
//=============================================================================
class SDPlayerInfo extends PlayerReplicationInfo;

var() string CreatureCategory[6];

// ugly code to manage summons
var bool                AmCasting;       //set to false soon as creature is summoned
var int                 MaxCreature;     // Array count of current CreatureCategory
var() int               MaxInCat[6];        // Array of Array counts, for MaxCreature

// what's selected. This info should display in the HUD
var travel int          CurrentSpell;    //Summon spell is always avalible, through key bindings
var travel int          CurrentCategory; //Category of creatures which can be summoned
var travel int          CurrentCreature; //Creature that will be summoned when summon spell is called

simulated function NextCategory() {
  if (CurrentCategory < (ArrayCount(CreatureCategory)-1)) {
    CurrentCategory++;
  } else {
    CurrentCategory = 0; 
  } 
  MaxCreature = MaxInCat[CurrentCategory];
  CurrentCreature = 0;
}

simulated function NextCreature() {
  if (CurrentCreature < MaxCreature) {
    CurrentCreature++;
  } else {
    CurrentCreature = 0; 
  } 
}

simulated function SDSummon() {
  AmCasting = true;
}

replication{
    // Things the server should send to the client.
    reliable if ( Role == ROLE_Authority )
     NextCategory,NextCreature,PreviousCreature,PreviousCategory;
//     CurrentSpell, 
//     CastingCreature, 
//     CurrentCategory,  
//     CurrentCreature, 
//     AmCasting;
}

replication{
    // Things the client should send to the server.
    unreliable if (Role == ROLE_Authority )
//  reliable if ( RemoteRole == ROLE_None ||            // Covering all the bases
//                 RemoteRole == ROLE_DumbProxy ||
//                 RemoteRole == ROLE_SimulatedProxy ||
//                 RemoteRole == ROLE_AutonomousProxy || // all player pawns are supposed to have ROLE_AutonomousProxy
//                 Role == ROLE_Authority
//                  ) 
     CurrentSpell,  //CastingCreature,
     CurrentCategory,  
     AmCasting,  
     CurrentCreature, CurrentUtility;
}

defaultproperties{
  CreatureCategory(0)="Fly"
  MaxInCat(0)=5
  CreatureCategory(1)="Manta"
  MaxInCat(1)=3 
  CreatureCategory(2)="Fish"
  MaxInCat(2)=5
  CreatureCategory(3)="Animal"
  MaxInCat(3)=4
  CreatureCategory(4)="Spider"
  MaxInCat(4)=3
  CreatureCategory(5)="Clone"
  MaxInCat(5)=2

  AmCasting=false
  MaxCreature=5
 
  CurrentSpell=0
  CurrentCategory=0
  CurrentCreature=0
}

In GameInfo

//=============================================================================
// LastSummonerStanding.
//=============================================================================
class LastSummonerStanding extends LastManStanding;

var int MaxSpellLevel;

var() string Fly[5];
var() string Manta[3];
var() string Fish[5];
var() string Animal[4];
var() string Clone[2];
var() string Spider[3];

function tick (float dt){
  local PlayerPawn NewPawn;
  local Bot NewBot;
  local bool AmCasting;
  local int CurrentCategory, CurrentCreature;
  local SDPlayerInfo PlayerInfo;
  local SDBotInfo BotInfo;

  Super.Tick(dt);

  //yes... I know this is ugly. But dunno how else to do it.  
  foreach AllActors (Class'Engine.PlayerPawn', NewPawn) {
    if (NewPawn != None){
      AmCasting = false;
      CurrentCategory = 0;
      CurrentCreature = 0;
      if (NewPawn.PlayerReplicationInfo.Isa('SDPlayerInfo')){
        PlayerInfo = SDPlayerInfo(NewPawn.PlayerReplicationInfo);
        CurrentCreature = PlayerInfo.CurrentCreature;
        CurrentCategory = PlayerInfo.CurrentCategory;
        AmCasting = PlayerInfo.AmCasting;
        PlayerInfo.AmCasting = false;
        if (AmCasting){
          NewPawn.ClientMessage("Current Creature is "$string(CurrentCreature)); // these lines return
          NewPawn.ClientMessage("Current Category is "$string(CurrentCategory)); // the wrong values
          SDMSummon(NewPawn,CurrentCategory, CurrentCreature);
        }
      }
    }
  }
  foreach AllActors (Class'Botpack.Bot', NewBot) {
    if (NewBot != None){
      AmCasting = false;
      CurrentCategory = 0;
      CurrentCreature = 0;
      if (NewBot.PlayerReplicationInfo.Isa('SDBotInfo')){
        NewBot.ClientMessage("I think you're a bot"); 
        CurrentCategory = SDBotInfo(NewBot.PlayerReplicationInfo).CurrentCategory;
        CurrentCreature = GetCurrentCreature(CurrentCategory);
        AmCasting = SDBotInfo(NewBot.PlayerReplicationInfo).AmCasting;
        SDBotInfo(NewBot.PlayerReplicationInfo).AmCasting = false;
        if (AmCasting){
          SDMSummon(NewBot,CurrentCategory, CurrentCreature);
        }
      } // end if bot info
    } // end sure bot
  } // end loop
} // end function

simulated function string GetCastingCreature(int CurrentCategory, int CurrentCreature){
  local string CastingCreature;
  CastingCreature = "None";
  if(CurrentCategory==0) {
    CastingCreature = Fly[CurrentCreature];
  }else if (CurrentCategory==1){
    CastingCreature = Manta[CurrentCreature];
  }else if (CurrentCategory==2){
    CastingCreature = Fish[CurrentCreature];
  }else if (CurrentCategory==3){
    CastingCreature= Animal[CurrentCreature];
  }else if (CurrentCategory==4){
    CastingCreature = Spider[CurrentCreature];
  }else if (CurrentCategory==5){
    CastingCreature = Clone[CurrentCreature];
  }
  return CastingCreature;
}

simulated function bool SDMSummon(Pawn Owner, int pCatID, int CurrentCreature){
   local class<actor> NewClass;
   local int LCreatureCount;
   local ScriptedPawn NewCreature;
   local vector NewVector;
   local Actor NewPawn;
   local string ClassName;

   ClassName = GetCastingCreature(pCatID,CurrentCreature);

   LCreatureCount = 0;
   foreach AllActors (Class 'UnrealShare.ScriptedPawn', NewCreature) {
     if (NewCreature.Owner == Owner) {
       LCreatureCount+=1;
     }
   }
   if(LCreatureCount > SDPlayerInfo(PlayerPawn(Owner).PlayerReplicationInfo).MaxSummons) { 
     Owner.ClientMessage("You have too many creatures still in play to summon more.");
   }else{
     NewClass = class<actor>( DynamicLoadObject(ClassName, class'Class' ));   
     if( NewClass!=None ) {
     NewVector = (Owner.Velocity*0.5)+(Owner.Location + 110 * Vector(Owner.Rotation) + vect(0,0,1) * 25);
     Spawn(class'WeaponLight',,'',NewVector);
     NewPawn = Spawn( NewClass,Owner,,NewVector,Owner.Rotation);

     if (NewPawn != None){
          SDPlayerInfo(PlayerPawn(Owner).PlayerReplicationInfo).CreatureCount[pCatID]++;
          Spawn(class'PawnTeleportEffect',,'',NewVector);
          Owner.PlaySound(Sound'U4eTM.zapper.zapcharge', SLOT_Misc, 4 * Owner.SoundDampening);
          return true;
        }else{
          Owner.ClientMessage("Summon Spell Failed");
          return false;
        }
     }else{
       Owner.ClientMessage("Dunno what a '"$ClassName$"' is.");
       return false;
     }
   }
}

defaultproperties{
  Fly(0)="SDCreatures.Gnat"
  Fly(1)="SDCreatures.SmallFly"
  Fly(2)="SDCreatures.GnatQueen"
  Fly(3)="SDCreatures.StandardFly"
  Fly(4)="SDCreatures.GiantFly"

  Manta(0)="SDCreatures.SmallManta"
  Manta(1)="SDCreatures.StandardManta"
  Manta(2)="SDCreatures.BossManta"

  Fish(0)="SDCreatures.BittyFish"
  Fish(1)="SDCreatures.SmallFish"
  Fish(2)="UnrealShare.DevilFish"
  Fish(3)="UnrealI.Squid"
  Fish(4)="SDCreatures.KillerFish"

  Animal(0)="SDCreatures.RabidRabbit"
  Animal(1)="UnrealShare.BabyCow"
  Animal(2)="UnrealShare.Cow"
  Animal(3)="UnrealShare.Bird1"

  Spider(0)="SDCreatures.TarantulaSpider"
  Spider(1)="SDCreatures.JumperSpider"
  Spider(2)="SDCreatures.SpitterSpider"

  Clone(0)="SDCreatures.Decoy"
  Clone(1)="SDCreatures.Clone"

     MaxSpellLevel=5
     bUseTranslocator=False
     bCanViewOthers=False
     bCanChangeSkin=true
     FragLimit=50
     TimeLimit=0
     bAlwaysForceRespawn=True
     bNoMonsters=False
     StartUpMessage="Last Summoner Standing.  How long can you live?"
     gamegoal="lives to try and keep"
     HackedMessage=" was hacked"
     ScoreBoardType=Class'Botpack.LMSScoreboard'
//     ScoreBoardType=Class'SDMods.LSSScoreBoard'
     RulesMenuType="UTMenu.UTLMSRulesSC"
//     RulesMenuType="SDMods.SDRulesClient"
     BeaconName="LSS"
//     BeaconName="LMS"
     HUDType=Class'SDMods.SDHud'
     GameName="Last Summoner Standing"
//     GameReplicationInfoClass=Class'SDMods.SDGameReplicationInfo'

}

Problem

  Even though category has changed in the player info, it always returns the default values in tick.

Description from IRC

in the "tick" function of LastSummonerStanding

I can't get it to see the actual CurrentCategory

or creature

at every point before that, if I put in a "My current value is" message, it seems to work fine

and it works fine in the HUD

which is very simplistic at this point

Reason summon is in Tick

Before it was in one of the above classes. The creatures would summon (and the right ones), but they were local copies that couldn't be seen across the network. Also, if the summoner walked through them, then they exploded. Which was funny, but not the desired effect.

Notes

Making the functions in the game info class simulated or not, doesn't seem to make a difference.

I don't think they should be at that point. I've tried making all functions above simulated, or not simulated, to no effect.

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In